summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c5
-rw-r--r--src/ustar.c28
-rw-r--r--src/ustar.h4
3 files changed, 36 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 8daefc6..3d92850 100644
--- a/src/main.c
+++ b/src/main.c
@@ -152,7 +152,10 @@ _opkg_opk_main_list_members(struct opkg_opk_ustar *ustar)
int ret;
while ((ret = opkg_opk_ustar_list(ustar, &member)) == OPKG_OPK_OK) {
- printf("%11d %s\n", member.size, member.name);
+ printf("%c %32s/%-32s %11d %s\n",
+ member.type,
+ member.uname, member.gname,
+ member.size, member.name);
}
if (ret == OPKG_OPK_ERROR) {
fputs("Error: Failed to list data files\n", stderr);
diff --git a/src/ustar.c b/src/ustar.c
index 4cc4651..7e00cb6 100644
--- a/src/ustar.c
+++ b/src/ustar.c
@@ -157,6 +157,34 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar,
member->name[sizeof(header.name)] = '\0';
}
member->size = ustar->data_size_remaining;
+ switch (*header.typeflag) {
+ case '0': /* Regular file */
+ case '7': /* High-performance or regular file */
+ member->type = '-';
+ break;
+ case '2': /* Symbolic link */
+ member->type = 'l';
+ strncpy(member->linkname, header.linkname,
+ sizeof(member->linkname));
+ break;
+ case '3': /* Character special file */
+ member->type = 'c';
+ break;
+ case '4': /* Block special file */
+ member->type = 'b';
+ break;
+ case '5': /* Directory */
+ member->type = 'd';
+ break;
+ case '6': /* FIFO special file */
+ member->type = 'p';
+ break;
+ case '1': /* Link */
+ default: /* Reserved */
+ return OPKG_OPK_ERROR; /* Unsupported */
+ }
+ strncpy(member->uname, header.uname, sizeof(member->uname));
+ strncpy(member->gname, header.gname, sizeof(member->gname));
while (ustar->data_size_remaining > 0) {
if (opkg_opk_ustar_read(ustar, NULL, NULL) == OPKG_OPK_ERROR) {
diff --git a/src/ustar.h b/src/ustar.h
index 4015639..6d5049b 100644
--- a/src/ustar.h
+++ b/src/ustar.h
@@ -31,6 +31,10 @@ struct opkg_opk_ustar;
struct opkg_opk_ustar_member {
char name[OPKG_OPK_USTAR_NAME_MAX_LEN];
int64_t size;
+ char type;
+ char linkname[100];
+ char uname [32];
+ char gname [32];
};
struct opkg_opk_ustar *