diff options
author | Karel Zak | 2006-12-07 00:25:39 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:39 +0100 |
commit | 7eda085c41faa3445b4b168ce78ab18dab87d98a (patch) | |
tree | eb8da4baebd0af68fa84818d3d51b4a3714667fc /mount | |
parent | Imported from util-linux-2.9i tarball. (diff) | |
download | kernel-qcow2-util-linux-7eda085c41faa3445b4b168ce78ab18dab87d98a.tar.gz kernel-qcow2-util-linux-7eda085c41faa3445b4b168ce78ab18dab87d98a.tar.xz kernel-qcow2-util-linux-7eda085c41faa3445b4b168ce78ab18dab87d98a.zip |
Imported from util-linux-2.9v tarball.
Diffstat (limited to 'mount')
-rw-r--r-- | mount/Makefile | 3 | ||||
-rw-r--r-- | mount/Makefile.standalone | 141 | ||||
-rw-r--r-- | mount/fstab.5 | 22 | ||||
-rw-r--r-- | mount/fstab.c | 127 | ||||
-rw-r--r-- | mount/fstab.h | 5 | ||||
-rw-r--r-- | mount/linux_fs.h | 23 | ||||
-rw-r--r-- | mount/lomount.c | 58 | ||||
-rw-r--r-- | mount/losetup.c | 31 | ||||
-rw-r--r-- | mount/mk_loop_h | 1 | ||||
-rw-r--r-- | mount/mntent.c | 15 | ||||
-rw-r--r-- | mount/mount.8 | 10 | ||||
-rw-r--r-- | mount/mount.c | 222 | ||||
-rw-r--r-- | mount/mount.smb | 68 | ||||
-rw-r--r-- | mount/mount_by_label.c | 8 | ||||
-rw-r--r-- | mount/mount_guess_fstype.c | 30 | ||||
-rw-r--r-- | mount/nfsmount.c | 64 | ||||
-rw-r--r-- | mount/sundries.c | 23 | ||||
-rw-r--r-- | mount/sundries.h | 9 | ||||
-rw-r--r-- | mount/swapon.c | 53 | ||||
-rw-r--r-- | mount/umount.8 | 4 | ||||
-rw-r--r-- | mount/umount.c | 74 |
21 files changed, 558 insertions, 433 deletions
diff --git a/mount/Makefile b/mount/Makefile index c61b4ae8c..0d370ff8c 100644 --- a/mount/Makefile +++ b/mount/Makefile @@ -1,6 +1,5 @@ -ifeq (../MCONFIG,$(wildcard ../MCONFIG)) +include ../make_include include ../MCONFIG -endif CC = gcc CFLAGS = -I$(LIB) $(OPT) diff --git a/mount/Makefile.standalone b/mount/Makefile.standalone deleted file mode 100644 index 1be375689..000000000 --- a/mount/Makefile.standalone +++ /dev/null @@ -1,141 +0,0 @@ -# ifeq (../MCONFIG,$(wildcard ../MCONFIG)) -# include ../MCONFIG -# endif - -# For now: a standalone version - -CC = gcc -CFLAGS = -O2 -I../lib - -#WARNFLAGS = -Wall -Wstrict-prototypes -# We really want -WARNFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes -# but at the moment that yields -#<linux/socket.h>:72: warning: no previous prototype for `cmsg_nxthdr' - -# you need rpcgen and libc-4.2 or rpclib to compile in the NFS support -# pregenerated files are included. -# Make sure nfsmount_clnt.c is newer than nfsmount.x to avoid gcc complaints. -DEFINES = -DHAVE_NFS - -RPCSVCDIR = rpcsvc -RPC_CFLAGS = -Wno-unused -RPCGEN = rpcgen - -INSTALL = install -INSTALLSUID = $(INSTALL) -m 4755 -o root -INSTALLPROG = $(INSTALL) -m 755 -INSTALLDATA = $(INSTALL) -m 644 -INSTALLDIR = mkdir -p -INSTALLMAN = $(INSTALLDATA) - -MANDIR = /usr/man -## for suid progs (mount, umount) -BINDIR = /bin -## for nosuid progs (swapon) -SBINDIR = /sbin - -# End of configuration section. - -COMPILE = $(CC) -c $(WARNFLAGS) $(CFLAGS) $(DEFINES) -LINK = $(CC) $(LDFLAGS) - -SUID_PROGS = mount umount -NOSUID_PROGS = swapon losetup -PROGS = $(SUID_PROGS) $(NOSUID_PROGS) -MAN5 = fstab.5 nfs.5 -MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8 - -# comment these out if you are not compiling in NFS support -NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o -# uncomment this if you don't have libc-4.2 but do have the rpclib -GEN_FILES = nfsmount.x nfsmount.h nfsmount_xdr.c nfsmount_clnt.c - -# comment these out if you are not compiling in loop support -LO_OBJS=lomount.o - -all: $(PROGS) - -install: $(PROGS) - $(INSTALLDIR) $(BINDIR) $(SBINDIR) - $(INSTALLSUID) -s $(SUID_PROGS) $(BINDIR) - $(INSTALLPROG) -s $(NOSUID_PROGS) $(SBINDIR) - (cd $(SBINDIR); ln -sf swapon swapoff) - $(INSTALLDIR) $(MANDIR)/man5 $(MANDIR)/man8 - $(INSTALLMAN) $(MAN5) $(MANDIR)/man5 - $(INSTALLMAN) $(MAN8) $(MANDIR)/man8 - -%.o: %.c - $(COMPILE) $< - -mount: mount.o fstab.o sundries.o realpath.o mntent.o version.o \ - mount_guess_fstype.o mount_by_label.o ../lib/setproctitle.o $(NFS_OBJS) $(LO_OBJS) - $(LINK) $^ -o $@ - -umount: umount.o fstab.o sundries.o realpath.o mntent.o version.o $(LO_OBJS) - $(LINK) $^ -o $@ - -swapon: swapon.o version.o - $(LINK) $^ -o $@ - -losetup: losetup.o - $(LINK) $^ -o $@ - -mount.o umount.o nfsmount.o losetup.o fstab.o sundries.o: sundries.h - -mount.o umount.o fstab.o sundries.o: fstab.h - -mount.o fstab.o mntent.o: mntent.h - -mount.o mount_guess_fstype.o: mount_guess_fstype.h - -mount.o umount.o losetup.o lomount.o: lomount.h loop.h - -swapon.o: swap_constants.h swapargs.h - -sundries.o nfsmount.o nfsmount_xdr.o nfsmount_clnt.o: nfsmount.h - -umount.o: mount_constants.h - -mount.o mount_by_label.o mount_guess_fstype.o: linux_fs.h - -nfsmount_clnt.o: nfsmount_clnt.c - $(COMPILE) $(RPC_CFLAGS) nfsmount_clnt.c - -nfsmount_xdr.o: nfsmount_xdr.c - $(COMPILE) $(RPC_CFLAGS) nfsmount_xdr.c - -nfsmount.h nfsmount_xdr.c nfsmount_clnt.c: nfsmount.x - rm -f nfsmount.h nfsmount_xdr.c nfsmount_clnt.c - $(RPCGEN) -h -o nfsmount.h nfsmount.x - $(RPCGEN) -c -o nfsmount_xdr.c nfsmount.x - $(RPCGEN) -l -o nfsmount_clnt.c nfsmount.x - -nfsmount.x: - cp $(RPCSVCDIR)/nfsmount.x . - -nfsmount.o: nfs_mountversion.h nfs_mount3.h - -NFSMOUNTH=/usr/include/linux/nfs_mount.h - -nfs_mountversion.h: - rm -f nfs_mountversion.h - if [ -f $(NFSMOUNTH) ]; then \ - grep NFS_MOUNT_VERSION $(NFSMOUNTH) \ - | sed -e 's/NFS/KERNEL_NFS/'; \ - else \ - echo '#define KERNEL_NFS_MOUNT_VERSION 0'; \ - fi > nfs_mountversion.h - -swapargs.h: - sh swap.configure - -loop.h: - sh mk_loop_h - -clean: - rm -f a.out core *~ *.o swapargs.h $(PROGS) swapoff - rm -f loop.h nfs_mountversion.h - -clobber distclean realclean: clean - rm -f $(GEN_FILES) diff --git a/mount/fstab.5 b/mount/fstab.5 index d343538db..5b85fb996 100644 --- a/mount/fstab.5 +++ b/mount/fstab.5 @@ -37,8 +37,9 @@ .\" Sat Nov 27 20:23:32 1993: Updated authorship information .\" Wed Jul 26 00:00:00 1995: Updated some nfs stuff, joey@infodrom.north.de .\" Tue Apr 2 00:38:28 1996: added info about "noauto", "user", etc. +.\" Tue Jun 15 20:02:18 1999: added LABEL and UUID .\" -.TH FSTAB 5 "27 November 1993" "Linux 0.99" "Linux Programmer's Manual" +.TH FSTAB 5 "15 June 1999" "Linux 2.2" "Linux Programmer's Manual" .SH NAME fstab \- static information about the filesystems .SH SYNOPSIS @@ -66,11 +67,28 @@ The first field, .RI ( fs_spec ), describes the block special device or remote filesystem to be mounted. +.LP +For ordinary mounts it will hold (a link to) a block special +device node (as created by +.BR mknod (8)) +for the device to be mounted, like `/dev/cdrom' or `/dev/sdb7'. +For NFS mounts one will have <host>:<dir>, e.g., `knuth.aeb.nl:/'. +For procfs, use `proc'. +.LP +Instead of giving the device explicitly, one may indicate +the (ext2) filesystem that is to be mounted by its UUID or +volume label (cf. +.BR e2label (8)), +writing LABEL=<label> or UUID=<uuid>, +e.g., `LABEL=Boot' or `UUID=3e6be9de\%-8139\%-11d1\%-9106\%-a43f08d823a6'. +This will make the system more robust: adding or removing a SCSI disk +changes the disk device name but not the filesystem volume label. The second field, .RI ( fs_file ), describes the mount point for the filesystem. For swap partitions, this -field should be specified as ``none''. +field should be specified as `none'. If the name of the mount point +contains spaces these can be escaped as `\\040'. The third field, .RI ( fs_vfstype ), diff --git a/mount/fstab.c b/mount/fstab.c index a67316ee9..793caddde 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -1,3 +1,9 @@ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls + */ + #include <unistd.h> #include <errno.h> #include <stdio.h> @@ -6,7 +12,7 @@ #include "mntent.h" #include "fstab.h" #include "sundries.h" /* for xmalloc() etc */ - +#include "nls.h" #define streq(s, t) (strcmp ((s), (t)) == 0) @@ -106,7 +112,8 @@ read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) { } mc0->prev = mc; if (ferror (mfp->mntent_fp)) { - error("warning: error reading %s: %s", fnam, strerror (errno)); + int errsv = errno; + error(_("warning: error reading %s: %s"), fnam, strerror (errsv)); mc0->nxt = mc0->prev = NULL; } my_endmntent(mfp); @@ -133,11 +140,11 @@ read_mounttable() { fnam = PROC_MOUNTS; mfp = my_setmntent (fnam, "r"); if (mfp == NULL || mfp->mntent_fp == NULL) { - error("warning: can't open %s: %s", MOUNTED, strerror (errsv)); + error(_("warning: can't open %s: %s"), MOUNTED, strerror (errsv)); return; } if (verbose) - printf ("mount: could not open %s - using %s instead\n", + printf (_("mount: could not open %s - using %s instead\n"), MOUNTED, PROC_MOUNTS); } read_mntentchn(mfp, fnam, mc); @@ -155,7 +162,8 @@ read_fstab() { fnam = _PATH_FSTAB; mfp = my_setmntent (fnam, "r"); if (mfp == NULL || mfp->mntent_fp == NULL) { - error("warning: can't open %s: %s", _PATH_FSTAB, strerror (errno)); + int errsv = errno; + error(_("warning: can't open %s: %s"), _PATH_FSTAB, strerror (errsv)); return; } read_mntentchn(mfp, fnam, mc); @@ -303,12 +311,14 @@ setlkw_timeout (int sig) { superfluous, but avoids an arbitrary sleep(). */ /* Where does the link point to? Obvious choices are mtab and mtab~~. - Maybe the latter is preferable. */ -#define MOUNTLOCK_LINKTARGET MOUNTED_LOCK "~" + HJLu points out that the latter leads to races. Right now we use + mtab~.<pid> instead. */ +#define MOUNTLOCK_LINKTARGET MOUNTED_LOCK "%d" void lock_mtab (void) { int tries = 3; + char *linktargetfile; if (!signals_have_been_setup) { int sig = 0; @@ -329,42 +339,49 @@ lock_mtab (void) { signals_have_been_setup = 1; } + /* somewhat clumsy, but some ancient systems do not have snprintf() */ + /* use 20 as upper bound for the length of %d output */ + linktargetfile = xmalloc(strlen(MOUNTLOCK_LINKTARGET) + 20); + sprintf(linktargetfile, MOUNTLOCK_LINKTARGET, getpid ()); + /* Repeat until it was us who made the link */ while (!we_created_lockfile) { struct flock flock; int errsv, fd, i, j; - i = open (MOUNTLOCK_LINKTARGET, O_WRONLY|O_CREAT, 0); + i = open (linktargetfile, O_WRONLY|O_CREAT, 0); if (i < 0) { - /* MOUNTLOCK_LINKTARGET does not exist (as a file) + int errsv = errno; + /* linktargetfile does not exist (as a file) and we cannot create it. Read-only filesystem? Too many files open in the system? Filesystem full? */ - die (EX_FILEIO, "can't create lock file %s: %s " - "(use -n flag to override)", - MOUNTLOCK_LINKTARGET, strerror (errno)); + die (EX_FILEIO, _("can't create lock file %s: %s " + "(use -n flag to override)"), + linktargetfile, strerror (errsv)); } close(i); - j = link(MOUNTLOCK_LINKTARGET, MOUNTED_LOCK); + j = link(linktargetfile, MOUNTED_LOCK); errsv = errno; - (void) unlink(MOUNTLOCK_LINKTARGET); + (void) unlink(linktargetfile); if (j < 0 && errsv != EEXIST) { - die (EX_FILEIO, "can't link lock file %s: %s " - "(use -n flag to override)", + die (EX_FILEIO, _("can't link lock file %s: %s " + "(use -n flag to override)"), MOUNTED_LOCK, strerror (errsv)); } fd = open (MOUNTED_LOCK, O_WRONLY); if (fd < 0) { + int errsv = errno; /* Strange... Maybe the file was just deleted? */ if (errno == ENOENT && tries-- > 0) continue; - die (EX_FILEIO, "can't open lock file %s: %s " - "(use -n flag to override)", - MOUNTED_LOCK, strerror (errno)); + die (EX_FILEIO, _("can't open lock file %s: %s " + "(use -n flag to override)"), + MOUNTED_LOCK, strerror (errsv)); } flock.l_type = F_WRLCK; @@ -375,9 +392,11 @@ lock_mtab (void) { if (j == 0) { /* We made the link. Now claim the lock. */ if (fcntl (fd, F_SETLK, &flock) == -1) { - if (verbose) - printf("Can't lock lock file %s: %s\n", - MOUNTED_LOCK, strerror (errno)); + if (verbose) { + int errsv = errno; + printf(_("Can't lock lock file %s: %s\n"), + MOUNTED_LOCK, strerror (errsv)); + } /* proceed anyway */ } we_created_lockfile = 1; @@ -385,9 +404,10 @@ lock_mtab (void) { /* Someone else made the link. Wait. */ alarm(LOCK_TIMEOUT); if (fcntl (fd, F_SETLKW, &flock) == -1) { - die (EX_FILEIO, "can't lock lock file %s: %s", + int errsv = errno; + die (EX_FILEIO, _("can't lock lock file %s: %s"), MOUNTED_LOCK, (errno == EINTR) ? - "timed out" : strerror (errno)); + _("timed out") : strerror (errsv)); } alarm(0); /* Maybe limit the number of iterations? */ @@ -431,23 +451,32 @@ update_mtab (const char *dir, struct mntent *instead) { mfp = my_setmntent(MOUNTED, "r"); if (mfp == NULL || mfp->mntent_fp == NULL) { - error ("cannot open %s (%s) - mtab not updated", - MOUNTED, strerror (errno)); + int errsv = errno; + error (_("cannot open %s (%s) - mtab not updated"), + MOUNTED, strerror (errsv)); goto leave; } mftmp = my_setmntent (MOUNTED_TEMP, "w"); if (mftmp == NULL || mfp->mntent_fp == NULL) { - error ("can't open %s (%s) - mtab not updated", - MOUNTED_TEMP, strerror (errno)); + int errsv = errno; + error (_("cannot open %s (%s) - mtab not updated"), + MOUNTED_TEMP, strerror (errsv)); goto leave; } while ((mnt = my_getmntent (mfp))) { if (streq (mnt->mnt_dir, dir) +#if 0 /* Matthew Wilcox <willy@odie.barnet.ac.uk> */ + /* This is meant for Patch 212 on Jitterbug, + still in incoming, to allow remounting + on a different directory. */ || (instead && instead->mnt_fsname && - (streq (mnt->mnt_fsname, instead->mnt_fsname)))) { + (!streq (instead->mnt_fsname, "none")) && + (streq (mnt->mnt_fsname, instead->mnt_fsname))) +#endif + ) { added++; if (instead) { /* a remount */ remnt = *instead; @@ -456,34 +485,42 @@ update_mtab (const char *dir, struct mntent *instead) { remnt.mnt_type = mnt->mnt_type; if (instead->mnt_fsname && !streq(mnt->mnt_fsname, instead->mnt_fsname)) - printf("mount: warning: cannot change " - "mounted device with a remount\n"); + printf(_("mount: warning: cannot change " + "mounted device with a remount\n")); else if (instead->mnt_type && !streq(instead->mnt_type, "unknown") && !streq(mnt->mnt_type, instead->mnt_type)) - printf("mount: warning: cannot change " - "filesystem type with a remount\n"); + printf(_("mount: warning: cannot change " + "filesystem type with a remount\n")); } else next = NULL; } else next = mnt; - if (next && my_addmntent(mftmp, next) == 1) - die (EX_FILEIO, "error writing %s: %s", - MOUNTED_TEMP, strerror (errno)); + if (next && my_addmntent(mftmp, next) == 1) { + int errsv = errno; + die (EX_FILEIO, _("error writing %s: %s"), + MOUNTED_TEMP, strerror (errsv)); + } } - if (instead && !added && my_addmntent(mftmp, instead) == 1) - die (EX_FILEIO, "error writing %s: %s", - MOUNTED_TEMP, strerror (errno)); + if (instead && !added && my_addmntent(mftmp, instead) == 1) { + int errsv = errno; + die (EX_FILEIO, _("error writing %s: %s"), + MOUNTED_TEMP, strerror (errsv)); + } my_endmntent (mfp); - if (fchmod (fileno (mftmp->mntent_fp), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) - fprintf(stderr, "error changing mode of %s: %s\n", MOUNTED_TEMP, - strerror (errno)); + 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)); + } my_endmntent (mftmp); - if (rename (MOUNTED_TEMP, MOUNTED) < 0) - fprintf(stderr, "can't rename %s to %s: %s\n", MOUNTED_TEMP, MOUNTED, - strerror(errno)); + if (rename (MOUNTED_TEMP, MOUNTED) < 0) { + int errsv = errno; + fprintf(stderr, _("can't rename %s to %s: %s\n"), MOUNTED_TEMP, MOUNTED, + strerror(errsv)); + } leave: unlock_mtab(); diff --git a/mount/fstab.h b/mount/fstab.h index e0b3895c2..acd8f6271 100644 --- a/mount/fstab.h +++ b/mount/fstab.h @@ -1,6 +1,11 @@ #define _PATH_FSTAB "/etc/fstab" +#ifdef _PATH_MOUNTED +#define MOUNTED_LOCK _PATH_MOUNTED "~" +#define MOUNTED_TEMP _PATH_MOUNTED ".tmp" +#else #define MOUNTED_LOCK "/etc/mtab~" #define MOUNTED_TEMP "/etc/mtab.tmp" +#endif #define LOCK_TIMEOUT 10 int mtab_is_writable(void); diff --git a/mount/linux_fs.h b/mount/linux_fs.h index bdc548c21..bd9243b55 100644 --- a/mount/linux_fs.h +++ b/mount/linux_fs.h @@ -76,3 +76,26 @@ struct ufs_super_block { #define ufsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \ (((uint) s.s_magic[2]) << 16) + \ (((uint) s.s_magic[3]) << 24)) + +/* From Richard.Russon@ait.co.uk Wed Feb 24 08:05:27 1999 */ +#define NTFS_SUPER_MAGIC "NTFS" +struct ntfs_super_block { + u_char s_dummy[3]; + u_char s_magic[4]; +}; + +/* From inspection of a few FAT filesystems - aeb */ +/* Unfortunately I find almost the same thing on an extended partition; + it looks like a primary has some directory entries where the extended + has a partition table: IO.SYS, MSDOS.SYS, WINBOOT.SYS */ +struct fat_super_block { + u_char s_dummy[3]; + u_char s_os[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */ + u_char s_dummy2[32]; + u_char s_label[11]; /* for DOS? */ + u_char s_fs[8]; /* "FAT12 " or "FAT16 " or all zero */ + /* OS/2 BM has "FAT " here. */ + u_char s_dummy3[9]; + u_char s_label2[11]; /* for Windows? */ + u_char s_fs2[8]; /* garbage or "FAT32 " */ +}; diff --git a/mount/lomount.c b/mount/lomount.c index 276ab4e49..d99078585 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -2,6 +2,12 @@ /* Added vfs mount options - aeb - 960223 */ /* Removed lomount - aeb - 960224 */ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls + */ + #define PROC_DEVICES "/proc/devices" /* @@ -20,6 +26,7 @@ #include "loop.h" #include "lomount.h" +#include "nls.h" char *xstrdup (const char *s); /* not: #include "sundries.h" */ void error (const char *fmt, ...); /* idem */ @@ -67,17 +74,19 @@ show_loop (char *device) int fd; if ((fd = open (device, O_RDONLY)) < 0) { - fprintf(stderr, "loop: can't open device %s: %s\n", - device, strerror (errno)); + int errsv = errno; + fprintf(stderr, _("loop: can't open device %s: %s\n"), + device, strerror (errsv)); return; } if (ioctl (fd, LOOP_GET_STATUS, &loopinfo) < 0) { - fprintf(stderr, "loop: can't get info on device %s: %s\n", - device, strerror (errno)); + int errsv = errno; + fprintf(stderr, _("loop: can't get info on device %s: %s\n"), + device, strerror (errsv)); close (fd); return; } - printf ("%s: [%04x]:%ld (%s) offset %d, %s encryption\n", + printf (_("%s: [%04x]:%ld (%s) offset %d, %s encryption\n"), device, loopinfo.lo_device, loopinfo.lo_inode, loopinfo.lo_name, loopinfo.lo_offset, crypt_name (loopinfo.lo_encrypt_type)); @@ -131,24 +140,24 @@ find_unused_loop_device (void) } if (!somedev) - error("mount: could not find any device /dev/loop#"); + error(_("mount: could not find any device /dev/loop#")); else if(!someloop) { if (loop_known == 1) - error( + error(_( "mount: Could not find any loop device.\n" -" Maybe /dev/loop# has a wrong major number?"); +" Maybe /dev/loop# has a wrong major number?")); else if (loop_known == -1) - error( + error(_( "mount: Could not find any loop device, and, according to %s,\n" " this kernel does not know about the loop device.\n" -" (If so, then recompile or `insmod loop.o'.)", PROC_DEVICES); +" (If so, then recompile or `insmod loop.o'.)"), PROC_DEVICES); else - error( + error(_( "mount: Could not find any loop device. Maybe this kernel does not know\n" " about the loop device (then recompile or `insmod loop.o'), or\n" -" maybe /dev/loop# has the wrong major number?"); +" maybe /dev/loop# has the wrong major number?")); } else - error("mount: could not find any free loop device"); + error(_("mount: could not find any free loop device")); return 0; } @@ -179,7 +188,7 @@ set_loop (const char *device, const char *file, int offset, loopinfo.lo_name[LO_NAME_SIZE - 1] = 0; if (encryption && (loopinfo.lo_encrypt_type = crypt_type (encryption)) < 0) { - fprintf (stderr, "Unsupported encryption type %s\n", encryption); + fprintf (stderr, _("Unsupported encryption type %s\n"), encryption); return 1; } loopinfo.lo_offset = offset; @@ -188,30 +197,30 @@ set_loop (const char *device, const char *file, int offset, loopinfo.lo_encrypt_key_size = 0; break; case LO_CRYPT_XOR: - pass = getpass ("Password: "); + pass = getpass (_("Password: ")); strncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); loopinfo.lo_encrypt_key[LO_KEY_SIZE - 1] = 0; loopinfo.lo_encrypt_key_size = strlen (loopinfo.lo_encrypt_key); break; case LO_CRYPT_DES: - pass = getpass ("Password: "); + pass = getpass (_("Password: ")); strncpy (loopinfo.lo_encrypt_key, pass, 8); loopinfo.lo_encrypt_key[8] = 0; loopinfo.lo_encrypt_key_size = 8; - pass = getpass ("Init (up to 16 hex digits): "); + pass = getpass (_("Init (up to 16 hex digits): ")); for (i = 0; i < 16 && pass[i]; i++) if (isxdigit (pass[i])) loopinfo.lo_init[i >> 3] |= (pass[i] > '9' ? (islower (pass[i]) ? toupper (pass[i]) : pass[i]) - 'A' + 10 : pass[i] - '0') << (i & 7) * 4; else { - fprintf (stderr, "Non-hex digit '%c'.\n", pass[i]); + fprintf (stderr, _("Non-hex digit '%c'.\n"), pass[i]); return 1; } break; default: fprintf (stderr, - "Don't know how to get key for encryption system %d\n", + _("Don't know how to get key for encryption system %d\n"), loopinfo.lo_encrypt_type); return 1; } @@ -227,7 +236,7 @@ set_loop (const char *device, const char *file, int offset, close (fd); close (ffd); if (verbose > 1) - printf("set_loop(%s,%s,%d): success\n", device, file, offset); + printf(_("set_loop(%s,%s,%d): success\n"), device, file, offset); return 0; } @@ -237,8 +246,9 @@ del_loop (const char *device) int fd; if ((fd = open (device, O_RDONLY)) < 0) { - fprintf(stderr, "loop: can't delete device %s: %s\n", - device, strerror (errno)); + int errsv = errno; + fprintf(stderr, _("loop: can't delete device %s: %s\n"), + device, strerror (errsv)); return 1; } if (ioctl (fd, LOOP_CLR_FD, 0) < 0) { @@ -247,7 +257,7 @@ del_loop (const char *device) } close (fd); if (verbose > 1) - printf("del_loop(%s): success\n", device); + printf(_("del_loop(%s): success\n"), device); return 0; } @@ -255,7 +265,7 @@ del_loop (const char *device) static void mutter(void) { fprintf(stderr, - "This mount was compiled without loop support. Please recompile.\n"); + _("This mount was compiled without loop support. Please recompile.\n")); } int diff --git a/mount/losetup.c b/mount/losetup.c index 8a75a9aef..911d73060 100644 --- a/mount/losetup.c +++ b/mount/losetup.c @@ -2,6 +2,10 @@ * losetup.c - setup and control loop devices */ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <stdio.h> #include <string.h> #include <ctype.h> @@ -13,6 +17,7 @@ #include "loop.h" #include "lomount.h" +#include "nls.h" #ifdef LOOP_SET_FD @@ -62,11 +67,11 @@ static void show_loop(const char *device) return; } if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) < 0) { - perror("Cannot get loop info"); + perror(_("Cannot get loop info")); close(fd); return; } - printf("%s: [%04x]:%ld (%s) offset %d, %s encryption\n", + printf(_("%s: [%04x]:%ld (%s) offset %d, %s encryption\n"), device, loopinfo.lo_device, loopinfo.lo_inode, loopinfo.lo_name, loopinfo.lo_offset, crypt_name(loopinfo.lo_encrypt_type)); @@ -98,7 +103,7 @@ int set_loop(const char *device, const char *file, int offset, loopinfo.lo_name[LO_NAME_SIZE-1] = 0; if (encryption && (loopinfo.lo_encrypt_type = crypt_type(encryption)) < 0) { - fprintf(stderr,"Unsupported encryption type %s\n",encryption); + fprintf(stderr,_("Unsupported encryption type %s\n"),encryption); exit(1); } loopinfo.lo_offset = offset; @@ -107,30 +112,30 @@ int set_loop(const char *device, const char *file, int offset, loopinfo.lo_encrypt_key_size = 0; break; case LO_CRYPT_XOR: - pass = getpass("Password: "); + pass = getpass(_("Password: ")); strncpy(loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); loopinfo.lo_encrypt_key[LO_KEY_SIZE-1] = 0; loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key); break; case LO_CRYPT_DES: - pass = getpass("Password: "); + pass = getpass(_("Password: ")); strncpy(loopinfo.lo_encrypt_key, pass, 8); loopinfo.lo_encrypt_key[8] = 0; loopinfo.lo_encrypt_key_size = 8; - pass = getpass("Init (up to 16 hex digits): "); + pass = getpass(_("Init (up to 16 hex digits): ")); for (i = 0; i < 16 && pass[i]; i++) if (isxdigit(pass[i])) loopinfo.lo_init[i >> 3] |= (pass[i] > '9' ? (islower(pass[i]) ? toupper(pass[i]) : pass[i])-'A'+10 : pass[i]-'0') << (i & 7)*4; else { - fprintf(stderr,"Non-hex digit '%c'.\n",pass[i]); + fprintf(stderr,_("Non-hex digit '%c'.\n"),pass[i]); exit(1); } break; default: fprintf(stderr, - "Don't know how to get key for encryption system %d\n", + _("Don't know how to get key for encryption system %d\n"), loopinfo.lo_encrypt_type); exit(1); } @@ -166,10 +171,10 @@ int del_loop(const char *device) static int usage(void) { - fprintf(stderr, "usage:\n\ + fprintf(stderr, _("usage:\n\ %s loop_device # give info\n\ %s -d loop_device # delete\n\ - %s [ -e encryption ] [ -o offset ] loop_device file # setup\n", + %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"), progname, progname, progname); exit(1); } @@ -180,6 +185,10 @@ int main(int argc, char **argv) int delete,off,c; int ro = 0; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + delete = off = 0; offset = encryption = NULL; progname = argv[0]; @@ -219,7 +228,7 @@ int main(int argc, char **argv) int main(int argc, char **argv) { fprintf(stderr, - "No loop support was available at compile time. Please recompile.\n"); + _("No loop support was available at compile time. Please recompile.\n")); return -1; } #endif diff --git a/mount/mk_loop_h b/mount/mk_loop_h index 0f8a1a617..dfeff296e 100644 --- a/mount/mk_loop_h +++ b/mount/mk_loop_h @@ -29,3 +29,4 @@ else fi echo '#undef dev_t' >> loop.h + diff --git a/mount/mntent.c b/mount/mntent.c index 0be20e8ca..ac9cce823 100644 --- a/mount/mntent.c +++ b/mount/mntent.c @@ -1,11 +1,16 @@ /* Private version of the libc *mntent() routines. */ /* Note slightly different prototypes. */ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <stdio.h> #include <string.h> /* for index */ #include <ctype.h> /* for isdigit */ #include "mntent.h" #include "sundries.h" /* for xmalloc */ +#include "nls.h" /* Unfortunately the classical Unix /etc/mtab and /etc/fstab do not handle directory names containing spaces. @@ -157,8 +162,8 @@ my_getmntent (mntFILE *mfp) { /* Missing final newline? Otherwise extremely */ /* long line - assume file was corrupted */ if (feof(mfp->mntent_fp)) { - fprintf(stderr, "[mntent]: warning: no final " - "newline at the end of %s\n", + fprintf(stderr, _("[mntent]: warning: no final " + "newline at the end of %s\n"), mfp->mntent_file); s = index (buf, 0); } else { @@ -167,6 +172,8 @@ my_getmntent (mntFILE *mfp) { } } *s = 0; + if (--s >= buf && *s == '\r') + *s = 0; s = skip_spaces(buf); } while (*s == '\0' || *s == '#'); @@ -206,9 +213,9 @@ my_getmntent (mntFILE *mfp) { err: mfp->mntent_softerrs++; - fprintf(stderr, "[mntent]: line %d in %s is bad%s\n", + fprintf(stderr, _("[mntent]: line %d in %s is bad%s\n"), mfp->mntent_lineno, mfp->mntent_file, (mfp->mntent_errs || mfp->mntent_softerrs >= ERR_MAX) ? - "; rest of file ignored" : ""); + _("; rest of file ignored") : ""); goto again; } diff --git a/mount/mount.8 b/mount/mount.8 index 633671b19..f42375fdc 100644 --- a/mount/mount.8 +++ b/mount/mount.8 @@ -1015,6 +1015,16 @@ If no explicit loop device is mentioned (but just an option `\fB\-o loop\fP' is given), then .B mount will try to find some unused loop device and use that. +If you are not so unwise as to make +.I /etc/mtab +a symbolic link to +.I /proc/mounts +then any loop device allocated by +.B mount +will be freed by +.BR umount . +You can also free a loop device by hand, using `losetup -d', see +.BR losetup (8). .SH FILES .I /etc/fstab diff --git a/mount/mount.c b/mount/mount.c index 5ee247daa..9f51db310 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -25,6 +25,13 @@ * Avoid unnecessary error messages about /proc. * Improve support for noncanonical names in /etc/fstab. * Add support for volume labels and UUIDs. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * 1999-03-21 Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls + * 1999-07-05 Hirokazu Takahashi <h-takaha@sss.abk.nec.co.jp> + * - fixed use of nouser option */ #include <unistd.h> @@ -50,6 +57,7 @@ #include "mount_guess_fstype.h" #include "mount_by_label.h" #include "getusername.h" +#include "nls.h" #define DO_PS_FIDDLING @@ -233,7 +241,8 @@ parse_opt (const char *opt, int *mask, char *extra_opts) *mask &= ~om->mask; else *mask |= om->mask; - if (om->mask == MS_USER || om->mask == MS_USERS) + if ((om->mask == MS_USER || om->mask == MS_USERS) + && !om->inv) *mask |= MS_SECURE; #ifdef MS_SILENT if (om->mask == MS_SILENT && om->inv) { @@ -311,10 +320,10 @@ already (const char *spec, const char *node) { int ret = 1; if ((mc = getmntfile(node)) != NULL) - error ("mount: according to mtab, %s is already mounted on %s", + error (_("mount: according to mtab, %s is already mounted on %s"), mc->mnt_fsname, node); else if ((mc = getmntfile(spec)) != NULL) - error ("mount: according to mtab, %s is mounted on %s", + error (_("mount: according to mtab, %s is mounted on %s"), spec, mc->mnt_dir); else ret = 0; @@ -333,9 +342,11 @@ create_mtab (void) { lock_mtab(); mfp = my_setmntent (MOUNTED, "a+"); - if (mfp == NULL || mfp->mntent_fp == NULL) - die (EX_FILEIO, "mount: can't open %s for writing: %s", - MOUNTED, strerror (errno)); + if (mfp == NULL || mfp->mntent_fp == NULL) { + int errsv = errno; + die (EX_FILEIO, _("mount: can't open %s for writing: %s"), + MOUNTED, strerror (errsv)); + } /* Find the root entry by looking it up in fstab */ if ((fstab = getfsfile ("/")) || (fstab = getfsfile ("root"))) { @@ -346,14 +357,18 @@ create_mtab (void) { mnt.mnt_opts = fix_opts_string (flags, extra_opts, NULL); mnt.mnt_freq = mnt.mnt_passno = 0; - if (my_addmntent (mfp, &mnt) == 1) - die (EX_FILEIO, "mount: error writing %s: %s", - MOUNTED, strerror (errno)); + if (my_addmntent (mfp, &mnt) == 1) { + int errsv = errno; + die (EX_FILEIO, _("mount: error writing %s: %s"), + MOUNTED, strerror (errsv)); + } } if (fchmod (fileno (mfp->mntent_fp), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) - if (errno != EROFS) - die (EX_FILEIO, "mount: error changing mode of %s: %s", - MOUNTED, strerror (errno)); + if (errno != EROFS) { + int errsv = errno; + die (EX_FILEIO, _("mount: error changing mode of %s: %s"), + MOUNTED, strerror (errsv)); + } my_endmntent (mfp); unlock_mtab(); @@ -401,14 +416,13 @@ try_mount5 (char *spec, char *node, char **type, int flags, char *mount_opts) { */ static int try_mount_one (const char *spec0, const char *node0, char *type0, - const char *opts0, int freq, int pass, int bg) { + const char *opts0, int freq, int pass, int bg, int ro) { struct mntentchn mcn; struct mntent mnt; int mnt_err; int flags; char *extra_opts; /* written in mtab */ char *mount_opts; /* actually used on system call */ - static int added_ro = 0; int loop, looptype, offset; const char *opts; char *spec, *node, *type, *loopdev, *loopfile; @@ -426,9 +440,9 @@ try_mount_one (const char *spec0, const char *node0, char *type0, if (suid) { if (!(flags & (MS_USER | MS_USERS))) { if (already (spec, node)) - die (EX_USAGE, "mount failed"); + die (EX_USAGE, _("mount failed")); else - die (EX_USAGE, "mount: only root can mount %s on %s", spec, node); + die (EX_USAGE, _("mount: only root can mount %s on %s"), spec, node); } if (flags & MS_USER) user = getusername(); @@ -453,13 +467,13 @@ try_mount_one (const char *spec0, const char *node0, char *type0, looptype = (type && strncmp("lo@", type, 3) == 0); if (looptype) { if (loopdev) - error("mount: loop device specified twice"); + error(_("mount: loop device specified twice")); loopdev = type+3; type = opt_vfstype; } else if (opt_vfstype) { if (type) - error("mount: type specified twice"); + error(_("mount: type specified twice")); else type = opt_vfstype; } @@ -471,7 +485,7 @@ try_mount_one (const char *spec0, const char *node0, char *type0, flags |= MS_LOOP; if (fake) { if (verbose) - printf("mount: skipping the setup of a loop device\n"); + printf(_("mount: skipping the setup of a loop device\n")); } else { int loopro = (flags & MS_RDONLY); @@ -480,15 +494,15 @@ try_mount_one (const char *spec0, const char *node0, char *type0, if (!loopdev) return EX_SYSERR; /* no more loop devices */ if (verbose) - printf("mount: going to use the loop device %s\n", loopdev); + printf(_("mount: going to use the loop device %s\n"), loopdev); offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0; if (set_loop (loopdev, loopfile, offset, opt_encryption, &loopro)) { if (verbose) - printf("mount: failed setting up loop device\n"); + printf(_("mount: failed setting up loop device\n")); return EX_FAIL; } if (verbose > 1) - printf("mount: setup loop device successfully\n"); + printf(_("mount: setup loop device successfully\n")); spec = loopdev; if (loopro) flags |= MS_RDONLY; @@ -501,8 +515,8 @@ try_mount_one (const char *spec0, const char *node0, char *type0, if (mnt_err) return mnt_err; #else - die (EX_SOFTWARE, "mount: this version was compiled " - "without support for the type `nfs'"); + die (EX_SOFTWARE, _("mount: this version was compiled " + "without support for the type `nfs'")); #endif } @@ -513,8 +527,9 @@ try_mount_one (const char *spec0, const char *node0, char *type0, if (type) #ifndef ALWAYS_STAT if (streq (type, "smb") || streq (type, "ncp") - /* || streq (type, "smbfs") || streq (type, "ncpfs") */ - ) + /* these are incorrect but perhaps used by smbmount or so */ + || streq (type, "smbfs") || streq (type, "ncpfs") + ) #else if (strlen (type) < 100) #endif @@ -548,8 +563,10 @@ try_mount_one (const char *spec0, const char *node0, char *type0, int status; wait(&status); return status; - } else - error("mount: cannot fork: %s", strerror(errno)); + } else { + int errsv = errno; + error(_("mount: cannot fork: %s"), strerror(errsv)); + } } } @@ -585,12 +602,15 @@ try_mount_one (const char *spec0, const char *node0, char *type0, lock_mtab(); mfp = my_setmntent(MOUNTED, "a+"); if (mfp == NULL || mfp->mntent_fp == NULL) { - error("mount: can't open %s: %s", MOUNTED, - strerror (errno)); + int errsv = errno; + error(_("mount: can't open %s: %s"), MOUNTED, + strerror (errsv)); } else { - if ((my_addmntent (mfp, &mnt)) == 1) - error("mount: error writing %s: %s", MOUNTED, - strerror (errno)); + if ((my_addmntent (mfp, &mnt)) == 1) { + int errsv = errno; + error(_("mount: error writing %s: %s"), MOUNTED, + strerror (errsv)); + } my_endmntent(mfp); } unlock_mtab(); @@ -611,57 +631,66 @@ try_mount_one (const char *spec0, const char *node0, char *type0, /* Mount failed, complain, but don't die. */ if (type == 0) - error ("mount: you must specify the filesystem type"); + error (_("mount: you must specify the filesystem type")); else switch (mnt_err) { case EPERM: if (geteuid() == 0) { if (stat (node, &statbuf) || !S_ISDIR(statbuf.st_mode)) - error ("mount: mount point %s is not a directory", node); + error (_("mount: mount point %s is not a directory"), node); else - error ("mount: permission denied"); + error (_("mount: permission denied")); } else - error ("mount: must be superuser to use mount"); + error (_("mount: must be superuser to use mount")); break; case EBUSY: if (flags & MS_REMOUNT) { - error ("mount: %s is busy", node); + error (_("mount: %s is busy"), node); } else if (!strcmp(type, "proc") && !strcmp(node, "/proc")) { /* heuristic: if /proc/version exists, then probably proc is mounted */ if (stat ("/proc/version", &statbuf)) /* proc mounted? */ - error ("mount: %s is busy", node); /* no */ + error (_("mount: %s is busy"), node); /* no */ else if(!all || verbose) /* yes, don't mention it */ - error ("mount: proc already mounted"); + error (_("mount: proc already mounted")); } else { - error ("mount: %s already mounted or %s busy", spec, node); + error (_("mount: %s already mounted or %s busy"), spec, node); already (spec, node); } break; case ENOENT: if (lstat (node, &statbuf)) - error ("mount: mount point %s does not exist", node); + error (_("mount: mount point %s does not exist"), node); else if (stat (node, &statbuf)) - error ("mount: mount point %s is a symbolic link to nowhere", + error (_("mount: mount point %s is a symbolic link to nowhere"), node); else if (stat (spec, &statbuf)) - error ("mount: special device %s does not exist", spec); + error (_("mount: special device %s does not exist"), spec); else { errno = mnt_err; perror("mount"); } break; case ENOTDIR: - error ("mount: mount point %s is not a directory", node); + if (stat (node, &statbuf) || ! S_ISDIR(statbuf.st_mode)) + error (_("mount: mount point %s is not a directory"), node); + else if (stat (spec, &statbuf) && errno == ENOTDIR) + error (_("mount: special device %s does not exist\n" + " (a path prefix is not a directory)\n"), spec); + else { + errno = mnt_err; + perror("mount"); + } break; case EINVAL: - { int fd, size; + { int fd; + long size; if (flags & MS_REMOUNT) { - error ("mount: %s not mounted already, or bad option", node); + error (_("mount: %s not mounted already, or bad option"), node); } else { - error ("mount: wrong fs type, bad option, bad superblock on %s,\n" - " or too many mounted file systems", + error (_("mount: wrong fs type, bad option, bad superblock on %s,\n" + " or too many mounted file systems"), spec); if (stat (spec, &statbuf) == 0 && S_ISBLK(statbuf.st_mode) @@ -675,17 +704,17 @@ try_mount_one (const char *spec0, const char *node0, char *type0, break; } case EMFILE: - error ("mount table full"); break; + error (_("mount table full")); break; case EIO: - error ("mount: %s: can't read superblock", spec); break; + error (_("mount: %s: can't read superblock"), spec); break; case ENODEV: if (is_in_procfs(type) || !strcmp(type, "guess")) - error("mount: %s has wrong major or minor number", spec); + error(_("mount: %s has wrong major or minor number"), spec); else if (have_procfs()) { char *lowtype, *p; int u; - error ("mount: fs type %s not supported by kernel", type); + error (_("mount: fs type %s not supported by kernel"), type); /* maybe this loser asked for FAT or ISO9660 or isofs */ lowtype = xstrdup(type); @@ -697,36 +726,35 @@ try_mount_one (const char *spec0, const char *node0, char *type0, } } if (u && is_in_procfs(lowtype)) - error ("mount: probably you meant %s", lowtype); + error (_("mount: probably you meant %s"), lowtype); else if (!strncmp(lowtype, "iso", 3) && is_in_procfs("iso9660")) - error ("mount: maybe you meant iso9660 ?"); + error (_("mount: maybe you meant iso9660 ?")); free(lowtype); } else - error ("mount: %s has wrong device number or fs type %s not supported", + error (_("mount: %s has wrong device number or fs type %s not supported"), spec, type); break; case ENOTBLK: if (stat (spec, &statbuf)) /* strange ... */ - error ("mount: %s is not a block device, and stat fails?", spec); + error (_("mount: %s is not a block device, and stat fails?"), spec); else if (S_ISBLK(statbuf.st_mode)) - error ("mount: the kernel does not recognize %s as a block device\n" - " (maybe `insmod driver'?)", spec); + error (_("mount: the kernel does not recognize %s as a block device\n" + " (maybe `insmod driver'?)"), spec); else if (S_ISREG(statbuf.st_mode)) - error ("mount: %s is not a block device (maybe try `-o loop'?)", + error (_("mount: %s is not a block device (maybe try `-o loop'?)"), spec); else - error ("mount: %s is not a block device", spec); + error (_("mount: %s is not a block device"), spec); break; case ENXIO: - error ("mount: %s is not a valid block device", spec); break; + error (_("mount: %s is not a valid block device"), spec); break; case EACCES: /* pre-linux 1.1.38, 1.1.41 and later */ case EROFS: /* linux 1.1.38 and later */ - if (added_ro) { - error ("mount: block device %s is not permitted on its filesystem", + if (ro) { + error (_("mount: block device %s is not permitted on its filesystem"), spec); break; } else { - added_ro = 1; if (loop) { opts = opts0; type = type0; @@ -739,9 +767,9 @@ try_mount_one (const char *spec0, const char *node0, char *type0, opts = "ro"; if (type && !strcmp(type, "guess")) type = 0; - error ("mount: %s%s is write-protected, mounting read-only", - loop ? "" : "block device ", spec0); - return try_mount_one (spec0, node0, type, opts, freq, pass, bg); + error (_("mount: %s%s is write-protected, mounting read-only"), + loop ? "" : _("block device "), spec0); + return try_mount_one (spec0, node0, type, opts, freq, pass, bg, 1); } break; default: @@ -826,10 +854,10 @@ mount_one (const char *spec, const char *node, char *type, const char *opts, if (nspec) { spec = nspec; if (verbose) - printf("mount: consider mounting %s by %s\n", spec, - (specset==1) ? "UUID" : "label"); + printf(_("mount: consider mounting %s by %s\n"), spec, + (specset==1) ? _("UUID") : _("label")); } else if(!all) - die (EX_USAGE, "mount: no such partition found"); + die (EX_USAGE, _("mount: no such partition found")); /* if -a then we may be rescued by a noauto option */ } @@ -837,8 +865,8 @@ mount_one (const char *spec, const char *node, char *type, const char *opts, if (strchr (spec, ':') != NULL) { type = "nfs"; if (verbose) - printf("mount: no type was given - " - "I'll assume nfs because of the colon\n"); + printf(_("mount: no type was given - " + "I'll assume nfs because of the colon\n")); } } @@ -846,14 +874,14 @@ mount_one (const char *spec, const char *node, char *type, const char *opts, * Try to mount the file system. When the exit status is EX_BG, * we will retry in the background. Otherwise, we're done. */ - status = try_mount_one (spec, node, type, opts, freq, pass, 0); + status = try_mount_one (spec, node, type, opts, freq, pass, 0, 0); if (status != EX_BG) return status; /* * Retry in the background. */ - printf ("mount: backgrounding \"%s\"\n", spec); + printf (_("mount: backgrounding \"%s\"\n"), spec); fflush( stdout ); /* prevent duplicate output */ if (fork() > 0) return 0; /* parent returns "success" */ @@ -862,9 +890,9 @@ mount_one (const char *spec, const char *node, char *type, const char *opts, type = xstrdup(type); opts = xstrdup(opts); set_proc_name (spec); /* make a nice "ps" listing */ - status2 = try_mount_one (spec, node, type, opts, freq, pass, 1); + status2 = try_mount_one (spec, node, type, opts, freq, pass, 1, 0); if (verbose && status2) - printf ("mount: giving up \"%s\"\n", spec); + printf (_("mount: giving up \"%s\"\n"), spec); exit (0); /* child stops here */ } @@ -913,7 +941,7 @@ mount_all (string_list types, char *options) { && !streq (mc->mnt_dir, "root")) { if (mounted (mc->mnt_fsname, mc->mnt_dir)) { if (verbose) - printf("mount: %s already mounted on %s\n", + printf(_("mount: %s already mounted on %s\n"), mc->mnt_fsname, mc->mnt_dir); } else { mtmp = (struct mntentchn *) xmalloc(sizeof(*mtmp)); @@ -960,8 +988,10 @@ mount_all (string_list types, char *options) { pid_t p = -1; if (optfork) { p = fork(); - if (p == -1) - error("mount: cannot fork: %s", strerror (errno)); + if (p == -1) { + int errsv = errno; + error(_("mount: cannot fork: %s"), strerror (errsv)); + } else if (p != 0) cp->pid = p; } @@ -1019,18 +1049,14 @@ static struct option longopts[] = { NULL, 0, 0, 0 } }; -const char *usage_string = "\ -Usage: mount [-hV]\n\ - mount -a [-nfFrsvw] [-t vfstypes]\n\ - mount [-nfrsvw] [-o options] special | node\n\ - mount [-nfrsvw] [-t vfstype] [-o options] special node\n\ -A special device can be indicated by -L label or -U uuid . -"; - static void usage (FILE *fp, int n) { - fprintf (fp, "%s", usage_string); + fprintf (fp, _("Usage: mount [-hV]\n" + " mount -a [-nfFrsvw] [-t vfstypes]\n" + " mount [-nfrsvw] [-o options] special | node\n" + " mount [-nfrsvw] [-t vfstype] [-o options] special node\n" + " A special device can be indicated by -L label or -U uuid .\n")); unlock_mtab(); exit (n); } @@ -1045,6 +1071,10 @@ main (int argc, char *argv[]) { struct mntentchn *mc; int fd; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + /* People report that a mount called from init without console writes error messages to /etc/mtab Let us try to avoid getting fd's 0,1,2 */ @@ -1128,12 +1158,12 @@ main (int argc, char *argv[]) { suid = 1; if (types || options || readwrite || nomtab || all || fake || (argc + specseen) != 1) - die (EX_USAGE, "mount: only root can do that"); + die (EX_USAGE, _("mount: only root can do that")); } if (!nomtab && mtab_does_not_exist()) { if (verbose > 1) - printf("mount: no %s found - creating it..\n", MOUNTED); + printf(_("mount: no %s found - creating it..\n"), MOUNTED); create_mtab (); } @@ -1143,9 +1173,9 @@ main (int argc, char *argv[]) { else spec = get_spec_by_volume_label(volumelabel); if (!spec) - die (EX_USAGE, "mount: no such partition found"); + die (EX_USAGE, _("mount: no such partition found")); if (verbose) - printf("mount: mounting %s\n", spec); + printf(_("mount: mounting %s\n"), spec); } else spec = NULL; /* just for gcc */ @@ -1154,7 +1184,7 @@ main (int argc, char *argv[]) { /* mount -a */ result = mount_all (types, options); if (result == 0 && verbose) - error("not mounted anything"); + error(_("not mounted anything")); break; case 1: @@ -1167,7 +1197,7 @@ main (int argc, char *argv[]) { if (mc == NULL) mc = getfsspec (spec); if (mc == NULL) - die (EX_USAGE, "mount: cannot find %s in %s", + die (EX_USAGE, _("mount: cannot find %s in %s"), spec, _PATH_FSTAB); mc->mnt_fsname = spec; } else { @@ -1181,7 +1211,7 @@ main (int argc, char *argv[]) { (mc = getfsfile (*argv)) == NULL && /* Try mtab - maybe this was a remount */ (mc = getmntfile (spec)) == NULL) - die (EX_USAGE, "mount: can't find %s in %s or %s", + die (EX_USAGE, _("mount: can't find %s in %s or %s"), spec, _PATH_FSTAB, MOUNTED); /* Earlier mtab was tried first, but this would sometimes try the wrong mount in case mtab had diff --git a/mount/mount.smb b/mount/mount.smb new file mode 100644 index 000000000..845f31067 --- /dev/null +++ b/mount/mount.smb @@ -0,0 +1,68 @@ +#!/bin/csh +# +# /sbin/mount.smb +# by Greg Galperin, MAR99 <grg@ai.mit.edu> +# ver 1.1 MAR99 GRG docs update: must escape special chars like $ +# ver 1.0 MAR99 GRG original version +# +# Intent is to allow calls to mount with -t smb to work properly +# (either manually or from an automounter). +# +# bugs: +# -- possible security hole, as this is a shell script called as root... +# -- arguments other than rw and ro which mount might supply are not handled +# +########################################################################### +# +# To use this from autofs: +# +# have an entry of the form +# key -fstype=smb,-Uadministrator,-Ppassword ://host/share +# in the appropriate /etc/auto.mountpoint file. +# +# This makes access to /mountpoint/key/ access smb //host/share/ +# as administrator (or another user, if you specify such) with the given +# password. You may have to supply a -c <unqualified-localhostname>. +# Special characters need to be 'escaped' with a backslash ('\') -- for +# instance, if you want to use the default share names with a "$" at the +# end (e.g., //host/c$), you must enter ://host/c\$ +# +# Note that mount/autofs is smart enough to figure out how to unmount +# this without any extra work on our part! +# +########################################################################### +# +# I get called in the form: /sbin/mount.smb //host/shr /mnt/tmp -o rw,arg1,arg2 +# +# It looks like mount tacks on either "rw" or "ro" as the first argument, +# so I'm going to count on having exactly 5 arguments. +# +# This has been developed and tested with mount-2.7 +# +########################################################################### + +# test for correct # args +if ( $# != 4 ) then + echo $0 does not know how to handle $# arguments: $* + exit -1 +endif + +# test for args in the form I expect +if ( "$3" != "-o" ) then + echo $0 does not know how to handle the 3rd argument not \"-o\" : $3 + exit -1 +endif + +setenv COMMAND "/usr/sbin/smbmount $1 $2" +foreach arg (`echo $4 | /usr/bin/tr ',' ' '`) + if ( "$arg" == "rw" ) then + setenv COMMAND "$COMMAND -f777 -d777" + else if ( "$arg" == "ro" ) then + setenv COMMAND "$COMMAND -f555 -d555" + else + setenv COMMAND "$COMMAND $arg" + endif +end + +$COMMAND + diff --git a/mount/mount_by_label.c b/mount/mount_by_label.c index a48c9de19..be37496f8 100644 --- a/mount/mount_by_label.c +++ b/mount/mount_by_label.c @@ -1,3 +1,7 @@ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <stdio.h> #include <string.h> #include <ctype.h> @@ -6,6 +10,7 @@ #include "sundries.h" /* for xstrdup */ #include "linux_fs.h" #include "mount_by_label.h" +#include "nls.h" #define PROC_PARTITIONS "/proc/partitions" #define DEVLABELDIR "/dev" @@ -133,7 +138,8 @@ get_spec_by_uuid(const char *s) { return get_spec_by_x(UUID, uuid); bad_uuid: - die(EX_USAGE, "mount: bad UUID"); + die(EX_USAGE, _("mount: bad UUID")); + return NULL; /* just for gcc */ } char * diff --git a/mount/mount_guess_fstype.c b/mount/mount_guess_fstype.c index b6b9e6582..8e8207223 100644 --- a/mount/mount_guess_fstype.c +++ b/mount/mount_guess_fstype.c @@ -14,7 +14,11 @@ * Wed Nov 11 11:33:55 1998: K.Garloff@ping.de, try /etc/filesystems before * /proc/filesystems * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * * aeb - many changes. + * */ #include <stdio.h> @@ -27,6 +31,7 @@ #include "linux_fs.h" #include "mount_guess_fstype.h" #include "sundries.h" /* for xstrdup */ +#include "nls.h" #define ETC_FILESYSTEMS "/etc/filesystems" #define PROC_FILESYSTEMS "/proc/filesystems" @@ -60,12 +65,14 @@ swapped(unsigned short a) { Corrected the test for xiafs - aeb Added romfs - aeb Added ufs from a patch by jj. But maybe there are several types of ufs? + Added ntfs from a patch by Richard Russon. + Added a very weak heuristic for vfat - aeb - Currently supports: minix, ext, ext2, xiafs, iso9660, romfs, ufs + Currently supports: minix, ext, ext2, xiafs, iso9660, romfs, ufs, ntfs, vfat */ static char *magic_known[] = { "minix", "ext", "ext2", "xiafs", "iso9660", "romfs", - "ufs" }; + "ufs", "ntfs" }; static int tested(const char *device) { @@ -89,6 +96,8 @@ fstype(const char *device) { union { struct xiafs_super_block xiasb; char romfs_magic[8]; + struct ntfs_super_block ntfssb; + struct fat_super_block fatsb; } xsb; struct ufs_super_block ufssb; union { @@ -132,6 +141,15 @@ fstype(const char *device) { type = "xiafs"; else if(!strncmp(xsb.romfs_magic, "-rom1fs-", 8)) type = "romfs"; + else if(!strncmp(xsb.ntfssb.s_magic, NTFS_SUPER_MAGIC, + sizeof(xsb.ntfssb.s_magic))) + type = "ntfs"; + else if ((!strncmp(xsb.fatsb.s_os, "MSDOS", 5) || + !strncmp(xsb.fatsb.s_os, "MSWIN", 5)) + && (!strncmp(xsb.fatsb.s_fs, "FAT12 ", 8) || + !strncmp(xsb.fatsb.s_fs, "FAT16 ", 8) || + !strncmp(xsb.fatsb.s_fs2, "FAT32 ", 8))) + type = "vfat"; /* only guessing - might as well be fat or umsdos */ } if (!type) { @@ -166,12 +184,12 @@ char * guess_fstype_from_superblock(const char *spec) { char *type = fstype(spec); if (verbose) { - printf ("mount: you didn't specify a filesystem type for %s\n", + printf (_("mount: you didn't specify a filesystem type for %s\n"), spec); if (type) - printf (" I will try type %s\n", type); + printf (_(" I will try type %s\n"), type); else - printf (" I will try all types mentioned in %s or %s\n", + printf (_(" I will try all types mentioned in %s or %s\n"), ETC_FILESYSTEMS, PROC_FILESYSTEMS); } return type; @@ -197,7 +215,7 @@ procfsopen(void) { static char * procfsnext(void) { char line[100]; - static char fsname[50]; + static char fsname[100]; while (fgets(line, sizeof(line), procfs)) { if (sscanf (line, "nodev %[^\n]\n", fsname) == 1) continue; diff --git a/mount/nfsmount.c b/mount/nfsmount.c index dd55d75a5..9500ec292 100644 --- a/mount/nfsmount.c +++ b/mount/nfsmount.c @@ -20,6 +20,10 @@ * * Wed Oct 1 23:55:28 1997: Dick Streefland <dick_streefland@tasking.com> * Implemented the "bg", "fg" and "retry" mount options for NFS. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * */ /* @@ -38,6 +42,7 @@ #include <sys/time.h> #include <sys/utsname.h> #include <sys/stat.h> +#include <netinet/in.h> #include <arpa/inet.h> #include "sundries.h" @@ -46,6 +51,9 @@ #include <linux/nfs.h> #include "mount_constants.h" #include "nfs_mount3.h" +#include "nls.h" + +#include "../defines.h" /* for HAVE_inet_aton */ static char *nfs_strerror(int stat); @@ -146,8 +154,8 @@ int nfsmount(const char *spec, const char *node, int *flags, msock = fsock = -1; mclient = NULL; if (strlen(spec) >= sizeof(hostdir)) { - fprintf(stderr, "mount: " - "excessively long host:dir argument\n"); + fprintf(stderr, _("mount: " + "excessively long host:dir argument\n")); goto fail; } strcpy(hostdir, spec); @@ -159,28 +167,28 @@ int nfsmount(const char *spec, const char *node, int *flags, until they can be fully supported. (mack@sgi.com) */ if ((s = strchr(hostdir, ','))) { *s = '\0'; - fprintf(stderr, "mount: warning: " - "multiple hostnames not supported\n"); + fprintf(stderr, _("mount: warning: " + "multiple hostnames not supported\n")); } } else { - fprintf(stderr, "mount: " - "directory to mount not in host:dir format\n"); + fprintf(stderr, _("mount: " + "directory to mount not in host:dir format\n")); goto fail; } server_addr.sin_family = AF_INET; -#if 1 /* old libc's do not have inet_aton() -- change 1 to 0 */ +#ifdef HAVE_inet_aton if (!inet_aton(hostname, &server_addr.sin_addr)) #endif { if ((hp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, "mount: can't get address for %s\n", + fprintf(stderr, _("mount: can't get address for %s\n"), hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { fprintf(stderr, - "mount: got bad hp->h_length\n"); + _("mount: got bad hp->h_length\n")); hp->h_length = sizeof(struct in_addr); } memcpy(&server_addr.sin_addr, @@ -197,8 +205,8 @@ int nfsmount(const char *spec, const char *node, int *flags, if (!old_opts) old_opts = ""; if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { - fprintf(stderr, "mount: " - "excessively long option argument\n"); + fprintf(stderr, _("mount: " + "excessively long option argument\n")); goto fail; } sprintf(new_opts, "%s%saddr=%s", @@ -288,19 +296,19 @@ int nfsmount(const char *spec, const char *node, int *flags, else if (!strncmp(opteq+1, "udp", 3)) tcp = 0; else - printf("Warning: Unrecognized proto= option.\n"); + printf(_("Warning: Unrecognized proto= option.\n")); } else if (!strcmp(opt, "namlen")) { #if NFS_MOUNT_VERSION >= 2 if (nfs_mount_version >= 2) data.namlen = val; else #endif - printf("Warning: Option namlen is not supported.\n"); + printf(_("Warning: Option namlen is not supported.\n")); } else if (!strcmp(opt, "addr")) /* ignore */; else { - printf("unknown nfs mount parameter: " - "%s=%d\n", opt, val); + printf(_("unknown nfs mount parameter: " + "%s=%d\n"), opt, val); goto fail; } } @@ -334,11 +342,11 @@ int nfsmount(const char *spec, const char *node, int *flags, if (nfs_mount_version >= 3) nolock = !val; else - printf("Warning: option nolock is not supported.\n"); + printf(_("Warning: option nolock is not supported.\n")); } else { if (!sloppy) { - printf("unknown nfs mount option: " - "%s%s\n", val ? "" : "no", opt); + printf(_("unknown nfs mount option: " + "%s%s\n"), val ? "" : "no", opt); goto fail; } } @@ -409,13 +417,13 @@ int nfsmount(const char *spec, const char *node, int *flags, mount_server_addr.sin_addr.s_addr = inet_addr(hostname); } else { if ((hp = gethostbyname(mounthost)) == NULL) { - fprintf(stderr, "mount: can't get address for %s\n", + fprintf(stderr, _("mount: can't get address for %s\n"), hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { fprintf(stderr, - "mount: got bad hp->h_length?\n"); + _("mount: got bad hp->h_length?\n")); hp->h_length = sizeof(struct in_addr); } mount_server_addr.sin_family = AF_INET; @@ -517,7 +525,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (status.fhs_status != 0) { fprintf(stderr, - "mount: %s:%s failed, reason given by server: %s\n", + _("mount: %s:%s failed, reason given by server: %s\n"), hostname, dirname, nfs_strerror(status.fhs_status)); goto fail; } @@ -528,18 +536,18 @@ int nfsmount(const char *spec, const char *node, int *flags, if (tcp) { if (nfs_mount_version < 3) { - printf("NFS over TCP is not supported.\n"); + printf(_("NFS over TCP is not supported.\n")); goto fail; } fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); } else fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (fsock < 0) { - perror("nfs socket"); + perror(_("nfs socket")); goto fail; } if (bindresvport(fsock, 0) < 0) { - perror("nfs bindresvport"); + perror(_("nfs bindresvport")); goto fail; } if (port == 0) { @@ -550,11 +558,11 @@ int nfsmount(const char *spec, const char *node, int *flags, port = NFS_PORT; #ifdef NFS_MOUNT_DEBUG else - printf("used portmapper to find NFS port\n"); + printf(_("used portmapper to find NFS port\n")); #endif } #ifdef NFS_MOUNT_DEBUG - printf("using port %d for nfs deamon\n", port); + printf(_("using port %d for nfs deamon\n"), port); #endif server_addr.sin_port = htons(port); /* @@ -565,7 +573,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (linux_version_code() <= 66314 && connect(fsock, (struct sockaddr *) &server_addr, sizeof (server_addr)) < 0) { - perror("nfs connect"); + perror(_("nfs connect")); goto fail; } @@ -654,7 +662,7 @@ static char *nfs_strerror(int stat) if (nfs_errtbl[i].stat == stat) return strerror(nfs_errtbl[i].errnum); } - sprintf(buf, "unknown nfs status return value: %d", stat); + sprintf(buf, _("unknown nfs status return value: %d"), stat); return buf; } diff --git a/mount/sundries.c b/mount/sundries.c index d7ace1b2d..a844724e9 100644 --- a/mount/sundries.c +++ b/mount/sundries.c @@ -3,6 +3,10 @@ * sundries.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp * * added fcntl locking by Kjetil T. (kjetilho@math.uio.no) - aeb, 950927 + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * */ #include <unistd.h> #include <stdio.h> @@ -11,7 +15,7 @@ #include "fstab.h" #include "sundries.h" #include "nfsmount.h" - +#include "nls.h" /* String list constructor. (car() and cdr() are defined in "sundries.h"). */ string_list @@ -33,7 +37,7 @@ xmalloc (size_t size) { t = malloc (size); if (t == NULL) - die (EX_SYSERR, "not enough memory"); + die (EX_SYSERR, _("not enough memory")); return t; } @@ -48,7 +52,7 @@ xstrdup (const char *s) { t = strdup (s); if (t == NULL) - die (EX_SYSERR, "not enough memory"); + die (EX_SYSERR, _("not enough memory")); return t; } @@ -58,7 +62,7 @@ xstrndup (const char *s, int n) { char *t; if (s == NULL) - die (EX_SOFTWARE, "bug in xstrndup call"); + die (EX_SOFTWARE, _("bug in xstrndup call")); t = xmalloc(n+1); strncpy(t,s,n); @@ -156,12 +160,15 @@ die (int err, const char *fmt, ...) { string_list parse_list (char *strings) { string_list list; - char *t; + char *s, *t; if (strings == NULL) return NULL; - list = cons (strtok (strings, ","), NULL); + /* strtok() destroys its argument, so we have to use a copy */ + s = xstrdup(strings); + + list = cons (strtok (s, ","), NULL); while ((t = strtok (NULL, ",")) != NULL) list = cons (t, list); @@ -185,7 +192,7 @@ matching_type (const char *type, string_list types) { return 1; if ((notype = alloca (strlen (type) + 3)) == NULL) - die (EX_SYSERR, "mount: out of memory"); + die (EX_SYSERR, _("%s: Out of memory!\n"), "mount"); sprintf (notype, "no%s", type); foundyes = foundno = no = 0; @@ -214,7 +221,7 @@ canonicalize (const char *path) { if (path == NULL) return NULL; - if (streq(path, "none") || streq(path, "proc")) + if (streq(path, "none") || streq(path, "proc") || streq(path, "devpts")) return xstrdup(path); canonical = xmalloc (PATH_MAX + 1); diff --git a/mount/sundries.h b/mount/sundries.h index cad87a1c8..742d761f4 100644 --- a/mount/sundries.h +++ b/mount/sundries.h @@ -46,16 +46,7 @@ char *xstrconcat2 (const char *, const char *); char *xstrconcat3 (const char *, const char *, const char *); char *xstrconcat4 (const char *, const char *, const char *, const char *); -/* Here is some serious cruft. */ -#ifdef __GNUC__ -#if defined(__GNUC_MINOR__) && __GNUC__ == 2 && __GNUC_MINOR__ >= 5 -void die (int errcode, const char *fmt, ...) __attribute__ ((noreturn)); -#else /* GNUC < 2.5 */ -void volatile die (int errcode, const char *fmt, ...); -#endif /* GNUC < 2.5 */ -#else /* !__GNUC__ */ void die (int errcode, const char *fmt, ...); -#endif /* !__GNUC__ */ #ifdef HAVE_NFS int nfsmount (const char *spec, const char *node, int *flags, diff --git a/mount/swapon.c b/mount/swapon.c index 41d1f3fce..2e49b627d 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -2,6 +2,12 @@ * A swapon(8)/swapoff(8) for Linux 0.99. * swapon.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp * Added '-s' (Summary option) <Vincent.Renardias@waw.com> 02/1997. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls + * */ #include <stdlib.h> @@ -13,6 +19,7 @@ #include <sys/stat.h> #include "swap_constants.h" #include "swapargs.h" +#include "nls.h" #define streq(s, t) (strcmp ((s), (t)) == 0) @@ -38,17 +45,14 @@ static struct option longopts[] = { NULL, 0, 0, 0 } }; -const char *usage_string = "\ -usage: %s [-hV]\n\ - %s -a [-v]\n\ - %s [-v] [-p priority] special ...\n\ - %s [-s]\n\ -"; - static void usage (FILE *fp, int n) { - fprintf (fp, usage_string, program_name, program_name, program_name, program_name); + fprintf (fp, _("usage: %s [-hV]\n" + " %s -a [-v]\n" + " %s [-v] [-p priority] special ...\n" + " %s [-s]\n"), + program_name, program_name, program_name, program_name); exit (n); } @@ -81,24 +85,27 @@ swap (const char *special, int prio) struct stat st; if (verbose) - printf("%s on %s\n", program_name, special); + printf(_("%s on %s\n"), program_name, special); if (streq (program_name, "swapon")) { if (stat(special, &st) < 0) { - fprintf (stderr, "swapon: cannot stat %s: %s\n", special, strerror (errno)); + int errsv = errno; + fprintf (stderr, _("swapon: cannot stat %s: %s\n"), special, strerror (errsv)); return -1; } - if ((st.st_mode & 07077) != 0) { - fprintf(stderr, "swapon: warning: %s has insecure permissions %04o, " - "0600 suggested\n", special, st.st_mode & 07777); + /* people generally dislike this warning - now it is printed + only when `verbose' is set */ + if (verbose && (st.st_mode & 07077) != 0) { + fprintf(stderr, _("swapon: warning: %s has insecure permissions %04o, " + "0600 suggested\n"), special, st.st_mode & 07777); } /* test for holes by LBT */ if (S_ISREG(st.st_mode)) { if (st.st_blocks * 512 < st.st_size) { fprintf(stderr, - "swapon: Skipping file %s - it appears to have holes.\n", + _("swapon: Skipping file %s - it appears to have holes.\n"), special); return -1; } @@ -124,8 +131,10 @@ swap (const char *special, int prio) } else status = swapoff (special); - if (status < 0) - fprintf (stderr, "%s: %s: %s\n", program_name, special, strerror (errno)); + if (status < 0) { + int errsv = errno; + fprintf (stderr, "%s: %s: %s\n", program_name, special, strerror (errsv)); + } return status; } @@ -137,8 +146,9 @@ display_summary(void) char line[200] ; if ((swaps = fopen(PROC_SWAPS, "r")) == NULL) { + int errsv = errno; fprintf (stderr, "%s: %s: %s\n", program_name, PROC_SWAPS, - strerror (errno)); + strerror (errsv)); return -1 ; } while ( fgets(line, sizeof(line), swaps)) @@ -155,6 +165,10 @@ main (int argc, char *argv[]) int all = 0; int c; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + if (strrchr (argv[0], '/') != NULL) program_name = strrchr (argv[0], '/') + 1; else @@ -195,8 +209,9 @@ main (int argc, char *argv[]) if (all) { FILE *fp = setmntent(_PATH_FSTAB, "r"); if (fp == NULL) { - fprintf(stderr, "%s: cannot open %s: %s\n", program_name, - _PATH_FSTAB, strerror(errno)); + int errsv = errno; + fprintf(stderr, _("%s: cannot open %s: %s\n"), program_name, + _PATH_FSTAB, strerror(errsv)); exit(2); } while ((fstab = getmntent(fp)) != NULL) { diff --git a/mount/umount.8 b/mount/umount.8 index 196bd7f8a..08d39888d 100644 --- a/mount/umount.8 +++ b/mount/umount.8 @@ -82,6 +82,10 @@ specified type. More than one type may be specified in a comma separated list. The list of file system types can be prefixed with .B no to specify the file system types on which no action should be taken. +.TP +.B \-f +Force unmount (in case of an unreachable NFS system). +(Requires kernel 2.1.116 or later.) .SH "THE LOOP DEVICE" The diff --git a/mount/umount.c b/mount/umount.c index ac233a70b..36f9407f2 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -36,6 +36,7 @@ #include "lomount.h" #include "loop.h" #include "fstab.h" +#include "nls.h" #ifdef HAVE_NFS #include <sys/socket.h> @@ -48,12 +49,11 @@ #include <arpa/inet.h> #endif -static int umount2(const char *path, int flags); - #ifdef MNT_FORCE /* Interesting ... it seems libc knows about MNT_FORCE and presumably about umount2 as well -- need not do anything */ #else /* MNT_FORCE */ +static int umount2(const char *path, int flags); /* Does the present kernel source know about umount2? */ #include <linux/unistd.h> @@ -62,7 +62,7 @@ _syscall2(int, umount2, const char *, path, int, flags); #else /* __NR_umount2 */ static int umount2(const char *path, int flags) { - fprintf(stderr, "umount: compiled without support for -f\n"); + fprintf(stderr, _("umount: compiled without support for -f\n")); errno = ENOSYS; return -1; } @@ -112,7 +112,7 @@ nfs_umount_rpc_call(const char *spec, const char *opts) hostname = xstrndup(spec, p-spec); dirname = xstrdup(p+1); #ifdef DEBUG - printf("host: %s, directory: %s\n", hostname, dirname); + printf(_("host: %s, directory: %s\n"), hostname, dirname); #endif if (opts && (p = strstr(opts, "addr="))) { @@ -129,12 +129,12 @@ nfs_umount_rpc_call(const char *spec, const char *opts) saddr.sin_addr.s_addr = inet_addr(hostname); else { if ((hostp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, "umount: can't get address for %s\n", + fprintf(stderr, _("umount: can't get address for %s\n"), hostname); return 1; } if (hostp->h_length > sizeof(struct in_addr)) { - fprintf(stderr, "umount: got bad hostp->h_length\n"); + fprintf(stderr, _("umount: got bad hostp->h_length\n")); hostp->h_length = sizeof(struct in_addr); } memcpy(&saddr.sin_addr, hostp->h_addr, hostp->h_length); @@ -172,23 +172,23 @@ nfs_umount_rpc_call(const char *spec, const char *opts) static void complain(int err, const char *dev) { switch (err) { case ENXIO: - error ("umount: %s: invalid block device", dev); break; + error (_("umount: %s: invalid block device"), dev); break; case EINVAL: - error ("umount: %s: not mounted", dev); break; + error (_("umount: %s: not mounted"), dev); break; case EIO: - error ("umount: %s: can't write superblock", dev); break; + error (_("umount: %s: can't write superblock"), dev); break; case EBUSY: /* Let us hope fstab has a line "proc /proc ..." and not "none /proc ..."*/ - error ("umount: %s: device is busy", dev); break; + error (_("umount: %s: device is busy"), dev); break; case ENOENT: - error ("umount: %s: not found", dev); break; + error (_("umount: %s: not found"), dev); break; case EPERM: - error ("umount: %s: must be superuser to umount", dev); break; + error (_("umount: %s: must be superuser to umount"), dev); break; case EACCES: - error ("umount: %s: block devices not permitted on fs", dev); break; + error (_("umount: %s: block devices not permitted on fs"), dev); break; default: - error ("umount: %s: %s", dev, strerror (err)); break; + error (_("umount: %s: %s"), dev, strerror (err)); break; } } @@ -232,7 +232,7 @@ umount_one (const char *spec, const char *node, const char *type, perror("umount2"); if (errno == ENOSYS) { if (verbose) - printf("no umount2, trying umount...\n"); + printf(_("no umount2, trying umount...\n")); res = umount (node); } } @@ -245,7 +245,7 @@ umount_one (const char *spec, const char *node, const char *type, /* if (umnt_err == ENOENT || umnt_err == EINVAL) */ if (umnt_err != EBUSY && strcmp(node, spec)) { if (verbose) - printf ("could not umount %s - trying %s instead\n", + printf (_("could not umount %s - trying %s instead\n"), node, spec); res = umount (spec); if (res < 0) @@ -261,7 +261,7 @@ umount_one (const char *spec, const char *node, const char *type, res=mount(spec, node, NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); if (res == 0) { struct mntent remnt; - fprintf(stderr, "umount: %s busy - remounted read-only\n", spec); + fprintf(stderr, _("umount: %s busy - remounted read-only\n"), spec); remnt.mnt_type = remnt.mnt_fsname = NULL; remnt.mnt_dir = xstrdup(node); remnt.mnt_opts = "ro"; @@ -269,7 +269,7 @@ umount_one (const char *spec, const char *node, const char *type, return 0; } else if (errno != EBUSY) { /* hmm ... */ perror("remount"); - fprintf(stderr, "umount: could not remount %s read-only\n", + fprintf(stderr, _("umount: could not remount %s read-only\n"), spec); } } @@ -277,7 +277,7 @@ umount_one (const char *spec, const char *node, const char *type, if (res >= 0) { /* Umount succeeded, update mtab. */ if (verbose) - printf ("%s umounted\n", spec); + printf (_("%s umounted\n"), spec); if (!nomtab && mtab_is_writable()) { /* Special stuff for loop devices */ @@ -360,7 +360,7 @@ umount_all (string_list types) { hd = mtab_head(); if (!hd->prev) - die (2, "umount: cannot find list of filesystems to unmount"); + die (2, _("umount: cannot find list of filesystems to unmount")); for (mc = hd->prev; mc != hd; mc = mc->prev) { if (matching_type (mc->mnt_type, types)) { errors |= umount_one (mc->mnt_fsname, mc->mnt_dir, @@ -386,16 +386,12 @@ static struct option longopts[] = { NULL, 0, 0, 0 } }; -char *usage_string = "\ -Usage: umount [-hV]\n\ - umount -a [-f] [-r] [-n] [-v] [-t vfstypes]\n\ - umount [-f] [-r] [-n] [-v] special | node...\n\ -"; - static void usage (FILE *fp, int n) { - fprintf (fp, "%s", usage_string); + fprintf (fp, _("Usage: umount [-hV]\n" + " umount -a [-f] [-r] [-n] [-v] [-t vfstypes]\n" + " umount [-f] [-r] [-n] [-v] special | node...\n")); exit (n); } @@ -412,6 +408,10 @@ main (int argc, char *argv[]) char *file; int result = 0; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + while ((c = getopt_long (argc, argv, "afhnrt:vV", longopts, NULL)) != EOF) switch (c) { @@ -450,7 +450,7 @@ main (int argc, char *argv[]) { suid = 1; if (all || types || nomtab || force) - die (2, "umount: only root can do that"); + die (2, _("umount: only root can do that")); } argc -= optind; @@ -458,32 +458,32 @@ main (int argc, char *argv[]) if (all) { if (types == NULL) - types = parse_list(xstrdup("noproc")); + types = parse_list("noproc"); result = umount_all (types); } else if (argc < 1) { usage (stderr, 2); } else while (argc--) { file = canonicalize (*argv); /* mtab paths are canonicalized */ if (verbose > 1) - printf("Trying to umount %s\n", file); + printf(_("Trying to umount %s\n"), file); mc = getmntfilesbackward (file, NULL); if (!mc && verbose) - printf("Could not find %s in mtab\n", file); + printf(_("Could not find %s in mtab\n"), file); if (suid) { if (!mc) - die (2, "umount: %s is not mounted (according to mtab)", file); + die (2, _("umount: %s is not mounted (according to mtab)"), file); if (getmntfilesbackward (file, mc)) - die (2, "umount: it seems %s is mounted multiple times", file); + die (2, _("umount: it seems %s is mounted multiple times"), file); if (!(fs = getfsspec (file)) && !(fs = getfsfile (file))) - die (2, "umount: %s is not in the fstab (and you are not root)", + die (2, _("umount: %s is not in the fstab (and you are not root)"), file); if ((!streq (mc->mnt_fsname, fs->mnt_fsname) && !streq (mc->mnt_fsname, canonicalize (fs->mnt_fsname))) || (!streq (mc->mnt_dir, fs->mnt_dir) && !streq (mc->mnt_dir, canonicalize (fs->mnt_dir)))) { - die (2, "umount: %s mount disagrees with the fstab", file); + die (2, _("umount: %s mount disagrees with the fstab"), file); } /* User mounting and unmounting is allowed only @@ -502,7 +502,7 @@ main (int argc, char *argv[]) options = cdr (options); } if (!options) - die (2, "umount: only root can unmount %s from %s", + die (2, _("umount: only root can unmount %s from %s"), fs->mnt_fsname, fs->mnt_dir); if (streq (car (options), "user")) { char *user = getusername(); @@ -512,7 +512,7 @@ main (int argc, char *argv[]) char *co = car (options); if (!strncmp(co, "user=", 5)) { if (!user || !streq(co+5,user)) - die(2, "umount: only %s can unmount %s from %s", + die(2, _("umount: only %s can unmount %s from %s"), co+5, fs->mnt_fsname, fs->mnt_dir); break; } |