Commit 612721db authored by Karel Zak's avatar Karel Zak

Imported from util-linux-2.11n tarball.

parent e8f26419
util-linux 2.11n
* Danish messages (Claus Hindsgaul)
* No new French messages yet
* German messages (Karl Eichwalder)
* Swedish messages (Christian Rose)
* Turkish messages now in UTF-8 (Nilgn Belma Bugner)
* blockdev: add --report option
* cal: fix for wide multibyte-char (Motonobu Ichimura)
* cfdisk: recognize ext3 and reiserfs (Flavio Stanchina)
* fsck.minix: i18n changes
* ipc.{info,texi}: minor correction
* login: compilation fix (Jaroslaw J. Pyszny)
* mount.8: tmpfs mount options (Karl Eichwalder)
* mount: recognize minix v2
* mount: support mount-by-label also for lvm (Kirby Bohling)
* mount: order guessing of fstypes according to seek offset
* pivot_root: compilation fix for ia64
* readprofile: byte order auto-detection (Werner Almesberger)
util-linux 2.11m
* Danish messages (Claus Hindsgaul)
......
......@@ -89,7 +89,7 @@ HAVE_SLN=no
HAVE_FDUTILS=no
# This enables building of raw
# ADD_RAW=yes
ADD_RAW=yes
# Different optimizations for different cpus.
# gcc 3.0 likes options -mcpu=i486 instead of -m486
......
......@@ -29,6 +29,17 @@
#define BLKBSZSET _IOW(0x12,113,sizeof(int))
#endif
/* Maybe <linux/hdreg.h> could be included */
#ifndef HDIO_GETGEO
#define HDIO_GETGEO 0x0301
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders; /* truncated */
unsigned long start;
};
#endif
const char *progname;
struct bdc {
......@@ -85,7 +96,10 @@ struct bdc {
static void
usage(void) {
int i;
fprintf(stderr, _("Usage: %s [-V] [-v|-q] commands devices\n"), progname);
fprintf(stderr, _("Usage:\n"));
fprintf(stderr, " %s -V\n", progname);
fprintf(stderr, _(" %s --report [devices]\n"), progname);
fprintf(stderr, _(" %s [-v|-q] commands devices\n"), progname);
fprintf(stderr, _("Available commands:\n"));
for (i = 0; i < SIZE(bdcms); i++) {
fprintf(stderr, "\t%s", bdcms[i].name);
......@@ -109,6 +123,9 @@ find_cmd(char *s) {
}
void do_commands(int fd, char **argv, int d);
void report_header(void);
void report_device(char *device, int quiet);
void report_all_devices(void);
int
main(int argc, char **argv) {
......@@ -136,6 +153,18 @@ main(int argc, char **argv) {
exit(0);
}
/* --report not together with other commands */
if (!strcmp(argv[1], "--report")) {
report_header();
if (argc > 2) {
for (d = 2; d < argc; d++)
report_device(argv[d], 0);
} else {
report_all_devices();
}
exit(0);
}
/* do each of the commands on each of the devices */
/* devices start after last command */
for (d = 1; d < argc; d++) {
......@@ -188,7 +217,8 @@ do_commands(int fd, char **argv, int d) {
j = find_cmd(argv[i]);
if (j == -1) {
fprintf(stderr, _("%s: Unknown command: %s\n"), progname, argv[i]);
fprintf(stderr, _("%s: Unknown command: %s\n"),
progname, argv[i]);
usage();
}
......@@ -246,8 +276,72 @@ do_commands(int fd, char **argv, int d) {
break;
default:
if (verbose)
printf("%s succeeded.\n", _(bdcms[j].help));
printf(_("%s succeeded.\n"), _(bdcms[j].help));
break;
}
}
}
#define PROC_PARTITIONS "/proc/partitions"
void
report_all_devices(void) {
FILE *procpt;
char line[200];
char ptname[200];
char device[210];
int ma, mi, sz;
procpt = fopen(PROC_PARTITIONS, "r");
if (!procpt) {
fprintf(stderr, _("%s: cannot open %s\n"),
progname, PROC_PARTITIONS);
exit(1);
}
while (fgets(line, sizeof(line), procpt)) {
if (sscanf (line, " %d %d %d %[^\n ]",
&ma, &mi, &sz, ptname) != 4)
continue;
sprintf(device, "/dev/%s", ptname);
report_device(device, 1);
}
}
void
report_device(char *device, int quiet) {
int fd;
int ro, ssz, bsz;
long ra, sz, ss;
struct hd_geometry g;
fd = open(device, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
if (!quiet)
fprintf(stderr, _("%s: cannot open %s\n"),
progname, device);
return;
}
ro = ssz = bsz = 0;
g.start = ra = sz = ss = 0;
if (ioctl (fd, BLKROGET, &ro) == 0 &&
ioctl (fd, BLKRAGET, &ra) == 0 &&
ioctl (fd, BLKSSZGET, &ssz) == 0 &&
ioctl (fd, BLKBSZGET, &bsz) == 0 &&
ioctl (fd, BLKGETSIZE, &sz) == 0 &&
ioctl (fd, HDIO_GETGEO, &g) == 0) {
printf("%s %5ld %5d %5d %10ld %10ld %s\n",
ro ? "ro" : "rw", ra, ssz, bsz, g.start, sz, device);
} else {
if (!quiet)
fprintf(stderr, _("%s: ioctl error on %s\n"),
progname, device);
}
}
void
report_header() {
printf(_("RO RA SSZ BSZ StartSec Size Device\n"));
}
This diff is collapsed.
......@@ -418,7 +418,9 @@ command (above) for more information on the print formats.
0: No errors; 1: Invocation error; 2: I/O error;
3: cannot get geometry; 4: bad partition table on disk.
.SH "SEE ALSO"
fdisk(8)
.BR fdisk (8),
.BR parted (8),
.BR sfdisk (8)
.SH BUGS
The current version does not support multiple disks.
.SH AUTHOR
......
......@@ -49,6 +49,8 @@
* Terabyte-sized disks.
* Sat Jun 30 05:23:19 EST 2001 <nathans@sgi.com>
* XFS label recognition.
* Thu Nov 22 15:42:56 CET 2001 <flavio.stanchina@tin.it>
* ext3 and ReiserFS recognition.
*
****************************************************************************/
......@@ -399,8 +401,12 @@ partition_type_text(int i) {
else if (p_info[i].id == LINUX) {
if (!strcmp(p_info[i].fstype, "ext2"))
return _("Linux ext2");
else if (!strcmp(p_info[i].fstype, "ext3"))
return _("Linux ext3");
else if (!strcmp(p_info[i].fstype, "xfs"))
return _("Linux XFS");
else if (!strcmp(p_info[i].fstype, "reiserfs"))
return _("Linux ReiserFS");
else
return _("Linux");
} else if (p_info[i].id == OS2_OR_NTFS) {
......@@ -593,84 +599,116 @@ dos_copy_to_info(char *to, int tosz, char *from, int fromsz) {
static void
get_dos_label(int i) {
char sector[128];
char sector[128];
#define DOS_OSTYPE_OFFSET 3
#define DOS_LABEL_OFFSET 43
#define DOS_FSTYPE_OFFSET 54
#define DOS_OSTYPE_SZ 8
#define DOS_LABEL_SZ 11
#define DOS_FSTYPE_SZ 8
ext2_loff_t offset;
offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
* SECTOR_SIZE;
if (ext2_llseek(fd, offset, SEEK_SET) == offset
&& read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
dos_copy_to_info(p_info[i].volume_label, LABELSZ,
sector+DOS_LABEL_OFFSET, DOS_LABEL_SZ);
dos_copy_to_info(p_info[i].fstype, FSTYPESZ,
sector+DOS_FSTYPE_OFFSET, DOS_FSTYPE_SZ);
}
ext2_loff_t offset;
offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
* SECTOR_SIZE;
if (ext2_llseek(fd, offset, SEEK_SET) == offset
&& read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
dos_copy_to_info(p_info[i].volume_label, LABELSZ,
sector+DOS_LABEL_OFFSET, DOS_LABEL_SZ);
dos_copy_to_info(p_info[i].fstype, FSTYPESZ,
sector+DOS_FSTYPE_OFFSET, DOS_FSTYPE_SZ);
}
}
#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];
};
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)));
}
static void
get_linux_label(int i) {
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT2LABELSZ 16
struct ext2_super_block {
char s_dummy0[56];
unsigned char s_magic[2];
char s_dummy1[62];
char s_volume_name[EXT2LABELSZ];
char s_last_mounted[64];
char s_dummy2[824];
} e2fsb;
#define EXT2_SUPER_MAGIC 0xEF53
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
struct ext2_super_block {
char s_dummy0[56];
unsigned char s_magic[2];
char s_dummy1[34];
unsigned char s_feature_compat[4];
char s_dummy2[24];
char s_volume_name[EXT2LABELSZ];
char s_last_mounted[64];
char s_dummy3[824];
} e2fsb;
#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
struct reiserfs_super_block reiserfsb;
#define XFS_SUPER_MAGIC "XFSB"
#define XFSLABELSZ 12
struct xfs_super_block {
unsigned char s_magic[4];
unsigned char s_dummy0[104];
unsigned char s_fname[XFSLABELSZ];
unsigned char s_dummy1[904];
} xfsb;
char *label;
ext2_loff_t offset;
int j;
struct xfs_super_block {
unsigned char s_magic[4];
unsigned char s_dummy0[104];
unsigned char s_fname[XFSLABELSZ];
unsigned char s_dummy1[904];
} xfsb;
char *label;
ext2_loff_t offset;
int j;
offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
* SECTOR_SIZE + 1024;
if (ext2_llseek(fd, offset, SEEK_SET) == offset
&& read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
&& e2fsb.s_magic[0] + (e2fsb.s_magic[1]<<8) == EXT2_SUPER_MAGIC) {
label = e2fsb.s_volume_name;
for(j=0; j<EXT2LABELSZ && j<LABELSZ && isprint(label[j]); j++)
p_info[i].volume_label[j] = label[j];
p_info[i].volume_label[j] = 0;
/* ext2 or ext3? */
if (e2fsb.s_feature_compat[0]&EXT3_FEATURE_COMPAT_HAS_JOURNAL)
strncpy(p_info[i].fstype, "ext3", FSTYPESZ);
else
strncpy(p_info[i].fstype, "ext2", FSTYPESZ);
return;
}
offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
* SECTOR_SIZE + 1024;
if (ext2_llseek(fd, offset, SEEK_SET) == offset
&& read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
&& e2fsb.s_magic[0] + 256*e2fsb.s_magic[1] == EXT2_SUPER_MAGIC) {
label = e2fsb.s_volume_name;
for(j=0; j<EXT2LABELSZ; j++)
if(!isprint(label[j]))
label[j] = 0;
label[EXT2LABELSZ] = 0;
strncpy(p_info[i].volume_label, label, LABELSZ);
strncpy(p_info[i].fstype, "ext2", FSTYPESZ);
return;
}
offset = ((ext2_loff_t) 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)) {
label = xfsb.s_fname;
for(j=0; j<XFSLABELSZ && 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, "xfs", FSTYPESZ);
return;
}
offset = ((ext2_loff_t) 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)) {
label = xfsb.s_fname;
for(j=0; j<XFSLABELSZ; j++)
if(!isprint(label[j]))
label[j] = 0;
label[XFSLABELSZ] = 0;
strncpy(p_info[i].volume_label, label, LABELSZ);
strncpy(p_info[i].fstype, "xfs", FSTYPESZ);
return;
}
/* reiserfs? */
offset = ((ext2_loff_t) 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)) {
strncpy(p_info[i].fstype, "reiserfs", FSTYPESZ);
return;
}
}
static void
......
......@@ -225,3 +225,7 @@ The option `dump partition table to file' is missing.
.\" Jakub Jelinek (jj@sunsite.mff.cuni.cz)
.\" Andreas Neuper (ANeuper@GUUG.de)
.\" and many others.
.SH "SEE ALSO"
.BR cfdisk (8),
.BR parted (8),
.BR sfdisk (8)
......@@ -512,6 +512,13 @@ A corresponding interactive
(with curses interface) is still lacking.
.LP
There are too many options.
.LP
There is no support for non-DOS partition types.
.SH AUTHOR
A. E. Brouwer (aeb@cwi.nl)
.SH "SEE ALSO"
.BR cfdisk (8),
.BR fdisk (8),
.BR parted (8)
......@@ -645,7 +645,7 @@ main(int argc, char **argv)
if (!(pwd = getpwnam(username))) {
fprintf(stderr, _("\nSession setup problem, abort.\n"));
syslog(LOG_ERR, _("Invalid user name \"%s\" in %s:%d. Abort."),
__FUNCTION__, __LINE__);
username, __FUNCTION__, __LINE__);
pam_end(pamh, PAM_SYSTEM_ERR);
exit(1);
}
......
......@@ -200,6 +200,22 @@ main(int argc, char **argv) {
textdomain(PACKAGE);
#if 0 /* setting week1stday is against man page */
/*
* What *is* the first day of the week? Note that glibc does not
* provide any information today, it (almost) always answers Monday.
* Sunday is the Jewish and Christian tradition.
* Sometimes an answer is built into the language:
* German calls Wednesday "Mittwoch", so starts at Sunday.
* Portuguese calls Monday "segunda-feira", so starts at Sunday.
* Russian calls Friday "pyatnitsa", so starts at Monday.
* ISO 8601 decided to start at Monday.
*
* The traditional Unix cal utility starts at Sunday.
* We start at Sunday and have an option -m for starting at Monday.
*
* At some future time this may become -s for Sunday, -m for Monday,
* no option for glibc-determined locale-dependent version.
*/
#ifdef HAVE_langinfo_h
week1stday = (int)(nl_langinfo(_NL_TIME_FIRST_WEEKDAY))[0];
#endif
......@@ -300,9 +316,9 @@ void headers_init(void)
wd = (i + week1stday) % 7;
#ifdef ENABLE_WIDECHAR
mbstowcs(wd_wc,weekday(wd),10);
if (wcslen(wd_wc) < 3)
if (wcswidth(wd_wc,10) < 3)
wcscat(j_day_headings_wc,L" ");
if (wcslen(wd_wc) < 2) {
if (wcswidth(wd_wc,10) < 2) {
wcscat(day_headings_wc, L" ");
wcscat(j_day_headings_wc, L" ");
}
......@@ -351,7 +367,11 @@ do_monthly(month, year, out)
*/
len = sprintf(lineout, _("%s %d"), full_month[month - 1], year);
#ifdef ENABLE_WIDECHAR
len = mbstowcs(lineout_wc,lineout,len);
if (mbstowcs(lineout_wc,lineout,len) > 0) {
len = wcswidth(lineout_wc,len);
} else {
len = strlen(lineout);
}
#endif
(void)sprintf(out->s[0],"%*s%s",
((julian ? J_WEEK_LEN : WEEK_LEN) - len) / 2, "", lineout );
......@@ -630,7 +650,11 @@ center(str, len, separate)
wchar_t str_wc[300];
int str_len;
str_len = mbstowcs(str_wc,str,300);
if (mbstowcs(str_wc,str,300) > 0) {
str_len = wcswidth(str_wc,300);
} else {
str_len = strlen(str);
}
len -= str_len;
#else
len -= strlen(str);
......
......@@ -13,8 +13,10 @@
#endif
#endif
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
#define MINIX_SUPER_MAGIC 0x137F /* minix v1, 14 char names */
#define MINIX_SUPER_MAGIC2 0x138F /* minix v1, 30 char names */
#define MINIX2_SUPER_MAGIC 0x2468 /* minix v2, 14 char names */
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix v2, 30 char names */
struct minix_super_block {
u_char s_dummy[16];
u_char s_magic[2];
......
......@@ -36,6 +36,7 @@
.\" 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
.\" 011124, Karl Eichwalder <ke@gnu.franken.de>: tmpfs options
.\"
.TH MOUNT 8 "14 September 1997" "Linux 2.0" "Linux Programmer's Manual"
.SH NAME
......@@ -347,6 +348,7 @@ currently supported are:
.IR romfs ,
.IR smbfs ,
.IR sysv ,
.IR tmpfs ,
.IR udf ,
.IR ufs ,
.IR umsdos ,
......@@ -391,9 +393,25 @@ 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 ", " ext3 ", " xiafs ", " iso9660 ,
.IR jfs ", " reiserfs ", " romfs ", " ufs ", " ntfs ", " qnx4 ", " bfs ,
.IR xfs ", " cramfs ", " hfs ", " hpfs ", " adfs ", " vxfs
.RI ( adfs ,
.IR bfs ,
.IR cramfs ,
.IR ext ,
.IR ext2 ,
.IR ext3 ,
.IR hfs ,
.IR hpfs ,
.IR iso9660 ,
.IR jfs ,
.IR minix ,
.IR ntfs ,
.IR qnx4 ,
.IR reiserfs ,
.IR romfs ,
.IR ufs ,
.IR vxfs ,
.IR xfs ,
.IR xiafs
are supported).
If this probe fails, mount will try to read the file
.IR /etc/filesystems ,
......@@ -1235,6 +1253,28 @@ and the current version of
.SH "Mount options for sysv"
None.
.SH "Mount options for tmpfs"
The following parameters accept a suffix
.BR k ,
.B m
or
.B g
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.
The size is given in bytes, and rounded down to entire pages.
The default is half of the memory.
.TP
.B nr_blocks=
Set number of blocks.
.TP
.B nr_inodes=
Set number of inodes.
.TP
.B mode=
Set initial permissions of the root directory.
.SH "Mount options for udf"
.TP
.B gid=
......
......@@ -653,7 +653,7 @@ cdrom_setspeed(char *spec) {
int speed = atoi(opt_speed);
if ((cdrom = open(spec, O_RDONLY | O_NONBLOCK)) < 0)
die(EX_FAIL, _("mount: cannot not open %s for setting speed"),
die(EX_FAIL, _("mount: cannot open %s for setting speed"),
spec);
if (ioctl(cdrom, CDROM_SELECT_SPEED, speed) < 0)
die(EX_FAIL, _("mount: cannot set speed: %s"),
......
......@@ -9,6 +9,8 @@
* - Added cache for UUID and disk labels
* 2000-11-07 Nathan Scott <nathans@sgi.com>
* - Added XFS support
* 2001-11-22 Kirby Bohling <kbohling@birddog.com>
* - Added support of labels on LVM
*/
#include <stdio.h>
......@@ -16,6 +18,9 @@
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h> /* needed for opendir */
#include <dirent.h>
#include "sundries.h" /* for xstrdup */
#include "linux_fs.h"
#include "mount_by_label.h"
......@@ -23,6 +28,7 @@
#define PROC_PARTITIONS "/proc/partitions"
#define DEVLABELDIR "/dev"
#define VG_DIR "/proc/lvm/VGs"
static struct uuidCache_s {
struct uuidCache_s *next;
......@@ -87,6 +93,44 @@ uuidcache_addentry(char *device, char *label, char *uuid) {
memcpy(last->uuid, uuid, sizeof(last->uuid));
}
/* LVM support - Kirby Bohling */
static void
uuidcache_init_lvm(void) {
char buffer[PATH_MAX];
char lvm_device[PATH_MAX];
DIR *vg_dir, *lv_list;
struct dirent *vg_iter, *lv_iter;
char uuid[16], *label;
vg_dir = opendir(VG_DIR);
if (vg_dir == NULL) /* to be expected */
return;
seekdir(vg_dir, 2);
while ((vg_iter = readdir(vg_dir)) != 0) {
sprintf(buffer, "%s/%s/LVs", VG_DIR, vg_iter->d_name);
lv_list = opendir(buffer);
if (lv_list == NULL) {
perror("mount (init_lvm)");
continue;
}
seekdir(lv_list, 2);
while ((lv_iter = readdir(lv_list)) != 0) {
/* Now we have the file.. could open it and read out
* where the device is, read the first line, second
* field... Instead we guess.
*/
sprintf(lvm_device, "%s/%s/%s", DEVLABELDIR,
vg_iter->d_name, lv_iter->d_name);
if (!get_label_uuid(lvm_device, &label, uuid))
uuidcache_addentry(strdup(lvm_device),
label, uuid);
}
closedir(lv_list);
}
closedir(vg_dir);
}
static void
uuidcache_init(void) {
char line[100];
......@@ -152,6 +196,8 @@ uuidcache_init(void) {
}
fclose(procpt);
uuidcache_init_lvm();
}
#define UUID 1
......
......@@ -76,7 +76,7 @@ assemble4le(unsigned char *p) {
Corrected the test for xiafs - aeb
Read the superblock only once - aeb
Added a very weak heuristic for vfat - aeb
Added iso9660, romfs, qnx4, udf, vxfs, swap - aeb
Added iso9660, minix-v2, romfs, qnx4, udf, vxfs, swap - aeb
Added a test for high sierra (iso9660) - quinlan@bucknell.edu
Added ufs from a patch by jj. But maybe there are several types of ufs?
Added ntfs from a patch by Richard Russon.
......@@ -94,14 +94,47 @@ static char
"vxfs", "xfs", "xiafs"
};
static struct tried {
struct tried *next;
char *type;
} *tried = NULL;
static int
tested(const char *device) {
char **m;
was_tested(const char *fstype) {
char **m;
struct tried *t;
for (m = magic_known; m - magic_known < SIZE(magic_known); m++)
if (!strcmp(*m, fstype))
return 1;
for (t = tried; t; t = t->next) {
if (!strcmp(t->type, fstype))
return 1;
}
return 0;
}
for (m = magic_known; m - magic_known < SIZE(magic_known); m++)
if (!strcmp(*m, device))
return 1;
return 0;
static void
set_tested(const char *fstype) {
struct tried *t = xmalloc(sizeof(struct tried));
t->next = tried;
t->type = xstrdup(fstype);
tried = t;
}
static void
free_tested(void) {
struct tried *t, *tt;
t = tried;
while(t) {
free(t->type);
tt = t->next;
free(t);
t = tt;
}
tried = NULL;
}
/* udf magic - I find that trying to mount garbage as an udf fs
......@@ -194,57 +227,8 @@ fstype(const char *device) {
if (fd < 0)
return 0;
if (lseek(fd, 1024, SEEK_SET) != 1024
|| read(fd, (char *) &sb, sizeof(sb)) != sizeof(sb))