Clean up.
fstab.c: In function ?lock_mtab?:
fstab.c:385: warning: declaration of ?errsv? shadows a previous local
fstab.c:367: warning: shadowed declaration is here
fstab.c:407: warning: declaration of ?errsv? shadows a previous local
fstab.c:367: warning: shadowed declaration is here
fstab.c:417: warning: declaration of ?tries? shadows a previous local
fstab.c:325: warning: shadowed declaration is here
fstab.c:422: warning: declaration of ?errsv? shadows a previous local
fstab.c:367: warning: shadowed declaration is here
These are probably harmless. Reusing a variable name, however, is a
little confusing to follow when reading the code.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
/* Repeat until it was us who made the link */
while (!we_created_lockfile) {
struct flock flock;
/* Repeat until it was us who made the link */
while (!we_created_lockfile) {
struct flock flock;
j = link(linktargetfile, MOUNTED_LOCK);
j = link(linktargetfile, MOUNTED_LOCK);
- if (j == 0)
- we_created_lockfile = 1;
- if (j < 0 && errsv != EEXIST) {
- (void) unlink(linktargetfile);
- die (EX_FILEIO, _("can't link lock file %s: %s "
- "(use -n flag to override)"),
- MOUNTED_LOCK, strerror (errsv));
+ if (j == 0)
+ we_created_lockfile = 1;
+
+ if (j < 0 && errsv != EEXIST) {
+ (void) unlink(linktargetfile);
+ die (EX_FILEIO, _("can't link lock file %s: %s "
+ "(use -n flag to override)"),
+ MOUNTED_LOCK, strerror (errsv));
+ }
}
lockfile_fd = open (MOUNTED_LOCK, O_WRONLY);
}
lockfile_fd = open (MOUNTED_LOCK, O_WRONLY);
}
(void) unlink(linktargetfile);
} else {
}
(void) unlink(linktargetfile);
} else {
+ static int retries = 0;
/* Someone else made the link. Wait. */
alarm(LOCK_TIMEOUT);
/* Someone else made the link. Wait. */
alarm(LOCK_TIMEOUT);
alarm(0);
/* Limit the number of iterations - maybe there
still is some old /etc/mtab~ */
alarm(0);
/* Limit the number of iterations - maybe there
still is some old /etc/mtab~ */
- ++tries;
- if (tries % 200 == 0)
+ ++retries;
+ if (retries % 200 == 0)
+ if (retries > 100000) {
(void) unlink(linktargetfile);
close(lockfile_fd);
die (EX_FILEIO, _("Cannot create link %s\n"
(void) unlink(linktargetfile);
close(lockfile_fd);
die (EX_FILEIO, _("Cannot create link %s\n"