# 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
repair: libxlog
-ifneq ($(ENABLE_BLKID), yes)
-mkfs: libdisk
-endif
-
ifeq ($(HAVE_BUILDDEFS), yes)
include $(BUILDRULES)
else
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]],,
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])
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); \
xfs_arch.h
PHFILES = darwin.h freebsd.h irix.h linux.h gnukfreebsd.h
-DKHFILES = volume.h fstyp.h dvh.h
LSRCFILES = $(shell echo $(PHFILES) | sed -e "s/$(PKG_PLATFORM).h//g")
LSRCFILES += platform_defs.h.in builddefs.in buildmacros buildrules install-sh
LSRCFILES += $(DKHFILES) $(LIBHFILES)
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@
ENABLE_GETTEXT = @enable_gettext@
ENABLE_EDITLINE = @enable_editline@
ENABLE_READLINE = @enable_readline@
-ENABLE_BLKID = @enable_blkid@
HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
+++ /dev/null
-/*
- * 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 __DVH_H__
-#define __DVH_H__
-
-/*
- * Format for volume header information
- *
- * The volume header is a block located at the beginning of all disk
- * media (sector 0). It contains information pertaining to physical
- * device parameters and logical partition information.
- *
- * The volume header is manipulated by disk formatters/verifiers,
- * partition builders (e.g. fx, dvhtool, and mkfs), and disk drivers.
- *
- * Previous versions of IRIX wrote a copy of the volume header is
- * located at sector 0 of each track of cylinder 0. These copies were
- * never used, and reduced the capacity of the volume header to hold large
- * files, so this practice was discontinued.
- * The volume header is constrained to be less than or equal to 512
- * bytes long. A particular copy is assumed valid if no drive errors
- * are detected, the magic number is correct, and the 32 bit 2's complement
- * of the volume header is correct. The checksum is calculated by initially
- * zeroing vh_csum, summing the entire structure and then storing the
- * 2's complement of the sum. Thus a checksum to verify the volume header
- * should be 0.
- *
- * The error summary table, bad sector replacement table, and boot blocks are
- * located by searching the volume directory within the volume header.
- *
- * Tables are sized simply by the integral number of table records that
- * will fit in the space indicated by the directory entry.
- *
- * The amount of space allocated to the volume header, replacement blocks,
- * and other tables is user defined when the device is formatted.
- */
-
-/*
- * device parameters are in the volume header to determine mapping
- * from logical block numbers to physical device addresses
- *
- * Linux doesn't care ...
- */
-struct device_parameters {
- unsigned char dp_skew; /* spiral addressing skew */
- unsigned char dp_gap1; /* words of 0 before header */
- unsigned char dp_gap2; /* words of 0 between hdr and data */
- unsigned char dp_spares_cyl; /* This is for drives (such as SCSI
- that support zone oriented sparing, where the zone is larger
- than one track. It gets subracteded from the cylinder size
- ( dp_trks0 * dp_sec) when doing partition size calculations */
- unsigned short dp_cyls; /* number of usable cylinders (i.e.,
- doesn't include cylinders reserved by the drive for badblocks,
- etc.). For drives with variable geometry, this number may be
- decreased so that:
- dp_cyls * ((dp_heads * dp_trks0) - dp_spares_cyl) <= actualcapacity
- This happens on SCSI drives such as the Wren IV and Toshiba 156
- Also see dp_cylshi below */
- unsigned short dp_shd0; /* starting head vol 0 */
- unsigned short dp_trks0; /* number of tracks / cylinder vol 0*/
- unsigned char dp_ctq_depth; /* Depth of CTQ queue */
- unsigned char dp_cylshi; /* high byte of 24 bits of cylinder count */
- unsigned short dp_unused; /* not used */
- unsigned short dp_secs; /* number of sectors/track */
- unsigned short dp_secbytes; /* length of sector in bytes */
- unsigned short dp_interleave; /* sector interleave */
- int dp_flags; /* controller characteristics */
- int dp_datarate; /* bytes/sec for kernel stats */
- int dp_nretries; /* max num retries on data error */
- int dp_mspw; /* ms per word to xfer, for iostat */
- unsigned short dp_xgap1; /* Gap 1 for xylogics controllers */
- unsigned short dp_xsync; /* sync delay for xylogics controllers */
- unsigned short dp_xrdly; /* read delay for xylogics controllers */
- unsigned short dp_xgap2; /* gap 2 for xylogics controllers */
- unsigned short dp_xrgate; /* read gate for xylogics controllers */
- unsigned short dp_xwcont; /* write continuation for xylogics */
-};
-
-/*
- * Device characterization flags
- * (dp_flags)
- */
-#define DP_SECTSLIP 0x00000001 /* sector slip to spare sector */
-#define DP_SECTFWD 0x00000002 /* forward to replacement sector */
-#define DP_TRKFWD 0x00000004 /* forward to replacement track */
-#define DP_MULTIVOL 0x00000008 /* multiple volumes per spindle */
-#define DP_IGNOREERRORS 0x00000010 /* transfer data regardless of errors */
-#define DP_RESEEK 0x00000020 /* recalibrate as last resort */
-#define DP_CTQ_EN 0x00000040 /* enable command tag queueing */
-
-/*
- * Boot blocks, bad sector tables, and the error summary table, are located
- * via the volume_directory.
- */
-#define VDNAMESIZE 8
-
-struct volume_directory {
- char vd_name[VDNAMESIZE]; /* name */
- int vd_lbn; /* logical block number */
- int vd_nbytes; /* file length in bytes */
-};
-
-/*
- * partition table describes logical device partitions
- * (device drivers examine this to determine mapping from logical units
- * to cylinder groups, device formatters/verifiers examine this to determine
- * location of replacement tracks/sectors, etc)
- *
- * NOTE: pt_firstlbn SHOULD BE CYLINDER ALIGNED
- */
-struct partition_table { /* one per logical partition */
- int pt_nblks; /* # of logical blks in partition */
- int pt_firstlbn; /* first lbn of partition */
- int pt_type; /* use of partition */
-};
-
-#define PTYPE_VOLHDR 0 /* partition is volume header */
-#define PTYPE_TRKREPL 1 /* partition is used for repl trks */
-#define PTYPE_SECREPL 2 /* partition is used for repl secs */
-#define PTYPE_RAW 3 /* partition is used for data */
-#define PTYPE_BSD42 4 /* partition is 4.2BSD file system */
-#define PTYPE_BSD 4 /* partition is 4.2BSD file system */
-#define PTYPE_SYSV 5 /* partition is SysV file system */
-#define PTYPE_VOLUME 6 /* partition is entire volume */
-#define PTYPE_EFS 7 /* partition is sgi EFS */
-#define PTYPE_LVOL 8 /* partition is part of a logical vol */
-#define PTYPE_RLVOL 9 /* part of a "raw" logical vol */
-#define PTYPE_XFS 10 /* partition is sgi XFS */
-#define PTYPE_XFSLOG 11 /* partition is sgi XFS log */
-#define PTYPE_XLV 12 /* partition is part of an XLV vol */
-#define PTYPE_XVM 13 /* partition is sgi XVM */
-#define NPTYPES 16
-
-#define VHMAGIC 0xbe5a941 /* randomly chosen value */
-#define NPARTAB 16 /* 16 unix partitions */
-#define NVDIR 15 /* max of 15 directory entries */
-#define BFNAMESIZE 16 /* max 16 chars in boot file name */
-
-/* Partition types for ARCS */
-#define NOT_USED 0 /* Not used */
-#define FAT_SHORT 1 /* FAT filesystem, 12-bit FAT entries */
-#define FAT_LONG 4 /* FAT filesystem, 16-bit FAT entries */
-#define EXTENDED 5 /* extended partition */
-#define HUGE 6 /* huge partition- MS/DOS 4.0 and later */
-
-/* Active flags for ARCS */
-#define BOOTABLE 0x00;
-#define NOT_BOOTABLE 0x80;
-
-struct volume_header {
- int vh_magic; /* identifies volume header */
- short vh_rootpt; /* root partition number */
- short vh_swappt; /* swap partition number */
- char vh_bootfile[BFNAMESIZE]; /* name of file to boot */
- struct device_parameters vh_dp; /* device parameters */
- struct volume_directory vh_vd[NVDIR]; /* other vol hdr contents */
- struct partition_table vh_pt[NPARTAB]; /* device partition layout */
- int vh_csum; /* volume header checksum */
- int vh_fill; /* fill out to 512 bytes */
-};
-
-#endif /* __DVH_H__ */
+++ /dev/null
-/*
- * 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__ */
+++ /dev/null
-/*
- * 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
- */
-#ifndef __VOLUME_H__
-#define __VOLUME_H__
-
-/*
- * Subvolume Types for all volume managers.
- *
- * There is a maximum of 255 subvolumes. 0 is reserved.
- * Note: SVTYPE_LOG, SVTYPE_DATA, SVTYPE_RT values matches XLV.
- * Do not change - Colin Ngam
- */
-typedef enum sv_type_e {
- SVTYPE_ALL =0, /* special: denotes all sv's */
- SVTYPE_LOG =1, /* XVM Log subvol type */
- SVTYPE_DATA, /* XVM Data subvol type */
- SVTYPE_RT, /* XVM Real Time subvol type */
- SVTYPE_SWAP, /* swap area */
- SVTYPE_RSVD5, /* reserved 5 */
- SVTYPE_RSVD6, /* reserved 6 */
- SVTYPE_RSVD7, /* reserved 7 */
- SVTYPE_RSVD8, /* reserved 8 */
- SVTYPE_RSVD9, /* reserved 9 */
- SVTYPE_RSVD10, /* reserved 10 */
- SVTYPE_RSVD11, /* reserved 11 */
- SVTYPE_RSVD12, /* reserved 12 */
- SVTYPE_RSVD13, /* reserved 13 */
- SVTYPE_RSVD14, /* reserved 14 */
- SVTYPE_RSVD15, /* reserved 15 */
- SVTYPE_USER1, /* First User Defined Subvol Type */
- SVTYPE_LAST =255
-} sv_type_t;
-
-extern void get_subvol_stripe_wrapper (char *, sv_type_t, int *, int *, int *);
-extern int get_driver_block_major (const char *, int);
-
-#endif /* __VOLUME_H__ */
+++ /dev/null
-#
-# 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
-
--include .ltdep
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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 "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
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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;
+++ /dev/null
-/*
- * 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@bogomips.ww.ubc.ca>; made into a function
- for mount(8) by Mike Grupenhoff <kashmir@umiacs.umd.edu>.
- Corrected the test for xiafs - aeb
- Read the superblock only once - aeb
- Added 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@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.
- Added xfs - 2000-03-21 Martin K. Petersen <mkp@linuxcare.com>
- Added cramfs, hfs, hpfs, adfs - Sepp Wijnands <mrrazz@garbage-coderz.net>
- Added ext3 - Andrew Morton
- Added jfs - Christoph Hellwig
- Added sysv - Tim Launchbury
- 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;
-}
+++ /dev/null
-/*
- * 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@sunsite.ms.mff.cuni.cz 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@ait.co.uk 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));
-}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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
-};
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-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)
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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;
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)
])
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)
+++ /dev/null
-/*
- * 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 "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);
-}
#include "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"
/*
int rtswidth; /* stripe width - rt subvolume */
int lsectorsize; /* logical sector size &*/
int psectorsize; /* physical sector size */
- int sectoralign;
};
/*
}
}
-#ifdef ENABLE_BLKID
/*
* Check for existing filesystem or partition table on device.
* Returns:
&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(
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
}
}
- if (ft.sectoralign || !ssflag) {
+ if (!ssflag) {
sectorlog = libxfs_highbit32(sectorsize);
if (loginternal) {
lsectorsize = sectorsize;
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"
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