diff options
author | Denis Vlasenko | 2006-11-24 14:57:31 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-11-24 14:57:31 +0000 |
commit | c50f370f98e5f5d24d18ca3df444770dacce1824 (patch) | |
tree | 45516e35a895fa4eccfb36ff0d8c1e29714a2c41 /archival/tar.c | |
parent | 4fbb584a0e6ee086d6b30936c7124c687b3e977f (diff) | |
download | busybox-c50f370f98e5f5d24d18ca3df444770dacce1824.zip busybox-c50f370f98e5f5d24d18ca3df444770dacce1824.tar.gz |
tar: cache [ug]id->username/groupname mappings. Cuts down amount
of open/read/close of /etc/passwd and /etc/group
dramatically (we were rereading those for each untarred file!!!)
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/archival/tar.c b/archival/tar.c index 99c4adb..51d34ea 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -211,12 +211,9 @@ static int writeTarHeader(struct TarBallInfo *tbInfo, putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime); strcpy(header.magic, "ustar "); - /* Enter the user and group names (default to root if it fails) */ -//cache!!! - if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL) - strcpy(header.uname, "root"); - if (bb_getgrgid(header.gname, statbuf->st_gid, sizeof(header.gname)) == NULL) - strcpy(header.gname, "root"); + /* Enter the user and group names */ + safe_strncpy(header.uname, get_cached_username(statbuf->st_uid), sizeof(header.uname)); + safe_strncpy(header.gname, get_cached_groupname(statbuf->st_gid), sizeof(header.gname)); if (tbInfo->hlInfo) { /* This is a hard link */ |