|
Packit Service |
1d0348 |
/*-
|
|
Packit Service |
1d0348 |
* Copyright (c) 2003-2007 Tim Kientzle
|
|
Packit Service |
1d0348 |
* All rights reserved.
|
|
Packit Service |
1d0348 |
*
|
|
Packit Service |
1d0348 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
1d0348 |
* modification, are permitted provided that the following conditions
|
|
Packit Service |
1d0348 |
* are met:
|
|
Packit Service |
1d0348 |
* 1. Redistributions of source code must retain the above copyright
|
|
Packit Service |
1d0348 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit Service |
1d0348 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit Service |
1d0348 |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit Service |
1d0348 |
* documentation and/or other materials provided with the distribution.
|
|
Packit Service |
1d0348 |
*
|
|
Packit Service |
1d0348 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
Packit Service |
1d0348 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
Packit Service |
1d0348 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
Packit Service |
1d0348 |
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
Packit Service |
1d0348 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
Packit Service |
1d0348 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit Service |
1d0348 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit Service |
1d0348 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit Service |
1d0348 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
Packit Service |
1d0348 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
1d0348 |
*/
|
|
Packit Service |
1d0348 |
#include "test.h"
|
|
Packit Service |
1d0348 |
__FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_format_newc.c,v 1.2 2008/08/22 02:09:10 kientzle Exp $");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Number of bytes needed to pad 'n' to multiple of 'block', assuming
|
|
Packit Service |
1d0348 |
* that 'block' is a power of two. This trick can be more easily
|
|
Packit Service |
1d0348 |
* remembered as -n & (block - 1), but many compilers quite reasonably
|
|
Packit Service |
1d0348 |
* warn about "-n" when n is an unsigned value. (~(n) + 1) is the
|
|
Packit Service |
1d0348 |
* same thing, but written in a way that won't offend anyone. */
|
|
Packit Service |
1d0348 |
#define PAD(n, block) ((~(n) + 1) & ((block) - 1))
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
static int
|
|
Packit Service |
1d0348 |
is_hex(const char *p, size_t l)
|
|
Packit Service |
1d0348 |
{
|
|
Packit Service |
1d0348 |
while (l > 0) {
|
|
Packit Service |
1d0348 |
if ((*p >= '0' && *p <= '9')
|
|
Packit Service |
1d0348 |
|| (*p >= 'a' && *p <= 'f')
|
|
Packit Service |
1d0348 |
|| (*p >= 'A' && *p <= 'F'))
|
|
Packit Service |
1d0348 |
{
|
|
Packit Service |
1d0348 |
--l;
|
|
Packit Service |
1d0348 |
++p;
|
|
Packit Service |
1d0348 |
} else
|
|
Packit Service |
1d0348 |
return (0);
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
return (1);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
static int
|
|
Packit Service |
1d0348 |
from_hex(const char *p, size_t l)
|
|
Packit Service |
1d0348 |
{
|
|
Packit Service |
1d0348 |
int r = 0;
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
while (l > 0) {
|
|
Packit Service |
1d0348 |
r *= 16;
|
|
Packit Service |
1d0348 |
if (*p >= 'a' && *p <= 'f')
|
|
Packit Service |
1d0348 |
r += *p + 10 - 'a';
|
|
Packit Service |
1d0348 |
else if (*p >= 'A' && *p <= 'F')
|
|
Packit Service |
1d0348 |
r += *p + 10 - 'A';
|
|
Packit Service |
1d0348 |
else
|
|
Packit Service |
1d0348 |
r += *p - '0';
|
|
Packit Service |
1d0348 |
--l;
|
|
Packit Service |
1d0348 |
++p;
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
return (r);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
#if !defined(_WIN32) || defined(__CYGWIN__)
|
|
Packit Service |
1d0348 |
static int
|
|
Packit Service |
1d0348 |
nlinks(const char *p)
|
|
Packit Service |
1d0348 |
{
|
|
Packit Service |
1d0348 |
struct stat st;
|
|
Packit Service |
1d0348 |
assertEqualInt(0, stat(p, &st);;
|
|
Packit Service |
1d0348 |
return st.st_nlink;
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
#endif
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
DEFINE_TEST(test_format_newc)
|
|
Packit Service |
1d0348 |
{
|
|
Packit Service |
1d0348 |
FILE *list;
|
|
Packit Service |
1d0348 |
int r;
|
|
Packit Service |
1d0348 |
int devmajor, devminor, ino, gid;
|
|
Packit Service |
1d0348 |
int uid = -1;
|
|
Packit Service |
1d0348 |
time_t t, t2, now;
|
|
Packit Service |
1d0348 |
char *p, *e;
|
|
Packit Service |
1d0348 |
size_t s, fs, ns;
|
|
Packit Service |
1d0348 |
char result[1024];
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
assertUmask(0);
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
#if !defined(_WIN32)
|
|
Packit Service |
1d0348 |
uid = getuid();
|
|
Packit Service |
1d0348 |
#endif
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/*
|
|
Packit Service |
1d0348 |
* Create an assortment of files.
|
|
Packit Service |
1d0348 |
* TODO: Extend this to cover more filetypes.
|
|
Packit Service |
1d0348 |
*/
|
|
Packit Service |
1d0348 |
list = fopen("list", "w");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* "file1" */
|
|
Packit Service |
1d0348 |
assertMakeFile("file1", 0644, "1234567890");
|
|
Packit Service |
1d0348 |
fprintf(list, "file1\n");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* "hardlink" */
|
|
Packit Service |
1d0348 |
assertMakeHardlink("hardlink", "file1");
|
|
Packit Service |
1d0348 |
fprintf(list, "hardlink\n");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Another hardlink, but this one won't be archived. */
|
|
Packit Service |
1d0348 |
assertMakeHardlink("hardlink2", "file1");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* "symlink" */
|
|
Packit Service |
1d0348 |
if (canSymlink()) {
|
|
Packit Service |
1d0348 |
assertMakeSymlink("symlink", "file1");
|
|
Packit Service |
1d0348 |
fprintf(list, "symlink\n");
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* "dir" */
|
|
Packit Service |
1d0348 |
assertMakeDir("dir", 0775);
|
|
Packit Service |
1d0348 |
fprintf(list, "dir\n");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Setup result message. */
|
|
Packit Service |
1d0348 |
memset(result, 0, sizeof(result));
|
|
Packit Service |
1d0348 |
if (is_LargeInode("file1")) {
|
|
Packit Service |
1d0348 |
strncat(result,
|
|
Packit Service |
1d0348 |
"bsdcpio: file1: large inode number truncated: ",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, strerror(ERANGE),
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, "\n",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
if (canSymlink() && is_LargeInode("symlink")) {
|
|
Packit Service |
1d0348 |
strncat(result,
|
|
Packit Service |
1d0348 |
"bsdcpio: symlink: large inode number truncated: ",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, strerror(ERANGE),
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, "\n",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
if (is_LargeInode("dir")) {
|
|
Packit Service |
1d0348 |
strncat(result,
|
|
Packit Service |
1d0348 |
"bsdcpio: dir: large inode number truncated: ",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, strerror(ERANGE),
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, "\n",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
if (is_LargeInode("hardlink")) {
|
|
Packit Service |
1d0348 |
strncat(result,
|
|
Packit Service |
1d0348 |
"bsdcpio: hardlink: large inode number truncated: ",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, strerror(ERANGE),
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
strncat(result, "\n",
|
|
Packit Service |
1d0348 |
sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Record some facts about what we just created: */
|
|
Packit Service |
1d0348 |
now = time(NULL); /* They were all created w/in last two seconds. */
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Use the cpio program to create an archive. */
|
|
Packit Service |
1d0348 |
fclose(list);
|
|
Packit Service |
1d0348 |
r = systemf("%s -o --format=newc <list >newc.out 2>newc.err",
|
|
Packit Service |
1d0348 |
testprog);
|
|
Packit Service |
1d0348 |
if (!assertEqualInt(r, 0))
|
|
Packit Service |
1d0348 |
return;
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Verify that nothing went to stderr. */
|
|
Packit Service |
1d0348 |
if (canSymlink()) {
|
|
Packit Service |
1d0348 |
strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
} else {
|
|
Packit Service |
1d0348 |
strncat(result, "1 block\n", sizeof(result) - strlen(result) -1);
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
assertTextFileContents(result, "newc.err");
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Verify that stdout is a well-formed cpio file in "newc" format. */
|
|
Packit Service |
1d0348 |
p = slurpfile(&s, "newc.out");
|
|
Packit Service |
1d0348 |
assertEqualInt(s, canSymlink() ? 1024 : 512);
|
|
Packit Service |
1d0348 |
e = p;
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/*
|
|
Packit Service |
1d0348 |
* Some of these assertions could be stronger, but it's
|
|
Packit Service |
1d0348 |
* a little tricky because they depend on the local environment.
|
|
Packit Service |
1d0348 |
*/
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* First entry is "file1" */
|
|
Packit Service |
1d0348 |
assert(is_hex(e, 110)); /* Entire header is octal digits. */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
|
Packit Service |
1d0348 |
ino = from_hex(e + 6, 8); /* ino */
|
|
Packit Service |
1d0348 |
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
Packit Service |
1d0348 |
/* Group members bits and others bits do not work. */
|
|
Packit Service |
1d0348 |
assertEqualInt(0x8180, from_hex(e + 14, 8) & 0xffc0); /* Mode */
|
|
Packit Service |
1d0348 |
#else
|
|
Packit Service |
1d0348 |
assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
|
|
Packit Service |
1d0348 |
#endif
|
|
Packit Service |
1d0348 |
if (uid < 0)
|
|
Packit Service |
1d0348 |
uid = from_hex(e + 22, 8);
|
|
Packit Service |
1d0348 |
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
|
Packit Service |
1d0348 |
gid = from_hex(e + 30, 8); /* gid */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 38, "00000003", 8); /* nlink */
|
|
Packit Service |
1d0348 |
t = from_hex(e + 46, 8); /* mtime */
|
|
Packit Service |
1d0348 |
failure("t=0x%08x now=0x%08x=%d", t, now, now);
|
|
Packit Service |
1d0348 |
assert(t <= now); /* File wasn't created in future. */
|
|
Packit Service |
1d0348 |
failure("t=0x%08x now - 2=0x%08x = %d", t, now - 2, now - 2);
|
|
Packit Service |
1d0348 |
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
|
Packit Service |
1d0348 |
failure("newc format stores body only with last appearance of a link\n"
|
|
Packit Service |
1d0348 |
" first appearance should be empty, so this file size\n"
|
|
Packit Service |
1d0348 |
" field should be zero");
|
|
Packit Service |
1d0348 |
assertEqualInt(0, from_hex(e + 54, 8)); /* File size */
|
|
Packit Service |
1d0348 |
fs = from_hex(e + 54, 8);
|
|
Packit Service |
1d0348 |
fs += PAD(fs, 4);
|
|
Packit Service |
1d0348 |
devmajor = from_hex(e + 62, 8); /* devmajor */
|
|
Packit Service |
1d0348 |
devminor = from_hex(e + 70, 8); /* devminor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 86, 8)); /* rdevminor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 94, "00000006", 8); /* Name size */
|
|
Packit Service |
1d0348 |
ns = from_hex(e + 94, 8);
|
|
Packit Service |
1d0348 |
ns += PAD(ns + 2, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110, "file1\0", 6); /* Name contents */
|
|
Packit Service |
1d0348 |
/* Since there's another link, no file contents here. */
|
|
Packit Service |
1d0348 |
/* But add in file size so that an error here doesn't cascade. */
|
|
Packit Service |
1d0348 |
e += 110 + fs + ns;
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
if (canSymlink()) {
|
|
Packit Service |
1d0348 |
/* "symlink" pointing to "file1" */
|
|
Packit Service |
1d0348 |
assert(is_hex(e, 110));
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 6, 8)); /* ino */
|
|
Packit Service |
1d0348 |
assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */
|
|
Packit Service |
1d0348 |
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
|
Packit Service |
1d0348 |
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 38, "00000001", 8); /* nlink */
|
|
Packit Service |
1d0348 |
t2 = from_hex(e + 46, 8); /* mtime */
|
|
Packit Service |
1d0348 |
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
|
Packit Service |
1d0348 |
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 54, "00000005", 8); /* File size */
|
|
Packit Service |
1d0348 |
fs = from_hex(e + 54, 8);
|
|
Packit Service |
1d0348 |
fs += PAD(fs, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
|
Packit Service |
1d0348 |
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 86, 8)); /* rdevminor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 94, "00000008", 8); /* Name size */
|
|
Packit Service |
1d0348 |
ns = from_hex(e + 94, 8);
|
|
Packit Service |
1d0348 |
ns += PAD(ns + 2, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110, "symlink\0\0\0", 10); /* Name contents */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110 + ns, "file1\0\0\0", 8); /* symlink target */
|
|
Packit Service |
1d0348 |
e += 110 + fs + ns;
|
|
Packit Service |
1d0348 |
}
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* "dir" */
|
|
Packit Service |
1d0348 |
assert(is_hex(e, 110));
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 6, 8)); /* ino */
|
|
Packit Service |
1d0348 |
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
Packit Service |
1d0348 |
/* Group members bits and others bits do not work. */
|
|
Packit Service |
1d0348 |
assertEqualInt(0x41c0, from_hex(e + 14, 8) & 0xffc0); /* Mode */
|
|
Packit Service |
1d0348 |
#else
|
|
Packit Service |
1d0348 |
/* Mode: sgid bit sometimes propagates from parent dirs, ignore it. */
|
|
Packit Service |
1d0348 |
assertEqualInt(040775, from_hex(e + 14, 8) & ~02000);
|
|
Packit Service |
1d0348 |
#endif
|
|
Packit Service |
1d0348 |
assertEqualInt(uid, from_hex(e + 22, 8)); /* uid */
|
|
Packit Service |
1d0348 |
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
|
Packit Service |
1d0348 |
#if !defined(_WIN32) || defined(__CYGWIN__)
|
|
Packit Service |
1d0348 |
assertEqualInt(nlinks("dir"), from_hex(e + 38, 8)); /* nlinks */
|
|
Packit Service |
1d0348 |
#endif
|
|
Packit Service |
1d0348 |
t2 = from_hex(e + 46, 8); /* mtime */
|
|
Packit Service |
1d0348 |
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
|
Packit Service |
1d0348 |
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 54, "00000000", 8); /* File size */
|
|
Packit Service |
1d0348 |
fs = from_hex(e + 54, 8);
|
|
Packit Service |
1d0348 |
fs += PAD(fs, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
|
Packit Service |
1d0348 |
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 86, 8)); /* rdevminor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 94, "00000004", 8); /* Name size */
|
|
Packit Service |
1d0348 |
ns = from_hex(e + 94, 8);
|
|
Packit Service |
1d0348 |
ns += PAD(ns + 2, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110, "dir\0\0\0", 6); /* Name contents */
|
|
Packit Service |
1d0348 |
e += 110 + fs + ns;
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Hardlink identical to "file1" */
|
|
Packit Service |
1d0348 |
/* Since we only wrote two of the three links to this
|
|
Packit Service |
1d0348 |
* file, this link should get deferred by the hardlink logic. */
|
|
Packit Service |
1d0348 |
assert(is_hex(e, 110));
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
|
Packit Service |
1d0348 |
failure("If these aren't the same, then the hardlink detection failed to match them.");
|
|
Packit Service |
1d0348 |
assertEqualInt(ino, from_hex(e + 6, 8)); /* ino */
|
|
Packit Service |
1d0348 |
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
Packit Service |
1d0348 |
/* Group members bits and others bits do not work. */
|
|
Packit Service |
1d0348 |
assertEqualInt(0x8180, from_hex(e + 14, 8) & 0xffc0); /* Mode */
|
|
Packit Service |
1d0348 |
#else
|
|
Packit Service |
1d0348 |
assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
|
|
Packit Service |
1d0348 |
#endif
|
|
Packit Service |
1d0348 |
assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
|
|
Packit Service |
1d0348 |
assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 38, "00000003", 8); /* nlink */
|
|
Packit Service |
1d0348 |
t2 = from_hex(e + 46, 8); /* mtime */
|
|
Packit Service |
1d0348 |
failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2);
|
|
Packit Service |
1d0348 |
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
|
Packit Service |
1d0348 |
assertEqualInt(10, from_hex(e + 54, 8)); /* File size */
|
|
Packit Service |
1d0348 |
fs = from_hex(e + 54, 8);
|
|
Packit Service |
1d0348 |
fs += PAD(fs, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
|
Packit Service |
1d0348 |
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
|
Packit Service |
1d0348 |
assert(is_hex(e + 86, 8)); /* rdevminor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 94, "00000009", 8); /* Name size */
|
|
Packit Service |
1d0348 |
ns = from_hex(e + 94, 8);
|
|
Packit Service |
1d0348 |
ns += PAD(ns + 2, 4);
|
|
Packit Service |
1d0348 |
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110, "hardlink\0\0", 10); /* Name contents */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110 + ns, "1234567890\0\0", 12); /* File contents */
|
|
Packit Service |
1d0348 |
e += 110 + ns + fs;
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
/* Last entry is end-of-archive marker. */
|
|
Packit Service |
1d0348 |
assert(is_hex(e, 110));
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 8, "00000000", 8); /* ino */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 14, "00000000", 8); /* mode */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 22, "00000000", 8); /* uid */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 30, "00000000", 8); /* gid */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 38, "00000001", 8); /* nlink */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 46, "00000000", 8); /* mtime */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 54, "00000000", 8); /* size */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 62, "00000000", 8); /* devmajor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 70, "00000000", 8); /* devminor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 86, "00000000", 8); /* rdevminor */
|
|
Packit Service |
1d0348 |
assertEqualInt(11, from_hex(e + 94, 8)); /* name size */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 102, "00000000", 8); /* check field */
|
|
Packit Service |
1d0348 |
assertEqualMem(e + 110, "TRAILER!!!\0\0", 12); /* Name */
|
|
Packit Service |
1d0348 |
|
|
Packit Service |
1d0348 |
free(p);
|
|
Packit Service |
1d0348 |
}
|