Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin Regularize error reporting of mount_* commands for fail...



details:   https://anonhg.NetBSD.org/src/rev/997729953aa8
branches:  trunk
changeset: 474008:997729953aa8
user:      perseant <perseant%NetBSD.org@localhost>
date:      Fri Jun 25 19:28:35 1999 +0000

description:
Regularize error reporting of mount_* commands for failure of mount(2)
to the form:

        mount_xxx: dev on dir: reason for failure

diffstat:

 sbin/mount_ados/mount_ados.c         |   6 +++---
 sbin/mount_cd9660/mount_cd9660.c     |   6 +++---
 sbin/mount_fdesc/mount_fdesc.c       |   6 +++---
 sbin/mount_filecore/mount_filecore.c |   4 ++--
 sbin/mount_kernfs/mount_kernfs.c     |   6 +++---
 sbin/mount_lfs/mount_lfs.c           |  28 +++++++++++++++++++++++-----
 sbin/mount_msdos/mount_msdos.c       |   6 +++---
 sbin/mount_nfs/mount_nfs.c           |  11 +++++++----
 sbin/mount_ntfs/mount_ntfs.c         |   6 +++---
 sbin/mount_null/mount_null.c         |   6 +++---
 sbin/mount_procfs/mount_procfs.c     |   6 +++---
 sbin/mount_umap/mount_umap.c         |   6 +++---
 sbin/mount_union/mount_union.c       |   6 +++---
 13 files changed, 62 insertions(+), 41 deletions(-)

diffs (truncated from 401 to 300 lines):

diff -r eb23eae61201 -r 997729953aa8 sbin/mount_ados/mount_ados.c
--- a/sbin/mount_ados/mount_ados.c      Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_ados/mount_ados.c      Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_ados.c,v 1.8 1998/03/01 02:20:11 fvdl Exp $      */
+/*     $NetBSD: mount_ados.c,v 1.9 1999/06/25 19:28:35 perseant Exp $  */
 
 /*
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mount_ados.c,v 1.8 1998/03/01 02:20:11 fvdl Exp $");
+__RCSID("$NetBSD: mount_ados.c,v 1.9 1999/06/25 19:28:35 perseant Exp $");
 #endif /* not lint */
 
 #include <sys/cdefs.h>
@@ -134,7 +134,7 @@
        }
 
        if (mount(MOUNT_ADOSFS, dir, mntflags, &args) < 0)
-               err(1, "mount");
+               err(1, "%s on %s", dev, dir);
 
        exit (0);
 }
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_cd9660/mount_cd9660.c
--- a/sbin/mount_cd9660/mount_cd9660.c  Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_cd9660/mount_cd9660.c  Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_cd9660.c,v 1.7 1999/05/28 10:10:25 mjl Exp $     */
+/*     $NetBSD: mount_cd9660.c,v 1.8 1999/06/25 19:28:35 perseant Exp $        */
 
 /*
  * Copyright (c) 1992, 1993, 1994
@@ -50,7 +50,7 @@
 #if 0
 static char sccsid[] = "@(#)mount_cd9660.c     8.7 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mount_cd9660.c,v 1.7 1999/05/28 10:10:25 mjl Exp $");
+__RCSID("$NetBSD: mount_cd9660.c,v 1.8 1999/06/25 19:28:35 perseant Exp $");
 #endif
 #endif /* not lint */
 
@@ -124,7 +124,7 @@
        args.flags = opts;
 
        if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0)
-               err(1, "%s", "");
+               err(1, "%s on %s", dev, dir);
        exit(0);
 }
 
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_fdesc/mount_fdesc.c
--- a/sbin/mount_fdesc/mount_fdesc.c    Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_fdesc/mount_fdesc.c    Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_fdesc.c,v 1.9 1997/09/16 12:26:56 lukem Exp $    */
+/*     $NetBSD: mount_fdesc.c,v 1.10 1999/06/25 19:28:36 perseant Exp $        */
 
 /*
  * Copyright (c) 1990, 1992 Jan-Simon Pendry
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)mount_fdesc.c      8.3 (Berkeley) 4/26/95";
 #else
-__RCSID("$NetBSD: mount_fdesc.c,v 1.9 1997/09/16 12:26:56 lukem Exp $");
+__RCSID("$NetBSD: mount_fdesc.c,v 1.10 1999/06/25 19:28:36 perseant Exp $");
 #endif
 #endif /* not lint */
 
@@ -94,7 +94,7 @@
                usage();
 
        if (mount(MOUNT_FDESC, argv[1], mntflags, NULL))
-               err(1, "%s", "");
+               err(1, "fdesc on %s", argv[1]);
        exit(0);
 }
 
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_filecore/mount_filecore.c
--- a/sbin/mount_filecore/mount_filecore.c      Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_filecore/mount_filecore.c      Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_filecore.c,v 1.1 1998/08/14 03:38:51 mark Exp $  */
+/*     $NetBSD: mount_filecore.c,v 1.2 1999/06/25 19:28:36 perseant Exp $      */
 
 /*
  * Copyright (c) 1998 Andrew McMurry
@@ -138,7 +138,7 @@
        args.flags = opts;
 
        if (mount(MOUNT_FILECORE, dir, mntflags, &args) < 0)
-               err(1, "%s", "");
+               err(1, "%s on %s", dev, dir);
        exit(0);
 }
 
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_kernfs/mount_kernfs.c
--- a/sbin/mount_kernfs/mount_kernfs.c  Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_kernfs/mount_kernfs.c  Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_kernfs.c,v 1.10 1997/09/16 12:29:16 lukem Exp $  */
+/*     $NetBSD: mount_kernfs.c,v 1.11 1999/06/25 19:28:36 perseant Exp $       */
 
 /*
  * Copyright (c) 1990, 1992 Jan-Simon Pendry
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)mount_kernfs.c     8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: mount_kernfs.c,v 1.10 1997/09/16 12:29:16 lukem Exp $");
+__RCSID("$NetBSD: mount_kernfs.c,v 1.11 1999/06/25 19:28:36 perseant Exp $");
 #endif
 #endif /* not lint */
 
@@ -94,7 +94,7 @@
                usage();
 
        if (mount(MOUNT_KERNFS, argv[1], mntflags, NULL))
-               err(1, "%s", "");
+               err(1, "kernfs on %s", argv[1]);
        exit(0);
 }
 
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_lfs/mount_lfs.c
--- a/sbin/mount_lfs/mount_lfs.c        Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_lfs/mount_lfs.c        Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_lfs.c,v 1.7 1998/03/01 02:20:41 fvdl Exp $       */
+/*     $NetBSD: mount_lfs.c,v 1.8 1999/06/25 19:28:36 perseant Exp $   */
 
 /*-
  * Copyright (c) 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)mount_lfs.c        8.4 (Berkeley) 4/26/95";
 #else
-__RCSID("$NetBSD: mount_lfs.c,v 1.7 1998/03/01 02:20:41 fvdl Exp $");
+__RCSID("$NetBSD: mount_lfs.c,v 1.8 1999/06/25 19:28:36 perseant Exp $");
 #endif
 #endif /* not lint */
 
@@ -53,6 +53,7 @@
 #include <ufs/ufs/ufsmount.h>
 
 #include <err.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -81,6 +82,7 @@
        struct ufs_args args;
        int ch, mntflags, noclean;
        char *fs_name, *options;
+       const char *errcause;
 
        options = NULL;
        mntflags = noclean = 0;
@@ -108,7 +110,7 @@
        if (argc != 2)
                usage();
 
-        args.fspec = argv[0];  /* the name of the device file */
+       args.fspec = argv[0];   /* the name of the device file */
        fs_name = argv[1];      /* the mount point */
 
 #define DEFAULT_ROOTUID        -2
@@ -118,8 +120,24 @@
        else
                args.export.ex_flags = 0;
 
-       if (mount(MOUNT_LFS, fs_name, mntflags, &args))
-               err(1, "%s", "");
+       if (mount(MOUNT_LFS, fs_name, mntflags, &args)) {
+               switch (errno) {
+               case EMFILE:
+                       errcause = "mount table full";
+                       break;
+               case EINVAL:
+                       if (mntflags & MNT_UPDATE)
+                               errcause =
+                           "specified device does not match mounted device";
+                       else
+                               errcause = "incorrect super block";
+                       break;
+               default:
+                       errcause = strerror(errno);
+                       break;
+               }
+               errx(1, "%s on %s: %s", args.fspec, fs_name, errcause);
+       }
 
        if (!noclean)
                invoke_cleaner(fs_name);
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_msdos/mount_msdos.c
--- a/sbin/mount_msdos/mount_msdos.c    Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_msdos/mount_msdos.c    Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_msdos.c,v 1.19 1998/03/01 02:20:45 fvdl Exp $    */
+/*     $NetBSD: mount_msdos.c,v 1.20 1999/06/25 19:28:36 perseant Exp $        */
 
 /*
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mount_msdos.c,v 1.19 1998/03/01 02:20:45 fvdl Exp $");
+__RCSID("$NetBSD: mount_msdos.c,v 1.20 1999/06/25 19:28:36 perseant Exp $");
 #endif /* not lint */
 
 #include <sys/cdefs.h>
@@ -146,7 +146,7 @@
        }
 
        if (mount(MOUNT_MSDOS, dir, mntflags, &args) < 0)
-               err(1, "mount");
+               err(1, "%s on %s", dev, dir);
 
        exit (0);
 }
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_nfs/mount_nfs.c
--- a/sbin/mount_nfs/mount_nfs.c        Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_nfs/mount_nfs.c        Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_nfs.c,v 1.22 1998/05/14 07:44:09 tron Exp $      */
+/*     $NetBSD: mount_nfs.c,v 1.23 1999/06/25 19:28:37 perseant Exp $  */
 
 /*
  * Copyright (c) 1992, 1993, 1994
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)mount_nfs.c        8.11 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: mount_nfs.c,v 1.22 1998/05/14 07:44:09 tron Exp $");
+__RCSID("$NetBSD: mount_nfs.c,v 1.23 1999/06/25 19:28:37 perseant Exp $");
 #endif
 #endif /* not lint */
 
@@ -205,7 +205,7 @@
        struct nfs_args nfsargs;
        struct nfsd_cargs ncd;
        int mntflags, altflags, i, nfssvc_flag, num;
-       char *name, *p, *spec;
+       char *name, *p, *spec, *ospec;
 #ifdef NFSKERB
        uid_t last_ruid;
 
@@ -431,11 +431,14 @@
 
        spec = *argv++;
        name = *argv;
+       if((ospec = strdup(spec))==NULL) {
+               err(1,"strdup");
+       }
 
        if (!getnfsargs(spec, nfsargsp))
                exit(1);
        if (mount(MOUNT_NFS, name, mntflags, nfsargsp))
-               err(1, "%s", name);
+               err(1, "%s on %s", ospec, name);
        if (nfsargsp->flags & (NFSMNT_NQNFS | NFSMNT_KERB)) {
                if ((opflags & ISBGRND) == 0) {
                        if ((i = fork()) != 0) {
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_ntfs/mount_ntfs.c
--- a/sbin/mount_ntfs/mount_ntfs.c      Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_ntfs/mount_ntfs.c      Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_ntfs.c,v 1.2 1999/05/06 16:08:55 christos Exp $  */
+/*     $NetBSD: mount_ntfs.c,v 1.3 1999/06/25 19:28:37 perseant Exp $  */
 
 /*
  * Copyright (c) 1994 Christopher G. Demetriou
@@ -35,7 +35,7 @@
  */
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mount_ntfs.c,v 1.2 1999/05/06 16:08:55 christos Exp $");
+__RCSID("$NetBSD: mount_ntfs.c,v 1.3 1999/06/25 19:28:37 perseant Exp $");
 #endif
 
 #include <sys/cdefs.h>
@@ -187,7 +187,7 @@
 #else
        if (mount(MOUNT_NTFS, dir, mntflags, &args) < 0)
 #endif
-               err(EX_OSERR, "%s", dev);
+               err(EX_OSERR, "%s on %s", dev, dir);
 
        exit (0);
 }
diff -r eb23eae61201 -r 997729953aa8 sbin/mount_null/mount_null.c
--- a/sbin/mount_null/mount_null.c      Fri Jun 25 19:05:49 1999 +0000
+++ b/sbin/mount_null/mount_null.c      Fri Jun 25 19:28:35 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount_null.c,v 1.5 1997/09/16 12:31:02 lukem Exp $     */
+/*     $NetBSD: mount_null.c,v 1.6 1999/06/25 19:28:37 perseant Exp $  */
 



Home | Main Index | Thread Index | Old Index