Because blkid is here for a long time, I hereby propose a patch for removing support for NOT having blkid. The current support through set of #ifdef is prone to errors like making a patch just in one of the branches, and according to a recent talk between Christoph and Eric, it is not necessary to keep it supported. Remove code for checking ENABLE_BLKID, and the code when ENABLE_BLKID is not defined. The only use of libdisk was in the removed code, so remove libdisk too. It makes blkid required for compilation. Signed-off-by: Jan Tulak <jtulak@xxxxxxxxxx> --- Makefile | 6 +- configure.ac | 6 +- debian/rules | 2 +- include/Makefile | 2 +- include/builddefs.in | 2 - include/fstyp.h | 43 ----- libdisk/Makefile | 37 ----- libdisk/dm.c | 112 ------------- libdisk/drivers.c | 82 ---------- libdisk/drivers.h | 45 ------ libdisk/evms.c | 68 -------- libdisk/evms.h | 32 ---- libdisk/fstype.c | 442 --------------------------------------------------- libdisk/fstype.h | 334 -------------------------------------- libdisk/lvm.c | 117 -------------- libdisk/md.c | 119 -------------- libdisk/md.h | 67 -------- libdisk/pttype.c | 118 -------------- libdisk/pttype.h | 50 ------ libdisk/xvm.c | 93 ----------- libdisk/xvm.h | 53 ------ m4/package_blkid.m4 | 20 ++- mkfs/Makefile | 22 +-- mkfs/fstyp.c | 59 ------- mkfs/xfs_mkfs.c | 100 +----------- po/de.po | 51 ------ po/pl.po | 49 ------ 27 files changed, 16 insertions(+), 2115 deletions(-) delete mode 100644 include/fstyp.h delete mode 100644 libdisk/Makefile delete mode 100644 libdisk/dm.c delete mode 100644 libdisk/drivers.c delete mode 100644 libdisk/drivers.h delete mode 100644 libdisk/evms.c delete mode 100644 libdisk/evms.h delete mode 100644 libdisk/fstype.c delete mode 100644 libdisk/fstype.h delete mode 100644 libdisk/lvm.c delete mode 100644 libdisk/md.c delete mode 100644 libdisk/md.h delete mode 100644 libdisk/pttype.c delete mode 100644 libdisk/pttype.h delete mode 100644 libdisk/xvm.c delete mode 100644 libdisk/xvm.h delete mode 100644 mkfs/fstyp.c diff --git a/Makefile b/Makefile index 6d6803b..798f02a 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ endif # header install rules to populate include/xfs correctly HDR_SUBDIRS = include libxfs -DLIB_SUBDIRS = libxlog libxcmd libhandle libdisk +DLIB_SUBDIRS = libxlog libxcmd libhandle LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS) TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \ mdrestore repair rtcp m4 man doc po debian @@ -71,10 +71,6 @@ quota: libxcmd repair: libxlog -ifneq ($(ENABLE_BLKID), yes) -mkfs: libdisk -endif - ifeq ($(HAVE_BUILDDEFS), yes) include $(BUILDRULES) else diff --git a/configure.ac b/configure.ac index fe991cc..fac3ea7 100644 --- a/configure.ac +++ b/configure.ac @@ -37,10 +37,6 @@ AC_ARG_ENABLE(termcap, test $enable_termcap = yes && libtermcap="-ltermcap",) AC_SUBST(libtermcap) -# AC_HAVE_BLKID_TOPO below wil find the library & check for topo support -AC_ARG_ENABLE(blkid, -[ --enable-blkid=[yes/no] Enable block device id library [default=yes]],, - enable_blkid=yes) AC_ARG_ENABLE(lib64, [ --enable-lib64=[yes/no] Enable lib64 support [default=yes]],, @@ -111,7 +107,7 @@ AC_HAVE_FALLOCATE AC_HAVE_FIEMAP AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE -AC_HAVE_BLKID_TOPO($enable_blkid) +AC_HAVE_BLKID_TOPO AC_HAVE_READDIR AC_CHECK_SIZEOF([long]) diff --git a/debian/rules b/debian/rules index 27b043f..10d04f8 100755 --- a/debian/rules +++ b/debian/rules @@ -47,7 +47,7 @@ dibuild: for dir in include libxfs; do \ $(MAKE) -C $$dir NODEP=1 install-headers; \ done; \ - for dir in include libxfs libdisk mkfs; do \ + for dir in include libxfs mkfs; do \ $(MAKE) -C $$dir; \ done; \ mv mkfs/mkfs.xfs mkfs/mkfs.xfs-$(bootpkg); \ diff --git a/include/Makefile b/include/Makefile index 91b33b0..63a7748 100644 --- a/include/Makefile +++ b/include/Makefile @@ -46,7 +46,7 @@ HFILES = handle.h \ xqm.h PHFILES = darwin.h freebsd.h irix.h linux.h gnukfreebsd.h -DKHFILES = volume.h fstyp.h dvh.h +DKHFILES = volume.h dvh.h LIBHFILES = command.h input.h path.h project.h LSRCFILES = $(shell echo $(PHFILES) | sed -e "s/$(PKG_PLATFORM).h//g") LSRCFILES += platform_defs.h.in builddefs.in buildmacros buildrules install-sh diff --git a/include/builddefs.in b/include/builddefs.in index 7e9f53d..925761d 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -37,7 +37,6 @@ LIBBLKID = @libblkid@ LIBXFS = $(TOPDIR)/libxfs/libxfs.la LIBXCMD = $(TOPDIR)/libxcmd/libxcmd.la LIBXLOG = $(TOPDIR)/libxlog/libxlog.la -LIBDISK = $(TOPDIR)/libdisk/libdisk.la LIBHANDLE = $(TOPDIR)/libhandle/libhandle.la PKG_NAME = @pkg_name@ @@ -89,7 +88,6 @@ ENABLE_SHARED = @enable_shared@ ENABLE_GETTEXT = @enable_gettext@ ENABLE_EDITLINE = @enable_editline@ ENABLE_READLINE = @enable_readline@ -ENABLE_BLKID = @enable_blkid@ HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@ diff --git a/include/fstyp.h b/include/fstyp.h deleted file mode 100644 index 04c1608..0000000 --- a/include/fstyp.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2000-2001, 2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef __FSTYP_H__ -#define __FSTYP_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * fstype allows the user to determine the filesystem identifier of - * mounted or unmounted filesystems, using heuristics. - * The filesystem type is required by mount(2) and sometimes by mount(8) - * to mount filesystems of different types. - */ -extern char *fstype (const char * __device); - -/* - * ptabtype allows one to determine the type of partition table in - * use on a given volume, using heuristics. - */ -extern char *pttype (const char *__device); - -#ifdef __cplusplus -} -#endif - -#endif /* __FSTYP_H__ */ diff --git a/libdisk/Makefile b/libdisk/Makefile deleted file mode 100644 index b058a9f..0000000 --- a/libdisk/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 2000-2001,2004 Silicon Graphics, Inc. All Rights Reserved. -# - -TOPDIR = .. -include $(TOPDIR)/include/builddefs - -LTLIBRARY = libdisk.la -LT_CURRENT = 0 -LT_REVISION = 0 -LT_AGE = 0 - -CFILES = drivers.c fstype.c pttype.c -HFILES = drivers.h fstype.h pttype.h md.h xvm.h evms.h -LINUX_DRIVERS = dm.c md.c xvm.c evms.c lvm.c - -ifeq ($(PKG_PLATFORM),linux) -CFILES += $(LINUX_DRIVERS) -else -LSRCFILES = $(LINUX_DRIVERS) -endif - -ifneq ($(ENABLE_BLKID), yes) -default: ltdepend $(LTLIBRARY) -else -default: -endif - -include $(BUILDRULES) - -install: default - -install-dev: default - -install-qa: install-dev - --include .ltdep diff --git a/libdisk/dm.c b/libdisk/dm.c deleted file mode 100644 index dfc1f37..0000000 --- a/libdisk/dm.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2004-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "drivers.h" - -int -mnt_is_dm_subvol( - dev_t dev) -{ - return get_driver_block_major("device-mapper", major(dev)); -} - -int -dm_get_subvol_stripe( - char *dfile, - sv_type_t type, - int *sunit, - int *swidth, - int *sectalign, - struct stat64 *sb) -{ - int count, stripes = 0, stripesize = 0; - int dmpipe[2]; - char *largv[7]; - FILE *stream; - long long offset, size; - static char *command = "table"; /* dmsetup table /dev/xxx */ - char major_str[4], minor_str[4]; - - if (!mnt_is_dm_subvol(sb->st_rdev)) - return 0; - - /* Quest for dmsetup */ - if (!access("/usr/local/sbin/dmsetup", R_OK|X_OK)) - largv[0] = "/usr/local/sbin/dmsetup"; - else if (!access("/usr/sbin/dmsetup", R_OK|X_OK)) - largv[0] = "/usr/sbin/dmsetup"; - else if (!access("/sbin/dmsetup", R_OK|X_OK)) - largv[0] = "/sbin/dmsetup"; - else { - fprintf(stderr, - _("Warning - device mapper device, but no dmsetup(8) found\n")); - return 0; - } - - snprintf(major_str, 4, "%d", major(sb->st_rdev)); - snprintf(minor_str, 4, "%d", minor(sb->st_rdev)); - - largv[1] = command; - largv[2] = "-j"; - largv[3] = major_str; - largv[4] = "-m"; - largv[5] = minor_str; - largv[6] = NULL; - - /* Open pipe */ - if (pipe(dmpipe) < 0) { - fprintf(stderr, _("Could not open pipe\n")); - exit(1); - } - - /* Spawn dmsetup */ - switch (fork()) { - case 0: - /* Plumbing */ - close(dmpipe[0]); - - if (dmpipe[1] != STDOUT_FILENO) - dup2(dmpipe[1], STDOUT_FILENO); - - execv(largv[0], largv); - - fprintf(stderr, _("Failed to execute %s\n"), largv[0]); - exit(1); - - case -1: - fprintf(stderr, _("Failed forking dmsetup process\n")); - exit(1); - - default: - break; - } - - close(dmpipe[1]); - stream = fdopen(dmpipe[0], "r"); - count = fscanf(stream, "%lld %lld striped %d %d ", - &offset, &size, &stripes, &stripesize); - fclose(stream); - if (count != 4) - return 0; - - /* Update sizes */ - *sunit = stripesize; - *swidth = (stripes * stripesize); - *sectalign = 0; - return 1; -} diff --git a/libdisk/drivers.c b/libdisk/drivers.c deleted file mode 100644 index 26c6ec1..0000000 --- a/libdisk/drivers.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "drivers.h" - -void -get_subvol_stripe_wrapper( - char *dev, - sv_type_t type, - int *sunit, - int *swidth, - int *sectalign) -{ - struct stat64 sb; - - if (dev == NULL) - return; - - if (stat64(dev, &sb)) { - fprintf(stderr, _("Cannot stat %s: %s\n"), - dev, strerror(errno)); - exit(1); - } - - if ( dm_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb)) - return; - if ( md_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb)) - return; - if ( lvm_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb)) - return; - if ( xvm_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb)) - return; - if (evms_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb)) - return; - - /* ... add new device drivers here */ -} - -#define DEVICES "/proc/devices" - -/* - * General purpose routine which dredges through procfs trying to - * match up device driver names with the associated major numbers - * being used in the running kernel. - */ -int -get_driver_block_major( - const char *driver, - int major) -{ - FILE *f; - char buf[64], puf[64]; - int dmajor, match = 0; - - if ((f = fopen(DEVICES, "r")) == NULL) - return match; - while (fgets(buf, sizeof(buf), f)) /* skip to block dev section */ - if (strncmp("Block devices:\n", buf, sizeof(buf)) == 0) - break; - while (fgets(buf, sizeof(buf), f)) - if ((sscanf(buf, "%u %s\n", &dmajor, puf) == 2) && - (strncmp(puf, driver, sizeof(puf)) == 0) && - (dmajor == major)) - match = 1; - fclose(f); - return match; -} diff --git a/libdisk/drivers.h b/libdisk/drivers.h deleted file mode 100644 index 22ac1ea..0000000 --- a/libdisk/drivers.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "xfs/libxfs.h" -#include <sys/stat.h> -#include <volume.h> - -/* - * This stuff is all very platform specific. - */ - -#ifdef __linux__ -extern int dm_get_subvol_stripe(char*, sv_type_t, int*, int*, int*, - struct stat64*); -extern int md_get_subvol_stripe(char*, sv_type_t, int*, int*, int*, - struct stat64*); -extern int lvm_get_subvol_stripe(char*, sv_type_t, int*, int*, int*, - struct stat64*); -extern int xvm_get_subvol_stripe(char*, sv_type_t, int*, int*, int*, - struct stat64*); -extern int evms_get_subvol_stripe(char*, sv_type_t, int*, int*, int*, - struct stat64*); -#else -#define stat64 stat -#define dm_get_subvol_stripe(dev, type, a, b, c, stat) (-1) -#define md_get_subvol_stripe(dev, type, a, b, c, stat) (-1) -#define lvm_get_subvol_stripe(dev, type, a, b, c, stat) (-1) -#define xvm_get_subvol_stripe(dev, type, a, b, c, stat) (-1) -#define evms_get_subvol_stripe(dev, type, a, b, c, stat) (-1) -#endif diff --git a/libdisk/evms.c b/libdisk/evms.c deleted file mode 100644 index 4c22ee1..0000000 --- a/libdisk/evms.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) International Business Machines Corp., 2002 - * - * 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 <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/ioctl.h> -#include <sys/sysmacros.h> -#include <disk/volume.h> -#include "evms.h" - -int -mnt_is_evms_subvol( - dev_t dev) -{ - if (major(dev) == EVMS_MAJOR) - return 1; - return get_driver_block_major("evms", major(dev)); -} - -int -evms_get_subvol_stripe( - char *device, - sv_type_t type, - int *sunit, - int *swidth, - int *sectalign, - struct stat64 *sb) -{ - if (mnt_is_evms_subvol(sb->st_rdev)) { - evms_vol_stripe_info_t info; - int fd; - - fd = open(device, O_RDONLY); - if (fd == -1) - return 0; - - if (ioctl(fd, EVMS_GET_VOL_STRIPE_INFO, &info)) { - close(fd); - return 0; - } - - /* Update sizes */ - *sunit = info.size; - *swidth = *sunit * info.width; - *sectalign = 0; - - close(fd); - return 1; - } - return 0; -} diff --git a/libdisk/evms.h b/libdisk/evms.h deleted file mode 100644 index aab797b..0000000 --- a/libdisk/evms.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) International Business Machines Corp., 2002 - * - * 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 - */ - -#define EVMS_MAJOR 117 -#define EVMS_GET_VOL_STRIPE_INFO \ - _IOR(EVMS_MAJOR, 0xF0, struct evms_vol_stripe_info_s) - -/* - * struct evms_vol_stripe_info_s - contains stripe information for a volume - * - * unit: the stripe unit specified in 512 byte block units - * width: the number of stripe members or RAID data disks - */ -typedef struct evms_vol_stripe_info_s { - u_int32_t size; - u_int32_t width; -} evms_vol_stripe_info_t; diff --git a/libdisk/fstype.c b/libdisk/fstype.c deleted file mode 100644 index 548f297..0000000 --- a/libdisk/fstype.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> -#include "fstype.h" - -/* - * From mount(8) source by Andries Brouwer. Hacked for XFS by mkp. - * Recent sync's to mount source: - * - util-linux-2.10o ... 06 Sep 00 - * - util-linux-2.10r ... 06 Dec 00 - * - util-linux-2.11g ... 02 Jul 01 - * - util-linux-2.11u ... 24 Aug 02 - * - util-linux-2.11z ... 13 May 03 - */ - -#define SIZE(a) (sizeof(a)/sizeof(a[0])) - -/* Most file system types can be recognized by a `magic' number - in the superblock. Note that the order of the tests is - significant: by coincidence a filesystem can have the - magic numbers for several file system types simultaneously. - For example, the romfs magic lives in the 1st sector; - xiafs does not touch the 1st sector and has its magic in - the 2nd sector; ext2 does not touch the first two sectors. */ - -static inline unsigned short -swapped(unsigned short a) { - return (a>>8) | (a<<8); -} - -/* - Probes the device and attempts to determine the type of filesystem - contained within. - - Original routine by <jmorriso@xxxxxxxxxxxxxxxxxx>; made into a function - for mount(8) by Mike Grupenhoff <kashmir@xxxxxxxxxxxxxx>. - Corrected the test for xiafs - aeb - Read the superblock only once - aeb - Added a very weak heuristic for vfat - aeb - Added iso9660, minix-v2, romfs, qnx4, udf, vxfs, swap - aeb - Added a test for high sierra (iso9660) - quinlan@xxxxxxxxxxxx - Added ufs from a patch by jj. But maybe there are several types of ufs? - Added ntfs from a patch by Richard Russon. - Added xfs - 2000-03-21 Martin K. Petersen <mkp@xxxxxxxxxxxxx> - Added cramfs, hfs, hpfs, adfs - Sepp Wijnands <mrrazz@xxxxxxxxxxxxxxxxxx> - Added ext3 - Andrew Morton - Added jfs - Christoph Hellwig - Added sysv - Tim Launchbury - Added udf - Bryce Nesbitt - Added gfs/gfs2, btrfs - Eric Sandeen -*/ - -/* - * 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; - - for (m = udf_magic; m - udf_magic < SIZE(udf_magic); m++) - if (!strncmp(*m, id, 5)) - return 1; - 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 || - strncmp(s-10, "SWAPSPACE2", 10) == 0); -} - -/* rather weak necessary condition */ -static int -may_be_adfs(const struct adfs_super_block *sb) { - char *p; - int sum; - - p = (char *)sb->s_checksum; - sum = 0; - while(--p != (char *)sb) - sum = (sum >> 8) + (sum & 0xff) + *p; - - return (sum & 0xff) == sb->s_checksum[0]; -} - -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))); -} - -char * -fstype(const char *device) { - int fd; - char *type = NULL; - union { - struct minix_super_block ms; - struct ext_super_block es; - struct ext2_super_block e2s; - struct vxfs_super_block vs; - struct hfs_super_block hs; - } sb; /* stuff at 1024 */ - union { - struct xiafs_super_block xiasb; - char romfs_magic[8]; - char qnx4fs_magic[10]; /* ignore first 4 bytes */ - unsigned int bfs_magic; - struct ntfs_super_block ntfssb; - struct fat_super_block fatsb; - struct xfs_super_block xfsb; - struct cramfs_super_block cramfssb; - } xsb; - struct ufs_super_block ufssb; - union { - 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 hpfs_super_block hpfssb; - struct adfs_super_block adfssb; - struct sysv_super_block svsb; - struct gfs2_sb gfs2sb; - struct btrfs_super_block btrfssb; - struct stat statbuf; - - /* opening and reading an arbitrary unknown path can have - undesired side effects - first check that `device' refers - to a block device or ordinary file */ - if (stat (device, &statbuf) || - !(S_ISBLK(statbuf.st_mode) || S_ISREG(statbuf.st_mode))) - return NULL; - - fd = open(device, O_RDONLY); - if (fd < 0) - return NULL; - - /* do seeks and reads in disk order, otherwise a very short - partition may cause a failure because of read error */ - - if (!type) { - /* block 0 */ - if (lseek(fd, 0, SEEK_SET) != 0 - || read(fd, (char *) &xsb, sizeof(xsb)) != sizeof(xsb)) - goto try_iso9660; - /* Gyorgy Kovesdi: none of my photocds has a readable block 0 */ - - if (xiafsmagic(xsb.xiasb) == _XIAFS_SUPER_MAGIC) - type = "xiafs"; - else if(!strncmp(xsb.romfs_magic, "-rom1fs-", 8)) - type = "romfs"; - else if(!strncmp(xsb.xfsb.s_magic, XFS_SUPER_MAGIC, 4)) - type = "xfs"; - else if(!strncmp(xsb.qnx4fs_magic+4, "QNX4FS", 6)) - type = "qnx4"; - else if(xsb.bfs_magic == 0x1badface) - type = "bfs"; - else if(!strncmp(xsb.ntfssb.s_magic, NTFS_SUPER_MAGIC, - sizeof(xsb.ntfssb.s_magic))) - type = "ntfs"; - else if(cramfsmagic(xsb.cramfssb) == CRAMFS_SUPER_MAGIC || - cramfsmagic(xsb.cramfssb) == CRAMFS_SUPER_MAGIC_BE) - type = "cramfs"; - else if ((!strncmp(xsb.fatsb.s_os, "MSDOS", 5) || - !strncmp(xsb.fatsb.s_os, "MSWIN", 5) || - !strncmp(xsb.fatsb.s_os, "MTOOL", 5) || - !strncmp(xsb.fatsb.s_os, "mkdosfs", 7) || - !strncmp(xsb.fatsb.s_os, "kmkdosfs", 8) || - /* Michal Svec: created by fdformat, old msdos utility for - formatting large (1.7) floppy disks. */ - !strncmp(xsb.fatsb.s_os, "CH-FOR18", 8)) - && (!strncmp(xsb.fatsb.s_fs, "FAT12 ", 8) || - !strncmp(xsb.fatsb.s_fs, "FAT16 ", 8) || - !strncmp(xsb.fatsb.s_fs2, "FAT32 ", 8))) - type = "vfat"; /* only guessing - might as well be fat or umsdos */ - } - - 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 1 */ - if (lseek(fd, 1024, SEEK_SET) != 1024 || - read(fd, (char *) &sb, sizeof(sb)) != sizeof(sb)) - goto io_error; - - /* ext2 has magic in little-endian on disk, so "swapped" is - superfluous; however, there have existed strange byteswapped - PPC ext2 systems */ - if (ext2magic(sb.e2s) == EXT2_SUPER_MAGIC || - ext2magic(sb.e2s) == EXT2_PRE_02B_MAGIC || - ext2magic(sb.e2s) == swapped(EXT2_SUPER_MAGIC)) { - type = "ext2"; - - /* maybe even ext3? */ - if ((assemble4le(sb.e2s.s_feature_compat) - & EXT3_FEATURE_COMPAT_HAS_JOURNAL) && - assemble4le(sb.e2s.s_journal_inum) != 0) - type = "ext3"; /* "ext3,ext2" */ - } - - else if (minixmagic(sb.ms) == MINIX_SUPER_MAGIC || - minixmagic(sb.ms) == MINIX_SUPER_MAGIC2 || - minixmagic(sb.ms) == swapped(MINIX_SUPER_MAGIC2) || - minixmagic(sb.ms) == MINIX2_SUPER_MAGIC || - minixmagic(sb.ms) == MINIX2_SUPER_MAGIC2) - type = "minix"; - - else if (extmagic(sb.es) == EXT_SUPER_MAGIC) - type = "ext"; - - else if (vxfsmagic(sb.vs) == VXFS_SUPER_MAGIC) - type = "vxfs"; - - else if (hfsmagic(sb.hs) == swapped(HFS_SUPER_MAGIC) || - (hfsmagic(sb.hs) == swapped(HFSPLUS_SUPER_MAGIC) && - hfsversion(sb.hs) == swapped(HFSPLUS_SUPER_VERSION))) - type = "hfs"; - } - - if (!type) { - /* block 3 */ - if (lseek(fd, 0xc00, SEEK_SET) != 0xc00 - || read(fd, (char *) &adfssb, sizeof(adfssb)) != sizeof(adfssb)) - goto io_error; - - /* only a weak test */ - if (may_be_adfs(&adfssb) - && (adfsblksize(adfssb) >= 8 && - adfsblksize(adfssb) <= 10)) - type = "adfs"; - } - - if (!type) { - int mag; - - /* block 8 */ - if (lseek(fd, 8192, SEEK_SET) != 8192 - || read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb)) - goto io_error; - - mag = ufsmagic(ufssb); - if (mag == UFS_SUPER_MAGIC_LE || mag == UFS_SUPER_MAGIC_BE) - type = "ufs"; - } - - 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 8 */ - if (lseek(fd, 0x2000, SEEK_SET) != 0x2000 - || read(fd, (char *) &hpfssb, sizeof(hpfssb)) != sizeof(hpfssb)) - goto io_error; - - if (hpfsmagic(hpfssb) == HPFS_SUPER_MAGIC) - type = "hpfs"; - } - - 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) { - /* block 32 */ - try_iso9660: - if (lseek(fd, 0x8000, SEEK_SET) != 0x8000 - || read(fd, (char *) &isosb, sizeof(isosb)) != sizeof(isosb)) - goto io_error; - - 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) { - /* 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 64 */ - if (lseek(fd, GFS_SUPERBLOCK_OFFSET, SEEK_SET) != GFS_SUPERBLOCK_OFFSET - || read(fd, (char *) &gfs2sb, sizeof(gfs2sb)) != sizeof(gfs2sb)) - goto io_error; - if (gfsmagic(gfs2sb)) { - if (gfsformat(gfs2sb) == GFS_FORMAT_FS && - gfsmultiformat(gfs2sb) == GFS_FORMAT_MULTI) - type = "gfs"; - else if (gfsformat(gfs2sb) == GFS2_FORMAT_FS && - gfsmultiformat(gfs2sb) == GFS2_FORMAT_MULTI) - type = "gfs2"; - } - } - - if (!type) { - /* block 64 */ - if (lseek(fd, BTRFS_SUPER_INFO_OFFSET, SEEK_SET) != BTRFS_SUPER_INFO_OFFSET - || read(fd, (char *) &btrfssb, sizeof(btrfssb)) != sizeof(btrfssb)) - goto io_error; - if (!strncmp((char *)(btrfssb.magic), BTRFS_MAGIC, - sizeof(btrfssb.magic))) { - type = "btrfs"; - } - } - - if (!type) { - /* perhaps the user tries to mount the swap space - on a new disk; warn her before she does mkfs on it */ - int pagesize = getpagesize(); - int rd; - char buf[128 * 1024]; /* 64k is current max pagesize */ - - if (pagesize > sizeof(buf)) - abort(); - - rd = pagesize; - if (rd < 8192) - rd = 8192; - if (rd > sizeof(buf)) - rd = sizeof(buf); - if (lseek(fd, 0, SEEK_SET) != 0 - || read(fd, buf, rd) != rd) - goto io_error; - if (may_be_swap(buf+pagesize) || - may_be_swap(buf+4096) || may_be_swap(buf+8192)) - type = "swap"; - } - - close (fd); - return(type); - -io_error: - close(fd); - return NULL; -} diff --git a/libdisk/fstype.h b/libdisk/fstype.h deleted file mode 100644 index c0abbab..0000000 --- a/libdisk/fstype.h +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#undef XFS_SUPER_MAGIC - -/* - * From mount(8) source by Andries Brouwer. Hacked for XFS by mkp. - * Recent sync's to mount source: - * - util-linux-2.10o ... 06 Sep 00 - * - util-linux-2.10r ... 06 Dec 00 - * - util-linux-2.11g ... 02 Jul 01 - * - util-linux-2.11u ... 24 Aug 02 - * - util-linux-2.11z ... 13 May 03 - */ - -/* Including <linux/fs.h> became more and more painful. - Below a very abbreviated version of some declarations, - only designed to be able to check a magic number - in case no filesystem type was given. */ - -#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 { - char s_dummy[16]; - char s_magic[2]; -}; -#define minixmagic(s) assemble2le(s.s_magic) - -#define ISODCL(from, to) (to - from + 1) -#define ISO_STANDARD_ID "CD001" -struct iso_volume_descriptor { - char type[ISODCL(1,1)]; /* 711 */ - char id[ISODCL(2,6)]; - char version[ISODCL(7,7)]; - char data[ISODCL(8,2048)]; -}; - -#define HS_STANDARD_ID "CDROM" -struct hs_volume_descriptor { - char foo[ISODCL ( 1, 8)]; /* 733 */ - char type[ISODCL ( 9, 9)]; /* 711 */ - char id[ISODCL ( 10, 14)]; - char version[ISODCL ( 15, 15)]; /* 711 */ - char data[ISODCL(16,2048)]; -}; - -#define EXT_SUPER_MAGIC 0x137D -struct ext_super_block { - char s_dummy[56]; - char s_magic[2]; -}; -#define extmagic(s) assemble2le(s.s_magic) - -#define EXT2_PRE_02B_MAGIC 0xEF51 -#define EXT2_SUPER_MAGIC 0xEF53 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 -struct ext2_super_block { - char s_dummy1[56]; - char s_magic[2]; - char s_dummy2[34]; - char s_feature_compat[4]; - char s_feature_incompat[4]; - char s_feature_ro_compat[4]; - char s_uuid[16]; - char s_volume_name[16]; - char s_dummy3[88]; - char s_journal_inum[4]; /* ext3 only */ -}; -#define ext2magic(s) assemble2le(s.s_magic) - -struct reiserfs_super_block -{ - char s_block_count[4]; - char s_free_blocks[4]; - char s_root_block[4]; - char s_journal_block[4]; - char s_journal_dev[4]; - char s_orig_journal_size[4]; - char s_journal_trans_max[4]; - char s_journal_block_count[4]; - char s_journal_max_batch[4]; - char s_journal_max_commit_age[4]; - char s_journal_max_trans_age[4]; - char s_blocksize[2]; - char s_oid_maxsize[2]; - char s_oid_cursize[2]; - char s_state[2]; - 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 { - char s_boot_segment[512]; /* 1st sector reserved for boot */ - char s_dummy[60]; - char s_magic[4]; -}; -#define xiafsmagic(s) assemble4le(s.s_magic) - -/* From jj@xxxxxxxxxxxxxxxxxxxxxx Mon Mar 23 15:19:05 1998 */ -#define UFS_SUPER_MAGIC_LE 0x00011954 -#define UFS_SUPER_MAGIC_BE 0x54190100 -struct ufs_super_block { - char s_dummy[0x55c]; - char s_magic[4]; -}; -#define ufsmagic(s) assemble4le(s.s_magic) - -/* From Richard.Russon@xxxxxxxxx Wed Feb 24 08:05:27 1999 */ -#define NTFS_SUPER_MAGIC "NTFS" -struct ntfs_super_block { - char s_dummy[3]; - char s_magic[4]; -}; - -/* From inspection of a few FAT filesystems - aeb */ -/* Unfortunately I find almost the same thing on an extended partition; - it looks like a primary has some directory entries where the extended - has a partition table: IO.SYS, MSDOS.SYS, WINBOOT.SYS */ -struct fat_super_block { - char s_dummy[3]; - char s_os[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */ - /* mtools-3.9.4 writes "MTOOL394" */ - char s_dummy2[32]; - char s_label[11]; /* for DOS? */ - char s_fs[8]; /* "FAT12 " or "FAT16 " or all zero */ - /* OS/2 BM has "FAT " here. */ - char s_dummy3[9]; - char s_label2[11]; /* for Windows? */ - char s_fs2[8]; /* garbage or "FAT32 " */ -}; - -#define XFS_SUPER_MAGIC "XFSB" -struct xfs_super_block { - char s_magic[4]; - char s_dummy[28]; - char s_uuid[16]; - char s_dummy2[60]; - char s_fname[12]; -}; - -#define CRAMFS_SUPER_MAGIC 0x28cd3d45 -#define CRAMFS_SUPER_MAGIC_BE 0x453dcd28 -struct cramfs_super_block { - char s_magic[4]; - char s_dummy[12]; - char s_id[16]; -}; -#define cramfsmagic(s) assemble4le(s.s_magic) - -#define HFS_SUPER_MAGIC 0x4244 -#define HFSPLUS_SUPER_MAGIC 0x482B -#define HFSPLUS_SUPER_VERSION 0x004 -struct hfs_super_block { - char s_magic[2]; - char s_version[2]; -}; -#define hfsmagic(s) assemble2le(s.s_magic) -#define hfsversion(s) assemble2le(s.s_version) - -#define HPFS_SUPER_MAGIC 0xf995e849 -struct hpfs_super_block { - char s_magic[4]; - char s_magic2[4]; -}; -#define hpfsmagic(s) assemble4le(s.s_magic) - -struct adfs_super_block { - char s_dummy[448]; - char s_blksize[1]; - char s_dummy2[62]; - char s_checksum[1]; -}; -#define adfsblksize(s) ((uint) s.s_blksize[0]) - -/* found in first 4 bytes of block 1 */ -struct vxfs_super_block { - char s_magic[4]; -}; -#define vxfsmagic(s) assemble4le(s.s_magic) -#define VXFS_SUPER_MAGIC 0xa501FCF5 - -struct jfs_super_block { - char s_magic[4]; - char s_version[4]; - char s_dummy1[93]; - char s_fpack[11]; - char s_dummy2[24]; - char s_uuid[16]; - char s_label[16]; -}; -#define JFS_SUPER1_OFF 0x8000 -#define JFS_MAGIC "JFS1" - -struct sysv_super_block { - char s_dummy1[504]; - char s_magic[4]; - char type[4]; -}; -#define sysvmagic(s) assemble4le(s.s_magic) -#define SYSV_SUPER_MAGIC 0xfd187e20 - -struct mdp_super_block { - char md_magic[4]; -}; -#define MD_SB_MAGIC 0xa92b4efc -#define mdsbmagic(s) assemble4le(s.md_magic) - -struct ocfs_volume_header { - char minor_version[4]; - char major_version[4]; - char signature[128]; -}; - -struct ocfs_volume_label { - char disk_lock[48]; - char label[64]; - char label_len[2]; -}; - -#define ocfslabellen(o) assemble2le(o.label_len) -#define OCFS_MAGIC "OracleCFS" - -/* Common gfs/gfs2 constants: */ -#define GFS_MAGIC 0x01161970 -#define GFS_DEFAULT_BSIZE 4096 -#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE) -#define GFS_LOCKNAME_LEN 64 - -/* gfs1 constants: */ -#define GFS_FORMAT_FS 1309 -#define GFS_FORMAT_MULTI 1401 -/* gfs2 constants: */ -#define GFS2_FORMAT_FS 1801 -#define GFS2_FORMAT_MULTI 1900 - -struct gfs2_meta_header { - char mh_magic[4]; - char mh_type[4]; - char __pad0[8]; /* Was generation number in gfs1 */ - char mh_format[4]; - char __pad1[4]; /* Was incarnation number in gfs1 */ -}; - -struct gfs2_inum { - char no_formal_ino[8]; - char no_addr[8]; -}; - -struct gfs2_sb { - struct gfs2_meta_header sb_header; - - char sb_fs_format[4]; - char sb_multihost_format[4]; - char __pad0[4]; /* Was superblock flags in gfs1 */ - - char sb_bsize[4]; - char sb_bsize_shift[4]; - char __pad1[4]; /* Was journal segment size in gfs1 */ - - struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */ - struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */ - struct gfs2_inum sb_root_dir; - - char sb_lockproto[GFS_LOCKNAME_LEN]; - char sb_locktable[GFS_LOCKNAME_LEN]; - /* In gfs1, quota and license dinodes followed */ -}; - -#define gfsmagic(s) assemble4be(s.sb_header.mh_magic) -#define gfsformat(s) assemble4be(s.sb_fs_format) -#define gfsmultiformat(s) assemble4be(s.sb_multihost_format) - -/* btrfs constants */ -#define BTRFS_SUPER_INFO_OFFSET (64 * 1024) - -/* 32 bytes in various csum fields */ -#define BTRFS_CSUM_SIZE 32 - -#define BTRFS_FSID_SIZE 16 - -#define BTRFS_MAGIC "_BHRfS_M" - -/* - * the super block basically lists the main trees of the FS - * it currently lacks any block count etc etc - */ -struct btrfs_super_block { - char csum[BTRFS_CSUM_SIZE]; - /* the first 3 fields must match struct btrfs_header */ - char fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ - char bytenr[8]; /* this block number */ - char flags[8]; - - /* allowed to be different from the btrfs_header from here own down */ - char magic[8]; - /* more follows but this is all our libdisk cares about*/ -} __attribute__ ((__packed__)); - -static inline int -assemble2le(char *p) { - return (p[0] | (p[1] << 8)); -} - -static inline int -assemble4le(char *p) { - return (p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24)); -} - -static inline int -assemble4be(char *p) { - return (p[3] | (p[2] << 8) | (p[1] << 16) | (p[0] << 24)); -} diff --git a/libdisk/lvm.c b/libdisk/lvm.c deleted file mode 100644 index d8d7536..0000000 --- a/libdisk/lvm.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "drivers.h" - -#ifndef LVM_BLK_MAJOR -#define LVM_BLK_MAJOR 58 -#endif - -int -mnt_is_lvm_subvol( - dev_t dev) -{ - if (major(dev) == LVM_BLK_MAJOR) - return 1; - return get_driver_block_major("lvm", major(dev)); -} - -int -lvm_get_subvol_stripe( - char *dfile, - sv_type_t type, - int *sunit, - int *swidth, - int *sectalign, - struct stat64 *sb) -{ - int lvpipe[2], stripes = 0, stripesize = 0; - char *largv[3], buf[1024]; - FILE *stream; - char tmppath[MAXPATHLEN]; - - if (!mnt_is_lvm_subvol(sb->st_rdev)) - return 0; - - /* Quest for lvdisplay */ - if (!access("/usr/local/sbin/lvdisplay", R_OK|X_OK)) - largv[0] = "/usr/local/sbin/lvdisplay"; - else if (!access("/usr/sbin/lvdisplay", R_OK|X_OK)) - largv[0] = "/usr/sbin/lvdisplay"; - else if (!access("/sbin/lvdisplay", R_OK|X_OK)) - largv[0] = "/sbin/lvdisplay"; - else { - fprintf(stderr, - _("Warning - LVM device, but no lvdisplay(8) found\n")); - return 0; - } - - /* realpath gives an absolute pathname */ - largv[1] = realpath(dfile, tmppath); - largv[2] = NULL; - - /* Open pipe */ - if (pipe(lvpipe) < 0) { - fprintf(stderr, _("Could not open pipe\n")); - exit(1); - } - - /* Spawn lvdisplay */ - switch (fork()) { - case 0: - /* Plumbing */ - close(lvpipe[0]); - - if (lvpipe[1] != STDOUT_FILENO) - dup2(lvpipe[1], STDOUT_FILENO); - - execv(largv[0], largv); - - fprintf(stderr, _("Failed to execute %s\n"), largv[0]); - exit(1); - - case -1: - fprintf(stderr, _("Failed forking lvdisplay process\n")); - exit(1); - - default: - break; - } - - close(lvpipe[1]); - stream = fdopen(lvpipe[0], "r"); - - /* Scan stream for keywords */ - while (fgets(buf, 1023, stream) != NULL) { - - if (!strncmp(buf, "Stripes", 7)) - sscanf(buf, "Stripes %d", &stripes); - - if (!strncmp(buf, "Stripe size", 11)) - sscanf(buf, "Stripe size (KByte) %d", &stripesize); - } - - /* Update sizes */ - *sunit = stripesize << 1; - *swidth = (stripes * stripesize) << 1; - *sectalign = 0; - - fclose(stream); - - return 1; -} diff --git a/libdisk/md.c b/libdisk/md.c deleted file mode 100644 index 82b1cf1..0000000 --- a/libdisk/md.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "drivers.h" -#include "md.h" - -int -mnt_is_md_subvol( - dev_t dev, - enum md_type *type) -{ - *type = MD_TYPE_MD; - if (major(dev) == MD_MAJOR) - return 1; - if (get_driver_block_major("md", major(dev))) - return 1; - *type = MD_TYPE_MDP; - if (get_driver_block_major("mdp", major(dev))) - return 1; - return 0; -} - -int -md_get_subvol_stripe( - char *dfile, - sv_type_t type, - int *sunit, - int *swidth, - int *sectalign, - struct stat64 *sb) -{ - char *pc; - char *dfile2 = NULL; - enum md_type md_type; - - if (mnt_is_md_subvol(sb->st_rdev, &md_type)) { - struct md_array_info md; - int fd; - - if (md_type == MD_TYPE_MDP) { - pc = strrchr(dfile, 'd'); - if (pc) - pc = strchr(pc, 'p'); - if (!pc) { - fprintf(stderr, - _("Error getting MD array device from %s\n"), - dfile); - exit(1); - } - dfile2 = malloc(pc - dfile + 1); - if (dfile2 == NULL) { - fprintf(stderr, - _("Couldn't malloc device string\n")); - exit(1); - } - strncpy(dfile2, dfile, pc - dfile); - dfile2[pc - dfile + 1] = '\0'; - } - /* Open device */ - fd = open(dfile2 ? dfile2 : dfile, O_RDONLY); - if (fd == -1) { - free(dfile2); - return 0; - } - - /* Is this thing on... */ - if (ioctl(fd, GET_ARRAY_INFO, &md)) { - fprintf(stderr, - _("Error getting MD array info from %s\n"), - dfile2 ? dfile2 : dfile); - exit(1); - } - close(fd); - free(dfile2); - - /* - * Ignore levels we don't want aligned (e.g. linear) - * and deduct disk(s) from stripe width on RAID4/5/6 - */ - switch (md.level) { - case 6: - md.raid_disks--; - /* fallthrough */ - case 5: - case 4: - md.raid_disks--; - /* fallthrough */ - case 1: - case 0: - case 10: - break; - default: - return 0; - } - - /* Update sizes */ - *sunit = md.chunk_size >> 9; - *swidth = *sunit * md.raid_disks; - *sectalign = (md.level == 4 || md.level == 5 || md.level == 6); - - return 1; - } - return 0; -} diff --git a/libdisk/md.h b/libdisk/md.h deleted file mode 100644 index c3284e5..0000000 --- a/libdisk/md.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2002-2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MD_MAJOR -#define MD_MAJOR 9 /* we also check at runtime */ -#endif - -#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, struct md_array_info) - -#define MD_SB_CLEAN 0 -#define MD_SB_ERRORS 1 - -struct md_array_info { - /* - * Generic constant information - */ - __uint32_t major_version; - __uint32_t minor_version; - __uint32_t patch_version; - __uint32_t ctime; - __uint32_t level; - __uint32_t size; - __uint32_t nr_disks; - __uint32_t raid_disks; - __uint32_t md_minor; - __uint32_t not_persistent; - - /* - * Generic state information - */ - __uint32_t utime; /* 0 Superblock update time */ - __uint32_t state; /* 1 State bits (clean, ...) */ - __uint32_t active_disks; /* 2 Number of currently active disks */ - __uint32_t working_disks; /* 3 Number of working disks */ - __uint32_t failed_disks; /* 4 Number of failed disks */ - __uint32_t spare_disks; /* 5 Number of spare disks */ - - /* - * Personality information - */ - __uint32_t layout; /* 0 the array's physical layout */ - __uint32_t chunk_size; /* 1 chunk size in bytes */ - -}; - -/* - * MDP = partitionable RAID arrays - */ -enum md_type { - MD_TYPE_MD, - MD_TYPE_MDP -}; diff --git a/libdisk/pttype.c b/libdisk/pttype.c deleted file mode 100644 index 172073a..0000000 --- a/libdisk/pttype.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/types.h> -#include <netinet/in.h> -#include <disk/dvh.h> -#include "pttype.h" - -#define blksize 512 - -static u_int32_t -twos_complement_32bit_sum(u_int32_t *base, int size) -{ - int i; - u_int32_t sum = 0; - - size = size / sizeof(u_int32_t); - for (i = 0; i < size; i++) - sum = sum - ntohl(base[i]); - return sum; -} - -static int -sgi_parttable(char *base) -{ - u_int32_t csum; - struct volume_header *vh = (struct volume_header *)base; - - if (ntohl(vh->vh_magic) != VHMAGIC) - return 0; - csum = twos_complement_32bit_sum((u_int32_t *)vh, - sizeof(struct volume_header)); - return !csum; -} - -static int -dos_parttable(char *base) -{ - return (base[510] == 0x55 && base[511] == 0xaa); -} - -static int -aix_parttable(char *base) -{ - return (aixlabel(base)->magic == AIX_LABEL_MAGIC || - aixlabel(base)->magic == AIX_LABEL_MAGIC_SWAPPED); -} - -static int -sun_parttable(char *base) -{ - unsigned short *ush; - int csum = 0; - - if (sunlabel(base)->magic != SUN_LABEL_MAGIC && - sunlabel(base)->magic != SUN_LABEL_MAGIC_SWAPPED) - return csum; - ush = ((unsigned short *) (sunlabel(base) + 1)) - 1; - while (ush >= (unsigned short *)sunlabel(base)) - csum ^= *ush--; - return !csum; -} - -static int -mac_parttable(char *base) -{ - return (ntohs(maclabel(base)->magic) == MAC_LABEL_MAGIC || - ntohs(maclabel(base)->magic) == MAC_PARTITION_MAGIC || - ntohs(maclabel(base)->magic) == MAC_OLD_PARTITION_MAGIC); -} - - -char * -pttype(char *device) -{ - int fd; - char *type = NULL; - char buf[blksize]; - - if ((fd = open(device, O_RDONLY)) < 0) - ; - else if (read(fd, buf, blksize) != blksize) - ; - else { - if (sgi_parttable(buf)) - type = "SGI"; - else if (sun_parttable(buf)) - type = "Sun"; - else if (aix_parttable(buf)) - type = "AIX"; - else if (dos_parttable(buf)) - type = "DOS"; - else if (mac_parttable(buf)) - type = "Mac"; - } - - if (fd >= 0) - close(fd); - return type; -} diff --git a/libdisk/pttype.h b/libdisk/pttype.h deleted file mode 100644 index 4f35c47..0000000 --- a/libdisk/pttype.h +++ /dev/null @@ -1,50 +0,0 @@ -typedef struct { - unsigned char info[128]; /* Informative text string */ - unsigned char spare0[14]; - struct sun_info { - unsigned char spare1; - unsigned char id; - unsigned char spare2; - unsigned char flags; - } infos[8]; - unsigned char spare1[246]; /* Boot information etc. */ - unsigned short rspeed; /* Disk rotational speed */ - unsigned short pcylcount; /* Physical cylinder count */ - unsigned short sparecyl; /* extra sects per cylinder */ - unsigned char spare2[4]; /* More magic... */ - unsigned short ilfact; /* Interleave factor */ - unsigned short ncyl; /* Data cylinder count */ - unsigned short nacyl; /* Alt. cylinder count */ - unsigned short ntrks; /* Tracks per cylinder */ - unsigned short nsect; /* Sectors per track */ - unsigned char spare3[4]; /* Even more magic... */ - struct sun_partition { - u_int32_t start_cylinder; - u_int32_t num_sectors; - } partitions[8]; - unsigned short magic; /* Magic number */ - unsigned short csum; /* Label xor'd checksum */ -} sun_partition; - -#define SUN_LABEL_MAGIC 0xDABE -#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA -#define sunlabel(x) ((sun_partition *)x) - -typedef struct { - unsigned int magic; /* expect AIX_LABEL_MAGIC */ - /* ... */ -} aix_partition; - -#define AIX_LABEL_MAGIC 0xc9c2d4c1 -#define AIX_LABEL_MAGIC_SWAPPED 0xc1d4c2c9 -#define aixlabel(x) ((aix_partition *)x) - -typedef struct { - unsigned short magic; - /* ... */ -} mac_partition; - -#define MAC_LABEL_MAGIC 0x4552 -#define MAC_PARTITION_MAGIC 0x504d -#define MAC_OLD_PARTITION_MAGIC 0x5453 -#define maclabel(x) ((mac_partition *)x) diff --git a/libdisk/xvm.c b/libdisk/xvm.c deleted file mode 100644 index 79dff21..0000000 --- a/libdisk/xvm.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <fcntl.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <disk/volume.h> -#include "xvm.h" - -int -mnt_is_xvm_subvol( - dev_t dev) -{ - return get_driver_block_major("xvm", major(dev)); -} - -/* - * If the logical device is a xvm striped volume, then it returns the - * stripe unit and stripe width information. - * Input parameters: the logical volume - * the subvolume type - (SVTYPE_RT or - * SVTYPE_DATA) - * Output parameters: the stripe unit and width in 512 byte blocks - * true/false - was this device an XVM volume? - */ -int -xvm_get_subvol_stripe( - char *dev, - sv_type_t type, - int *sunit, - int *swidth, - int *sectalign, - struct stat64 *sb) -{ - int fd; - xvm_getdev_t getdev; - xvm_subvol_stripe_t subvol_stripe; - - if (!mnt_is_xvm_subvol(sb->st_rdev)) - return 0; - - /* - * This will actually open the data subvolume. - */ - if ((fd = open(dev, O_RDONLY)) < 0) - return 0; - - /* - * Go and get the the information for the correct - * subvolume. - */ - if (ioctl(fd, DIOCGETVOLDEV, &getdev) < 0) { - close(fd); - return 0; - } - if ( (type == SVTYPE_RT) && (getdev.rt_subvol_dev) ) - subvol_stripe.dev = getdev.rt_subvol_dev; - else if ( (type == SVTYPE_DATA) && (getdev.data_subvol_dev) ) - subvol_stripe.dev = getdev.data_subvol_dev; - else { - close(fd); - return 0; - } - - if (ioctl(fd, DIOCGETVOLSTRIPE, &subvol_stripe) < 0) { - close(fd); - return 0; - } - - *sunit = subvol_stripe.unit_size; - *swidth = *sunit * subvol_stripe.width_size; - *sectalign = 0; - close(fd); - return 1; -} diff --git a/libdisk/xvm.h b/libdisk/xvm.h deleted file mode 100644 index 307e77b..0000000 --- a/libdisk/xvm.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define _DIOC_(x) (('d'<<8) | x) -#define DIOCGETVOLDEV _DIOC_(36) /* subvolume devices */ -#define DIOCGETVOLSTRIPE _DIOC_(47) /* subvolume stripe info */ - -/* - * Structure returned by the DIOCGETVOLDEV ioctl to list the - * subvolume device nodes in a volume. These are external device - * numbers. - */ -#define XVM_GETDEV_VERS 1 - -typedef __uint32_t xvm_dev_t; - -typedef struct { - __uint32_t version; - xvm_dev_t data_subvol_dev; - - xvm_dev_t log_subvol_dev; - xvm_dev_t rt_subvol_dev; - - xvm_dev_t sp_subvol_dev; -} xvm_getdev_t; - -/* - * Structure returned by the DIOCGETVOLSTRIPE ioctl to describe - * the subvolume stripe units and width. - */ -#define XVM_SUBVOL_GEOMETRY_VERS 1 -typedef struct xvm_subvol_stripe_s { - __uint32_t version; - __uint32_t unit_size; /* in blocks */ - __uint32_t width_size; /* in blocks */ - __uint32_t pad1; /* padding */ - xvm_dev_t dev; -} xvm_subvol_stripe_t; diff --git a/m4/package_blkid.m4 b/m4/package_blkid.m4 index 44ca2cc..9510dce 100644 --- a/m4/package_blkid.m4 +++ b/m4/package_blkid.m4 @@ -4,17 +4,15 @@ AC_DEFUN([AC_HAVE_BLKID_TOPO], [ - enable_blkid="$1" - if test "$enable_blkid" = "yes"; then - AC_SEARCH_LIBS([blkid_probe_all], [blkid]) - AC_CHECK_FUNCS(blkid_probe_get_topology) - if test $ac_cv_func_blkid_probe_get_topology = yes; then - libblkid="-lblkid" - else - libblkd="" - enable_blkid="no" - AC_SUBST(enable_blkid) - fi + AC_SEARCH_LIBS([blkid_probe_all], [blkid]) + AC_CHECK_FUNCS(blkid_probe_get_topology) + if test $ac_cv_func_blkid_probe_get_topology = yes; then + libblkid="-lblkid" + else + echo + echo 'FATAL ERROR: could not find a valid BLKID header.' + echo 'Install the Block device ID development package.' + exit 1 fi AC_SUBST(libblkid) ]) diff --git a/mkfs/Makefile b/mkfs/Makefile index fd1f615..570ab07 100644 --- a/mkfs/Makefile +++ b/mkfs/Makefile @@ -6,38 +6,18 @@ TOPDIR = .. include $(TOPDIR)/include/builddefs LTCOMMAND = mkfs.xfs -FSTYP = fstyp HFILES = xfs_mkfs.h CFILES = maxtrres.c proto.c xfs_mkfs.c -ifeq ($(ENABLE_BLKID),yes) -LLDLIBS += $(LIBBLKID) -CFLAGS += -DENABLE_BLKID -else -LLDLIBS += $(LIBDISK) -LTDEPENDENCIES += $(LIBDISK) -endif - -LLDLIBS += $(LIBXFS) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) +LLDLIBS += $(LIBBLKID) $(LIBXFS) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) LTDEPENDENCIES += $(LIBXFS) LLDFLAGS = -static-libtool-libs -LSRCFILES = $(FSTYP).c -LDIRT = $(FSTYP) - default: depend $(LTCOMMAND) -ifneq ($(ENABLE_BLKID),yes) -default: $(FSTYP) -endif - include $(BUILDRULES) -$(FSTYP): - @echo " [CC] $@" - $(Q)$(LTLINK) $@.c -o $@ $(CFLAGS) $(LDFLAGS) $(LIBDISK) $(PLDLIBS) - install: default $(INSTALL) -m 755 -d $(PKG_ROOT_SBIN_DIR) $(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_ROOT_SBIN_DIR) diff --git a/mkfs/fstyp.c b/mkfs/fstyp.c deleted file mode 100644 index 7410516..0000000 --- a/mkfs/fstyp.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * 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. - * - * This program is distributed in the hope that it would 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 the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "xfs/libxfs.h" -#include <disk/fstyp.h> - -/* - * fstyp allows the user to determine the filesystem identifier of - * mounted or unmounted filesystems using heuristics. - * - * The filesystem type is required by mount(2) and sometimes by mount(8) - * to mount filesystems of different types. fstyp uses exactly the same - * heuristics that mount does to determine whether the supplied device - * special file is of a known filesystem type. If it is, fstyp prints - * on standard output the usual filesystem identifier for that type and - * exits with a zero return code. If no filesystem is identified, fstyp - * prints "Unknown" to indicate failure and exits with a non-zero status. - * - * WARNING: The use of heuristics implies that the result of fstyp is not - * guaranteed to be accurate. - */ - -int -main(int argc, char *argv[]) -{ - char *type; - - if (argc != 2) { - fprintf(stderr, "Usage: %s <device>\n", basename(argv[0])); - exit(1); - } - - if (access(argv[1], R_OK) < 0) { - perror(argv[1]); - exit(1); - } - - if ((type = fstype(argv[1])) == NULL) { - printf("Unknown\n"); - exit(1); - } - printf("%s\n", type); - exit(0); -} diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 11e9f4b..cf75a02 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -18,12 +18,7 @@ #include "xfs/libxfs.h" #include <ctype.h> -#ifdef ENABLE_BLKID #include <blkid/blkid.h> -#else -#include <disk/fstyp.h> -#include <disk/volume.h> -#endif #include "xfs_mkfs.h" /* @@ -35,7 +30,6 @@ struct fs_topology { int rtswidth; /* stripe width - rt subvolume */ int lsectorsize; /* logical sector size &*/ int psectorsize; /* physical sector size */ - int sectoralign; }; /* @@ -297,7 +291,6 @@ calc_stripe_factors( } } -#ifdef ENABLE_BLKID /* * Check for existing filesystem or partition table on device. * Returns: @@ -502,85 +495,6 @@ static void get_topology( &lsectorsize, &psectorsize, force_overwrite); } } -#else /* ENABLE_BLKID */ -static int -check_overwrite( - char *device) -{ - char *type; - - if (device && *device) { - if ((type = fstype(device)) != NULL) { - fprintf(stderr, - _("%s: %s appears to contain an existing " - "filesystem (%s).\n"), progname, device, type); - return 1; - } - if ((type = pttype(device)) != NULL) { - fprintf(stderr, - _("%s: %s appears to contain a partition " - "table (%s).\n"), progname, device, type); - return 1; - } - } - return 0; -} - -static void get_topology( - libxfs_init_t *xi, - struct fs_topology *ft, - int force_overwrite) -{ - struct stat statbuf; - char *dfile = xi->volname ? xi->volname : xi->dname; - int bsz = BBSIZE; - - /* - * If our target is a regular file, use platform_findsizes - * to try to obtain the underlying filesystem's requirements - * for direct IO; we'll set our sector size to that if possible. - */ - if (xi->disfile || - (!stat(dfile, &statbuf) && S_ISREG(statbuf.st_mode))) { - int fd; - int flags = O_RDONLY; - long long dummy; - - /* with xi->disfile we may not have the file yet! */ - if (xi->disfile) - flags |= O_CREAT; - - fd = open(dfile, flags, 0666); - /* If this fails we just fall back to BBSIZE */ - if (fd >= 0) { - platform_findsizes(dfile, fd, &dummy, &bsz); - close(fd); - } - } else { - int fd; - long long dummy; - - get_subvol_stripe_wrapper(dfile, SVTYPE_DATA, - &ft->dsunit, &ft->dswidth, &ft->sectoralign); - fd = open(dfile, O_RDONLY); - /* If this fails we just fall back to BBSIZE */ - if (fd >= 0) { - platform_findsizes(dfile, fd, &dummy, &bsz); - close(fd); - } - } - - ft->lsectorsize = bsz; - ft->psectorsize = bsz; - - if (xi->rtname && !xi->risfile) { - int dummy1; - - get_subvol_stripe_wrapper(dfile, SVTYPE_RT, &dummy1, - &ft->rtswidth, &dummy1); - } -} -#endif /* ENABLE_BLKID */ static void fixup_log_stripe_unit( @@ -1804,17 +1718,7 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"), memset(&ft, 0, sizeof(ft)); get_topology(&xi, &ft, force_overwrite); - if (ft.sectoralign) { - /* - * Older Linux software RAID versions want the sector size - * to match the block size to avoid switching I/O sizes. - * For the legacy libdisk case we thus set the sector size to - * match the block size. For systems using libblkid we assume - * that the kernel is recent enough to not require this and - * ft.sectoralign will never be set. - */ - sectorsize = blocksize; - } else if (!ssflag) { + if (!ssflag) { /* * Unless specified manually on the command line use the * advertised sector size of the device. We use the physical @@ -1842,7 +1746,7 @@ _("switching to logical sector size %d\n"), } } - if (ft.sectoralign || !ssflag) { + if (!ssflag) { sectorlog = libxfs_highbit32(sectorsize); if (loginternal) { lsectorsize = sectorsize; diff --git a/po/de.po b/po/de.po index 7933636..fc62525 100644 --- a/po/de.po +++ b/po/de.po @@ -5706,57 +5706,6 @@ msgstr "[-cpv]" msgid "print or check parent inodes" msgstr "Eltern-Inodes ausgeben oder prüfen" -#: .././libdisk/lvm.c:60 -#, c-format -msgid "Warning - LVM device, but no lvdisplay(8) found\n" -msgstr "Warnung: LVM-Gerät, aber es wurde kein lvdisplay(8) gefunden\n" - -#: .././libdisk/lvm.c:70 .././libdisk/dm.c:73 -#, c-format -msgid "Could not open pipe\n" -msgstr "Weiterleitung kann nicht geöffnet werden\n" - -#: .././libdisk/lvm.c:85 .././libdisk/dm.c:88 -#, c-format -msgid "Failed to execute %s\n" -msgstr "Ausführen von %s fehlgeschlagen\n" - -#: .././libdisk/lvm.c:89 -#, c-format -msgid "Failed forking lvdisplay process\n" -msgstr "Erstellen des »lvdisplay«-Unterprozesses fehlgeschlagen\n" - -#: .././libdisk/drivers.c:35 -#, c-format -msgid "Cannot stat %s: %s\n" -msgstr "Kann Status für »%s« nicht abfragen:%s\n" - -#: .././libdisk/md.c:61 -#, c-format -msgid "Error getting MD array device from %s\n" -msgstr "Fehler beim Ermitteln des MD-Array-Geräts von %s\n" - -#: .././libdisk/md.c:68 -#, c-format -msgid "Couldn't malloc device string\n" -msgstr "malloc von Gerätzeichenkette konnte nicht durchgeführt werden\n" - -#: .././libdisk/md.c:84 -#, c-format -msgid "Error getting MD array info from %s\n" -msgstr "Fehler beim Ermitteln der MD-Array-Informationen von %s\n" - -#: .././libdisk/dm.c:57 -#, c-format -msgid "Warning - device mapper device, but no dmsetup(8) found\n" -msgstr "" -"Warnung: »device mapper«-Gerät, aber es wurde kein dmsetup(8) gefunden\n" - -#: .././libdisk/dm.c:92 -#, c-format -msgid "Failed forking dmsetup process\n" -msgstr "Erstellen des »dmsetup«-Unterprozesses fehlgeschlagen\n" - #: .././libxcmd/command.c:85 #, c-format msgid "bad argument count %d to %s, expected at least %d arguments\n" diff --git a/po/pl.po b/po/pl.po index 02d8c22..a950f77 100644 --- a/po/pl.po +++ b/po/pl.po @@ -5606,55 +5606,6 @@ msgstr "offset" msgid "truncates the current file at the given offset" msgstr "ucięcie bieżącego pliku na podanym offsecie" -#: .././libdisk/dm.c:57 -#, c-format -msgid "Warning - device mapper device, but no dmsetup(8) found\n" -msgstr "Uwaga - urządzenie device mappera, ale nie znaleziono dmsetup(8)\n" - -#: .././libdisk/dm.c:73 .././libdisk/lvm.c:70 -#, c-format -msgid "Could not open pipe\n" -msgstr "Nie udało się otworzyć potoku\n" - -#: .././libdisk/dm.c:88 .././libdisk/lvm.c:85 -#, c-format -msgid "Failed to execute %s\n" -msgstr "Nie udało się wywołać %s\n" - -#: .././libdisk/dm.c:92 -#, c-format -msgid "Failed forking dmsetup process\n" -msgstr "Nie udało się odgałęzić procesu dmsetup\n" - -#: .././libdisk/drivers.c:35 -#, c-format -msgid "Cannot stat %s: %s\n" -msgstr "Nie można wykonać stat na %s: %s\n" - -#: .././libdisk/lvm.c:60 -#, c-format -msgid "Warning - LVM device, but no lvdisplay(8) found\n" -msgstr "Uwaga - urządzenie LVM, ale nie znaleziono lvdisplay(8)\n" - -#: .././libdisk/lvm.c:89 -#, c-format -msgid "Failed forking lvdisplay process\n" -msgstr "Nie udało się odgałęzić procesu lvdisplay\n" - -#: .././libdisk/md.c:61 -#, c-format -msgid "Error getting MD array device from %s\n" -msgstr "Błąd podczas pobierania urządzenia macierzy MD z %s\n" - -#: .././libdisk/md.c:68 -#, c-format -msgid "Couldn't malloc device string\n" -msgstr "Nie można przydzielić łańcucha nazwy urządzenia\n" - -#: .././libdisk/md.c:84 -#, c-format -msgid "Error getting MD array info from %s\n" -msgstr "Błąd podczas pobierania informacji o macierzy MD z %s\n" #: .././libxcmd/command.c:85 #, c-format -- 2.4.5 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs