diff options
author | Karel Zak | 2006-12-07 00:25:53 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:53 +0100 |
commit | ffc4374869b9ac10539a3c18e13b29d1b0c64484 (patch) | |
tree | 1b8054e83f7f70e8fa77499fc9246d1cc16faa15 /mount | |
parent | Imported from util-linux-2.11n tarball. (diff) | |
download | kernel-qcow2-util-linux-ffc4374869b9ac10539a3c18e13b29d1b0c64484.tar.gz kernel-qcow2-util-linux-ffc4374869b9ac10539a3c18e13b29d1b0c64484.tar.xz kernel-qcow2-util-linux-ffc4374869b9ac10539a3c18e13b29d1b0c64484.zip |
Imported from util-linux-2.11o tarball.
Diffstat (limited to 'mount')
-rw-r--r-- | mount/fstab.5 | 105 | ||||
-rw-r--r-- | mount/linux_fs.h | 3 | ||||
-rw-r--r-- | mount/lomount.c | 2 | ||||
-rw-r--r-- | mount/mount.8 | 83 | ||||
-rw-r--r-- | mount/mount.c | 19 | ||||
-rw-r--r-- | mount/mount_guess_fstype.c | 88 | ||||
-rw-r--r-- | mount/mount_guess_fstype.h | 3 | ||||
-rw-r--r-- | mount/swapon.c | 2 | ||||
-rw-r--r-- | mount/umount.c | 72 |
9 files changed, 272 insertions, 105 deletions
diff --git a/mount/fstab.5 b/mount/fstab.5 index a9ff43835..fa3d2b782 100644 --- a/mount/fstab.5 +++ b/mount/fstab.5 @@ -52,7 +52,7 @@ contains descriptive information about the various file systems. is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs -or spaces. The order of records in +or spaces. Lines starting with '#' are comments. The order of records in .B fstab is important because .BR fsck (8), @@ -94,50 +94,53 @@ contains spaces these can be escaped as `\\040'. The third field, .RI ( fs_vfstype ), -describes the type of the filesystem. The system currently supports these -types of filesystems (and possibly others - consult -.IR /proc/filesystems ): -.TP -.I minix -a local filesystem, supporting filenames of length 14 or 30 characters. -.TP -.I ext -a local filesystem with longer filenames and larger inodes. This -filesystem has been replaced by the -.I ext2 -file system, and should no longer be used. -.TP -.I ext2 -a local filesystem with longer filenames, larger inodes, and lots of other -features. -.TP -.I xiafs -a local filesystem with longer filenames, larger inodes, and lots of other -features. -.TP -.I xfs -a local filesystem with journaling, scalability and lots of other -features. -.TP -.I msdos -a local filesystem for MS-DOS partitions. -.TP -.I hpfs -a local filesystem for HPFS partitions. -.TP -.I iso9660 -a local filesystem used for CD-ROM drives. -.TP -.I nfs -a filesystem for mounting partitions from remote systems. -.TP -.I swap -a disk partition to be used for swapping. -.PP -If -.I fs_vfstype -is specified as ``ignore'' the entry is ignored. This is useful to show -disk partitions which are currently unused. +describes the type of the filesystem. Linux supports lots +of filesystem types, such as +.IR adfs , +.IR affs , +.IR autofs , +.IR coda , +.IR coherent , +.IR cramfs , +.IR devpts , +.IR efs , +.IR ext2 , +.IR ext3 , +.IR hfs , +.IR hpfs , +.IR iso9660 , +.IR jfs , +.IR minix , +.IR msdos , +.IR ncpfs , +.IR nfs , +.IR ntfs , +.IR proc , +.IR qnx4 , +.IR reiserfs , +.IR romfs , +.IR smbfs , +.IR sysv , +.IR tmpfs , +.IR udf , +.IR ufs , +.IR umsdos , +.IR vfat , +.IR xenix , +.IR xfs , +and possibly others. For more details, see +.BR mount (8). +For the filesystems currently supported by the running kernel, see +.IR /proc/filesystems . +An entry +.I swap +denotes a file or partition to be used +for swapping, cf.\& +.BR swapon (8). +An entry +.I ignore +causes the line to be ignored. This is useful +to show disk partitions which are currently unused. The fourth field, .RI ( fs_mntops ), @@ -187,14 +190,6 @@ is to use the routines .BR getmntent (3). .SH FILES .I /etc/fstab -The file -.B fstab -resides in -.IR /etc . -.SH BUGS -The documentation in -.BR mount (8) -is often more up-to-date. .SH "SEE ALSO" .BR getmntent (3), .BR mount (8), @@ -202,6 +197,8 @@ is often more up-to-date. .BR fs (5) .BR nfs (5) .SH HISTORY -The +The ancestor of this .B fstab file format appeared in 4.0BSD. +.\" But without comment convention, and options and vfs_type. +.\" Instead there was a type rw/ro/rq/sw/xx, where xx is the present 'ignore'. diff --git a/mount/linux_fs.h b/mount/linux_fs.h index 53cdf573d..c6ef8105e 100644 --- a/mount/linux_fs.h +++ b/mount/linux_fs.h @@ -101,7 +101,8 @@ struct xiafs_super_block { (((uint) s.s_magic[3]) << 24)) /* From jj@sunsite.ms.mff.cuni.cz Mon Mar 23 15:19:05 1998 */ -#define UFS_SUPER_MAGIC 0x00011954 +#define UFS_SUPER_MAGIC_LE 0x00011954 +#define UFS_SUPER_MAGIC_BE 0x54190100 struct ufs_super_block { u_char s_dummy[0x55c]; u_char s_magic[4]; diff --git a/mount/lomount.c b/mount/lomount.c index 26e895018..70a8ff0ab 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -399,7 +399,7 @@ main(int argc, char **argv) { delete = off = 0; offset = encryption = NULL; progname = argv[0]; - while ((c = getopt(argc,argv,"de:o:v")) != EOF) { + while ((c = getopt(argc,argv,"de:o:v")) != -1) { switch (c) { case 'd': delete = 1; diff --git a/mount/mount.8 b/mount/mount.8 index 7114b2952..01a722b7a 100644 --- a/mount/mount.8 +++ b/mount/mount.8 @@ -107,6 +107,14 @@ file hierarchy somewhere else. The call is .br .B "mount --bind olddir newdir" .RE +After this call the same contents is accessible in two places. + +Since Linux 2.5.1 it is possible to atomically move a subtree +to another place. The call is +.RS +.br +.B "mount --move olddir newdir" +.RE The .I proc @@ -408,6 +416,7 @@ type is specified, the superblock is probed for the filesystem type .IR qnx4 , .IR reiserfs , .IR romfs , +.IR udf , .IR ufs , .IR vxfs , .IR xfs , @@ -423,8 +432,13 @@ except for those that are labeled "nodev" (e.g., .I proc and .IR nfs ). +If +.I /etc/filesystems +ends in a line with a single * only, mount will read +.I /proc/filesystems +afterwards. -Note that the +The .B auto type may be useful for user-mounted floppies. Creating a file @@ -432,7 +446,10 @@ Creating a file can be useful to change the probe order (e.g., to try vfat before msdos) or if you use a kernel module autoloader. Warning: the probing uses a heuristic (the presence of appropriate `magic'), -and could recognize the wrong filesystem type. +and could recognize the wrong filesystem type, possibly with catastrophic +consequences. If your data is valuable, don't ask +.B mount +to guess. More than one type may be specified in a comma separated list. The list of file system types can be prefixed with @@ -547,6 +564,13 @@ This option implies the options (unless overridden by subsequent options, as in the option line .BR users,exec,dev,suid ). .RE +.TP +.B \-\-bind +Remount a subtree somewhere else (so that its contents are available +in both places). See above. +.TP +.B \-\-move +Move a subtree to some other place. See above. .SH "FILESYSTEM SPECIFIC MOUNT OPTIONS" The following options apply only to certain file systems. @@ -937,6 +961,11 @@ just read what is in the file. This is the default. Do not abort mounting when certain consistency checks fail. .SH "Mount options for iso9660" +ISO 9660 is a standard describing a filesystem structure to be used +on CD-ROMs. (This filesystem type is also seen on some DVDs. See also the +.I udf +filesystem.) + Normal .I iso9660 filenames appear in a 8.3 format (i.e., DOS-like restrictions on filename @@ -1154,6 +1183,7 @@ By default, the files are owned by root and not readable by somebody else. These options are recognized, but have no effect as far as I can see. .SH "Mount options for reiserfs" +Reiserfs is a journaling filesystem. The reiserfs mount options are more fully described at .IR http://www.namesys.com/mount-options.html . .TP @@ -1276,6 +1306,10 @@ Set number of inodes. Set initial permissions of the root directory. .SH "Mount options for udf" +udf is the "Universal Disk Format" filesystem defined by the Optical +Storage Technology Association, and is often used for DVD-ROM. +See also +.IR iso9660 . .TP .B gid= Set the default group. @@ -1359,6 +1393,7 @@ For NextStep CDROMs (block_size == 2048), read-only. .TP .B openstep For filesystems created by OpenStep (currently read only). +The same filesystem type is also used by Mac OS X. .RE .TP @@ -1412,6 +1447,17 @@ before trying UTF8 is the filesystem safe 8-bit encoding of Unicode that is used by the console. It can be be enabled for the filesystem with this option. If `uni_xlate' gets set, UTF8 gets disabled. +.TP +.B shortname=[lower|win95|winnt|mixed] +Option (available since 2.4.13) that sets how short filenames are to be +created and displayed. +.nf + lower = display lower, create win95 filenames + win95 = display win95, create win95 filenames + winnt = display winnt, create winnt filenames + mixed = display winnt, create win95 filenames +.fi +Default is "lower". .SH "Mount options for xenix" None. @@ -1550,6 +1596,39 @@ will be freed by You can also free a loop device by hand, using `losetup -d', see .BR losetup (8). +.SH RETURN CODES +.B mount +has the following return codes (the bits can be ORed): +.TP +.BR 0 +success +.TP +.BR 1 +incorrect invocation or permissions +.TP +.BR 2 +system error (out of memory, cannot fork, no more loop devices) +.TP +.BR 4 +internal +.B mount +bug or missing +.BR nfs +support in +.B mount +.TP +.BR 8 +user interrupt +.TP +.BR 16 +problems writing or locking /etc/mtab +.TP +.BR 32 +mount failure +.TP +.BR 64 +some mount succeeded + .SH FILES .I /etc/fstab file system table diff --git a/mount/mount.c b/mount/mount.c index 97b8aebba..dc10e64bb 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -467,7 +467,7 @@ guess_fstype_and_mount (char *spec, char *node, char **types, *types = "none"; /* random, but not "bind" */ if (!*types && !(flags & MS_REMOUNT)) { - *types = guess_fstype_from_superblock(spec); + *types = guess_fstype(spec); if (*types && !strcmp(*types, "swap")) { error(_("%s looks like swapspace - not mounted"), spec); *types = NULL; @@ -1312,6 +1312,7 @@ static struct option longopts[] = { { "before", 0, 0, 131 }, { "over", 0, 0, 132 }, { "move", 0, 0, 133 }, + { "guess-fstype", 1, 0, 134 }, { NULL, 0, 0, 0 } }; @@ -1335,6 +1336,8 @@ usage (FILE *fp, int n) { "a filesystem (of the given type) found on the device.\n" "One can also mount an already visible directory tree elsewhere:\n" " mount --bind olddir newdir\n" + "or move a subtree:\n" + " mount --move olddir newdir\n" "A device can be given by name, say /dev/hda1 or /dev/cdrom,\n" "or by label, using -L label or by uuid, using -U uuid .\n" "Other options: [-nfFrsvw] [-o options].\n" @@ -1375,7 +1378,7 @@ main (int argc, char *argv[]) { #endif while ((c = getopt_long (argc, argv, "afFhlL:no:rsU:vVwt:", - longopts, NULL)) != EOF) { + longopts, NULL)) != -1) { switch (c) { case 'a': /* mount everything in fstab */ ++all; @@ -1448,7 +1451,17 @@ main (int argc, char *argv[]) { case 133: /* move */ mounttype = MS_MOVE; break; - + case 134: + /* undocumented, may go away again: + call: mount --guess-fstype device + use only for testing purposes - + the guessing is not reliable at all */ + { + char *fstype; + fstype = do_guess_fstype(optarg); + printf("%s\n", fstype ? fstype : "unknown"); + exit(fstype ? 0 : EX_FAIL); + } case '?': default: usage (stderr, EX_USAGE); diff --git a/mount/mount_guess_fstype.c b/mount/mount_guess_fstype.c index 6b8def09f..63b00ba83 100644 --- a/mount/mount_guess_fstype.c +++ b/mount/mount_guess_fstype.c @@ -66,7 +66,7 @@ assemble4le(unsigned char *p) { } /* - char *guess_fstype_from_superblock(const char *device); + char *guess_fstype(const char *device); Probes the device and attempts to determine the type of filesystem contained within. @@ -85,6 +85,7 @@ assemble4le(unsigned char *p) { Added ext3 - Andrew Morton Added jfs - Christoph Hellwig Added sysv - Tim Launchbury + Added udf - Bryce Nesbitt */ static char *magic_known[] = { @@ -137,15 +138,22 @@ free_tested(void) { tried = NULL; } -/* udf magic - I find that trying to mount garbage as an udf fs - causes a very large kernel delay, almost killing the machine. - So, we do not try udf unless there is positive evidence that it - might work. Try iso9660 first, it is much more likely. - Strings below taken from ECMA 167. */ +/* + * udf magic - I find that trying to mount garbage as an udf fs + * causes a very large kernel delay, almost killing the machine. + * So, we do not try udf unless there is positive evidence that it + * might work. Strings below taken from ECMA 167. + */ +/* + * It seems that before udf 2.00 the volume descriptor was not well + * defined. For 2.00 you're supposed to keep scanning records until + * you find one NOT in this list. (See ECMA 2/8.3.1). + */ static char *udf_magic[] = { "BEA01", "BOOT2", "CD001", "CDW02", "NSR02", "NSR03", "TEA01" }; + static int may_be_udf(const char *id) { char **m; @@ -156,6 +164,43 @@ may_be_udf(const char *id) { return 0; } +/* we saw "CD001" - may be iso9660 or udf - Bryce Nesbitt */ +static int +is_really_udf(int fd) { + int j, bs; + struct iso_volume_descriptor isosb; + + /* determine the block size by scanning in 2K increments + (block sizes larger than 2K will be null padded) */ + for (bs = 1; bs < 16; bs++) { + lseek(fd, bs*2048+32768, SEEK_SET); + if (read(fd, (char *)&isosb, sizeof(isosb)) != sizeof(isosb)) + return 0; + if (isosb.id[0]) + break; + } + + /* Scan up to another 64 blocks looking for additional VSD's */ + for (j = 1; j < 64; j++) { + if (j > 1) { + lseek(fd, j*bs*2048+32768, SEEK_SET); + if (read(fd, (char *)&isosb, sizeof(isosb)) + != sizeof(isosb)) + return 0; + } + /* If we find NSR0x then call it udf: + NSR01 for UDF 1.00 + NSR02 for UDF 1.50 + NSR03 for UDF 2.00 */ + if (!strncmp(isosb.id, "NSR0", 4)) + return 1; + if (!may_be_udf(isosb.id)) + return 0; + } + + return 0; +} + static int may_be_swap(const char *s) { return (strncmp(s-10, "SWAP-SPACE", 10) == 0 || @@ -184,8 +229,8 @@ static int is_reiserfs_magic_string (struct reiserfs_super_block * rs) strlen ( REISER2FS_SUPER_MAGIC_STRING))); } -static char * -fstype(const char *device) { +char * +do_guess_fstype(const char *device) { int fd; char *type = NULL; union { @@ -292,7 +337,7 @@ fstype(const char *device) { if ((assemble4le(sb.e2s.s_feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) && assemble4le(sb.e2s.s_journal_inum) != 0) - type = "ext3,ext2"; + type = "ext3"; /* "ext3,ext2" */ } else if (minixmagic(sb.ms) == MINIX_SUPER_MAGIC || @@ -340,12 +385,15 @@ fstype(const char *device) { } if (!type) { + int mag; + /* block 8 */ if (lseek(fd, 8192, SEEK_SET) != 8192 || read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb)) goto io_error; - if (ufsmagic(ufssb) == UFS_SUPER_MAGIC) /* also test swapped version? */ + mag = ufsmagic(ufssb); + if (mag == UFS_SUPER_MAGIC_LE || mag == UFS_SUPER_MAGIC_BE) type = "ufs"; } @@ -385,11 +433,17 @@ fstype(const char *device) { || read(fd, (char *) &isosb, sizeof(isosb)) != sizeof(isosb)) goto io_error; - if(strncmp(isosb.iso.id, ISO_STANDARD_ID, sizeof(isosb.iso.id)) == 0 - || strncmp(isosb.hs.id, HS_STANDARD_ID, sizeof(isosb.hs.id)) == 0) - type = "iso9660"; - else if (may_be_udf(isosb.iso.id)) - type = "udf"; + if (strncmp(isosb.hs.id, HS_STANDARD_ID, sizeof(isosb.hs.id)) == 0) { + /* "CDROM" */ + type = "iso9660"; + } else if (strncmp(isosb.iso.id, ISO_STANDARD_ID, + sizeof(isosb.iso.id)) == 0) { + /* CD001 */ + type = "iso9660"; + if (is_really_udf(fd)) + type = "udf"; + } else if (may_be_udf(isosb.iso.id)) + type = "udf"; } if (!type) { @@ -436,8 +490,8 @@ io_error: } char * -guess_fstype_from_superblock(const char *spec) { - char *type = fstype(spec); +guess_fstype(const char *spec) { + char *type = do_guess_fstype(spec); if (verbose) { printf (_("mount: you didn't specify a filesystem type for %s\n"), spec); diff --git a/mount/mount_guess_fstype.h b/mount/mount_guess_fstype.h index 9c0903b54..d005c9187 100644 --- a/mount/mount_guess_fstype.h +++ b/mount/mount_guess_fstype.h @@ -8,7 +8,8 @@ struct mountargs { extern int verbose; -char *guess_fstype_from_superblock(const char *device); +char *guess_fstype(const char *device); +char *do_guess_fstype(const char *device); int procfsloop(int (*mount_fn)(struct mountargs *), struct mountargs *args, char **type); int is_in_procfs(const char *fstype); diff --git a/mount/swapon.c b/mount/swapon.c index 9f25fcbe7..29c859dbc 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -183,7 +183,7 @@ main (int argc, char *argv[]) else program_name = argv[0]; - while ((c = getopt_long (argc, argv, "ahp:svV", longopts, NULL)) != EOF) + while ((c = getopt_long (argc, argv, "ahp:svV", longopts, NULL)) != -1) switch (c) { case 'a': /* all */ diff --git a/mount/umount.c b/mount/umount.c index b2beb9acb..4688495e2 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -25,6 +25,7 @@ * 001202: aeb - remove at most one line from /etc/mtab * 010914: Jamie Strandboge - use tcp if that was used for mount * 011005: hch - add lazy umount support + * 020105: aeb - permission test owner umount */ #include <stdio.h> @@ -497,6 +498,30 @@ parse_list (char *strings) { return list; } + +static int +contains(string_list list, char *s) { + while (list) { + if (streq (car (list), s)) + return 1; + list = cdr (list); + } + return 0; +} + +/* + * If list contains "user=peter" and we ask for "user=", return "peter" + */ +static char * +get_value(string_list list, char *s) { + int n = strlen(s); + while (list) { + if (strncmp (car (list), s, n) == 0) + return car(list)+n; + list = cdr (list); + } + return 0; +} /*=======================================================================*/ static int @@ -504,6 +529,7 @@ umount_file (char *arg) { struct mntentchn *mc, *fs; char *file; string_list options; + int fstab_has_user, fstab_has_users, fstab_has_owner, ok; file = canonicalize (arg); /* mtab paths are canonicalized */ if (verbose > 1) @@ -536,7 +562,8 @@ umount_file (char *arg) { } /* User mounting and unmounting is allowed only - if fstab contains the option `user' or `users' */ + if fstab contains one of the options `user', + `users' or `owner'. */ /* The option `users' allows arbitrary users to mount and unmount - this may be a security risk. */ /* The option `user' only allows unmounting by the user @@ -544,40 +571,35 @@ umount_file (char *arg) { /* The option `owner' only allows (un)mounting by the owner. */ /* A convenient side effect is that the user who mounted is visible in mtab. */ + options = parse_list (fs->m.mnt_opts); - while (options) { - if (streq (car (options), "user") || - streq (car (options), "users") || - streq (car (options), "owner")) - break; - options = cdr (options); - } - if (!options) - die (2, _("umount: only root can unmount %s from %s"), - fs->m.mnt_fsname, fs->m.mnt_dir); - if (streq (car (options), "user") || - streq (car (options), "owner")) { + fstab_has_user = contains(options, "user"); + fstab_has_users = contains(options, "users"); + fstab_has_owner = contains(options, "owner"); + ok = 0; + + if (fstab_has_users) + ok = 1; + + if (!ok && (fstab_has_user || fstab_has_owner)) { char *user = getusername(); + char *mtab_user; options = parse_list (mc->m.mnt_opts); - while (options) { - 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"), - co+5, fs->m.mnt_fsname, fs->m.mnt_dir); - break; - } - options = cdr (options); - } + mtab_user = get_value(options, "user="); + + if (user && mtab_user && streq (user, mtab_user)) + ok = 1; } + if (!ok) + die (2, _("umount: only root can unmount %s from %s"), + fs->m.mnt_fsname, fs->m.mnt_dir); } if (mc) return umount_one_bw (file, mc); else return umount_one (arg, arg, arg, arg, NULL); - } int @@ -593,7 +615,7 @@ main (int argc, char *argv[]) { textdomain(PACKAGE); while ((c = getopt_long (argc, argv, "adfhlnrt:vV", - longopts, NULL)) != EOF) + longopts, NULL)) != -1) switch (c) { case 'a': /* umount everything */ ++all; |