summaryrefslogtreecommitdiffstats
path: root/mount
diff options
context:
space:
mode:
Diffstat (limited to 'mount')
-rw-r--r--mount/fstab.57
-rw-r--r--mount/linux_fs.h52
-rw-r--r--mount/mount.8176
-rw-r--r--mount/mount_by_label.c4
-rw-r--r--mount/mount_guess_fstype.c83
-rw-r--r--mount/mount_guess_rootdev.c18
-rw-r--r--mount/nfs.52
-rw-r--r--mount/nfsmount.c27
-rw-r--r--mount/nfsmount.x1
-rw-r--r--mount/rpcsvc/nfsmount.h1
-rw-r--r--mount/rpcsvc/nfsmount.x1
-rw-r--r--mount/sundries.c2
-rw-r--r--mount/swapon.c2
-rw-r--r--mount/umount.818
-rw-r--r--mount/umount.c53
15 files changed, 379 insertions, 68 deletions
diff --git a/mount/fstab.5 b/mount/fstab.5
index 608f81d82..a9ff43835 100644
--- a/mount/fstab.5
+++ b/mount/fstab.5
@@ -76,7 +76,7 @@ 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 or XFS) filesystem that is to be mounted by its UUID or
+the (ext2 or xfs) filesystem that is to be mounted by its UUID or
volume label (cf.
.BR e2label (8)
or
@@ -151,8 +151,9 @@ see
For documentation on all nfs-specific options have a look at
.BR nfs (5).
Common for all types of file system are the options ``noauto''
-(do not mount when "mount -a" is given, e.g., at boot time),
-and ``user'' (allow a user to mount). For more details, see
+(do not mount when "mount -a" is given, e.g., at boot time), ``user''
+(allow a user to mount), and ``owner''
+(allow device owner to mount). For more details, see
.BR mount (8).
The fifth field,
diff --git a/mount/linux_fs.h b/mount/linux_fs.h
index 978573892..1ed02b8c5 100644
--- a/mount/linux_fs.h
+++ b/mount/linux_fs.h
@@ -63,6 +63,31 @@ struct ext2_super_block {
};
#define ext2magic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8))
+struct reiserfs_super_block
+{
+ u_char s_block_count[4];
+ u_char s_free_blocks[4];
+ u_char s_root_block[4];
+ u_char s_journal_block[4];
+ u_char s_journal_dev[4];
+ u_char s_orig_journal_size[4];
+ u_char s_journal_trans_max[4];
+ u_char s_journal_block_count[4];
+ u_char s_journal_max_batch[4];
+ u_char s_journal_max_commit_age[4];
+ u_char s_journal_max_trans_age[4];
+ u_char s_blocksize[2];
+ u_char s_oid_maxsize[2];
+ u_char s_oid_cursize[2];
+ u_char s_state[2];
+ u_char s_magic[12];
+};
+#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
+#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
+#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
+/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */
+#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
+
#define _XIAFS_SUPER_MAGIC 0x012FD16D
struct xiafs_super_block {
u_char s_boot_segment[512]; /* 1st sector reserved for boot */
@@ -154,3 +179,30 @@ struct adfs_super_block {
u_char s_checksum[1];
};
#define adfsblksize(s) ((uint) s.s_blksize[0])
+
+/* found in first 4 bytes of block 1 */
+struct vxfs_super_block {
+ u_char s_magic[4];
+};
+#define vxfsmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \
+ (((uint) s.s_magic[2]) << 16) + \
+ (((uint) s.s_magic[3]) << 24))
+#define VXFS_SUPER_MAGIC 0xa501FCF5
+
+struct jfs_super_block {
+ char s_magic[4];
+};
+#define JFS_SUPER1_OFF 0x8000
+#define JFS_MAGIC "JFS1"
+
+#define SYSV_SUPER_MAGIC 0xfd187e20
+
+struct sysv_super_block {
+ u_char s_dummy1[504];
+ u_char s_magic[4];
+ u_char type[4];
+};
+
+#define sysvmagic(s) ((uint) s.s_magic[0] + (((uint) s.s_magic[1]) << 8) + \
+ (((uint) s.s_magic[2]) << 16) + \
+ (((uint) s.s_magic[3]) << 24))
diff --git a/mount/mount.8 b/mount/mount.8
index 6f96457df..0280bb844 100644
--- a/mount/mount.8
+++ b/mount/mount.8
@@ -35,6 +35,7 @@
.\" 990111, aeb: documented /sbin/mount.smbfs
.\" 990730, Yann Droneaud <lch@multimania.com>: updated page
.\" 991214, Elrond <Elrond@Wunder-Nett.org>: added some docs on devpts
+.\" 010725, Nikita Danilov <NikitaDanilov@Yahoo.COM>: reiserfs options
.\"
.TH MOUNT 8 "14 September 1997" "Linux 2.0" "Linux Programmer's Manual"
.SH NAME
@@ -95,7 +96,7 @@ prints a version string; and just
.RE
lists all mounted file systems (of type
.IR type ).
-The option \-l adds the (ext2 and XFS) labels in this listing.
+The option \-l adds the (ext2, ext3 and XFS) labels in this listing.
See below.
.\" In fact since 2.3.99. At first the syntax was mount -t bind.
@@ -276,9 +277,9 @@ command is trying to do. It can also be used to add entries for devices
that were mounted earlier with the -n option.
.TP
.B \-l
-Add the ext2 and XFS labels in the mount output. Mount must have permission to
-read the disk device (e.g. be suid root) for this to work.
-One can set such a label for ext2 using the
+Add the ext2, ext3 and XFS labels in the mount output. Mount must have
+permission to read the disk device (e.g. be suid root) for this to work.
+One can set such a label for ext2 or ext3 using the
.BR e2label (8)
utility, or for XFS using
.BR xfs_admin (8).
@@ -330,9 +331,11 @@ currently supported are:
.IR efs ,
.IR ext ,
.IR ext2 ,
+.IR ext3 ,
.IR hfs ,
.IR hpfs ,
.IR iso9660 ,
+.IR jfs ,
.IR minix ,
.IR msdos ,
.IR ncpfs ,
@@ -340,6 +343,7 @@ currently supported are:
.IR ntfs ,
.IR proc ,
.IR qnx4 ,
+.IR reiserfs ,
.IR romfs ,
.IR smbfs ,
.IR sysv ,
@@ -387,9 +391,9 @@ is the default. If no
option is given, or if the
.B auto
type is specified, the superblock is probed for the filesystem type
-.RI ( minix ", " ext ", " ext2 ", " xiafs ", " iso9660 ", " romfs
-.RI , ufs ", " ntfs ", " qnx4 ", " bfs ", " xfs ", " cramfs ", " hfs
-.RI , hpfs ", " adfs
+.RI ( minix ", " ext ", " ext2 ", " ext3 ", " xiafs ", " iso9660 ,
+.IR jfs ", " reiserfs ", " romfs ", " ufs ", " ntfs ", " qnx4 ", " bfs ,
+.IR xfs ", " cramfs ", " hfs ", " hpfs ", " adfs ", " vxfs
are supported).
If this probe fails, mount will try to read the file
.IR /etc/filesystems ,
@@ -440,7 +444,7 @@ Some of these options are only useful when they appear in the
file. The following options apply to any file system that is being
mounted (but not every file system actually honors them - e.g., the
.B sync
-option today has effect only for ext2 and ufs):
+option today has effect only for ext2, ext3 and ufs):
.RS
.TP
.B async
@@ -510,11 +514,20 @@ effect.
All I/O to the file system should be done synchronously.
.TP
.B user
-Allow an ordinary user to mount the file system. This option implies
-the options
+Allow an ordinary user to mount the file system.
+The name of the mounting user is written to mtab so that he can unmount
+the file system again.
+This option implies the options
.BR noexec ", " nosuid ", and " nodev
(unless overridden by subsequent options, as in the option line
.BR user,exec,dev,suid ).
+.TP
+.B users
+Allow every user to mount and unmount the file system.
+This option implies the options
+.BR noexec ", " nosuid ", and " nodev
+(unless overridden by subsequent options, as in the option line
+.BR users,exec,dev,suid ).
.RE
.SH "FILESYSTEM SPECIFIC MOUNT OPTIONS"
@@ -706,10 +719,58 @@ superblocks, and since version 1.15 this is the default. Note
that this may mean that ext2 filesystems created by a recent
.B mke2fs
cannot be mounted r/w under Linux 2.0.*.)
+The block number here uses 1k units. Thus, if you want to use logical
+block 32768 on a filesystem with 4k blocks, use "sb=131072".
.TP
.BR grpquota " / " noquota " / " quota " / " usrquota
These options are accepted but ignored.
+.TP
+.BR nouid32
+Disables 32-bit UIDs and GIDs. This is for interoperability with older
+kernels which only store and expect 16-bit values.
+
+
+.SH "Mount options for ext3"
+The `ext3' file system is version of the ext2 file system which has been
+enhanced with journalling. It supports the same options as ext2 as
+well as the following additions:
+.\" .TP
+.\" .BR abort
+.\" Mount the file system in abort mode, as if a fatal error has occurred.
+.TP
+.BR journal=update
+Update the ext3 file system's journal to the current format.
+.TP
+.BR journal=inum
+When a journal already exists, this option is ignored. Otherwise, it
+specifies the number of the inode which will represent the ext3 file system's
+journal file; ext3 will create a new journal, overwriting the old contents
+of the file whose inode number is
+.IR inum .
+.TP
+.BR noload
+Do not load the ext3 file system's journal on mounting.
+.TP
+.BR data=journal " / " data=ordered " / " data=writeback
+Specifies the journalling mode for file data. Metadata is always journaled.
+.RS
+.TP
+.B journal
+All data is committed into the journal prior to being written into the
+main file system.
+.TP
+.B ordered
+This is the default mode. All data is forced directly out to the main file
+system prior to its metadata being committed to the journal.
+.TP
+.B writeback
+Data ordering is not preserved - data may be written into the main
+file system after its metadata has been committed to the journal.
+This is rumoured to be the highest-throughput option. It guarantees
+internal file system integrity, however it can allow old data to appear
+in files after a crash and journal recovery.
+
.SH "Mount options for fat"
(Note:
.I fat
@@ -1054,9 +1115,11 @@ unconvertible characters.
Use UTF-8 for converting file names.
.TP
.B uni_xlate=[0|1|2]
-For 0 (or `no' or `false') or 1 (or `yes' or `true'):
-use the VFAT-style encoding for file names outside the current
-character set. A value of 2 will disable the encoding with ":".
+For 0 (or `no' or `false'), do not use escape sequences
+for unknown Unicode characters.
+For 1 (or `yes' or `true') or 2, use vfat-style 4-byte escape sequences
+starting with ":". Here 2 give a little-endian encoding
+and 1 a byteswapped bigendian encoding.
.TP
.B posix=[0|1]
If enabled (posix=1), the file system distinguishes between
@@ -1072,6 +1135,89 @@ By default, the files are owned by root and not readable by somebody else.
\fBuid=\fP\fIvalue\fP and \fBgid=\fP\fIvalue\fP
These options are recognized, but have no effect as far as I can see.
+.SH "Mount options for reiserfs"
+The reiserfs mount options are more fully described at
+.IR http://www.namesys.com/mount-options.html .
+.TP
+.BR conv
+Instructs version 3.6 reiserfs software to mount a version 3.5 file system,
+using the 3.6 format for newly created objects. This file system will no
+longer be compatible with reiserfs 3.5 tools.
+.TP
+.BR hash=rupasov " / " hash=tea " / " hash=r5 " / " hash=detect
+Choose which hash function reiserfs will use to find files within directories.
+.RS
+.TP
+.B rupasov
+A hash invented by Yury Yu. Rupasov. It is fast and preserves locality,
+mapping lexicographically close file names to close hash values.
+This option should not be used, as it causes a high probability of hash
+collisions.
+.TP
+.B tea
+A Davis-Meyer function implemented by Jeremy Fitzhardinge.
+It uses hash permuting bits in the name. It gets high randomness
+and, therefore, low probability of hash collisions at come CPU cost.
+This may be used if EHASHCOLLISION errors are experienced with the r5 hash.
+.TP
+.B r5
+A modified version of the rupasov hash. It is used by default and is
+the best choice unless the file system has huge directories and
+unusual file-name patterns.
+.TP
+.B detect
+Instructs
+.IR mount
+to detect which hash function is in use by examining
+the file system being mounted, and to write this information into
+the reiserfs superblock. This is only useful on the first mount of
+an old format file system.
+.RE
+.TP
+.BR hashed_relocation
+Tunes the block allocator. This may provide performance improvements
+in some situations.
+.TP
+.BR no_unhashed_relocation
+Tunes the block allocator. This may provide performance improvements
+in some situations.
+.TP
+.BR noborder
+Disable the border allocator algorithm invented by Yury Yu. Rupasov.
+This may provide performance improvements in some situations.
+.TP
+.BR nolog
+Disable journalling. This will provide slight performance improvements in
+some situations at the cost of losing reiserfs's fast recovery from crashes.
+Even with this option turned on, reiserfs still performs all journalling
+operations, save for actual writes into its journalling area. Implementation
+of
+.IR nolog
+is a work in progress.
+.TP
+.BR notail
+By default, reiserfs stores small files and `file tails' directly into its
+tree. This confuses some utilities such as
+.BR LILO (8) .
+This option is used to disable packing of files into the tree.
+.TP
+.BR replayonly
+Replay the transactions which are in the journal, but do not actually
+mount the file system. Mainly used by
+.IR reiserfsck .
+.TP
+.BI resize= number
+A remount option which permits online expansion of reiserfs partitions.
+Instructs reiserfs to assume that the device has
+.I number
+blocks.
+This option is designed for use with devices which are under logical
+volume management (LVM).
+There is a special
+.I resizer
+utility which can be obtained from
+.IR ftp://ftp.namesys.com/pub/reiserfsprogs .
+
.SH "Mount options for romfs"
None.
@@ -1396,8 +1542,8 @@ It is possible for a corrupted file system to cause a crash.
.PP
Some Linux file systems don't support
.B "\-o sync"
-(the ext2fs
-.I does
+(the ext2 and ext3 file systems
+.I do
support synchronous updates (a la BSD) when mounted with the
.B sync
option).
diff --git a/mount/mount_by_label.c b/mount/mount_by_label.c
index 18344e4bd..f4d455d72 100644
--- a/mount/mount_by_label.c
+++ b/mount/mount_by_label.c
@@ -31,11 +31,11 @@ static struct uuidCache_s {
char *device;
} *uuidCache = NULL;
-/* for now, only ext2 and xfs are supported */
+/* for now, only ext2, ext3 and xfs are supported */
static int
get_label_uuid(const char *device, char **label, char *uuid) {
- /* start with ext2 and xfs tests, taken from mount_guess_fstype */
+ /* start with ext2/3 and xfs tests, taken from mount_guess_fstype */
/* should merge these later */
int fd;
int rv = 1;
diff --git a/mount/mount_guess_fstype.c b/mount/mount_guess_fstype.c
index 8694213d0..f6940af36 100644
--- a/mount/mount_guess_fstype.c
+++ b/mount/mount_guess_fstype.c
@@ -18,11 +18,14 @@
* so useful anymore.]
*
* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
- * - added Native Language Support
+ * added Native Language Support
*
- * Fri Dec 1 23:31:00 2000: Sepp Wijnands <mrrazz@garbage-coderz.net>
+ * 2000-12-01 Sepp Wijnands <mrrazz@garbage-coderz.net>
* added probes for cramfs, hfs, hpfs and adfs.
*
+ * 2001-10-26 Tim Launchbury
+ * added sysv magic.
+ *
* aeb - many changes.
*
*/
@@ -70,23 +73,25 @@ assemble4le(unsigned char *p) {
Original routine by <jmorriso@bogomips.ww.ubc.ca>; made into a function
for mount(8) by Mike Grupenhoff <kashmir@umiacs.umd.edu>.
+ Corrected the test for xiafs - aeb
Read the superblock only once - aeb
- Added iso9660, romfs, qnx4, udf, swap - aeb
+ Added a very weak heuristic for vfat - aeb
+ Added iso9660, romfs, qnx4, udf, vxfs, swap - aeb
Added a test for high sierra (iso9660) - quinlan@bucknell.edu
- Corrected the test for xiafs - 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
Added xfs - 2000-03-21 Martin K. Petersen <mkp@linuxcare.com>
Added cramfs, hfs, hpfs, adfs - Sepp Wijnands <mrrazz@garbage-coderz.net>
Added ext3 - Andrew Morton
+ Added jfs - Christoph Hellwig
+ Added sysv - Tim Launchbury
*/
static char
*magic_known[] = {
"adfs", "bfs", "cramfs", "ext", "ext2", "ext3",
- "hfs", "hpfs", "iso9660", "minix", "ntfs",
- "qnx4", "romfs", "swap", "udf", "ufs",
- "xfs", "xiafs"
+ "hfs", "hpfs", "iso9660", "jfs", "minix", "ntfs",
+ "qnx4", "reiserfs", "romfs", "swap", "sysv", "udf", "ufs",
+ "vxfs", "xfs", "xiafs"
};
static int
@@ -138,6 +143,14 @@ may_be_adfs(const u_char *s) {
return (sum == p[511]);
}
+static int is_reiserfs_magic_string (struct reiserfs_super_block * rs)
+{
+ return (!strncmp (rs->s_magic, REISERFS_SUPER_MAGIC_STRING,
+ strlen ( REISERFS_SUPER_MAGIC_STRING)) ||
+ !strncmp (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING,
+ strlen ( REISER2FS_SUPER_MAGIC_STRING)));
+}
+
static char *
fstype(const char *device) {
int fd;
@@ -146,7 +159,8 @@ fstype(const char *device) {
struct minix_super_block ms;
struct ext_super_block es;
struct ext2_super_block e2s;
- } sb;
+ struct vxfs_super_block vs;
+ } sb; /* stuff at 1024 */
union {
struct xiafs_super_block xiasb;
char romfs_magic[8];
@@ -162,9 +176,12 @@ fstype(const char *device) {
struct iso_volume_descriptor iso;
struct hs_volume_descriptor hs;
} isosb;
+ struct reiserfs_super_block reiserfssb; /* block 64 or 8 */
+ struct jfs_super_block jfssb; /* block 32 */
struct hfs_super_block hfssb;
struct hpfs_super_block hpfssb;
struct adfs_super_block adfssb;
+ struct sysv_super_block svsb;
struct stat statbuf;
/* opening and reading an arbitrary unknown path can have
@@ -204,7 +221,33 @@ fstype(const char *device) {
else if (extmagic(sb.es) == EXT_SUPER_MAGIC)
type = "ext";
+ else if (vxfsmagic(sb.vs) == VXFS_SUPER_MAGIC)
+ type = "vxfs";
+
+ if (!type) {
+ /* block 64 */
+ if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET) !=
+ REISERFS_DISK_OFFSET_IN_BYTES
+ || read(fd, (char *) &reiserfssb, sizeof(reiserfssb)) !=
+ sizeof(reiserfssb))
+ goto io_error;
+ if (is_reiserfs_magic_string(&reiserfssb))
+ type = "reiserfs";
+ }
+
if (!type) {
+ /* block 8 */
+ if (lseek(fd, REISERFS_OLD_DISK_OFFSET_IN_BYTES, SEEK_SET) !=
+ REISERFS_OLD_DISK_OFFSET_IN_BYTES
+ || read(fd, (char *) &reiserfssb, sizeof(reiserfssb)) !=
+ sizeof(reiserfssb))
+ goto io_error;
+ if (is_reiserfs_magic_string(&reiserfssb))
+ type = "reiserfs";
+ }
+
+ if (!type) {
+ /* block 0 */
if (lseek(fd, 0, SEEK_SET) != 0
|| read(fd, (char *) &xsb, sizeof(xsb)) != sizeof(xsb))
goto io_error;
@@ -216,7 +259,7 @@ fstype(const char *device) {
else if(!strncmp(xsb.xfsb.s_magic, XFS_SUPER_MAGIC, 4))
type = "xfs";
else if(!strncmp(xsb.qnx4fs_magic+4, "QNX4FS", 6))
- type = "qnx4fs";
+ type = "qnx4";
else if(xsb.bfs_magic == 0x1badface)
type = "bfs";
else if(!strncmp(xsb.ntfssb.s_magic, NTFS_SUPER_MAGIC,
@@ -239,6 +282,24 @@ fstype(const char *device) {
}
if (!type) {
+ /* sector 1 */
+ if (lseek(fd, 512 , SEEK_SET) != 512
+ || read(fd, (char *) &svsb, sizeof(svsb)) != sizeof(svsb))
+ goto io_error;
+ if (sysvmagic(svsb) == SYSV_SUPER_MAGIC )
+ type = "sysv";
+ }
+
+ if (!type) {
+ /* block 32 */
+ if (lseek(fd, JFS_SUPER1_OFF, SEEK_SET) != JFS_SUPER1_OFF
+ || read(fd, (char *) &jfssb, sizeof(jfssb)) != sizeof(jfssb))
+ goto io_error;
+ if (!strncmp(jfssb.s_magic, JFS_MAGIC, 4))
+ type = "jfs";
+ }
+
+ if (!type) {
if (lseek(fd, 8192, SEEK_SET) != 8192
|| read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb))
goto io_error;
@@ -395,7 +456,7 @@ procfsloop(int (*mount_fn)(struct mountargs *), struct mountargs *args,
int errsv = 0;
int i;
- if (!strncmp(*types, "no", 2)) {
+ if (*types && !strncmp(*types, "no", 2)) {
no = 1;
notypes = (*types) + 2;
}
diff --git a/mount/mount_guess_rootdev.c b/mount/mount_guess_rootdev.c
index 7246d319a..1c63cd7c1 100644
--- a/mount/mount_guess_rootdev.c
+++ b/mount/mount_guess_rootdev.c
@@ -69,15 +69,21 @@ char *
mount_guess_rootdev() {
FILE *cf;
char line[1024];
- char *p;
+ char *p, *ret = NULL;
cf = fopen(PROC_CMDLINE, "r");
- if (cf && fgets(line, sizeof(line), cf)) {
- for (p = line; *p; p++)
- if (!strncmp(p, " root=", 6))
- return rootdev(p+6);
+ if (cf) {
+ if (fgets(line, sizeof(line), cf)) {
+ for (p = line; *p; p++) {
+ if (!strncmp(p, " root=", 6)) {
+ ret = rootdev(p+6);
+ break;
+ }
+ }
+ }
+ fclose(cf);
}
- return NULL;
+ return ret;
}
#if 0
diff --git a/mount/nfs.5 b/mount/nfs.5
index b29a8bdb0..d2165b853 100644
--- a/mount/nfs.5
+++ b/mount/nfs.5
@@ -201,7 +201,7 @@ Do not use locking. Do not start lockd.
.TP 1.5i
.I tcp
Mount the NFS filesystem using the TCP protocol instead of the
-default UDP protocol. Many NFS severs only support UDP.
+default UDP protocol. Many NFS servers only support UDP.
.TP 1.5i
.I udp
Mount the NFS filesystem using the UDP protocol. This
diff --git a/mount/nfsmount.c b/mount/nfsmount.c
index d81c062e1..c0e27f0d4 100644
--- a/mount/nfsmount.c
+++ b/mount/nfsmount.c
@@ -132,9 +132,6 @@ get_mountport(struct sockaddr_in *server_addr,
struct pmaplist *pmap;
static struct pmap p = {0, 0, 0, 0};
- server_addr->sin_port = PMAPPORT;
- pmap = pmap_getmaps(server_addr);
-
if (version > MAX_NFSPROT)
version = MAX_NFSPROT;
if (!prog)
@@ -144,6 +141,9 @@ get_mountport(struct sockaddr_in *server_addr,
p.pm_prot = proto;
p.pm_port = port;
+ server_addr->sin_port = PMAPPORT;
+ pmap = pmap_getmaps(server_addr);
+
while (pmap) {
if (pmap->pml_map.pm_prog != prog)
goto next;
@@ -163,10 +163,22 @@ get_mountport(struct sockaddr_in *server_addr,
}
if (!p.pm_vers)
p.pm_vers = MOUNTVERS;
- if (!p.pm_port)
- p.pm_port = MOUNTPORT;
if (!p.pm_prot)
p.pm_prot = IPPROTO_TCP;
+#if 0
+ if (!p.pm_port) {
+ p.pm_port = pmap_getport(server_addr, p.pm_prog, p.pm_vers,
+ p.pm_prot);
+ }
+#endif
+#if 0
+#define MOUNTPORT 635
+ /* HJLu wants to remove all traces of the old default port.
+ Are there still people running a mount RPC service on this
+ port without having a portmapper? */
+ if (!p.pm_port)
+ p.pm_port = MOUNTPORT;
+#endif
return &p;
}
@@ -188,7 +200,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
struct hostent *hp;
struct sockaddr_in server_addr;
struct sockaddr_in mount_server_addr;
- struct pmap* pm_mnt;
+ struct pmap *pm_mnt;
int msock, fsock;
struct timeval retry_timeout;
union {
@@ -576,7 +588,8 @@ int nfsmount(const char *spec, const char *node, int *flags,
&msock);
if (mclient)
break;
- mount_server_addr.sin_port = htons(pm_mnt->pm_port);
+ mount_server_addr.sin_port =
+ htons(pm_mnt->pm_port);
msock = RPC_ANYSOCK;
case IPPROTO_TCP:
mclient = clnttcp_create(&mount_server_addr,
diff --git a/mount/nfsmount.x b/mount/nfsmount.x
index c27e74b7c..ad4bf9989 100644
--- a/mount/nfsmount.x
+++ b/mount/nfsmount.x
@@ -48,7 +48,6 @@
#endif
%#include <asm/types.h>
-const MOUNTPORT = 635;
const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */
const MNTNAMLEN = 255; /* maximum bytes in a name argument */
const FHSIZE = 32; /* size in bytes of a file handle */
diff --git a/mount/rpcsvc/nfsmount.h b/mount/rpcsvc/nfsmount.h
index 55b5d8e7e..aa4a93bd0 100644
--- a/mount/rpcsvc/nfsmount.h
+++ b/mount/rpcsvc/nfsmount.h
@@ -50,7 +50,6 @@ extern "C" {
#ifndef _rpcsvc_mount_h
#define _rpcsvc_mount_h
#include <asm/types.h>
-#define MOUNTPORT 635
#define MNTPATHLEN 1024
#define MNTNAMLEN 255
#define FHSIZE 32
diff --git a/mount/rpcsvc/nfsmount.x b/mount/rpcsvc/nfsmount.x
index c27e74b7c..ad4bf9989 100644
--- a/mount/rpcsvc/nfsmount.x
+++ b/mount/rpcsvc/nfsmount.x
@@ -48,7 +48,6 @@
#endif
%#include <asm/types.h>
-const MOUNTPORT = 635;
const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */
const MNTNAMLEN = 255; /* maximum bytes in a name argument */
const FHSIZE = 32; /* size in bytes of a file handle */
diff --git a/mount/sundries.c b/mount/sundries.c
index 59b069678..621282cf5 100644
--- a/mount/sundries.c
+++ b/mount/sundries.c
@@ -193,7 +193,7 @@ matching_type (const char *type, const char *types) {
char *
canonicalize (const char *path) {
char *canonical;
-
+
if (path == NULL)
return NULL;
diff --git a/mount/swapon.c b/mount/swapon.c
index b87a021ae..9f25fcbe7 100644
--- a/mount/swapon.c
+++ b/mount/swapon.c
@@ -158,9 +158,11 @@ display_summary(void)
strerror (errsv));
return -1 ;
}
+
while ( fgets(line, sizeof(line), swaps))
printf ("%s", line);
+ fclose(swaps);
return 0 ;
}
diff --git a/mount/umount.8 b/mount/umount.8
index 0b67314c5..ecc1fa64b 100644
--- a/mount/umount.8
+++ b/mount/umount.8
@@ -29,15 +29,17 @@ umount \- unmount file systems
.SH SYNOPSIS
.BI "umount [\-hV]"
.LP
-.BI "umount -a [\-nrv] [\-t " vfstype ]
+.BI "umount -a [\-dflnrv] [\-t " vfstype ]
.br
-.BI "umount [\-nrv] " "device " | " dir " [...]
+.BI "umount [\-dflnrv] " "dir " | " device " [...]
.SH DESCRIPTION
The
.B umount
command detaches the file system(s) mentioned from the file hierarchy.
-A file system is specified either by giving the directory where it
-has been mounted, or by giving the special device on which it lives.
+A file system is specified by giving the directory where it
+has been mounted. Giving the special device on which the file system lives
+may also work, but is obsolete, mainly because it will fail
+in case this device was mounted on more than one directory.
Note that a file system cannot be unmounted when it is `busy' -
for example, when there are open files on it, or when some process
@@ -46,6 +48,7 @@ The offending process could even be
.B umount
itself - it opens libc, and libc in its turn may open for example
locale files.
+A lazy unmount avoids this problem.
Options for the
.B umount
@@ -90,6 +93,12 @@ to specify the file system types on which no action should be taken.
.B \-f
Force unmount (in case of an unreachable NFS system).
(Requires kernel 2.1.116 or later.)
+.TP
+.B \-l
+Lazy unmount. Detach the filesystem from the filesystem hierarchy now,
+and cleanup all references to the filesystem as soon as it is not busy
+anymore.
+(Requires kernel 2.4.11 or later.)
.SH "THE LOOP DEVICE"
The
@@ -101,7 +110,6 @@ or when the \-d option was given.
Any pending loop devices can be freed using `losetup -d', see
.BR losetup (8).
-
.SH FILES
.I /etc/mtab
table of mounted file systems
diff --git a/mount/umount.c b/mount/umount.c
index 92400875a..b2beb9acb 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -23,6 +23,8 @@
* in mtab, try them all, with last one tried first
* - Differentiate "user" and "users" key words in fstab
* 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
*/
#include <stdio.h>
@@ -83,9 +85,16 @@ umount2(const char *path, int flags) {
#endif /* MNT_FORCE */
+#if !defined(MNT_DETACH)
+#define MNT_DETACH 2
+#endif
+
/* Nonzero for force umount (-f). There is kernel support since 2.1.116. */
int force = 0;
+/* Nonzero for lazy umount (-l). There is kernel support since 2.4.11. */
+int lazy = 0;
+
/* When umount fails, attempt a read-only remount (-r). */
int remount = 0;
@@ -171,10 +180,20 @@ nfs_umount_rpc_call(const char *spec, const char *opts)
saddr.sin_port = htons(port);
pertry.tv_sec = 3;
pertry.tv_usec = 0;
- if ((clp = clntudp_create(&saddr, MOUNTPROG, MOUNTVERS,
- pertry, &so)) == NULL) {
- clnt_pcreateerror("Cannot MOUNTPROG RPC");
- return (1);
+ if (opts && (p = strstr(opts, "tcp"))) {
+ /* possibly: make sure option is not "notcp"
+ possibly: try udp if tcp fails */
+ if ((clp = clnttcp_create(&saddr, MOUNTPROG, MOUNTVERS,
+ &so, 0, 0)) == NULL) {
+ clnt_pcreateerror("Cannot MOUNTPROG RPC (tcp)");
+ return 1;
+ }
+ } else {
+ if ((clp = clntudp_create(&saddr, MOUNTPROG, MOUNTVERS,
+ pertry, &so)) == NULL) {
+ clnt_pcreateerror("Cannot MOUNTPROG RPC");
+ return 1;
+ }
}
clp->cl_auth = authunix_create_default();
try.tv_sec = 20;
@@ -186,12 +205,12 @@ nfs_umount_rpc_call(const char *spec, const char *opts)
if (clnt_stat != RPC_SUCCESS) {
clnt_perror(clp, "Bad UMNT RPC");
- return (1);
+ return 1;
}
auth_destroy(clp->cl_auth);
clnt_destroy(clp);
- return (0);
+ return 0;
}
#endif /* HAVE_NFS */
@@ -248,13 +267,16 @@ umount_one (const char *spec, const char *node, const char *type,
#endif
umnt_err = umnt_err2 = 0;
- if (force) {
- /* completely untested;
- 2.1.116 only has some support in nfs case */
- /* probably this won't work */
- int flags = MNT_FORCE;
-
- res = umount2 (node, flags);
+ if (lazy) {
+ res = umount2 (node, MNT_DETACH);
+ if (res < 0) {
+ complain(errno, node);
+ return 1;
+ } else
+ return 0;
+ }
+ if (force) { /* only supported for NFS */
+ res = umount2 (node, MNT_FORCE);
if (res == -1) {
perror("umount2");
if (errno == ENOSYS) {
@@ -570,7 +592,7 @@ main (int argc, char *argv[]) {
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((c = getopt_long (argc, argv, "adfhnrt:vV",
+ while ((c = getopt_long (argc, argv, "adfhlnrt:vV",
longopts, NULL)) != EOF)
switch (c) {
case 'a': /* umount everything */
@@ -586,6 +608,9 @@ main (int argc, char *argv[]) {
case 'h': /* help */
usage (stdout, 0);
break;
+ case 'l': /* lazy umount */
+ ++lazy;
+ break;
case 'n': /* do not write in /etc/mtab */
++nomtab;
break;