+util-linux 2.12m
+
+* cfdisk: recognize JFS, support reiserfs labels (flavio.stanchina@tin.it)
+* mount: fix option parsing bug
+* mount.8: several updates
+* swapon.8: document -v option
+
util-linux 2.12l
* Makefile: remove cat-id-tbl.c upon make clean
* XFS label recognition.
* Thu Nov 22 15:42:56 CET 2001 <flavio.stanchina@tin.it>
* ext3 and ReiserFS recognition.
+ * Sun Oct 12 17:43:43 CEST 2003 <flavio.stanchina@tin.it>
+ * JFS recognition; ReiserFS label recognition.
*
****************************************************************************/
return _("Linux ext3");
else if (!strcmp(p_info[i].fstype, "xfs"))
return _("Linux XFS");
+ else if (!strcmp(p_info[i].fstype, "jfs"))
+ return _("Linux JFS");
else if (!strcmp(p_info[i].fstype, "reiserfs"))
return _("Linux ReiserFS");
else
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
struct reiserfs_super_block {
- char s_dummy0[ 52];
- char s_magic [ 12];
- char s_dummy1[140];
+ char s_dummy0[52];
+ char s_magic [10];
+ char s_dummy1[38];
+ u_char s_label[16];
};
+#define REISERFSLABELSZ sizeof(reiserfsb.s_label)
static int
-is_reiserfs_magic_string(const 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)));
+has_reiserfs_magic_string(const struct reiserfs_super_block *rs, int *is_3_6) {
+ if (!strncmp(rs->s_magic, REISERFS_SUPER_MAGIC_STRING,
+ strlen(REISERFS_SUPER_MAGIC_STRING))) {
+ *is_3_6 = 0;
+ return 1;
+ }
+ if (!strncmp(rs->s_magic, REISER2FS_SUPER_MAGIC_STRING,
+ strlen(REISER2FS_SUPER_MAGIC_STRING))) {
+ *is_3_6 = 1;
+ return 1;
+ }
+ return 0;
}
static void
#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
struct reiserfs_super_block reiserfsb;
+ int reiserfs_is_3_6;
+
+#define JFS_SUPER1_OFF 0x8000
+#define JFS_MAGIC "JFS1"
+#define JFSLABELSZ 16
+ struct jfs_super_block {
+ char s_magic[4];
+ u_char s_version[4];
+ u_char s_dummy1[93];
+ char s_fpack[11];
+ u_char s_dummy2[24];
+ u_char s_uuid[16];
+ char s_label[JFSLABELSZ];
+ } jfsb;
#define XFS_SUPER_MAGIC "XFSB"
#define XFSLABELSZ 12
offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE + 0;
if (ext2_llseek(fd, offset, SEEK_SET) == offset
&& read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb)
- && !strcmp(xfsb.s_magic, XFS_SUPER_MAGIC)) {
+ && !strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4)) {
label = xfsb.s_fname;
for(j=0; j<XFSLABELSZ && j<LABELSZ && isprint(label[j]); j++)
p_info[i].volume_label[j] = label[j];
return;
}
+ /* jfs? */
+ offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
+ + JFS_SUPER1_OFF;
+ if (ext2_llseek(fd, offset, SEEK_SET) == offset
+ && read(fd, &jfsb, sizeof(jfsb)) == sizeof(jfsb)
+ && !strncmp(jfsb.s_magic, JFS_MAGIC, strlen(JFS_MAGIC))) {
+ label = jfsb.s_label;
+ for(j=0; j<JFSLABELSZ && j<LABELSZ && isprint(label[j]); j++)
+ p_info[i].volume_label[j] = label[j];
+ p_info[i].volume_label[j] = 0;
+ strncpy(p_info[i].fstype, "jfs", FSTYPESZ);
+ return;
+ }
+
/* reiserfs? */
offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
+ REISERFS_DISK_OFFSET_IN_BYTES;
if (ext2_llseek(fd, offset, SEEK_SET) == offset
&& read(fd, &reiserfsb, 1024) == 1024
- && is_reiserfs_magic_string(&reiserfsb)) {
+ && has_reiserfs_magic_string(&reiserfsb, &reiserfs_is_3_6)) {
+ if (reiserfs_is_3_6) {
+ /* label only on version 3.6 onward */
+ label = reiserfsb.s_label;
+ for(j=0; j<REISERFSLABELSZ && j<LABELSZ &&
+ isprint(label[j]); j++)
+ p_info[i].volume_label[j] = label[j];
+ p_info[i].volume_label[j] = 0;
+ }
strncpy(p_info[i].fstype, "reiserfs", FSTYPESZ);
return;
}
break;
default:
usage(argv[0]);
- break;
+ exit(1);
}
}
break;
warn_geometry(void) {
char *m = NULL;
int prev = 0;
+
+ if (sgi_label) /* cannot set cylinders etc anyway */
+ return 0;
if (!heads)
prev = test_c(&m, _("heads"));
if (!sectors)
"information.\n"));
if (leave) {
- close(fd);
+ if (fsync(fd) || close(fd)) {
+ fprintf(stderr, _("\nError closing file\n"));
+ exit(1);
+ }
printf(_("Syncing disks.\n"));
sync();
{0x85, N_("Linux extended")},
{0x86, N_("NTFS volume set")},
{0x87, N_("NTFS volume set")},
+ {0x88, N_("Linux plaintext")},
{0x8e, N_("Linux LVM")},
{0x93, N_("Amoeba")},
{0x94, N_("Amoeba BBT")}, /* (bad block table) */
-.\" Copyright (c) 1996 Andries Brouwer
+.\" Copyright (c) 1996-2004 Andries Brouwer
.\"
.\" This page is somewhat derived from a page that was
.\" (c) 1980, 1989, 1991 The Regents of the University of California
.\" 010725, Nikita Danilov <NikitaDanilov@Yahoo.COM>: reiserfs options
.\" 011124, Karl Eichwalder <ke@gnu.franken.de>: tmpfs options
.\"
-.TH MOUNT 8 "14 September 1997" "Linux 2.0" "Linux Programmer's Manual"
+.TH MOUNT 8 "2004-12-16" "Linux 2.6" "Linux Programmer's Manual"
.SH NAME
mount \- mount a file system
.SH SYNOPSIS
.I fstab
contains the
.B user
-option on a line, then anybody can mount the corresponding system.
+option on a line, anybody can mount the corresponding system.
.LP
Thus, given a line
.RS
One can set such a label for ext2 or ext3 using the
.BR e2label (8)
utility, or for XFS using
-.BR xfs_admin (8).
+.BR xfs_admin (8),
+or for reiserfs using
+.BR reiserfstune (8).
.TP
.B \-n
Mount without writing in
The argument following the
.B \-t
is used to indicate the file system type. The file system types which are
-currently supported are:
+currently supported include:
.IR adfs ,
.IR affs ,
.IR autofs ,
(unless overridden by subsequent options, as in the option line
.BR group,dev,suid ).
.TP
+.B mand
+Allow mandatory locks on this filesystem. See
+.BR fcntl (2).
+.TP
.B _netdev
The filesystem resides on a device that requires network access
(used to prevent the system from attempting to mount these filesystems
(Until recently it was possible to run binaries anyway using a command like
/lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.)
.TP
+.B nomand
+Do not allow mandatory locks on this filesystem.
+.TP
.B nosuid
Do not allow set-user-identifier or set-group-identifier bits to take
effect. (This seems safe, but is in fact rather unsafe if you have
We sort them by file system. They all follow the
.B \-o
flag.
+
+What options are supported depends a bit on the running kernel.
+More info may be found in the kernel source subdirectory
+.IR Documentation/filesystems .
+
.SH "Mount options for adfs"
.TP
\fBuid=\fP\fIvalue\fP and \fBgid=\fP\fIvalue\fP
.SH "Mount options for ext3"
-The `ext3' file system is version of the ext2 file system which has been
+The `ext3' file system is a 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
.TP
.BR data=journal " / " data=ordered " / " data=writeback
Specifies the journalling mode for file data. Metadata is always journaled.
+To use modes other than
+.B ordered
+on the root file system, pass the mode to the kernel as boot parameter, e.g.
+.IR rootflags=data=journal .
.RS
.TP
.B 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.
+.RE
+.TP
+.BI commit= nrsec
+Sync all data and metadata every
+.I nrsec
+seconds. The default value is 5 seconds. Zero means default.
.SH "Mount options for fat"
(Note:
Set blocksize (default 512).
.TP
\fBuid=\fP\fIvalue\fP and \fBgid=\fP\fIvalue\fP
-Set the owner and group of all files. (Default: the uid and gid
-of the current process.)
+Set the owner and group of all files.
+(Default: the uid and gid of the current process.)
.TP
.BI umask= value
Set the umask (the bitmask of the permissions that are
.BI dmask= value
Set the umask applied to directories only.
The default is the umask of the current process.
-The value is given in octal. Present since 2.5.43.
+The value is given in octal.
+.\" Present since Linux 2.5.43.
.TP
.BI fmask= value
Set the umask applied to regular files only.
The default is the umask of the current process.
-The value is given in octal. Present since 2.5.43.
+The value is given in octal.
+.\" Present since Linux 2.5.43.
.TP
.BI check= value
Three different levels of pickyness can be chosen:
Various misguided attempts to force Unix or DOS conventions
onto a FAT file system.
+.SH "Mount options for hfs"
+.TP
+.BI creator= cccc ", type=" cccc
+Set the creator/type values as shown by the MacOS finder
+used for creating new files. Default values: '????'.
+.TP
+.BI uid= n ", gid=" n
+Set the owner and group of all files.
+(Default: the uid and gid of the current process.)
+.TP
+.BI dir_umask= n ", file_umask=" n ", umask=" n
+Set the umask used for all directories, all regular files, or all
+files and directories. Defaults to the umask of the current process.
+.TP
+.BI session= n
+Select the CDROM session to mount.
+Defaults to leaving that decision to the CDROM driver.
+This option will fail with anything but a CDROM as underlying device.
+.TP
+.BI part= n
+Select partition number n from the device.
+Only makes sense for CDROMS.
+Defaults to not parsing the partition table at all.
+.TP
+.B quiet
+Don't complain about invalid mount options.
+
.SH "Mount options for hpfs"
.TP
\fBuid=\fP\fIvalue\fP and \fBgid=\fP\fIvalue\fP
.BI iocharset= name
Character set to use when returning file names.
Unlike VFAT, NTFS suppresses names that contain
-unconvertible characters.
+unconvertible characters. Deprecated.
+.\" since 2.5.11
+.TP
+.BI nls= name
+New name for the option earlier called
+.IR iocharset .
+.\" since 2.5.11
.TP
.BR utf8
Use UTF-8 for converting file names.
.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.
+and, therefore, low probability of hash collisions at some CPU cost.
This may be used if EHASHCOLLISION errors are experienced with the r5 hash.
.TP
.B r5
for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.
.TP
.BI size= nbytes
-Override default size of the filesystem.
+Override default maximum size of the filesystem.
The size is given in bytes, and rounded down to entire pages.
The default is half of the memory.
.TP
.B undelete
Show deleted files in lists.
.TP
-.B strict
-Set strict conformance (unused).
-.TP
-.B utf8
-(unused).
+.B nostrict
+Unset strict conformance.
+.\" .TP
+.\" .B utf8
+.\" (unused).
.TP
.B iocharset
-(unused).
+Set the NLS character set.
.TP
.B bs=
Set the block size. (May not work unless 2048.)
.B norecovery
must be mounted read-only or the mount will fail.
.TP
+.B nouuid
+Ignore the filesystem uuid. This avoids errors for duplicate uuids.
+.TP
.B osyncisdsync
Make writes to files opened with the O_SYNC flag set behave
as if the O_DSYNC flag had been used instead.
.IR /tmp/fdimage ,
and then mount this device on
.IR /mnt .
+
This type of mount knows about three options, namely
.BR loop ", " offset " and " encryption ,
that are really options to
-.BR losetup (8).
+.BR \%losetup (8).
+(These options can be used in addition to those specific
+to the filesystem type.)
+
If no explicit loop device is mentioned
(but just an option `\fB\-o loop\fP' is given), then
.B mount
.B umask
for the
.IR fatfs ).
+.PP
+Mount by label or uuid will work only if your devices have the names listed in
+.IR /proc/partitions .
+In particular, it may well fail if the kernel was compiled with devfs
+but devfs is not mounted.
.SH HISTORY
A
.B mount
* For the options uid= and gid= replace user or group name by its value.
*/
static inline void
-parse_opt (const char *opt, int *mask, char *extra_opts) {
+parse_opt(const char *opt, int *mask, char *extra_opts, int len) {
const struct opt_map *om;
for (om = opt_map; om->opt != NULL; om++)
return;
}
- if (*extra_opts)
+ len -= strlen(extra_opts);
+
+ if (*extra_opts && --len > 0)
strcat(extra_opts, ",");
/* convert nonnumeric ids to numeric */
if (pw) {
sprintf(uidbuf, "uid=%d", pw->pw_uid);
- strcat(extra_opts, uidbuf);
+ if ((len -= strlen(uidbuf)) > 0)
+ strcat(extra_opts, uidbuf);
return;
}
}
if (gr) {
sprintf(gidbuf, "gid=%d", gr->gr_gid);
- strcat(extra_opts, gidbuf);
+ if ((len -= strlen(gidbuf)) > 0)
+ strcat(extra_opts, gidbuf);
return;
}
}
- strcat(extra_opts, opt);
+ if ((len -= strlen(opt)) > 0)
+ strcat(extra_opts, opt);
}
/* Take -o options list and compute 4th and 5th args to mount(2). flags
if (options != NULL) {
char *opts = xstrdup(options);
char *opt;
+ int len = strlen(opts) + 20;
- *extra_opts = xmalloc (strlen (opts) + 1);
+ *extra_opts = xmalloc(len);
**extra_opts = '\0';
- for (opt = strtok (opts, ","); opt; opt = strtok (NULL, ","))
- if (!parse_string_opt (opt))
- parse_opt (opt, flags, *extra_opts);
+ for (opt = strtok(opts, ","); opt; opt = strtok(NULL, ","))
+ if (!parse_string_opt(opt))
+ parse_opt(opt, flags, *extra_opts, len);
free(opts);
}
error (_("mount: %s not mounted already, or bad option"), node);
} else {
error (_("mount: wrong fs type, bad option, bad superblock on %s,\n"
- " missing codepage, or too many mounted file systems"),
+ " missing codepage or other error"),
spec);
if (stat(spec, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)
if (ioctl(fd, BLKGETSIZE, &size) == 0) {
if (size == 0 && !loop) {
warned++;
- error (" (could this be the IDE device where you in fact use\n"
- " ide-scsi so that sr0 or sda or so is needed?)");
+ error(_(
+ " (could this be the IDE device where you in fact use\n"
+ " ide-scsi so that sr0 or sda or so is needed?)"));
}
if (size && size <= 2) {
warned++;
- error (" (aren't you trying to mount an extended partition,\n"
- " instead of some logical partition inside?)");
+ error(_(
+ " (aren't you trying to mount an extended partition,\n"
+ " instead of some logical partition inside?)"));
}
close(fd);
}
}
#endif
}
+ error(_(
+ " In some cases useful info is found in syslog - try\n"
+ " dmesg | tail or so\n"));
}
break;
}
types = types0;
}
if (opts) {
- char *opts2 = realloc(xstrdup(opts), strlen(opts)+4);
+ char *opts2 = xrealloc(xstrdup(opts), strlen(opts)+4);
strcat(opts2, ",ro");
my_free(opts1);
opts = opts1 = opts2;
fseek(procpt, 0, SEEK_SET);
while (fgets(line, sizeof(line), procpt)) {
+ if (!index(line, '\n'))
+ break;
+
if (sscanf (line, " %d %d %d %[^\n ]",
&ma, &mi, &sz, ptname) != 4)
continue;
/* heuristic: partition name ends in a digit */
/* devfs has .../disc and .../part1 etc. */
- for(s = ptname; *s; s++);
+ for (s = ptname; *s; s++);
if (isdigit(s[-1]) || is_xvm(ptname)) {
/*
return t;
}
+void *
+xrealloc (void *p, size_t size) {
+ void *t;
+
+ t = realloc(p, size);
+ if (t == NULL)
+ die (EX_SYSERR, _("not enough memory"));
+
+ return t;
+}
+
char *
xstrdup (const char *s) {
char *t;
if (path == NULL)
return NULL;
+#if 1
if (streq(path, "none") ||
streq(path, "proc") ||
streq(path, "devpts"))
return xstrdup(path);
-
+#endif
if (myrealpath (path, canonical, PATH_MAX+1))
return xstrdup(canonical);
int matching_type (const char *type, const char *types);
int matching_opts (const char *options, const char *test_opts);
void *xmalloc (size_t size);
+void *xrealloc (void *t, size_t size);
char *xstrdup (const char *s);
char *xstrndup (const char *s, int n);
char *xstrconcat2 (const char *, const char *);
When
.B \-a
is used with swapon,
-.B
-\-e
+.B \-e
makes swapon silently skip devices that
do not exist.
.TP
.I /etc/fstab
for use with
.BR "swapon -a" .
+.TP
+.B \-v
+Be verbose.
.PP
.B Swapoff
disables swapping on the specified devices and files.
read_proc_swaps(void) {
FILE *swaps;
char line[1024];
- char *p;
+ char *p, **q;
numSwaps = 0;
swapFiles = NULL;
for (p = line; *p && *p != ' '; p++);
*p = 0;
- numSwaps++;
- swapFiles = realloc(swapFiles,
- numSwaps * sizeof(*swapFiles));
- swapFiles[numSwaps-1] = strdup(line);
+ q = realloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
+ if (q == NULL)
+ break;
+ swapFiles = q;
+
+ swapFiles[numSwaps++] = strdup(line);
}
fclose(swaps);
}
int i;
for (i = 0; i < numSwaps; i++)
- if (!strcmp(fname, swapFiles[i]))
+ if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
return 1;
return 0;
}
if (all) {
/*
- * In case /proc/swaps exists, unmount stuff listed there.
+ * In case /proc/swaps exists, unswap stuff listed there.
* We are quiet but report errors in status.
* Errors might mean that /proc/swaps
* exists as ordinary file, not in procfs.
status |= do_swapoff(swapFiles[i], QUIET);
/*
- * Unmount stuff mentioned in /etc/fstab.
+ * Unswap stuff mentioned in /etc/fstab.
* Probably it was unmounted already, so errors are not bad.
* Doing swapoff -a twice should not give error messages.
*/