]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Make imap available as an expert xfs_io command.
authorNathan Scott <nathans@sgi.com>
Wed, 9 Mar 2005 14:09:45 +0000 (14:09 +0000)
committerNathan Scott <nathans@sgi.com>
Wed, 9 Mar 2005 14:09:45 +0000 (14:09 +0000)
Merge of master-melb:xfs-cmds:21780a by kenmcd.

Makefile
imap/Makefile [deleted file]
include/irix.h
io/Makefile
io/imap.c [moved from imap/xfs_imap.c with 68% similarity]
io/init.c
io/io.h

index 72a1ddc84a9171df27dfd1c74eac979d143924ff..9cd405ec3ee19255d689471bcbdd3dcb57eedd2a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+# 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 version 2 of the GNU General Public License as
@@ -44,7 +44,7 @@ LDIRT = config.log .dep config.status config.cache confdefs.h conftest* \
        Logs/* built .census install.* install-dev.* *.gz
 
 SUBDIRS = include libxfs libxlog libhandle libdisk \
-       copy db fsck growfs io imap logprint mkfile mkfs repair rtcp \
+       copy db fsck growfs io logprint mkfile mkfs repair rtcp \
        m4 man doc po debian build
 
 default: $(CONFIGURE)
diff --git a/imap/Makefile b/imap/Makefile
deleted file mode 100644 (file)
index b000982..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of 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/
-#
-
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
-
-LTCOMMAND = xfs_imap
-CFILES = xfs_imap.c
-
-default: $(LTCOMMAND)
-
-include $(BUILDRULES)
-
-install:
-install-dev:
index dee62795380025ebda122d7b7495903719cb68d7..a263359e7dd2e304fd659505d083b6a5351bf47a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * 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 version 2 of the GNU General Public License as
@@ -118,8 +118,9 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg)
                return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, 0, arg);
        }
        switch (cmd) {
+               case SGI_FS_INUMBERS:
                case SGI_FS_BULKSTAT:
-                       return syssgi(SGI_FS_BULKSTAT, fd, 
+                       return syssgi(cmd, fd, 
                                        ((xfs_fsop_bulkreq_t*)arg)->lastip,
                                        ((xfs_fsop_bulkreq_t*)arg)->icount,
                                        ((xfs_fsop_bulkreq_t*)arg)->ubuffer,
@@ -206,7 +207,7 @@ static __inline__ char * strsep(char **s, const char *ct)
 #define XFS_IOC_FSGEOMETRY_V1          XFS_FS_GEOMETRY
 #define XFS_IOC_FSBULKSTAT             SGI_FS_BULKSTAT     
 #define XFS_IOC_FSBULKSTAT_SINGLE      SGI_FS_BULKSTAT_SINGLE
-#define XFS_IOC_FSINUMBERS             /* TODO */
+#define XFS_IOC_FSINUMBERS             SGI_FS_INUMBERS
 #define XFS_IOC_PATH_TO_FSHANDLE       /* TODO */
 #define XFS_IOC_PATH_TO_HANDLE         /* TODO */
 #define XFS_IOC_FD_TO_HANDLE           /* TODO */
index ff622e00352bf6f793289bed5ca52c95afc95763..f132273bdd55c1e2f31424a4a7dc50f4f5433c1f 100644 (file)
@@ -37,7 +37,7 @@ LTCOMMAND = xfs_io
 LSRCFILES = xfs_bmap.sh xfs_freeze.sh
 HFILES = command.h input.h init.h io.h
 CFILES = command.c input.c init.c help.c quit.c \
-       attr.c bmap.c file.c freeze.c fsync.c getrusage.c \
+       attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c \
        mmap.c open.c pread.c prealloc.c pwrite.c truncate.c
 
 ifeq ($(HAVE_FADVISE),yes)
similarity index 68%
rename from imap/xfs_imap.c
rename to io/imap.c
index 7e193bd863c66d88d448f44a3ed5b4244f27f129..839b0ce0ae8dab7f3203d9b64a574228d47285a0 100644 (file)
+++ b/io/imap.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2001-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 version 2 of the GNU General Public License as
  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  */
 
-/*
- * Inode map display utility for XFS.
- */
-
 #include <xfs/libxfs.h>
+#include "command.h"
+#include "input.h"
+#include "init.h"
+#include "io.h"
+
+#if defined(__sgi__)
+# define ino64p                ino64_t *
+#else
+# define ino64p                __u64 *
+#endif
 
-int main(int argc, char **argv)
+static cmdinfo_t imap_cmd;
+
+int
+imap_f(int argc, char **argv)
 {
        int             count;
        int             nent;
-       int             fd;
        int             i;
-       char            *name;
-       char            *progname;
        __s64           last = 0;
        xfs_inogrp_t    *t;
        xfs_fsop_bulkreq_t bulkreq;
 
-       progname = basename(argv[0]);
-       setlocale(LC_ALL, "");
-       bindtextdomain(PACKAGE, LOCALEDIR);
-       textdomain(PACKAGE);
-
-       if (argc < 2)
-               name = ".";
-       else
-               name = argv[1];
-       fd = open(name, O_RDONLY);
-       if (fd < 0) {
-               perror(name);
-               return 1;
-       }
-       if (!platform_test_xfs_fd(fd)) {
-               fprintf(stderr, _("%s: specified file "
-                       "[\"%s\"] is not on an XFS filesystem\n"),
-                       progname, name);
-               exit(1);
-       }
-
-       if (argc < 3)
+       if (argc != 2)
                nent = 1;
        else
-               nent = atoi(argv[2]);
+               nent = atoi(argv[1]);
 
        t = malloc(nent * sizeof(*t));
 
-       bulkreq.lastip  = &last;
+       bulkreq.lastip  = (ino64p)&last;
        bulkreq.icount  = nent;
-       bulkreq.ubuffer = t;
+       bulkreq.ubuffer = (void *)t;
        bulkreq.ocount  = &count;
 
-       while (xfsctl(name, fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
+       while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
                if (count == 0)
                        return 0;
                for (i = 0; i < count; i++) {
@@ -92,5 +77,21 @@ int main(int argc, char **argv)
                }
        }
        perror("xfsctl(XFS_IOC_FSINUMBERS)");
-       return 1;
+       exitcode = 1;
+       return 0;
+}
+
+void
+imap_init(void)
+{
+       imap_cmd.name = _("imap");
+       imap_cmd.cfunc = imap_f;
+       imap_cmd.argmin = 0;
+       imap_cmd.argmax = 0;
+       imap_cmd.args = _("[nentries]");
+       imap_cmd.flags = CMD_NOMAP_OK;
+       imap_cmd.oneline = _("inode map for filesystem of current file");
+
+       if (expert)
+               add_command(&imap_cmd);
 }
index 2c3f6a5d262317b6061c627b80df360396531932..dc6018d7819fab1bdf5a503374f07042b3a79fd5 100644 (file)
--- a/io/init.c
+++ b/io/init.c
@@ -64,6 +64,7 @@ init_commands(void)
        fsync_init();
        getrusage_init();
        help_init();
+       imap_init();
        inject_init();
        mmap_init();
        open_init();
diff --git a/io/io.h b/io/io.h
index 22633165b508f750208d57a1de5b96c3c4b6f2c7..d68f013a8fab5ad4153e327014aba6b739d9e0a2 100644 (file)
--- a/io/io.h
+++ b/io/io.h
@@ -94,6 +94,7 @@ extern void           freeze_init(void);
 extern void            fsync_init(void);
 extern void            getrusage_init(void);
 extern void            help_init(void);
+extern void            imap_init(void);
 extern void            inject_init(void);
 extern void            mmap_init(void);
 extern void            open_init(void);