From 8034d053d2a29f7721066ff1190aa6814a300d40 Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 6 Jun 2024 21:54:54 +0000 Subject: tpax_dirent_init_from_uctx(): move up in anticipation of -L support. --- src/logic/tpax_archive_enqueue.c | 78 ++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/logic/tpax_archive_enqueue.c b/src/logic/tpax_archive_enqueue.c index b81661b..ab07ab5 100644 --- a/src/logic/tpax_archive_enqueue.c +++ b/src/logic/tpax_archive_enqueue.c @@ -83,6 +83,45 @@ static char * tpax_add_prefix_item_from_path( return tpax_add_prefix_item(dctx,pathbuf); } +static int tpax_dirent_init_from_uctx( + const struct stat * st, + const char * basename, + struct dirent * dirent) +{ + /* st_mode to d_type translation */ + if (S_ISREG(st->st_mode)) + dirent->d_type = DT_REG; + else if (S_ISLNK(st->st_mode)) + dirent->d_type = DT_LNK; + else if (S_ISDIR(st->st_mode)) + dirent->d_type = DT_DIR; + else if (S_ISCHR(st->st_mode)) + dirent->d_type = DT_CHR; + else if (S_ISBLK(st->st_mode)) + dirent->d_type = DT_CHR; + else if (S_ISFIFO(st->st_mode)) + dirent->d_type = DT_CHR; + else + return -1; + + /* d_off, d_ino */ + dirent->d_off = 0; + dirent->d_ino = st->st_ino; + + /* d_reclen */ + dirent->d_reclen = offsetof(struct dirent,d_name); + dirent->d_reclen += strlen(basename) + 1; + + dirent->d_reclen += 0x1; + dirent->d_reclen |= 0x1; + dirent->d_reclen ^= 0x1; + + /* d_name */ + strcpy(dirent->d_name,basename); + + return 0; +} + static struct tpax_dirent_buffer * tpax_dirent_buf_first_alloc( const struct tpax_driver_ctx * dctx) { @@ -356,45 +395,6 @@ static const char * tpax_path_prefix_mark(const char * path) return (mark <= pathbuf) ? 0 : &path[--mark-pathbuf]; } -static int tpax_dirent_init_from_uctx( - const struct stat * st, - const char * basename, - struct dirent * dirent) -{ - /* st_mode to d_type translation */ - if (S_ISREG(st->st_mode)) - dirent->d_type = DT_REG; - else if (S_ISLNK(st->st_mode)) - dirent->d_type = DT_LNK; - else if (S_ISDIR(st->st_mode)) - dirent->d_type = DT_DIR; - else if (S_ISCHR(st->st_mode)) - dirent->d_type = DT_CHR; - else if (S_ISBLK(st->st_mode)) - dirent->d_type = DT_CHR; - else if (S_ISFIFO(st->st_mode)) - dirent->d_type = DT_CHR; - else - return -1; - - /* d_off, d_ino */ - dirent->d_off = 0; - dirent->d_ino = st->st_ino; - - /* d_reclen */ - dirent->d_reclen = offsetof(struct dirent,d_name); - dirent->d_reclen += strlen(basename) + 1; - - dirent->d_reclen += 0x1; - dirent->d_reclen |= 0x1; - dirent->d_reclen ^= 0x1; - - /* d_name */ - strcpy(dirent->d_name,basename); - - return 0; -} - int tpax_archive_enqueue( const struct tpax_driver_ctx * dctx, const struct tpax_unit_ctx * uctx) -- cgit v1.2.3