diff -urN util-linux-2.11a/mount/Makefile util-linux-2.11a-fstyp/mount/Makefile --- util-linux-2.11a/mount/Makefile Sun Mar 4 19:38:53 2001 +++ util-linux-2.11a-fstyp/mount/Makefile Wed Apr 11 14:44:36 2001 @@ -11,9 +11,9 @@ LINK = $(CC) $(LDFLAGS) SUID_PROGS = mount umount -NOSUID_PROGS = swapon losetup +NOSUID_PROGS = swapon losetup fstyp MAN5 = fstab.5 nfs.5 -MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8 +MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8 fstyp.8 ifeq "$(HAVE_PIVOT_ROOT)" "yes" NOSUID_PROGS := $(NOSUID_PROGS) pivot_root @@ -58,6 +58,9 @@ $(COMPILE) -DMAIN lomount.c -o $@ losetup: main_losetup.o $(LIB)/xstrncpy.o + $(LINK) $^ -o $@ + +fstyp: fstyp.o mount_guess_fstype.o version.o $(LINK) $^ -o $@ mount.o umount.o nfsmount.o losetup.o fstab.o realpath.o sundries.o: sundries.h diff -urN util-linux-2.11a/mount/fstyp.8 util-linux-2.11a-fstyp/mount/fstyp.8 --- util-linux-2.11a/mount/fstyp.8 Wed Dec 31 19:00:00 1969 +++ util-linux-2.11a-fstyp/mount/fstyp.8 Wed Apr 11 14:53:25 2001 @@ -0,0 +1,77 @@ +.\" Copyright (c) 2001 Martin K. Petersen +.\" +.\" This is free documentation; you can redistribute it and/or +.\" modify it under the terms of the GNU General Public License as +.\" published by the Free Software Foundation; either version 2 of +.\" the License, or (at your option) any later version. +.\" +.\" The GNU General Public License's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" This manual is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public +.\" License along with this manual; if not, write to the Free +.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, +.\" USA. +.\" +.TH FSTYP 8 "21 March 2000" "Linux 2.2" "Linux Programmer's Manual" +.SH NAME +fstyp \- identify file systems +.SH SYNOPSIS +.BI "fstyp " "device" +.LP +.BI "fstyp [\-hV]" +.SH DESCRIPTION +The +.B fstyp +command tries to guess the filesystem type of a device and outputs its +findings. + +If a filesystem can be successfully identified, its name is printed +and 0 returned. + +If no known superblocks can be found, +.B fstyp +prints an empty string and returns a non-zero value. + +.B fstyp +is often used in backup scripts to pick +.B dump +and +.B restore +commands appropriate for the filesystem type. + +Since +.B fstyp +relies on heuristics to identify the filesystem, there is no guarantee +for correct results. + +The detection algorithm used in +.B fstyp +is the same as in the +.BR mount(8) +command. + +.SH OPTIONS +.TP +.B \-V +Print version and exit. +.TP +.B \-h +Print help message and exit. + +.SH FILES +.I /proc/filesystems +List of supported filesystem types. + +.SH "SEE ALSO" +.BR umount (2), +.BR mount (8), +.BR dump (8), +.BR restore (8) diff -urN util-linux-2.11a/mount/fstyp.c util-linux-2.11a-fstyp/mount/fstyp.c --- util-linux-2.11a/mount/fstyp.c Wed Dec 31 19:00:00 1969 +++ util-linux-2.11a-fstyp/mount/fstyp.c Wed Apr 11 14:53:49 2001 @@ -0,0 +1,78 @@ +/* + * fstyp.c + * + * Copyright (C) 2000, 2001 Martin K. Petersen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "mount_guess_fstype.h" +#include "nls.h" + + +extern char version[]; +int verbose = 0; + + +void usage (void); + + +void +usage (void) +{ + fprintf (stderr, "Usage: fstyp [-hV]\n fstyp special\n"); + exit (EXIT_FAILURE); +} + + +int +main (int argc, char **argv) +{ + char opt, *type = NULL; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + while ((opt = getopt(argc, argv, "hV")) != EOF) { + switch (opt) { + case 'V': + fprintf (stderr, "fstyp: %s\n", version); + exit (EXIT_FAILURE); + default: + usage(); + } + } + + if (argc != 2) + usage(); + + type = fstype (argv[1]); + + if (type) { + fprintf (stdout, "%s\n", type); + exit (EXIT_SUCCESS); + } + + exit (EXIT_FAILURE); +} diff -urN util-linux-2.11a/mount/mount_guess_fstype.c util-linux-2.11a-fstyp/mount/mount_guess_fstype.c --- util-linux-2.11a/mount/mount_guess_fstype.c Fri Mar 9 18:16:00 2001 +++ util-linux-2.11a-fstyp/mount/mount_guess_fstype.c Wed Apr 11 14:20:09 2001 @@ -132,7 +132,7 @@ return (sum == p[511]); } -static char * +char * fstype(const char *device) { int fd; char *type = NULL; diff -urN util-linux-2.11a/mount/mount_guess_fstype.h util-linux-2.11a-fstyp/mount/mount_guess_fstype.h --- util-linux-2.11a/mount/mount_guess_fstype.h Mon May 15 08:05:01 2000 +++ util-linux-2.11a-fstyp/mount/mount_guess_fstype.h Wed Apr 11 14:32:11 2001 @@ -8,6 +8,7 @@ extern int verbose; +char *fstype(const char *device); char *guess_fstype_from_superblock(const char *device); int procfsloop(int (*mount_fn)(struct mountargs *), struct mountargs *args, char **type);