don't attempt to run this test on systems where userspace (libc/fileutils)
authorNathan Scott <nathans@sgi.com>
Tue, 22 May 2001 04:50:41 +0000 (04:50 +0000)
committerNathan Scott <nathans@sgi.com>
Tue, 22 May 2001 04:50:41 +0000 (04:50 +0000)
doesn't support chown of >2^16 uid/gid.

054
src/feature.c

diff --git a/054 b/054
index 8f6f0d3af5cebfb992bb52a32d17f7b0fc295dc2..27a457eee5b79beabdea7c950f5712ec4cc0b478 100755 (executable)
--- a/054
+++ b/054
@@ -82,6 +82,9 @@ _exercise()
 
        umask 022
        touch $SCRATCH_MNT/testfile
 
        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
 
        chown 12345 $SCRATCH_MNT/testfile
        chgrp 54321 $SCRATCH_MNT/testfile
index 61ef4e40ebc8740875f5121a72a1047f3522084a..4e86ba57066035c2eb274d522877d8a5757446d9 100644 (file)
@@ -32,6 +32,7 @@
 
 /*
  * Test for filesystem features on given mount point or device
 
 /*
  * 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)
  *   -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] -<q|u|g|U|G> <filesystem>\n");
 usage(void)
 {
        fprintf(stderr, "Usage: feature [-v] -<q|u|g|U|G> <filesystem>\n");
+       fprintf(stderr, "       feature [-v] -c <file>\n");
        exit(1);
 }
 
        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)
 {
 int
 hasxfsquota(int type, int q, char *device)
 {
@@ -85,6 +124,7 @@ int
 main(int argc, char **argv)
 {
        int     c;
 main(int argc, char **argv)
 {
        int     c;
+       int     cflag = 0;
        int     gflag = 0;
        int     Gflag = 0;
        int     qflag = 0;
        int     gflag = 0;
        int     Gflag = 0;
        int     qflag = 0;
@@ -92,8 +132,11 @@ main(int argc, char **argv)
        int     Uflag = 0;
        char    *fs;
 
        int     Uflag = 0;
        char    *fs;
 
-       while ((c = getopt(argc, argv, "gGquUv")) != EOF) {
+       while ((c = getopt(argc, argv, "cgGquUv")) != EOF) {
                switch (c) {
                switch (c) {
+               case 'c':
+                       cflag++;
+                       break;
                case 'g':
                        gflag++;
                        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];
 
                usage();
        if (optind != argc-1)
                usage();
        fs = argv[argc-1];
 
+       if (cflag)
+               return(haschown32(fs));
        if (qflag)
                return(hasxfsquota(0, 0, fs));
        if (gflag)
        if (qflag)
                return(hasxfsquota(0, 0, fs));
        if (gflag)