diff options
author | 1996-12-09 13:38:47 +0000 | |
---|---|---|
committer | 1996-12-09 13:38:47 +0000 | |
commit | ce6aab8df381a33a3781dd839863436cc422c056 (patch) | |
tree | 1a29efde93c8105f352bc0f5f54b0f5d4edabb9f | |
parent | for -a option, refuse if disklabel type != fstab type (diff) | |
download | wireguard-openbsd-ce6aab8df381a33a3781dd839863436cc422c056.tar.xz wireguard-openbsd-ce6aab8df381a33a3781dd839863436cc422c056.zip |
better error messages
-rw-r--r-- | sbin/mount_lfs/mount_lfs.c | 27 | ||||
-rw-r--r-- | sbin/mount_msdos/mount_msdos.c | 26 |
2 files changed, 45 insertions, 8 deletions
diff --git a/sbin/mount_lfs/mount_lfs.c b/sbin/mount_lfs/mount_lfs.c index 47dee48316d..fcec7fa7902 100644 --- a/sbin/mount_lfs/mount_lfs.c +++ b/sbin/mount_lfs/mount_lfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_lfs.c,v 1.3 1996/06/23 14:31:24 deraadt Exp $ */ +/* $OpenBSD: mount_lfs.c,v 1.4 1996/12/09 13:38:47 deraadt Exp $ */ /* $NetBSD: mount_lfs.c,v 1.4 1996/04/13 05:35:44 cgd Exp $ */ /*- @@ -44,12 +44,14 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mount_lfs.c 8.3 (Berkeley) 3/27/94"; #else -static char rcsid[] = "$OpenBSD: mount_lfs.c,v 1.3 1996/06/23 14:31:24 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mount_lfs.c,v 1.4 1996/12/09 13:38:47 deraadt Exp $"; #endif #endif /* not lint */ +#include <sys/types.h> #include <sys/param.h> #include <sys/mount.h> +#include <errno.h> #include <err.h> #include <stdio.h> @@ -79,6 +81,7 @@ main(argc, argv) struct ufs_args args; int ch, mntflags, noclean; char *fs_name, *options; + char *errcause; options = NULL; mntflags = noclean = 0; @@ -116,8 +119,24 @@ main(argc, argv) else args.export.ex_flags = 0; - if (mount(MOUNT_LFS, fs_name, mntflags, &args)) - err(1, NULL); + if (mount(MOUNT_LFS, fs_name, mntflags, &args) == -1) { + 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 --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c index 44d3ca3f92e..fb13e8f90a8 100644 --- a/sbin/mount_msdos/mount_msdos.c +++ b/sbin/mount_msdos/mount_msdos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_msdos.c,v 1.6 1996/11/24 23:46:46 millert Exp $ */ +/* $OpenBSD: mount_msdos.c,v 1.7 1996/12/09 13:40:55 deraadt Exp $ */ /* $NetBSD: mount_msdos.c,v 1.16 1996/10/24 00:12:50 cgd Exp $ */ /* @@ -32,7 +32,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.6 1996/11/24 23:46:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.7 1996/12/09 13:40:55 deraadt Exp $"; #endif /* not lint */ #include <sys/cdefs.h> @@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.6 1996/11/24 23:46:46 millert #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> #include "mntopts.h" @@ -70,6 +71,7 @@ main(argc, argv) struct stat sb; int c, mntflags, set_gid, set_uid, set_mask; char *dev, *dir, ndir[MAXPATHLEN+1]; + char *errcause; mntflags = set_gid = set_uid = set_mask = 0; (void)memset(&args, '\0', sizeof(args)); @@ -143,8 +145,24 @@ main(argc, argv) args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } - if (mount(MOUNT_MSDOS, dir, mntflags, &args) < 0) - err(1, "mount"); + if (mount(MOUNT_MSDOS, dir, mntflags, &args) < 0) { + 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, dir, errcause); + } exit (0); } |