The following commit has been merged in the master branch:
commit d87b7d37ac9f6ce5b91599a09781d8d79ac00143
Author: Guillem Jover <[email protected]>
Date: Wed Jul 28 00:58:03 2010 +0200
libdpkg: Rename and namespace TarFileType to tar_filetype
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 3f82d13..000f491 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -149,7 +149,7 @@ DecodeTarHeader(char *block, struct TarInfo *d)
checksum = OtoL(h->Checksum, sizeof(h->Checksum));
d->UserID = (uid_t)OtoL(h->UserID, sizeof(h->UserID));
d->GroupID = (gid_t)OtoL(h->GroupID, sizeof(h->GroupID));
- d->Type = (enum TarFileType)h->LinkFlag;
+ d->Type = (enum tar_filetype)h->LinkFlag;
if (passwd)
d->UserID = passwd->pw_uid;
@@ -210,7 +210,8 @@ TarExtractor(void *ctx, const struct tar_operations *ops)
}
break;
}
- if (h.Type != GNU_LONGLINK && h.Type != GNU_LONGNAME) {
+ if (h.Type != tar_filetype_gnu_longlink &&
+ h.Type != tar_filetype_gnu_longname) {
if (next_long_name)
h.Name = next_long_name;
@@ -231,24 +232,24 @@ TarExtractor(void *ctx, const struct tar_operations *ops)
nameLength = strlen(h.Name);
switch (h.Type) {
- case NormalFile0:
- case NormalFile1:
+ case tar_filetype_file0:
+ case tar_filetype_file:
/* Compatibility with pre-ANSI ustar. */
if (h.Name[nameLength - 1] != '/') {
status = ops->extract_file(ctx, &h);
break;
}
/* Else, fall through. */
- case Directory:
+ case tar_filetype_dir:
if (h.Name[nameLength - 1] == '/') {
h.Name[nameLength - 1] = '\0';
}
status = ops->mkdir(ctx, &h);
break;
- case HardLink:
+ case tar_filetype_hardlink:
status = ops->link(ctx, &h);
break;
- case SymbolicLink:
+ case tar_filetype_symlink:
symlink_node = m_malloc(sizeof(*symlink_node));
memcpy(&symlink_node->h, &h, sizeof(struct TarInfo));
symlink_node->h.Name = m_strdup(h.Name);
@@ -262,16 +263,16 @@ TarExtractor(void *ctx, const struct tar_operations *ops)
symlink_tail = symlink_node;
status = 0;
break;
- case CharacterDevice:
- case BlockDevice:
- case FIFO:
+ case tar_filetype_chardev:
+ case tar_filetype_blockdev:
+ case tar_filetype_fifo:
status = ops->mknod(ctx, &h);
break;
- case GNU_LONGLINK:
- case GNU_LONGNAME:
+ case tar_filetype_gnu_longlink:
+ case tar_filetype_gnu_longname:
/* Set longp to the location of the long filename or
* link we're trying to deal with. */
- longp = ((h.Type == GNU_LONGNAME) ?
+ longp = ((h.Type == tar_filetype_gnu_longname) ?
&next_long_name :
&next_long_link);
diff --git a/lib/dpkg/tarfn.h b/lib/dpkg/tarfn.h
index e5a7e63..efbb072 100644
--- a/lib/dpkg/tarfn.h
+++ b/lib/dpkg/tarfn.h
@@ -35,17 +35,17 @@ enum tar_format {
tar_format_pax,
};
-enum TarFileType {
- NormalFile0 = '\0', /* For compatibility with decades-old bug */
- NormalFile1 = '0',
- HardLink = '1',
- SymbolicLink = '2',
- CharacterDevice = '3',
- BlockDevice = '4',
- Directory = '5',
- FIFO = '6',
- GNU_LONGLINK = 'K',
- GNU_LONGNAME = 'L'
+enum tar_filetype {
+ tar_filetype_file0 = '\0', /* For compatibility with decades-old
bug */
+ tar_filetype_file = '0',
+ tar_filetype_hardlink = '1',
+ tar_filetype_symlink = '2',
+ tar_filetype_chardev = '3',
+ tar_filetype_blockdev = '4',
+ tar_filetype_dir = '5',
+ tar_filetype_fifo = '6',
+ tar_filetype_gnu_longlink = 'K',
+ tar_filetype_gnu_longname = 'L',
};
struct TarInfo {
@@ -54,7 +54,7 @@ struct TarInfo {
mode_t Mode; /* Unix mode, including device bits. */
size_t Size; /* Size of file */
time_t ModTime; /* Last-modified time */
- enum TarFileType Type; /* Regular, Directory, Special, Link */
+ enum tar_filetype Type; /* Regular, Directory, Special, Link */
char * LinkName; /* Name for symbolic and hard links */
dev_t Device; /* Special device for mknod() */
uid_t UserID; /* Numeric UID */
diff --git a/src/archives.c b/src/archives.c
index 68b7cfa..755b28d 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -188,7 +188,7 @@ tarfile_skip_one_forward(struct tarcontext *tc, struct
TarInfo *ti)
/* We need to advance the tar file to the next object, so read the
* file data and set it to oblivion.
*/
- if ((ti->Type == NormalFile0) || (ti->Type == NormalFile1)) {
+ if ((ti->Type == tar_filetype_file0) || (ti->Type == tar_filetype_file)) {
char fnamebuf[256];
fd_null_copy(tc->backendpipe, ti->Size,
@@ -496,26 +496,29 @@ tarobject(void *ctx, struct TarInfo *ti)
*/
existingdirectory = false;
switch (ti->Type) {
- case SymbolicLink:
+ case tar_filetype_symlink:
/* If it's already an existing directory, do nothing. */
if (!statr && S_ISDIR(stab.st_mode)) {
- debug(dbg_eachfiledetail,"tarobject SymbolicLink exists as directory");
+ debug(dbg_eachfiledetail, "tarobject symlink exists as directory");
existingdirectory = true;
} else if (!statr && S_ISLNK(stab.st_mode)) {
if (linktosameexistingdir(ti, fnamevb.buf, &symlinkfn))
existingdirectory = true;
}
break;
- case Directory:
+ case tar_filetype_dir:
/* If it's already an existing directory, do nothing. */
if (!stat(fnamevb.buf,&stabtmp) && S_ISDIR(stabtmp.st_mode)) {
- debug(dbg_eachfiledetail,"tarobject Directory exists");
+ debug(dbg_eachfiledetail, "tarobject directory exists");
existingdirectory = true;
}
break;
- case NormalFile0: case NormalFile1:
- case CharacterDevice: case BlockDevice: case FIFO:
- case HardLink:
+ case tar_filetype_file0:
+ case tar_filetype_file:
+ case tar_filetype_chardev:
+ case tar_filetype_blockdev:
+ case tar_filetype_fifo:
+ case tar_filetype_hardlink:
break;
default:
ohshit(_("archive contained object `%.255s' of unknown type
0x%x"),ti->Name,ti->Type);
@@ -606,7 +609,7 @@ tarobject(void *ctx, struct TarInfo *ti)
/* WTA: At this point we are replacing something without a Replaces.
* if the new object is a directory and the previous object does not
* exist assume it's also a directory and don't complain. */
- if (!(statr && ti->Type == Directory))
+ if (!(statr && ti->Type == tar_filetype_dir))
forcibleerr(fc_overwrite,
_("trying to overwrite '%.250s', "
"which is also in package %.250s %.250s"),
@@ -654,7 +657,8 @@ tarobject(void *ctx, struct TarInfo *ti)
/* Extract whatever it is as .dpkg-new ... */
switch (ti->Type) {
- case NormalFile0: case NormalFile1:
+ case tar_filetype_file0:
+ case tar_filetype_file:
/* We create the file with mode 0 to make sure nobody can do anything with
* it until we apply the proper mode, which might be a statoverride.
*/
@@ -662,7 +666,7 @@ tarobject(void *ctx, struct TarInfo *ti)
if (fd < 0)
ohshite(_("unable to create `%.255s' (while processing `%.255s')"),
fnamenewvb.buf, ti->Name);
push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
- debug(dbg_eachfiledetail,"tarobject NormalFile[01] open size=%lu",
+ debug(dbg_eachfiledetail, "tarobject file open size=%lu",
(unsigned long)ti->Size);
{ char fnamebuf[256];
fd_fd_copy(tc->backendpipe, fd, ti->Size,
@@ -694,25 +698,25 @@ tarobject(void *ctx, struct TarInfo *ti)
ohshite(_("error closing/writing `%.255s'"),ti->Name);
newtarobject_utime(fnamenewvb.buf,ti);
break;
- case FIFO:
+ case tar_filetype_fifo:
if (mkfifo(fnamenewvb.buf,0))
ohshite(_("error creating pipe `%.255s'"),ti->Name);
- debug(dbg_eachfiledetail,"tarobject FIFO");
+ debug(dbg_eachfiledetail, "tarobject fifo");
newtarobject_allmodes(fnamenewvb.buf,ti, nifd->namenode->statoverride);
break;
- case CharacterDevice:
+ case tar_filetype_chardev:
if (mknod(fnamenewvb.buf,S_IFCHR, ti->Device))
ohshite(_("error creating device `%.255s'"),ti->Name);
- debug(dbg_eachfiledetail,"tarobject CharacterDevice");
+ debug(dbg_eachfiledetail, "tarobject chardev");
newtarobject_allmodes(fnamenewvb.buf,ti, nifd->namenode->statoverride);
break;
- case BlockDevice:
+ case tar_filetype_blockdev:
if (mknod(fnamenewvb.buf,S_IFBLK, ti->Device))
ohshite(_("error creating device `%.255s'"),ti->Name);
- debug(dbg_eachfiledetail,"tarobject BlockDevice");
+ debug(dbg_eachfiledetail, "tarobject blockdev");
newtarobject_allmodes(fnamenewvb.buf,ti, nifd->namenode->statoverride);
break;
- case HardLink:
+ case tar_filetype_hardlink:
varbufreset(&hardlinkfn);
varbufaddstr(&hardlinkfn,instdir); varbufaddc(&hardlinkfn,'/');
varbufaddstr(&hardlinkfn, ti->LinkName);
@@ -722,24 +726,24 @@ tarobject(void *ctx, struct TarInfo *ti)
varbufaddc(&hardlinkfn, '\0');
if (link(hardlinkfn.buf,fnamenewvb.buf))
ohshite(_("error creating hard link `%.255s'"),ti->Name);
- debug(dbg_eachfiledetail,"tarobject HardLink");
+ debug(dbg_eachfiledetail, "tarobject hardlink");
newtarobject_allmodes(fnamenewvb.buf,ti, nifd->namenode->statoverride);
break;
- case SymbolicLink:
+ case tar_filetype_symlink:
/* We've already cheched for an existing directory. */
if (symlink(ti->LinkName,fnamenewvb.buf))
ohshite(_("error creating symbolic link `%.255s'"),ti->Name);
- debug(dbg_eachfiledetail,"tarobject SymbolicLink creating");
+ debug(dbg_eachfiledetail, "tarobject symlink creating");
if (lchown(fnamenewvb.buf,
nifd->namenode->statoverride ? nifd->namenode->statoverride->uid :
ti->UserID,
nifd->namenode->statoverride ? nifd->namenode->statoverride->gid :
ti->GroupID))
ohshite(_("error setting ownership of symlink `%.255s'"),ti->Name);
break;
- case Directory:
+ case tar_filetype_dir:
/* We've already checked for an existing directory. */
if (mkdir(fnamenewvb.buf,0))
ohshite(_("error creating directory `%.255s'"),ti->Name);
- debug(dbg_eachfiledetail,"tarobject Directory creating");
+ debug(dbg_eachfiledetail, "tarobject directory creating");
newtarobject_allmodes(fnamenewvb.buf,ti,nifd->namenode->statoverride);
break;
default:
@@ -773,7 +777,7 @@ tarobject(void *ctx, struct TarInfo *ti)
if (statr) { /* Don't try to back it up if it didn't exist. */
debug(dbg_eachfiledetail,"tarobject new - no backup");
} else {
- if (ti->Type == Directory || S_ISDIR(stab.st_mode)) {
+ if (ti->Type == tar_filetype_dir || S_ISDIR(stab.st_mode)) {
/* One of the two is a directory - can't do atomic install. */
debug(dbg_eachfiledetail,"tarobject directory, nonatomic");
nifd->namenode->flags |= fnnf_no_atomic_overwrite;
@@ -808,7 +812,7 @@ tarobject(void *ctx, struct TarInfo *ti)
* in dpkg-new.
*/
- if (ti->Type == NormalFile0 || ti->Type == NormalFile1) {
+ if (ti->Type == tar_filetype_file0 || ti->Type == tar_filetype_file) {
nifd->namenode->flags |= fnnf_deferred_rename;
debug(dbg_eachfiledetail, "tarobject done and installation deferred");
diff --git a/src/filters.c b/src/filters.c
index d512e10..8bac329 100644
--- a/src/filters.c
+++ b/src/filters.c
@@ -93,7 +93,8 @@ filter_should_skip(struct TarInfo *ti)
* directories than necessary, but better err on the side of caution
* than failing with “no such file or directory” (which would leave
* the package in a very bad state). */
- if (skip && (ti->Type == Directory || ti->Type == SymbolicLink)) {
+ if (skip && (ti->Type == tar_filetype_dir ||
+ ti->Type == tar_filetype_symlink)) {
debug(dbg_eachfile,
"filter seeing if '%s' needs to be reincluded",
&ti->Name[1]);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]