From: Nathan Scott Date: Tue, 22 May 2001 04:50:41 +0000 (+0000) Subject: don't attempt to run this test on systems where userspace (libc/fileutils) X-Git-Tag: v1.1.0~1252 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=738198096d75e5d6f111e37a933573b5ac87926e;p=users%2Fhch%2Fxfstests-dev.git don't attempt to run this test on systems where userspace (libc/fileutils) doesn't support chown of >2^16 uid/gid. --- diff --git a/054 b/054 index 8f6f0d3af..27a457eee 100755 --- a/054 +++ b/054 @@ -82,6 +82,9 @@ _exercise() umask 022 touch $SCRATCH_MNT/testfile + if src/feature -c $SCRATCH_MNT/testfile; then + _notrun "Installed fileutils doesn't support 32 bit uids/gids" + fi chown 12345 $SCRATCH_MNT/testfile chgrp 54321 $SCRATCH_MNT/testfile diff --git a/src/feature.c b/src/feature.c index 61ef4e40e..4e86ba570 100644 --- a/src/feature.c +++ b/src/feature.c @@ -32,6 +32,7 @@ /* * Test for filesystem features on given mount point or device + * -c test for 32bit chown support (via libc) * -q test for quota support (kernel compile option) * -u test for user quota enforcement support (mount option) * -g test for group quota enforcement support (mount option) @@ -50,9 +51,47 @@ void usage(void) { fprintf(stderr, "Usage: feature [-v] - \n"); + fprintf(stderr, " feature [-v] -c \n"); exit(1); } +int check_big_ID(char *filename) +{ + struct stat64 sbuf; + + memset(&sbuf, 0, sizeof(struct stat64)); + if (lstat64(filename, &sbuf) < 0) { + fprintf(stderr, "lstat64 failed on "); + perror(filename); + return(1); + } + + /* 98789 is greater than 2^16 (65536) */ + if ((__u32)sbuf.st_uid == 98789 || (__u32)sbuf.st_gid == 98789) + return(0); + if (verbose) + fprintf(stderr, "lstat64 on %s gave uid=%d, gid=%d\n", + filename, sbuf.st_uid, sbuf.st_gid); + return(1); +} + +int +haschown32(char *filename) +{ + if (check_big_ID(filename) == 0) + return(0); + + if (chown(filename, 98789, 98789) < 0) { + fprintf(stderr, "chown failed on "); + perror(filename); + return(1); + } + + if (check_big_ID(filename) == 0) + return(0); + return (1); +} + int hasxfsquota(int type, int q, char *device) { @@ -85,6 +124,7 @@ int main(int argc, char **argv) { int c; + int cflag = 0; int gflag = 0; int Gflag = 0; int qflag = 0; @@ -92,8 +132,11 @@ main(int argc, char **argv) int Uflag = 0; char *fs; - while ((c = getopt(argc, argv, "gGquUv")) != EOF) { + while ((c = getopt(argc, argv, "cgGquUv")) != EOF) { switch (c) { + case 'c': + cflag++; + break; case 'g': gflag++; break; @@ -117,12 +160,14 @@ main(int argc, char **argv) } } - if (!uflag && !gflag && !qflag && !Uflag && !Gflag) + if (!cflag && !uflag && !gflag && !qflag && !Uflag && !Gflag) usage(); if (optind != argc-1) usage(); fs = argv[argc-1]; + if (cflag) + return(haschown32(fs)); if (qflag) return(hasxfsquota(0, 0, fs)); if (gflag)