From cb5600ac708ddeac608ce47363c43bfd566b26d2 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 17 Apr 2023 17:49:22 -0400 Subject: ustar, main: Show type, uname, and gname --- (limited to 'src/ustar.c') 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) { -- cgit v0.9.1