]> git.wh0rd.org - dump.git/commitdiff
Fix big endian issues with EA/ACL
authorStelian Pop <stelian@popies.net>
Wed, 8 Jun 2005 13:24:08 +0000 (13:24 +0000)
committerStelian Pop <stelian@popies.net>
Wed, 8 Jun 2005 13:24:08 +0000 (13:24 +0000)
CHANGES
restore/tape.c
restore/xattr.c

diff --git a/CHANGES b/CHANGES
index f2ce5fe0355400c79bc64779ac0408946e7c4427..1c3488f7a2d8bb474778da168fa7f9164c80d383 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,4 @@
-$Id: CHANGES,v 1.276 2005/06/08 09:34:33 stelian Exp $
+$Id: CHANGES,v 1.277 2005/06/08 13:24:08 stelian Exp $
 
 Changes between versions 0.4b40 and 0.4b41 (released ???????????)
 =================================================================
 
 Changes between versions 0.4b40 and 0.4b41 (released ???????????)
 =================================================================
@@ -7,6 +7,9 @@ Changes between versions 0.4b40 and 0.4b41 (released ???????????)
        code for EA works fine, but ACLs needed conversion from the
        ext2/3 disk format to posix_acl format before restoring.
 
        code for EA works fine, but ACLs needed conversion from the
        ext2/3 disk format to posix_acl format before restoring.
 
+2.     Fix some issues with restoration of EA on big endian
+       platforms.
+
 Changes between versions 0.4b39 and 0.4b40 (released May 2, 2005)
 =================================================================
 
 Changes between versions 0.4b39 and 0.4b40 (released May 2, 2005)
 =================================================================
 
index e60921bf3b86b1afff5ce0a8666978da04fe89d7..c74e3909f10e46cf1f1ae026573f5d9cfab56bde 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: tape.c,v 1.89 2005/05/02 15:10:46 stelian Exp $";
+       "$Id: tape.c,v 1.90 2005/06/08 13:24:11 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -346,6 +346,7 @@ setup(void)
 #endif
        FLUSHTAPEBUF();
        findtapeblksize();
 #endif
        FLUSHTAPEBUF();
        findtapeblksize();
+       cvtflag = 0;
        if (gethead(&spcl) == FAIL) {
                blkcnt--; /* push back this block */
                blksread--;
        if (gethead(&spcl) == FAIL) {
                blkcnt--; /* push back this block */
                blksread--;
@@ -2412,6 +2413,7 @@ findtapeblksize(void)
                errx(1, "Tape read error on first record");
 
        memcpy(&spclpt, tapebuf, TP_BSIZE);
                errx(1, "Tape read error on first record");
 
        memcpy(&spclpt, tapebuf, TP_BSIZE);
+       cvtflag = 0;
        if (converthead(&spclpt) == FAIL) {
                cvtflag++;
                if (converthead(&spclpt) == FAIL) {
        if (converthead(&spclpt) == FAIL) {
                cvtflag++;
                if (converthead(&spclpt) == FAIL) {
@@ -2622,7 +2624,7 @@ converthead(struct s_spcl *buf)
                if (checksum((int *)buf) == FAIL)
                        return (FAIL);
                if (Bcvt)
                if (checksum((int *)buf) == FAIL)
                        return (FAIL);
                if (Bcvt)
-                       swabst((u_char *)"8i4s31i528bi192b3i", (u_char *)buf);
+                       swabst((u_char *)"8i4s1l29i528bi192b4i", (u_char *)buf);
                goto good;
        }
        memcpy(&u_ospcl.s_ospcl, buf, TP_BSIZE);
                goto good;
        }
        memcpy(&u_ospcl.s_ospcl, buf, TP_BSIZE);
index 1182d8558317e91ad66f717c958bd9d990b53338..290f8b9694f56a26b734c90f3a4a554a44b1f95f 100644 (file)
@@ -29,7 +29,7 @@
 
 #ifndef lint
 static const char rcsid[] =
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: xattr.c,v 1.2 2005/06/08 09:34:40 stelian Exp $";
+       "$Id: xattr.c,v 1.3 2005/06/08 13:24:12 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
 #endif /* not lint */
 
 #include <config.h>
@@ -308,15 +308,17 @@ posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size) {
        }
 
        ext_acl->a_version = POSIX_ACL_XATTR_VERSION;
        }
 
        ext_acl->a_version = POSIX_ACL_XATTR_VERSION;
-       if (Bcvt) 
-               swabst("1i", (u_char *)ext_acl);
+#if BYTE_ORDER == BIG_ENDIAN
+       swabst("1i", (u_char *)ext_acl);
+#endif
 
        for (n=0; n < acl->a_count; n++, ext_entry++) {
                ext_entry->e_tag  = acl->a_entries[n].e_tag;
                ext_entry->e_perm = acl->a_entries[n].e_perm;
                ext_entry->e_id   = acl->a_entries[n].e_id;
 
        for (n=0; n < acl->a_count; n++, ext_entry++) {
                ext_entry->e_tag  = acl->a_entries[n].e_tag;
                ext_entry->e_perm = acl->a_entries[n].e_perm;
                ext_entry->e_id   = acl->a_entries[n].e_id;
-               if (Bcvt)
-                       swabst("2s1i", (u_char *)ext_entry);
+#if BYTE_ORDER == BIG_ENDIAN
+               swabst("2s1i", (u_char *)ext_entry);
+#endif
        }
        return real_size;
 }
        }
        return real_size;
 }
@@ -334,8 +336,9 @@ ext3_acl_from_disk(const void *value, size_t size)
                fprintf(stderr, "ACL size too little\n");
                return NULL;
        }
                fprintf(stderr, "ACL size too little\n");
                return NULL;
        }
-       if (Bcvt) 
-               swabst("1i", (u_char *)value);
+#if BYTE_ORDER == BIG_ENDIAN
+       swabst("1i", (u_char *)value);
+#endif
        if (((ext3_acl_header *)value)->a_version != EXT3_ACL_VERSION) {
                fprintf(stderr, "ACL version unknown\n");
                return NULL;
        if (((ext3_acl_header *)value)->a_version != EXT3_ACL_VERSION) {
                fprintf(stderr, "ACL version unknown\n");
                return NULL;
@@ -356,9 +359,10 @@ ext3_acl_from_disk(const void *value, size_t size)
        acl->a_count = count;
 
        for (n=0; n < count; n++) {
        acl->a_count = count;
 
        for (n=0; n < count; n++) {
-               if (Bcvt)
-                       swabst("2s1i", (u_char *)value);
                ext3_acl_entry *entry = (ext3_acl_entry *)value;
                ext3_acl_entry *entry = (ext3_acl_entry *)value;
+#if BYTE_ORDER == BIG_ENDIAN
+               swabst("2s", (u_char *)entry);
+#endif
                if ((char *)value + sizeof(ext3_acl_entry_short) > end)
                        goto fail;
                acl->a_entries[n].e_tag  = entry->e_tag;
                if ((char *)value + sizeof(ext3_acl_entry_short) > end)
                        goto fail;
                acl->a_entries[n].e_tag  = entry->e_tag;
@@ -374,6 +378,9 @@ ext3_acl_from_disk(const void *value, size_t size)
 
                case ACL_USER:
                case ACL_GROUP:
 
                case ACL_USER:
                case ACL_GROUP:
+#if BYTE_ORDER == BIG_ENDIAN
+                       swabst("4b1i", (u_char *)entry);
+#endif
                        value = (char *)value + sizeof(ext3_acl_entry);
                        if ((char *)value > end)
                                goto fail;
                        value = (char *)value + sizeof(ext3_acl_entry);
                        if ((char *)value > end)
                                goto fail;
@@ -453,8 +460,9 @@ xattr_verify(char *buffer)
 
        end = buffer + XATTR_MAXSIZE;
 
 
        end = buffer + XATTR_MAXSIZE;
 
-       if (Bcvt)
-               swabst("4i", (u_char *)buffer);
+#if BYTE_ORDER == BIG_ENDIAN
+       swabst("4i", (u_char *)buffer);
+#endif
 
        if (HDR(buffer)->h_magic != EXT2_XATTR_MAGIC &&
            HDR(buffer)->h_magic != EXT2_XATTR_MAGIC2) {
 
        if (HDR(buffer)->h_magic != EXT2_XATTR_MAGIC &&
            HDR(buffer)->h_magic != EXT2_XATTR_MAGIC2) {
@@ -466,8 +474,9 @@ xattr_verify(char *buffer)
 
        /* check the on-disk data structure */
        entry = FIRST_ENTRY(buffer);
 
        /* check the on-disk data structure */
        entry = FIRST_ENTRY(buffer);
-       if (Bcvt) 
-               swabst("2b1s3i", (u_char *)entry);
+#if BYTE_ORDER == BIG_ENDIAN
+       swabst("2b1s3i", (u_char *)entry);
+#endif
        while (!IS_LAST_ENTRY(entry)) {
                struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(entry);
 
        while (!IS_LAST_ENTRY(entry)) {
                struct ext2_xattr_entry *next = EXT2_XATTR_NEXT(entry);
 
@@ -476,8 +485,9 @@ xattr_verify(char *buffer)
                        return FAIL;
                }
                entry = next;
                        return FAIL;
                }
                entry = next;
-               if (Bcvt) 
-                       swabst("2b1s3i", (u_char *)entry);
+#if BYTE_ORDER == BIG_ENDIAN
+               swabst("2b1s3i", (u_char *)entry);
+#endif
        }
        return GOOD;
 }
        }
        return GOOD;
 }