X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmount%2Ffstab.c;h=a742e648d0e4d133c7e24eb07f2c4d591ad44cd5;hp=e19e58b0d95fa9d246e6a0034adf5480644bf6c2;hb=ffa577350b03ddd421d455a8cd4cff86e3718264;hpb=58080798db321d025143df39c97f707ea994ba26 diff --git a/utils/mount/fstab.c b/utils/mount/fstab.c index e19e58b..a742e64 100644 --- a/utils/mount/fstab.c +++ b/utils/mount/fstab.c @@ -1,4 +1,4 @@ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* 1999-02-22 Arkadiusz Miskiewicz * - added Native Language Support * Sun Mar 21 1999 - Arnaldo Carvalho de Melo * - fixed strerr(errno) in gettext calls @@ -285,7 +285,7 @@ handler (int sig) { } static void -setlkw_timeout (int sig) { +setlkw_timeout (__attribute__((unused)) int sig) { /* nothing, fcntl will fail anyway */ } @@ -364,19 +364,22 @@ lock_mtab (void) { /* Repeat until it was us who made the link */ while (!we_created_lockfile) { struct flock flock; - int errsv, j; + int j; j = link(linktargetfile, MOUNTED_LOCK); - errsv = errno; - if (j == 0) - we_created_lockfile = 1; + { + int errsv = errno; - 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); @@ -414,7 +417,7 @@ lock_mtab (void) { } (void) unlink(linktargetfile); } else { - static int tries = 0; + static int retries = 0; /* Someone else made the link. Wait. */ alarm(LOCK_TIMEOUT); @@ -428,10 +431,10 @@ lock_mtab (void) { 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) usleep(30); - if (tries > 100000) { + if (retries > 100000) { (void) unlink(linktargetfile); close(lockfile_fd); die (EX_FILEIO, _("Cannot create link %s\n" @@ -546,8 +549,12 @@ update_mtab (const char *dir, struct mntent *instead) * from the present mtab before renaming. */ struct stat sbuf; - if (stat (MOUNTED, &sbuf) == 0) - chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid); + if (stat (MOUNTED, &sbuf) == 0) { + if (chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid) < 0) { + nfs_error(_("%s: error changing owner of %s: %s"), + progname, MOUNTED_TEMP, strerror (errno)); + } + } } /* rename mtemp to mtab */