]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Minor update - include less kernel headers, abstract some Linux/IRIX diffs
authorNathan Scott <nathans@sgi.com>
Wed, 13 Nov 2002 06:59:25 +0000 (06:59 +0000)
committerNathan Scott <nathans@sgi.com>
Wed, 13 Nov 2002 06:59:25 +0000 (06:59 +0000)
in growfs to more easily keep track of changes there.
Add in explore source file targets.

growfs/Makefile
growfs/explore.c [new file with mode: 0644]
growfs/explore.h [new file with mode: 0644]
growfs/xfs_growfs.c
include/xfs_fs.h
include/xfs_types.h
include/xqm.h
libxfs/xfs.h

index aa82b4d363f01fe257c8a886d9d38129a440b4a2..7bae9bf9c135dc7790b82d69580f58365bbb4d64 100644 (file)
@@ -35,7 +35,9 @@ include $(TOPDIR)/include/builddefs
 
 LTCOMMAND = xfs_growfs
 
-CFILES = xfs_growfs.c
+CFILES = explore.c xfs_growfs.c
+HFILES = explore.h
+
 LLDLIBS = $(LIBXFS) $(LIBUUID)
 LTDEPENDENCIES = $(LIBXFS)
 LLDFLAGS = -static
diff --git a/growfs/explore.c b/growfs/explore.c
new file mode 100644 (file)
index 0000000..27c184e
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 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.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA  94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+
+#include <libxfs.h>
+#include <mntent.h>
+
+extern char    *fname;         /* mount point name */
+extern char    *datadev;       /* data device name */
+extern char    *logdev;        /*  log device name */
+extern char    *rtdev;         /*   RT device name */
+
+void
+explore_mtab(char *mtab, char *mntpoint)
+{
+       struct mntent   *mnt;
+       struct stat64   statuser;
+       struct stat64   statmtab;
+       FILE            *mtp;
+       char            *rtend;
+       char            *logend;
+
+       if (!mtab)
+               mtab = MOUNTED;
+
+       if ((mtp = setmntent(mtab, "r")) == NULL) {
+               fprintf(stderr, "%s: cannot access mount list %s: %s\n",
+                       progname, MOUNTED, strerror(errno));
+               exit(1);
+       }
+       if (stat64(mntpoint, &statuser) < 0) {
+               fprintf(stderr, "%s: cannot access mount point %s: %s\n",
+                       progname, mntpoint, strerror(errno));
+               exit(1);
+       }
+
+       while ((mnt = getmntent(mtp)) != NULL) {
+               if (stat64(mnt->mnt_dir, &statmtab) < 0) {
+                       fprintf(stderr, "%s: ignoring entry %s in %s: %s\n",
+                               progname, mnt->mnt_dir, mtab, strerror(errno));
+                       continue;
+               }
+               if (statuser.st_ino != statmtab.st_ino ||
+                               statuser.st_dev != statmtab.st_dev)
+                       continue;
+               else if (strcmp(mnt->mnt_type, "xfs") != 0) {
+                       fprintf(stderr, "%s: %s is not an XFS filesystem\n",
+                               progname, mntpoint);
+                       exit(1);
+               }
+               break;  /* we've found it */
+       }
+
+       if (mnt == NULL) {
+               fprintf(stderr,
+               "%s: %s is not a filesystem mount point, according to %s\n",
+                       progname, mntpoint, MOUNTED);
+               exit(1);
+       }
+
+       /* find the data, log (logdev=), and realtime (rtdev=) devices */
+       rtend = logend = NULL;
+       fname = mnt->mnt_dir;
+       datadev = mnt->mnt_fsname;
+       if ((logdev = hasmntopt(mnt, "logdev="))) {
+               logdev += 7;
+               logend = strtok(logdev, " ,");
+       }
+       if ((rtdev = hasmntopt(mnt, "rtdev="))) {
+               rtdev += 6;
+               rtend = strtok(rtdev, " ,");
+       }
+
+       /* Do this only after we've finished processing mount options */
+       if (logdev && logend != logdev)
+               *logend = '\0'; /* terminate end of log device name */
+       if (rtdev && rtend != rtdev)
+               *rtend = '\0';  /* terminate end of rt device name */
+
+       endmntent(mtp);
+}
diff --git a/growfs/explore.h b/growfs/explore.h
new file mode 100644 (file)
index 0000000..8f2b480
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 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.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA  94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+#ifndef XFS_GROWFS_EXPLORE_H
+#define XFS_GROWFS_EXPLORE_H
+
+/*
+ * This was written as part of the Linux port.  On IRIX,
+ * the volume managers have knowledge of log and realtime
+ * subvolumes, and the equivalent functionality is built
+ * into the kernel - XFS/XLV/XVM talk amongst themselves
+ * and there are no rtdev/logdev mount parameters at all.
+ */
+#ifdef __linux__
+extern void explore_mtab(char *mtab, char *mntpoint);
+#else
+# define explore_mtab(mtab, mpoint)    do { } while (0)
+#endif
+
+#endif /* XFS_GROWFS_EXPLORE_H */
index ab883cd51a982ceb6f54028b25e84f6e3557e568..3ab380a32c1ea94daf9ddedb4ad44f10142117a1 100644 (file)
@@ -31,8 +31,8 @@
  */
 
 #include <libxfs.h>
-#include <mntent.h>
 #include <sys/ioctl.h>
+#include "explore.h"
 
 /*
  * When growing a filesystem, this is the most significant
 
 #define XFS_MAX_INODE_SIG_BITS 32
 
-static char    *fname;         /* mount point name */
-static char    *datadev;       /* data device name */
-static char    *logdev;        /*  log device name */
-static char    *rtdev;         /*   RT device name */
+char   *fname;         /* mount point name */
+char   *datadev;       /* data device name */
+char   *logdev;        /*  log device name */
+char   *rtdev;         /*   RT device name */
 
 static void
 usage(void)
@@ -99,73 +99,6 @@ report_info(
               (long long)geo.rtblocks, (long long)geo.rtextents);
 }
 
-void
-explore_mtab(char *mtab, char *mntpoint)
-{
-       struct mntent   *mnt;
-       struct stat64   statuser;
-       struct stat64   statmtab;
-       FILE            *mtp;
-       char            *rtend;
-       char            *logend;
-
-       if ((mtp = setmntent(mtab, "r")) == NULL) {
-               fprintf(stderr, "%s: cannot access mount list %s: %s\n",
-                       progname, MOUNTED, strerror(errno));
-               exit(1);
-       }
-       if (stat64(mntpoint, &statuser) < 0) {
-               fprintf(stderr, "%s: cannot access mount point %s: %s\n",
-                       progname, mntpoint, strerror(errno));
-               exit(1);
-       }
-
-       while ((mnt = getmntent(mtp)) != NULL) {
-               if (stat64(mnt->mnt_dir, &statmtab) < 0) {
-                       fprintf(stderr, "%s: ignoring entry %s in %s: %s\n",
-                               progname, mnt->mnt_dir, mtab, strerror(errno));
-                       continue;
-               }
-               if (statuser.st_ino != statmtab.st_ino ||
-                               statuser.st_dev != statmtab.st_dev)
-                       continue;
-               else if (strcmp(mnt->mnt_type, "xfs") != 0) {
-                       fprintf(stderr, "%s: %s is not an XFS filesystem\n",
-                               progname, mntpoint);
-                       exit(1);
-               }
-               break;  /* we've found it */
-       }
-
-       if (mnt == NULL) {
-               fprintf(stderr,
-               "%s: %s is not a filesystem mount point, according to %s\n",
-                       progname, mntpoint, MOUNTED);
-               exit(1);
-       }
-
-       /* find the data, log (logdev=), and realtime (rtdev=) devices */
-       rtend = logend = NULL;
-       fname = mnt->mnt_dir;
-       datadev = mnt->mnt_fsname;
-       if ((logdev = hasmntopt(mnt, "logdev="))) {
-               logdev += 7;
-               logend = strtok(logdev, " ,");
-       }
-       if ((rtdev = hasmntopt(mnt, "rtdev="))) {
-               rtdev += 6;
-               rtend = strtok(rtdev, " ,");
-       }
-
-       /* Do this only after we've finished processing mount options */
-       if (logdev && logend != logdev)
-               *logend = '\0'; /* terminate end of log device name */
-       if (rtdev && rtend != rtdev)
-               *rtend = '\0';  /* terminate end of rt device name */
-
-       endmntent(mtp);
-}
-
 int
 main(int argc, char **argv)
 {
@@ -197,15 +130,17 @@ main(int argc, char **argv)
        int                     xflag;  /* -x flag */
        libxfs_init_t           xi;     /* libxfs structure */
 
-       mtab = MOUNTED;
        progname = basename(argv[0]);
-       aflag = dflag = iflag = lflag = mflag = nflag = rflag = xflag = 0;
+
+       mtab = NULL;
        maxpct = esize = 0;
        dsize = lsize = rsize = 0LL;
+       aflag = dflag = iflag = lflag = mflag = nflag = rflag = xflag = 0;
+
        while ((c = getopt(argc, argv, "dD:e:ilL:m:np:rR:t:xV")) != EOF) {
                switch (c) {
                case 'D':
-                       dsize = atoll(optarg);
+                       dsize = strtoll(optarg, NULL, 10);
                        /* fall through */
                case 'd':
                        dflag = 1;
@@ -218,7 +153,7 @@ main(int argc, char **argv)
                        lflag = iflag = 1;
                        break;
                case 'L':
-                       lsize = atoll(optarg);
+                       lsize = strtoll(optarg, NULL, 10);
                        /* fall through */
                case 'l':
                        lflag = 1;
@@ -234,7 +169,7 @@ main(int argc, char **argv)
                        progname = optarg;
                        break;
                case 'R':
-                       rsize = atoll(optarg);
+                       rsize = strtoll(optarg, NULL, 10);
                        /* fall through */
                case 'r':
                        rflag = 1;
index 0311d1258076cf3b8a83fd70185d9b9ee1e5a66b..a50ee40bffc0ec1a384d4692db7cbba09366e064 100644 (file)
  *
  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  */
-#ifndef _LINUX_XFS_FS_H
-#define _LINUX_XFS_FS_H
-
-#include <linux/types.h>
-#include <asm/ioctl.h>
-
+#ifndef __XFS_FS_H__
+#define __XFS_FS_H__
 
 /*
  * SGI's XFS filesystem's major stuff (constants, structures)
@@ -394,11 +390,13 @@ typedef struct {
  * This is typically called by a stateless file server in order to generate
  * "file handles".
  */
+#ifndef MAXFIDSZ
 #define MAXFIDSZ       46
 typedef struct fid {
        __u16           fid_len;                /* length of data in bytes */
        unsigned char   fid_data[MAXFIDSZ];     /* data (variable length)  */
 } fid_t;
+#endif
 
 typedef struct xfs_fid {
        __u16   xfs_fid_len;            /* length of remainder  */
@@ -499,4 +497,4 @@ typedef struct xfs_handle {
 #define BTOBBT(bytes)  ((__u64)(bytes) >> BBSHIFT)
 #define BBTOB(bbs)     ((bbs) << BBSHIFT)
 
-#endif /* _LINUX_XFS_FS_H */
+#endif /* __XFS_FS_H__ */
index e08f8b727a65b1968be03216cf03006f62336cb9..d831799bf2e492e55b50c73838be9a93c5b611a6 100644 (file)
@@ -34,8 +34,6 @@
 
 #ifdef __KERNEL__
 
-#include <linux/types.h>
-
 /*
  * POSIX Extensions
  */
@@ -56,9 +54,6 @@ typedef unsigned int          __uint32_t;
 typedef signed long long int   __int64_t;
 typedef unsigned long long int __uint64_t;
 
-typedef enum { B_FALSE, B_TRUE } boolean_t;
-
-
 typedef __int64_t              prid_t;         /* project ID */
 typedef __uint32_t             inst_t;         /* an instruction */
 
@@ -68,11 +63,17 @@ typedef __s64                       xfs_daddr_t;    /* <disk address> type */
 typedef char *                 xfs_caddr_t;    /* <core address> type */
 typedef __u32                  xfs_dev_t;
 
-typedef struct timespec                timespec_t;
+typedef struct xfs_dirent {            /* data from readdir() */
+       xfs_ino_t       d_ino;          /* inode number of entry */
+       xfs_off_t       d_off;          /* offset of disk directory entry */
+       unsigned short  d_reclen;       /* length of this record */
+       char            d_name[1];      /* name of file */
+} xfs_dirent_t;
 
-typedef struct {
-       unsigned char   __u_bits[16];
-} uuid_t;
+#define DIRENTBASESIZE         (((xfs_dirent_t *)0)->d_name - (char *)0)
+#define DIRENTSIZE(namelen)    \
+       ((DIRENTBASESIZE + (namelen) + \
+               sizeof(xfs_off_t)) & ~(sizeof(xfs_off_t) - 1))
 
 /* __psint_t is the same size as a pointer */
 #if (BITS_PER_LONG == 32)
@@ -151,7 +152,7 @@ typedef __uint64_t  xfs_fileoff_t;  /* block number in a file */
 typedef __int64_t      xfs_sfiloff_t;  /* signed block number in a file */
 typedef __uint64_t     xfs_filblks_t;  /* number of blocks in a file */
 
-typedef __uint8_t      xfs_arch_t;     /* architecutre of an xfs fs */
+typedef __uint8_t      xfs_arch_t;     /* architecture of an xfs fs */
 
 /*
  * Null values for the types.
@@ -195,119 +196,6 @@ typedef enum {
 } xfs_btnum_t;
 
 
-#if defined(CONFIG_PROC_FS) && defined(__KERNEL__) && !defined(XFS_STATS_OFF)
-/*
- * XFS global statistics
- */
-struct xfsstats {
-# define XFSSTAT_END_EXTENT_ALLOC      4
-       __uint32_t              xs_allocx;
-       __uint32_t              xs_allocb;
-       __uint32_t              xs_freex;
-       __uint32_t              xs_freeb;
-# define XFSSTAT_END_ALLOC_BTREE       (XFSSTAT_END_EXTENT_ALLOC+4)
-       __uint32_t              xs_abt_lookup;
-       __uint32_t              xs_abt_compare;
-       __uint32_t              xs_abt_insrec;
-       __uint32_t              xs_abt_delrec;
-# define XFSSTAT_END_BLOCK_MAPPING     (XFSSTAT_END_ALLOC_BTREE+7)
-       __uint32_t              xs_blk_mapr;
-       __uint32_t              xs_blk_mapw;
-       __uint32_t              xs_blk_unmap;
-       __uint32_t              xs_add_exlist;
-       __uint32_t              xs_del_exlist;
-       __uint32_t              xs_look_exlist;
-       __uint32_t              xs_cmp_exlist;
-# define XFSSTAT_END_BLOCK_MAP_BTREE   (XFSSTAT_END_BLOCK_MAPPING+4)
-       __uint32_t              xs_bmbt_lookup;
-       __uint32_t              xs_bmbt_compare;
-       __uint32_t              xs_bmbt_insrec;
-       __uint32_t              xs_bmbt_delrec;
-# define XFSSTAT_END_DIRECTORY_OPS     (XFSSTAT_END_BLOCK_MAP_BTREE+4)
-       __uint32_t              xs_dir_lookup;
-       __uint32_t              xs_dir_create;
-       __uint32_t              xs_dir_remove;
-       __uint32_t              xs_dir_getdents;
-# define XFSSTAT_END_TRANSACTIONS      (XFSSTAT_END_DIRECTORY_OPS+3)
-       __uint32_t              xs_trans_sync;
-       __uint32_t              xs_trans_async;
-       __uint32_t              xs_trans_empty;
-# define XFSSTAT_END_INODE_OPS         (XFSSTAT_END_TRANSACTIONS+7)
-       __uint32_t              xs_ig_attempts;
-       __uint32_t              xs_ig_found;
-       __uint32_t              xs_ig_frecycle;
-       __uint32_t              xs_ig_missed;
-       __uint32_t              xs_ig_dup;
-       __uint32_t              xs_ig_reclaims;
-       __uint32_t              xs_ig_attrchg;
-# define XFSSTAT_END_LOG_OPS           (XFSSTAT_END_INODE_OPS+5)
-       __uint32_t              xs_log_writes;
-       __uint32_t              xs_log_blocks;
-       __uint32_t              xs_log_noiclogs;
-       __uint32_t              xs_log_force;
-       __uint32_t              xs_log_force_sleep;
-# define XFSSTAT_END_TAIL_PUSHING      (XFSSTAT_END_LOG_OPS+10)
-       __uint32_t              xs_try_logspace;
-       __uint32_t              xs_sleep_logspace;
-       __uint32_t              xs_push_ail;
-       __uint32_t              xs_push_ail_success;
-       __uint32_t              xs_push_ail_pushbuf;
-       __uint32_t              xs_push_ail_pinned;
-       __uint32_t              xs_push_ail_locked;
-       __uint32_t              xs_push_ail_flushing;
-       __uint32_t              xs_push_ail_restarts;
-       __uint32_t              xs_push_ail_flush;
-# define XFSSTAT_END_WRITE_CONVERT     (XFSSTAT_END_TAIL_PUSHING+2)
-       __uint32_t              xs_xstrat_quick;
-       __uint32_t              xs_xstrat_split;
-# define XFSSTAT_END_READ_WRITE_OPS    (XFSSTAT_END_WRITE_CONVERT+2)
-       __uint32_t              xs_write_calls;
-       __uint32_t              xs_read_calls;
-# define XFSSTAT_END_ATTRIBUTE_OPS     (XFSSTAT_END_READ_WRITE_OPS+4)
-       __uint32_t              xs_attr_get;
-       __uint32_t              xs_attr_set;
-       __uint32_t              xs_attr_remove;
-       __uint32_t              xs_attr_list;
-# define XFSSTAT_END_QUOTA_OPS         (XFSSTAT_END_ATTRIBUTE_OPS+8)
-       __uint32_t              xs_qm_dqreclaims;
-       __uint32_t              xs_qm_dqreclaim_misses;
-       __uint32_t              xs_qm_dquot_dups;
-       __uint32_t              xs_qm_dqcachemisses;
-       __uint32_t              xs_qm_dqcachehits;
-       __uint32_t              xs_qm_dqwants;
-       __uint32_t              xs_qm_dqshake_reclaims;
-       __uint32_t              xs_qm_dqinact_reclaims;
-# define XFSSTAT_END_INODE_CLUSTER     (XFSSTAT_END_QUOTA_OPS+3)
-       __uint32_t              xs_iflush_count;
-       __uint32_t              xs_icluster_flushcnt;
-       __uint32_t              xs_icluster_flushinode;
-# define XFSSTAT_END_VNODE_OPS         (XFSSTAT_END_INODE_CLUSTER+8)
-       __uint32_t              vn_active;      /* # vnodes not on free lists */
-       __uint32_t              vn_alloc;       /* # times vn_alloc called */
-       __uint32_t              vn_get;         /* # times vn_get called */
-       __uint32_t              vn_hold;        /* # times vn_hold called */
-       __uint32_t              vn_rele;        /* # times vn_rele called */
-       __uint32_t              vn_reclaim;     /* # times vn_reclaim called */
-       __uint32_t              vn_remove;      /* # times vn_remove called */
-       __uint32_t              vn_free;        /* # times vn_free called */
-/* Extra precision counters */
-       __uint64_t              xs_xstrat_bytes;
-       __uint64_t              xs_write_bytes;
-       __uint64_t              xs_read_bytes;
-};
-
-extern struct xfsstats xfsstats;
-
-# define XFS_STATS_INC(count)          ( (count)++ )
-# define XFS_STATS_DEC(count)          ( (count)-- )
-# define XFS_STATS_ADD(count, inc)     ( (count) += (inc) )
-#else  /* !CONFIG_PROC_FS */
-# define XFS_STATS_INC(count)
-# define XFS_STATS_DEC(count)
-# define XFS_STATS_ADD(count, inc)
-#endif /* !CONFIG_PROC_FS */
-
-
 /*
  * Juggle IRIX device numbers - still used in ondisk structures
  */
index 925769dc4e541e7f469bc55f51f27ff74170e007..63c25d6fb02aa999bcc71fae397491cd6d8f181c 100644 (file)
  *
  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  */
-#ifndef _LINUX_XQM_H
-#define _LINUX_XQM_H
+#ifndef __XQM_H__
+#define __XQM_H__
 
-#include <linux/types.h>
+#include <libxfs.h>
 
 /*
  * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
@@ -156,4 +156,4 @@ typedef struct fs_quota_stat {
        __u16           qs_iwarnlimit;  /* limit for num warnings */
 } fs_quota_stat_t;
 
-#endif /* _LINUX_XQM_H */
+#endif /* __XQM_H__ */
index 4794c912150b0a5b895e17d2b4953f79c03ef609..889a1de77f9bdcaff568b1c00fd5b709524771c5 100644 (file)
@@ -251,6 +251,9 @@ typedef struct { dev_t dev; } xfs_buftarg_t;
 #define TRACE_ALLOC(s,a)               ((void) 0)
 #define TRACE_MODAGF(a,b,c)            ((void) 0)
 #define XFS_FORCED_SHUTDOWN(mp)                0
+#define XFS_STATS_INC(count)           do { } while (0)
+#define XFS_STATS_DEC(count, x)                do { } while (0)
+#define XFS_STATS_ADD(count, x)                do { } while (0)
 #define XFS_MOUNT_WSYNC                        0       /* ignored in userspace */
 #define XFS_MOUNT_NOALIGN              0       /* ignored in userspace */
 #define XFS_MOUNT_32BITINODES          0x1     /* enforce in userspace */