From: Nathan Scott Date: Wed, 9 Mar 2005 14:09:45 +0000 (+0000) Subject: Make imap available as an expert xfs_io command. X-Git-Tag: v2.7.0~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9527f2d5f07a8597f954020acb62c7d851c8073d;p=thirdparty%2Fxfsprogs-dev.git Make imap available as an expert xfs_io command. Merge of master-melb:xfs-cmds:21780a by kenmcd. --- diff --git a/Makefile b/Makefile index 72a1ddc84..9cd405ec3 100644 --- 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 index b00098219..000000000 --- a/imap/Makefile +++ /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: diff --git a/include/irix.h b/include/irix.h index dee627953..a263359e7 100644 --- a/include/irix.h +++ b/include/irix.h @@ -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 */ diff --git a/io/Makefile b/io/Makefile index ff622e003..f132273bd 100644 --- a/io/Makefile +++ b/io/Makefile @@ -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) diff --git a/imap/xfs_imap.c b/io/imap.c similarity index 68% rename from imap/xfs_imap.c rename to io/imap.c index 7e193bd86..839b0ce0a 100644 --- a/imap/xfs_imap.c +++ 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 @@ -30,58 +30,43 @@ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -/* - * Inode map display utility for XFS. - */ - #include +#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); } diff --git a/io/init.c b/io/init.c index 2c3f6a5d2..dc6018d78 100644 --- 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 22633165b..d68f013a8 100644 --- 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);