From: Nathan Scott Date: Fri, 3 Jun 2005 06:07:09 +0000 (+0000) Subject: Portability changes to get xfs_quota to compile on IRIX as well. X-Git-Tag: v2.7.0~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0717a7db7dc33248624d7ea8fd1a61f9db169e20;p=thirdparty%2Fxfsprogs-dev.git Portability changes to get xfs_quota to compile on IRIX as well. Merge of master-melb:xfs-cmds:22792a by kenmcd. --- diff --git a/include/path.h b/include/path.h index e2f8e41b2..e3bf02143 100644 --- a/include/path.h +++ b/include/path.h @@ -29,8 +29,8 @@ * * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ */ -#ifndef __PATHS_H__ -#define __PATHS_H__ +#ifndef __PATH_H__ +#define __PATH_H__ #include @@ -80,4 +80,4 @@ typedef struct fs_cursor { extern void fs_cursor_initialise(char *__dir, uint __flags, fs_cursor_t *__cp); extern fs_path_t *fs_cursor_next_entry(fs_cursor_t *__cp); -#endif /* __PATHS_H__ */ +#endif /* __PATH_H__ */ diff --git a/include/project.h b/include/project.h index b605211bf..defe70c2c 100644 --- a/include/project.h +++ b/include/project.h @@ -34,7 +34,10 @@ #include +#if !defined(__sgi__) typedef __uint32_t prid_t; +#endif + extern int setprojid(const char *__name, int __fd, prid_t __id); extern int getprojid(const char *__name, int __fd, prid_t *__id); diff --git a/io/attr.c b/io/attr.c index fae6d73d8..8854256e6 100644 --- a/io/attr.c +++ b/io/attr.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/bmap.c b/io/bmap.c index 75fc32e9d..7e5edb742 100644 --- a/io/bmap.c +++ b/io/bmap.c @@ -31,7 +31,7 @@ */ #include -#include "command.h" +#include #include "init.h" #include "io.h" diff --git a/io/fadvise.c b/io/fadvise.c index 29dede4b8..429f4f57a 100644 --- a/io/fadvise.c +++ b/io/fadvise.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/file.c b/io/file.c index a82736260..bb23109a2 100644 --- a/io/file.c +++ b/io/file.c @@ -31,9 +31,9 @@ */ #include +#include +#include #include -#include "command.h" -#include "input.h" #include "init.h" #include "io.h" diff --git a/io/freeze.c b/io/freeze.c index 03f300438..f45726844 100644 --- a/io/freeze.c +++ b/io/freeze.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/fsync.c b/io/fsync.c index ab77bdd79..928afb7ef 100644 --- a/io/fsync.c +++ b/io/fsync.c @@ -31,7 +31,7 @@ */ #include -#include "command.h" +#include #include "init.h" #include "io.h" diff --git a/io/getrusage.c b/io/getrusage.c index 2b321fe7b..ea922e231 100644 --- a/io/getrusage.c +++ b/io/getrusage.c @@ -31,10 +31,10 @@ */ #include +#include +#include #include #include -#include "command.h" -#include "input.h" #include "init.h" static cmdinfo_t getrusage_cmd; diff --git a/io/imap.c b/io/imap.c index 839b0ce0a..7ec049341 100644 --- a/io/imap.c +++ b/io/imap.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/init.c b/io/init.c index 60fb024bd..0f92b3da6 100644 --- a/io/init.c +++ b/io/init.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/inject.c b/io/inject.c index c06515228..cb01f3725 100644 --- a/io/inject.c +++ b/io/inject.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/madvise.c b/io/madvise.c index d611fb107..f52267810 100644 --- a/io/madvise.c +++ b/io/madvise.c @@ -31,9 +31,9 @@ */ #include +#include +#include #include -#include "command.h" -#include "input.h" #include "init.h" #include "io.h" diff --git a/io/mincore.c b/io/mincore.c index e182b954e..24ffea64b 100644 --- a/io/mincore.c +++ b/io/mincore.c @@ -31,9 +31,9 @@ */ #include +#include +#include #include -#include "command.h" -#include "input.h" #include "init.h" #include "io.h" diff --git a/io/mmap.c b/io/mmap.c index cb7531d91..fd71bc73e 100644 --- a/io/mmap.c +++ b/io/mmap.c @@ -31,10 +31,10 @@ */ #include +#include +#include #include #include -#include "command.h" -#include "input.h" #include "init.h" #include "io.h" diff --git a/io/open.c b/io/open.c index 6a4bc3ec9..9c837912c 100644 --- a/io/open.c +++ b/io/open.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/pread.c b/io/pread.c index 3d5a01466..2ed1b9316 100644 --- a/io/pread.c +++ b/io/pread.c @@ -31,9 +31,9 @@ */ #include +#include +#include #include -#include "command.h" -#include "input.h" #include "init.h" #include "io.h" diff --git a/io/prealloc.c b/io/prealloc.c index ae12f5045..4c8dc889b 100644 --- a/io/prealloc.c +++ b/io/prealloc.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/pwrite.c b/io/pwrite.c index 3ff05e846..b3956f2a7 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/resblks.c b/io/resblks.c index 5d92ba31e..a4719db0f 100644 --- a/io/resblks.c +++ b/io/resblks.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/sendfile.c b/io/sendfile.c index 5607e8f08..3a5fbdcee 100644 --- a/io/sendfile.c +++ b/io/sendfile.c @@ -31,9 +31,9 @@ */ #include +#include +#include #include -#include "command.h" -#include "input.h" #include "init.h" #include "io.h" diff --git a/io/shutdown.c b/io/shutdown.c index c9294f339..c75677a0a 100644 --- a/io/shutdown.c +++ b/io/shutdown.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/io/truncate.c b/io/truncate.c index 1d9d6a41a..ce525dbe2 100644 --- a/io/truncate.c +++ b/io/truncate.c @@ -31,8 +31,8 @@ */ #include -#include "command.h" -#include "input.h" +#include +#include #include "init.h" #include "io.h" diff --git a/quota/free.c b/quota/free.c index df42954bc..63b1fb4b1 100644 --- a/quota/free.c +++ b/quota/free.c @@ -155,8 +155,7 @@ projects_free_space_data( return 0; } - if ((xfsctl(path->fs_dir, fd, XFS_IOC_GETPROJID, &projid)) < 0) { - perror("XFS_IOC_GETPROJID"); + if ((getprojid(path->fs_dir, fd, &projid)) < 0) { close(fd); return 0; } diff --git a/quota/irix.c b/quota/irix.c index e568f3000..f6d7cfc0f 100644 --- a/quota/irix.c +++ b/quota/irix.c @@ -44,15 +44,15 @@ xcommand_to_qcommand( case XFS_QUOTAOFF: return Q_XQUOTAOFF; case XFS_GETQUOTA: - if (type == XFS_GRPQUOTA) + if (type == XFS_GROUP_QUOTA) return Q_XGETGQUOTA; - if (type == XFS_PRJQUOTA) + if (type == XFS_PROJ_QUOTA) return Q_XGETPQUOTA; return Q_XGETQUOTA; case XFS_SETQLIM: - if (type == XFS_GRPQUOTA) + if (type == XFS_GROUP_QUOTA) return Q_XSETGQLIM; - if (type == XFS_PRJQUOTA) + if (type == XFS_PROJ_QUOTA) return Q_XSETPQLIM; return Q_XSETQLIM; case XFS_GETQSTAT: @@ -74,5 +74,5 @@ xfsquotactl( int qcommand; qcommand = xcommand_to_qcommand(command, type); - return quotactl(qcommand, device, id, addr); + return quotactl(qcommand, (char *)device, id, addr); } diff --git a/quota/path.c b/quota/path.c index 7b985fb0e..939e0c391 100644 --- a/quota/path.c +++ b/quota/path.c @@ -111,11 +111,12 @@ path_f( int argc, char **argv) { + int i; + if (argc <= 1) return pathlist_f(); - int i = atoi(argv[1]); - + i = atoi(argv[1]); if (i < 0 || i >= fs_count) { printf(_("value %d is out of range (0-%d)\n"), i, fs_count-1); diff --git a/quota/state.c b/quota/state.c index 32a0533ff..4fb1467d0 100644 --- a/quota/state.c +++ b/quota/state.c @@ -262,8 +262,10 @@ enable_enforcement( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = - { .qs_version = FS_QSTAT_VERSION, .qs_flags = qflags }; + fs_quota_stat_t qstat = { 0 }; + + qstat.qs_version = FS_QSTAT_VERSION; + qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -285,8 +287,10 @@ disable_enforcement( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = - { .qs_version = FS_QSTAT_VERSION, .qs_flags = qflags }; + fs_quota_stat_t qstat = { 0 }; + + qstat.qs_version = FS_QSTAT_VERSION; + qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -308,8 +312,10 @@ quotaoff( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = - { .qs_version = FS_QSTAT_VERSION, .qs_flags = qflags }; + fs_quota_stat_t qstat = { 0 }; + + qstat.qs_version = FS_QSTAT_VERSION; + qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { @@ -331,8 +337,10 @@ remove_extents( uint flags) { fs_path_t *mount; - fs_quota_stat_t qstat = - { .qs_version = FS_QSTAT_VERSION, .qs_flags = qflags }; + fs_quota_stat_t qstat = { 0 }; + + qstat.qs_version = FS_QSTAT_VERSION; + qstat.qs_flags = qflags; mount = fs_table_lookup(dir, FS_MOUNT_POINT); if (!mount) { diff --git a/quota/util.c b/quota/util.c index 7b9c1f9e2..3113b1788 100644 --- a/quota/util.c +++ b/quota/util.c @@ -231,12 +231,18 @@ type_to_string( * Identifier caches - user/group/project names/IDs */ +#ifndef UT_NAMESIZE +struct utmp utmp; +#define NMAX (sizeof(utmp.ut_name)) +#else +#define NMAX UT_NAMESIZE +#endif #define NID 4096 #define IDMASK (NID-1) typedef struct { __uint32_t id; - char name[UT_NAMESIZE + 1]; + char name[NMAX+1]; } idcache_t; static idcache_t uidnc[NID]; @@ -258,7 +264,7 @@ getnextpwent( if ((pw = byid? getpwuid(id) : getpwent()) == NULL) return NULL; idc.id = pw->pw_uid; - strncpy(idc.name, pw->pw_name, UT_NAMESIZE); + strncpy(idc.name, pw->pw_name, NMAX); return &idc; } @@ -273,7 +279,7 @@ getnextgrent( if ((gr = byid? getgrgid(id) : getgrent()) == NULL) return NULL; idc.id = gr->gr_gid; - strncpy(idc.name, gr->gr_name, UT_NAMESIZE); + strncpy(idc.name, gr->gr_name, NMAX); return &idc; } @@ -288,7 +294,7 @@ getnextprent( if ((pr = byid? getprprid(id) : getprent()) == NULL) return NULL; idc.id = pr->pr_prid; - strncpy(idc.name, pr->pr_name, UT_NAMESIZE); + strncpy(idc.name, pr->pr_name, NMAX); return &idc; }