tar: Minor style fixes

This commit is contained in:
sin 2015-04-23 17:45:35 +01:00
parent ac694e6c4a
commit fbd39af1fa

58
tar.c
View File

@ -15,6 +15,26 @@
#include "fs.h" #include "fs.h"
#include "util.h" #include "util.h"
#define BLKSIZ 512
#undef major
#define major(dev) ((int)(((unsigned int)(dev) >> 8) & 0xff))
#undef minor
#define minor(dev) ((int)((dev) & 0xff))
#undef makedev
#define makedev(major, minor) (((major) << 8) | (minor))
enum Type {
REG = '0',
AREG = '\0',
HARDLINK = '1',
SYMLINK = '2',
CHARDEV = '3',
BLOCKDEV = '4',
DIRECTORY = '5',
FIFO = '6'
};
struct header { struct header {
char name[100]; char name[100];
char mode[8]; char mode[8];
@ -34,19 +54,12 @@ struct header {
char prefix[155]; char prefix[155];
}; };
#define BLKSIZ 512 static struct ent {
char *name;
time_t mtime;
} *ents;
#undef major static size_t entslen;
#define major(dev) ((int)(((unsigned int)(dev) >> 8) & 0xff))
#undef minor
#define minor(dev) ((int)((dev) & 0xff))
#undef makedev
#define makedev(major, minor) (((major) << 8) | (minor))
enum Type {
REG = '0', AREG = '\0', HARDLINK = '1', SYMLINK = '2', CHARDEV = '3',
BLOCKDEV = '4', DIRECTORY = '5', FIFO = '6'
};
static int tarfd; static int tarfd;
static ino_t tarinode; static ino_t tarinode;
@ -55,28 +68,21 @@ static dev_t tardev;
static int mflag; static int mflag;
static int filtermode; static int filtermode;
static struct ent {
char *name;
time_t mtime;
} *ents;
static size_t entlen;
static void static void
pushent(char *name, time_t mtime) pushent(char *name, time_t mtime)
{ {
ents = reallocarray(ents, entlen + 1, sizeof(*ents)); ents = reallocarray(ents, entslen + 1, sizeof(*ents));
ents[entlen].name = strdup(name); ents[entslen].name = strdup(name);
ents[entlen].mtime = mtime; ents[entslen].mtime = mtime;
entlen++; entslen++;
} }
static struct ent * static struct ent *
popent(void) popent(void)
{ {
if (entlen) { if (entslen) {
entlen--; entslen--;
return &ents[entlen]; return &ents[entslen];
} }
return NULL; return NULL;
} }