aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/tar
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2008-01-02 00:21:27 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2008-01-02 00:21:27 +0000
commitfd3fd2a992a0ee378c8638c0bda18f982466dba6 (patch)
tree1f02030a6463bf5e32bc7f3d093f27de2bef8048 /usr.bin/tar
parentb47d2925d7ef68d679cbf299ce1bbc7af59b3a5b (diff)
downloadsrc-fd3fd2a992a0ee378c8638c0bda18f982466dba6.tar.gz
src-fd3fd2a992a0ee378c8638c0bda18f982466dba6.zip
Use archive_entry_strmode() instead of a local bsdtar_strmode().
(This does a couple of things that the standard library's strmode() doesn't; it proved useful in bsdcpio as well, so I pushed it down into libarchive.)
Notes
Notes: svn path=/head/; revision=175048
Diffstat (limited to 'usr.bin/tar')
-rw-r--r--usr.bin/tar/bsdtar.h1
-rw-r--r--usr.bin/tar/read.c5
-rw-r--r--usr.bin/tar/util.c50
3 files changed, 3 insertions, 53 deletions
diff --git a/usr.bin/tar/bsdtar.h b/usr.bin/tar/bsdtar.h
index 8a56ddfea984..2dfa7e744d3c 100644
--- a/usr.bin/tar/bsdtar.h
+++ b/usr.bin/tar/bsdtar.h
@@ -99,7 +99,6 @@ struct bsdtar {
void bsdtar_errc(struct bsdtar *, int _eval, int _code,
const char *fmt, ...);
-void bsdtar_strmode(struct archive_entry *entry, char *bp);
void bsdtar_warnc(struct bsdtar *, int _code, const char *fmt, ...);
void cleanup_exclusions(struct bsdtar *);
void do_chdir(struct bsdtar *);
diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c
index b0c5d2c8edea..de08fd1a3cc9 100644
--- a/usr.bin/tar/read.c
+++ b/usr.bin/tar/read.c
@@ -291,8 +291,9 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
}
if (!now)
time(&now);
- bsdtar_strmode(entry, tmp);
- fprintf(out, "%s %d ", tmp, (int)(st->st_nlink));
+ fprintf(out, "%s %d ",
+ archive_entry_strmode(entry),
+ (int)(st->st_nlink));
/* Use uname if it's present, else uid. */
p = archive_entry_uname(entry);
diff --git a/usr.bin/tar/util.c b/usr.bin/tar/util.c
index 080252c39d1b..e05e52c39938 100644
--- a/usr.bin/tar/util.c
+++ b/usr.bin/tar/util.c
@@ -199,56 +199,6 @@ yes(const char *fmt, ...)
return (0);
}
-void
-bsdtar_strmode(struct archive_entry *entry, char *bp)
-{
- static const char *perms = "?rwxrwxrwx ";
- static const mode_t permbits[] =
- { S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP,
- S_IROTH, S_IWOTH, S_IXOTH };
- mode_t mode;
- int i;
-
- /* Fill in a default string, then selectively override. */
- strcpy(bp, perms);
-
- mode = archive_entry_mode(entry);
- switch (mode & S_IFMT) {
- case S_IFREG: bp[0] = '-'; break;
- case S_IFBLK: bp[0] = 'b'; break;
- case S_IFCHR: bp[0] = 'c'; break;
- case S_IFDIR: bp[0] = 'd'; break;
- case S_IFLNK: bp[0] = 'l'; break;
- case S_IFSOCK: bp[0] = 's'; break;
-#ifdef S_IFIFO
- case S_IFIFO: bp[0] = 'p'; break;
-#endif
-#ifdef S_IFWHT
- case S_IFWHT: bp[0] = 'w'; break;
-#endif
- }
-
- for (i = 0; i < 9; i++)
- if (!(mode & permbits[i]))
- bp[i+1] = '-';
-
- if (mode & S_ISUID) {
- if (mode & S_IXUSR) bp[3] = 's';
- else bp[3] = 'S';
- }
- if (mode & S_ISGID) {
- if (mode & S_IXGRP) bp[6] = 's';
- else bp[6] = 'S';
- }
- if (mode & S_ISVTX) {
- if (mode & S_IXOTH) bp[9] = 't';
- else bp[9] = 'T';
- }
- if (archive_entry_acl_count(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS))
- bp[10] = '+';
-}
-
-
/*
* Read lines from file and do something with each one. If option_null
* is set, lines are terminated with zero bytes; otherwise, they're