From 5ecb3de2f1d48c0ce664d2947124c4a1e8a1c4cf Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Fri, 10 Sep 2004 02:23:29 +0000 Subject: [PATCH] Updates mainly to get a clean xfs_io compile on IRIX (non-gcc), and to add a couple more inode flags needed initially on IRIX (Linux soon). Bump version number. --- VERSION | 2 +- db/inode.c | 8 +++- debian/changelog | 6 +++ doc/CHANGES | 10 ++++- include/irix.h | 25 +++++------ include/platform_defs.h.in | 2 +- include/xfs_dinode.h | 7 ++- include/xfs_fs.h | 2 + io/mmap.c | 19 +++++---- io/open.c | 87 ++++++++++++++++++++++++++++++++++++++ io/pread.c | 2 +- io/pwrite.c | 20 +++++++-- 12 files changed, 157 insertions(+), 33 deletions(-) diff --git a/VERSION b/VERSION index 244a1b429..0743ecc96 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=6 -PKG_REVISION=21 +PKG_REVISION=22 PKG_BUILD=1 diff --git a/db/inode.c b/db/inode.c index 6302dde86..10c4fb23e 100644 --- a/db/inode.c +++ b/db/inode.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2004 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 @@ -140,6 +140,12 @@ const field_t inode_core_flds[] = { { "rtinherit", FLDT_UINT1, OI(COFF(flags) + bitsz(__uint16_t) - XFS_DIFLAG_RTINHERIT_BIT-1), C1, 0, TYP_NONE }, + { "projinherit", FLDT_UINT1, + OI(COFF(flags) + bitsz(__uint16_t) - XFS_DIFLAG_PROJINHERIT_BIT-1),C1, + 0, TYP_NONE }, + { "nosymlinks", FLDT_UINT1, + OI(COFF(flags) + bitsz(__uint16_t) - XFS_DIFLAG_NOSYMLINKS_BIT-1), C1, + 0, TYP_NONE }, { "gen", FLDT_UINT32D, OI(COFF(gen)), C1, 0, TYP_NONE }, { NULL } }; diff --git a/debian/changelog b/debian/changelog index 4be9976f8..8c6ad651e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +xfsprogs (2.6.22-1) unstable; urgency=low + + * New upstream release. + + -- Nathan Scott Fri, 10 Sep 2004 11:10:57 +1000 + xfsprogs (2.6.21-1) unstable; urgency=low * New upstream release. diff --git a/doc/CHANGES b/doc/CHANGES index 95d1a3baa..a40a19392 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,5 +1,13 @@ -[cvs] +xfsprogs-2.6.22 (10 September 2004) + - Update xfs_io to get a clean compile on IRIX with the + MIPSPro compilers. - Add documentation about additional XFS inode flags. + - Add xfs_io write options to include fsync/fdatasync + in the timing results it displays. + - Add xfs_fsop_counts output to the xfs_io statfs data, + which also shows free realtime space, etc. + - Add knowledge of additional inode flags for nosymlinks + and project ID inheritance. xfsprogs-2.6.21 (09 August 2004) - Support realtime bit inheritance on directories. diff --git a/include/irix.h b/include/irix.h index 8d61b3009..37d92eb35 100644 --- a/include/irix.h +++ b/include/irix.h @@ -47,7 +47,7 @@ #include #include #include -//#include +#include #define __s8 char #define __s16 short @@ -73,7 +73,15 @@ typedef flock64_t xfs_flock64_t; #define __BYTE_ORDER BYTE_ORDER #define __BIG_ENDIAN BIG_ENDIAN #define __LITTLE_ENDIAN LITTLE_ENDIAN -#include +#define __fswab16(x) (x) +#define __fswab32(x) (x) +#define __fswab64(x) (x) + +/* Map some gcc macros for the MipsPRO compiler */ +#ifndef __GNUC__ +#define __sgi__ __sgi +#define __inline__ __inline +#endif #define INT_MAX INT32_MAX #define UINT_MAX UINT32_MAX @@ -135,7 +143,7 @@ static __inline__ char * strsep(char **s, const char *ct) #define HAVE_IOCMACROS 1 #define HAVE_BBMACROS 1 -#define __XFS_FS_H__ +#define __XFS_FS_H__ 1 #define XFS_IOC_DIOINFO F_DIOINFO #define XFS_IOC_FSGETXATTR F_FSGETXATTR @@ -176,15 +184,4 @@ static __inline__ char * strsep(char **s, const char *ct) #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN -#define XFS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */ -#define XFS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */ -#define XFS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */ -#define XFS_XFLAG_APPEND 0x00000010 /* all writes append */ -#define XFS_XFLAG_SYNC 0x00000020 /* all writes synchronous */ -#define XFS_XFLAG_NOATIME 0x00000040 /* do not update access time */ -#define XFS_XFLAG_NODUMP 0x00000080 /* do not include in backups */ -#define XFS_XFLAG_RTINHERIT 0x00000100 /* new files have rt bit set */ -#define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ - - #endif /* __XFS_IRIX_H__ */ diff --git a/include/platform_defs.h.in b/include/platform_defs.h.in index d8210405a..902be05bb 100644 --- a/include/platform_defs.h.in +++ b/include/platform_defs.h.in @@ -52,7 +52,7 @@ #include #elif defined(__APPLE__) #include -#elif defined(__sgi__) +#elif defined(__sgi__) || defined(___sgi) #include #else # error unknown platform... have fun porting! diff --git a/include/xfs_dinode.h b/include/xfs_dinode.h index a8f9b42df..f43530fdc 100644 --- a/include/xfs_dinode.h +++ b/include/xfs_dinode.h @@ -457,6 +457,8 @@ xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp); #define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */ #define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */ #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */ +#define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents project id */ +#define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */ #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) @@ -466,10 +468,13 @@ xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp); #define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT) #define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT) #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT) +#define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT) +#define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT) #define XFS_DIFLAG_ANY \ (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ - XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT) + XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ + XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS) #endif /* __XFS_DINODE_H__ */ diff --git a/include/xfs_fs.h b/include/xfs_fs.h index 096c1f978..4c95ee8ec 100644 --- a/include/xfs_fs.h +++ b/include/xfs_fs.h @@ -77,6 +77,8 @@ struct fsxattr { #define XFS_XFLAG_NOATIME 0x00000040 /* do not update access time */ #define XFS_XFLAG_NODUMP 0x00000080 /* do not include in backups */ #define XFS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */ +#define XFS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */ +#define XFS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */ #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ /* diff --git a/io/mmap.c b/io/mmap.c index 300eff083..3d49e785f 100644 --- a/io/mmap.c +++ b/io/mmap.c @@ -72,7 +72,7 @@ print_mapping( printf("%c%d%c 0x%lx - 0x%lx %s %14s (%lld : %ld)\n", braces? '[' : ' ', index, braces? ']' : ' ', (unsigned long)map->addr, - (unsigned long)(map->addr + map->length), + (unsigned long)((char *)map->addr + map->length), buffer, map->name ? map->name : "???", (long long)map->offset, (long)map->length); } @@ -103,13 +103,13 @@ check_mapping_range( (long long)mapping->offset, (long)mapping->length); return NULL; } - if (pagealign && (long)(mapping->addr + relative) % pagesize) { + if (pagealign && (long)((char *)mapping->addr + relative) % pagesize) { printf(_("offset address (%p) is not page aligned\n"), - mapping->addr + relative); + (char *)mapping->addr + relative); return NULL; } - return mapping->addr + relative; + return (char *)mapping->addr + relative; } int @@ -168,7 +168,7 @@ mmap_f( char **argv) { off64_t offset; - size_t length; + ssize_t length; void *address; char *filename; int blocksize, sectsize; @@ -284,7 +284,7 @@ msync_f( char **argv) { off64_t offset; - size_t length; + ssize_t length; void *start; int c, flags = 0, blocksize, sectsize; @@ -387,7 +387,8 @@ mread_f( char **argv) { off64_t offset, tmp; - size_t length, dumplen; + ssize_t length; + size_t dumplen; char *bp; void *start; int dump = 0, rflag = 0; @@ -476,7 +477,7 @@ munmap_f( int argc, char **argv) { - size_t length; + ssize_t length; unsigned int offset; if (munmap(mapping->addr, mapping->length) < 0) { @@ -531,7 +532,7 @@ mwrite_f( char **argv) { off64_t offset, tmp; - size_t length; + ssize_t length; void *start; char *sp; int seed = 'X'; diff --git a/io/open.c b/io/open.c index dcf9398cf..40d3de3cb 100644 --- a/io/open.c +++ b/io/open.c @@ -43,6 +43,8 @@ static cmdinfo_t setfl_cmd; static cmdinfo_t statfs_cmd; static cmdinfo_t chattr_cmd; static cmdinfo_t lsattr_cmd; +static cmdinfo_t chproj_cmd; +static cmdinfo_t lsproj_cmd; static cmdinfo_t extsize_cmd; off64_t @@ -95,6 +97,8 @@ printxattr(int flags, int verbose, int dofname, int dobraces, int doeol) { XFS_XFLAG_NOATIME, "A", "no-atime" }, { XFS_XFLAG_NODUMP, "d", "no-dump" }, { XFS_XFLAG_RTINHERIT, "R", "rt-inherit" }, + { XFS_XFLAG_PROJINHERIT,"P", "proj-inherit" }, + { XFS_XFLAG_NOSYMLINKS, "S", "nosymlinks" }, { 0, NULL, NULL } }; int first = 1; @@ -450,6 +454,9 @@ lsattr_help(void) " s -- all updates are synchronous\n" " A -- the access time is not updated for this inode\n" " d -- do not include this file in a dump of the filesystem\n" +" R -- child created in this directory has realtime bit set by default\n" +" P -- child created in this directory has parents project ID by default\n" +" S -- symbolic links cannot be created in this directory\n" "\n" " Options:\n" " -a -- show all flags which can be set alongside those which are set\n" @@ -473,6 +480,8 @@ chattr_f( { XFS_XFLAG_NOATIME, 'A' }, { XFS_XFLAG_NODUMP, 'd' }, { XFS_XFLAG_RTINHERIT, 'R' }, + { XFS_XFLAG_PROJINHERIT,'P' }, + { XFS_XFLAG_NOSYMLINKS, 'S' }, { 0, '\0' } }; struct fsxattr attr; @@ -540,6 +549,9 @@ chattr_help(void) " +/-s -- set/clear the sync flag\n" " +/-A -- set/clear the no-atime flag\n" " +/-d -- set/clear the no-dump flag\n" +" +/-R -- set/clear the realtime inheritance flag\n" +" +/-P -- set/clear the project ID inheritance flag\n" +" +/-S -- set/clear the no-symbolic-links flag\n" " Note1: user must have certain capabilities to modify immutable/append-only.\n" " Note2: immutable/append-only files cannot be deleted; removing these files\n" " requires the immutable/append-only flag to be cleared first.\n" @@ -548,6 +560,49 @@ chattr_help(void) "\n")); } +static int +lsproj_f( + int argc, + char **argv) +{ + __uint32_t id; + +#if defined(__sgi__) + struct stat64 st; + if (fstat64(file->fd, &st) < 0) { + perror("fstat64"); + return 0; + } + id = st.st_projid; +#else + id = 0; +#endif + printf("projid = %u\n", (unsigned int)id); + return 0; +} + +static int +chproj_f( + int argc, + char **argv) +{ + __uint32_t id; + char *sp; + + id = (__uint32_t) strtoul(argv[1], &sp, 0); + if (!sp || sp == argv[1]) { + printf(_("non-numeric project ID -- %s\n"), argv[1]); + return 0; + } +#if defined(__sgi__) + if (fchproj(file->fd, id) < 0) + perror("fchproj"); +#else + printf(_("Not yet implemented\n")); +#endif + return 0; +} + static int setfl_f( int argc, @@ -620,6 +675,7 @@ statfs_f( int argc, char **argv) { + struct xfs_fsop_counts fscounts; struct xfs_fsop_geom fsgeo; struct statfs st; @@ -655,6 +711,18 @@ statfs_f( printf(_("geom.sunit = %u\n"), fsgeo.sunit); printf(_("geom.swidth = %u\n"), fsgeo.swidth); } + if ((xfsctl(file->name, file->fd, XFS_IOC_FSCOUNTS, &fscounts)) < 0) { + perror("XFS_IOC_FSCOUNTS"); + } else { + printf(_("counts.freedata = %llu\n"), + (unsigned long long) fscounts.freedata); + printf(_("counts.freertx = %llu\n"), + (unsigned long long) fscounts.freertx); + printf(_("counts.freeino = %llu\n"), + (unsigned long long) fscounts.freeino); + printf(_("counts.allocino = %llu\n"), + (unsigned long long) fscounts.allocino); + } return 0; } @@ -720,6 +788,23 @@ open_init(void) _("list extended inode flags set on the currently open file"); lsattr_cmd.help = lsattr_help; + chproj_cmd.name = _("chproj"); + chproj_cmd.cfunc = chproj_f; + chproj_cmd.args = _("projid"); + chproj_cmd.argmin = 1; + chproj_cmd.argmax = 1; + chproj_cmd.flags = CMD_NOMAP_OK; + chproj_cmd.oneline = + _("change project identifier on the currently open file"); + + lsproj_cmd.name = _("lsproj"); + lsproj_cmd.cfunc = lsproj_f; + lsproj_cmd.argmin = 0; + lsproj_cmd.argmax = 0; + lsproj_cmd.flags = CMD_NOMAP_OK; + lsproj_cmd.oneline = + _("list project identifier set on the currently open file"); + extsize_cmd.name = _("extsize"); extsize_cmd.cfunc = extsize_f; extsize_cmd.argmin = 1; @@ -735,6 +820,8 @@ open_init(void) add_command(&statfs_cmd); add_command(&chattr_cmd); add_command(&lsattr_cmd); + add_command(&chproj_cmd); + add_command(&lsproj_cmd); if (expert) add_command(&extsize_cmd); diff --git a/io/pread.c b/io/pread.c index 5be9f25e8..ed0d20e6c 100644 --- a/io/pread.c +++ b/io/pread.c @@ -146,7 +146,7 @@ pread_f( { off64_t offset; long long count, total; - unsigned int blocksize, sectsize; + int blocksize, sectsize; struct timeval t1, t2; char s1[64], s2[64], ts[64]; int uflag = 0, vflag = 0; diff --git a/io/pwrite.c b/io/pwrite.c index 9a69b9757..88c62222e 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -54,6 +54,8 @@ pwrite_help(void) " -i -- specifies an input file from which to source data to write\n" " -d -- open the input file for direct IO\n" " -s -- skip a number of bytes at the start of the input file\n" +" -w -- call fdatasync(2) at the end (included in timing results)\n" +" -W -- call fsync(2) at the end (included in timing results)\n" " The writes are performed in sequential blocks starting at offset, with the\n" " blocksize tunable using the -b option (default blocksize is 4096 bytes).\n" "\n")); @@ -104,14 +106,14 @@ pwrite_f( off64_t offset, skip = 0; long long count, total; unsigned int seed = 0xcdcdcdcd; - unsigned int blocksize, sectsize; + int blocksize, sectsize; struct timeval t1, t2; char s1[64], s2[64], ts[64]; char *sp, *infile = NULL; - int c, fd = -1, uflag = 0, dflag = 0; + int c, fd = -1, uflag = 0, dflag = 0, wflag = 0, Wflag = 0; init_cvtnum(&blocksize, §size); - while ((c = getopt(argc, argv, "b:df:i:s:S:u")) != EOF) { + while ((c = getopt(argc, argv, "b:df:i:s:S:uwW")) != EOF) { switch (c) { case 'b': blocksize = cvtnum(blocksize, sectsize, optarg); @@ -144,6 +146,12 @@ pwrite_f( case 'u': uflag = 1; break; + case 'w': + wflag = 1; + break; + case 'W': + Wflag = 1; + break; default: return command_usage(&pwrite_cmd); } @@ -175,6 +183,10 @@ pwrite_f( close(fd); return 0; } + if (Wflag) + fsync(file->fd); + if (wflag) + fdatasync(file->fd); gettimeofday(&t2, NULL); t2 = tsub(t2, t1); @@ -199,7 +211,7 @@ pwrite_init(void) pwrite_cmd.argmax = -1; pwrite_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK; pwrite_cmd.args = - _("[-i infile [-d] [-s skip]] [-b bs] [-S seed] off len"); + _("[-i infile [-d] [-s skip]] [-b bs] [-S seed] [-wW] off len"); pwrite_cmd.oneline = _("writes a number of bytes at a specified offset"); pwrite_cmd.help = pwrite_help; -- 2.47.2