diff options
author | midipix <writeonce@midipix.org> | 2024-06-09 03:33:08 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-06-09 04:38:23 +0000 |
commit | f9e2cb296c7939daf67133cfe5bc4843241a2346 (patch) | |
tree | bfa69bd24d9e3eaafaf82c7b86fec14c503e2a15 /src/logic/tpax_archive_enqueue.c | |
parent | b56498361d59ed226132c4ac6ff889db0387ba21 (diff) | |
download | tpax-f9e2cb296c7939daf67133cfe5bc4843241a2346.tar.bz2 tpax-f9e2cb296c7939daf67133cfe5bc4843241a2346.tar.xz |
logic: tpax_archive_add_queue_item(): record queue item device id as needed.
Diffstat (limited to 'src/logic/tpax_archive_enqueue.c')
-rw-r--r-- | src/logic/tpax_archive_enqueue.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/logic/tpax_archive_enqueue.c b/src/logic/tpax_archive_enqueue.c index 3afcb67..0d8c28f 100644 --- a/src/logic/tpax_archive_enqueue.c +++ b/src/logic/tpax_archive_enqueue.c @@ -192,6 +192,7 @@ static int tpax_archive_add_queue_item( const struct dirent * dirent, const struct tpax_dirent * parent, const char * prefix, + dev_t stdev, int depth, int flags, int fdat, @@ -231,6 +232,7 @@ static int tpax_archive_add_queue_item( cdent->fdat = fdat; cdent->depth = depth; cdent->flags = flags; + cdent->stdev = stdev; cdent->nsize = needed; cdent->parent = parent; cdent->prefix = prefix; @@ -272,6 +274,7 @@ static int tpax_archive_enqueue_dir_entries( int depth; bool fkeep; bool flinks; + bool fstdev; long nbytes; struct dirent * lnkent; struct dirent * dirent; @@ -316,8 +319,12 @@ static int tpax_archive_enqueue_dir_entries( lnkent = (struct dirent *)lnkbuf; flinks = (dctx->cctx->drvflags & TPAX_DRIVER_PAX_SYMLINK_ITEMS); + fstdev = (dctx->cctx->drvflags & TPAX_DRIVER_STRICT_DEVICE_ID); nbytes = tpax_getdents(fd,dirents,TPAX_DIRENT_BUFLEN); + /* debugging, struct stat initialization when fstdev is false */ + memset(&st,0,sizeof(st)); + while ((nbytes == -EINTR) || ((nbytes < 0) && (errno == EINTR))) nbytes = tpax_getdents(fd,dirents,TPAX_DIRENT_BUFLEN); @@ -344,11 +351,16 @@ static int tpax_archive_enqueue_dir_entries( if (S_ISDIR(st.st_mode)) { dirent->d_type = DT_DIR; } + } else if (fstdev) { + if (fstatat(fd,dirent->d_name,&st,AT_SYMLINK_NOFOLLOW)) + return tpax_archive_enqueue_ret( + TPAX_SYSTEM_ERROR(dctx), + uctx); } if (tpax_archive_add_queue_item( - dctx,dirent, - dent,0,depth, + dctx,dirent,dent,0, + st.st_dev,depth, TPAX_ITEM_IMPLICIT, fd,&fkeep) < 0) return tpax_archive_enqueue_ret( @@ -386,7 +398,8 @@ static int tpax_archive_enqueue_dir_entries( cdent->flags |= TPAX_ITEM_NAMEREF; if (tpax_archive_add_queue_item( - dctx,lnkent,cdent,0,depth+1, + dctx,lnkent,cdent,0, + lnkst.st_dev,depth+1, TPAX_ITEM_IMPLICIT|TPAX_ITEM_SYMLINK, fd,&fkeep) < 0) return tpax_archive_enqueue_ret( @@ -496,7 +509,8 @@ int tpax_archive_enqueue( /* add to queue */ if (tpax_archive_add_queue_item( - dctx,dirent,0,prefix,0, + dctx,dirent,0,prefix, + uctx->st->st_dev,0, TPAX_ITEM_EXPLICIT, fdat,&fkeep) < 0) return tpax_archive_enqueue_ret( @@ -528,7 +542,8 @@ int tpax_archive_enqueue( cdent->flags |= TPAX_ITEM_NAMEREF; if (tpax_archive_add_queue_item( - dctx,lnkent,cdent,0,1, + dctx,lnkent,cdent,0, + lnkst.st_dev,1, TPAX_ITEM_EXPLICIT|TPAX_ITEM_SYMLINK, fdat,&fkeep) < 0) return tpax_archive_enqueue_ret( |