Skip to content

Commit

Permalink
Merge pull request #24 from josch/tarhardlinks
Browse files Browse the repository at this point in the history
fix support for hardlinks in tarballs
  • Loading branch information
bestouff authored Jun 25, 2020
2 parents ce4de57 + 761e2a7 commit 4741110
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions genext2fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct fslayer {
};

#define TAR_BLOCKSIZE 512
#define TAR_FULLFILENAME (100 + 155)
#define TAR_FULLFILENAME (100 + 155 + 1)

struct tar_header {
char filename[100];
Expand Down Expand Up @@ -2321,7 +2321,9 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids,
path = longname;
has_longname = 0;
} else {
snprintf(pathbuf, sizeof pathbuf, "%s%s", tarhead->prefix, tarhead->filename);
strncpy(pathbuf, tarhead->prefix, sizeof tarhead->prefix);
strncpy(pathbuf+strnlen(pathbuf, sizeof pathbuf), tarhead->filename, sizeof tarhead->filename);
pathbuf[strnlen(pathbuf, sizeof pathbuf - 1)] = '\0';
path = pathbuf;
}
if (stats)
Expand Down Expand Up @@ -2397,7 +2399,7 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids,
fseek(fh, padding, SEEK_CUR);
break;
case '1':
if(!(hlnod = find_path(fs, this_nod, dir)))
if(!(hlnod = find_path(fs, this_nod, tarhead->linkedname)))
{
error_msg("tarball entry %s skipped: can't find hardlink destination '%s' to create '%s''", path, dir, name);
fseek(fh, filesize + padding, SEEK_CUR);
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ ftest 3db16dd57bd15c1c80dd6bc900411c58 4096 default device_table.txt
ltest c21b5a3cad405197e821ba7143b0ea9b 200 1024 123456789 device_table_link.txt
ltest 18b04b4bea2f7ebf315a116be5b92589 200 1024 1234567890 device_table_link.txt
ltest 8aaed693b75dbdf77607f376d661027a 200 4096 12345678901 device_table_link.txt
atest 402860495b7e2e1f714e017ef37466c6 200 1024 H4sIAAAAAAACA+3VQQ6CMBCF4a49RU8AnZaZOY8sSIgNTRASj29FVyzUTQno+zYlwAL4M7SqTXEuU+ZlzdbrckxBlJga5SafV/ViLJsNzNfpPFprxpSmd/d9un5QVT3MMZbvL03zfX/yTpyx4Uj9n+9BrzUcp3/Xd2k//UVC7u9Y1FjB/G/QP/bDpZpuU9n+qvpVf9a8T1Bg8sb6LqW6PY9Fn+7v+z8+8n72f2ZZ5p8I+/92/csO2ef/P6/6e/fo79C/uDbO7ckAAAAAAAAAAAAAAAAAwC+4A2+TDLQAKAAA
atest 994ca42d3179c88263af777bedec0c55 200 1024 H4sIAAAAAAAAA+3WTW6DMBAF4Fn3FD6B8fj3PKAqahQSSwSk9vY1uKssGiJliFretzECJAYeY1s3JM4UKYRlLG7H5ZhdTIHZGevK+ZTYkgrypRFN17EdlKIh5/G3++5d/6N004qbA47er8/fWVduV2aLD7D7/A85C88Ba/ufA/sQIhk25VdA/2+h5t+1gx4/pd7vfv+Hm/ytmfNH/8vr+ql7e3UR8DK6uUx9L/uMtev/3P8p+KX/oyHlZMuqntX/9T34Z9yk9Gco8//xkGWf8Uj+Mbpl/Y+JVJQtq9r5/K+bj3Z474+Xk9wG4JH86/rvyzxAirfYnOw+/+vXWTb+uv9PaV3+JfiSv/WOlJVPf/f5AwAAAAAAAAAAAMD/9A0cPbO/ACgAAA==

0 comments on commit 4741110

Please sign in to comment.