]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/fstab.c
Imported Upstream version 1.2.3
[nfs-utils.git] / utils / mount / fstab.c
index 6ac5c70c5b118b104800a6342d144f4412df6063..051fa38c872503e37dfaca9e5c89c4ec4f2f7738 100644 (file)
@@ -1,4 +1,4 @@
-/* 1999-02-22 Arkadiusz MiΒΆkiewicz <misiek@pld.ORG.PL>
+/* 1999-02-22 Arkadiusz Miskiewicz <misiek@pld.ORG.PL>
  * - added Native Language Support
  * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  * - fixed strerr(errno) in gettext calls
@@ -25,6 +25,7 @@
 #define streq(s, t)    (strcmp ((s), (t)) == 0)
 #define PROC_MOUNTS            "/proc/mounts"
 
+extern char *progname;
 extern int verbose;
 
 /* Information about mtab. ------------------------------------*/
@@ -45,6 +46,11 @@ get_mtab_info(void) {
        }
 }
 
+void
+reset_mtab_info(void) {
+        have_mtab_info = 0;
+}
+
 int
 mtab_does_not_exist(void) {
        get_mtab_info();
@@ -174,9 +180,8 @@ read_mounttable() {
                         return;
                 }
                 if (verbose)
-                        printf (_("mount: could not open %s - "
-                                  "using %s instead\n"),
-                                MOUNTED, PROC_MOUNTS);
+                        printf(_("%s: could not open %s; using %s instead\n"),
+                               progname, MOUNTED, PROC_MOUNTS);
         }
         read_mntentchn(mfp, fnam, mc);
 }
@@ -280,7 +285,7 @@ handler (int sig) {
 }
 
 static void
-setlkw_timeout (int sig) {
+setlkw_timeout (__attribute__((unused)) int sig) {
      /* nothing, fcntl will fail anyway */
 }
 
@@ -400,8 +405,10 @@ lock_mtab (void) {
                        if (fcntl (lockfile_fd, F_SETLK, &flock) == -1) {
                                if (verbose) {
                                    int errsv = errno;
-                                   printf(_("Can't lock lock file %s: %s\n"),
-                                          MOUNTED_LOCK, strerror (errsv));
+                                   nfs_error(_("%s: Can't lock lock file "
+                                               "%s: %s"), progname,
+                                               MOUNTED_LOCK,
+                                               strerror (errsv));
                                }
                                /* proceed anyway */
                        }
@@ -528,8 +535,8 @@ update_mtab (const char *dir, struct mntent *instead)
        if (fchmod (fileno (mftmp->mntent_fp),
                    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
                int errsv = errno;
-               fprintf(stderr, _("error changing mode of %s: %s\n"),
-                       MOUNTED_TEMP, strerror (errsv));
+               nfs_error(_("%s: error changing mode of %s: %s"),
+                               progname, MOUNTED_TEMP, strerror (errsv));
        }
        nfs_endmntent (mftmp);
 
@@ -539,15 +546,20 @@ 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 */
        if (rename (MOUNTED_TEMP, MOUNTED) < 0) {
                int errsv = errno;
-               fprintf(stderr, _("can't rename %s to %s: %s\n"),
-                       MOUNTED_TEMP, MOUNTED, strerror(errsv));
+               nfs_error(_("%s: can't rename %s to %s: %s\n"),
+                               progname, MOUNTED_TEMP, MOUNTED,
+                               strerror(errsv));
        }
 
  leave: