diff options
author | ewt <devnull@localhost> | 1997-07-31 14:04:56 +0000 |
---|---|---|
committer | ewt <devnull@localhost> | 1997-07-31 14:04:56 +0000 |
commit | 9174be23bae7e21c3e1ffb11c0b301a2ca14bc1b (patch) | |
tree | 2a1d650341bfb895bf9d0466b7d3dc4d4a1d240f /lib/cpio.c | |
parent | ce379332c44dd6f69929da17da3e338874733850 (diff) | |
download | librpm-tizen-9174be23bae7e21c3e1ffb11c0b301a2ca14bc1b.tar.gz librpm-tizen-9174be23bae7e21c3e1ffb11c0b301a2ca14bc1b.tar.bz2 librpm-tizen-9174be23bae7e21c3e1ffb11c0b301a2ca14bc1b.zip |
1) cpio can now conditionally follow symlinks
2) directory archiving is fixed
CVS patchset: 1778
CVS date: 1997/07/31 14:04:56
Diffstat (limited to 'lib/cpio.c')
-rw-r--r-- | lib/cpio.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/cpio.c b/lib/cpio.c index 81135c58e..44ccb0526 100644 --- a/lib/cpio.c +++ b/lib/cpio.c @@ -651,7 +651,7 @@ static int writeFile(int fd, struct stat sb, struct cpioFileMapping * map, if (map->mapFlags & CPIO_MAP_GID) sb.st_gid = map->finalGid; - if (!writeData) { + if (!writeData || S_ISDIR(sb.st_mode)) { sb.st_size = 0; } else if (S_ISLNK(sb.st_mode)) { /* While linux puts the size of a symlink in the st_size field, @@ -788,11 +788,18 @@ int cpioBuildArchive(int fd, struct cpioFileMapping * mappings, struct hardLink hlinkList = { NULL }; struct hardLink * hlink, * parent; + hlinkList.next = NULL; + for (i = 0; i < numMappings; i++) { - if (lstat(mappings[i].fsPath, &sb)) + if (mappings[i].mapFlags & CPIO_FOLLOW_SYMLINKS) + rc = stat(mappings[i].fsPath, &sb); + else + rc = lstat(mappings[i].fsPath, &sb); + + if (rc) return CPIO_STAT_FAILED; - if (sb.st_nlink > 1) { + if (!S_ISDIR(sb.st_mode) && sb.st_nlink > 1) { hlink = hlinkList.next; while (hlink && (hlink->dev != sb.st_dev || hlink->inode != sb.st_ino)) |