ALL_CHILDREN
};
-#define DIRF_INIT 0x0001 /* directory structure is initialized
- (procdir called at least once) */
-#define DIRF_NFS 0x0002 /* directory is mounted on nfs */
-#define DIRF_FOUND 0x0004 /* directory is found on fs */
-#define DIRF_NEW 0x0008 /* directory is new (not found
- in the previous dump) */
-#define DIRF_RENAMED 0x0010 /* Last target in a chain of renames */
-/* A directory which is renamed from another one is recognized by its
- orig member, which is not-NULL. This directory may eventually be
- the source for another rename, in which case it will be pointed to by
- the orig member of another directory structure. The last directory
- in such a chain of renames (the one which is not pointed to by any
- other orig) is marked with the DIRF_RENAMED flag. This marks a starting
- point from which append_incremental_renames starts encoding renames for
- this chain. */
-
-#define DIR_IS_INITED(d) ((d)->flags & DIRF_INIT)
-#define DIR_IS_NFS(d) ((d)->flags & DIRF_NFS)
-#define DIR_IS_FOUND(d) ((d)->flags & DIRF_FOUND)
-/* #define DIR_IS_NEW(d) ((d)->flags & DIRF_NEW) FIXME: not used */
-#define DIR_IS_RENAMED(d) ((d)->flags & DIRF_RENAMED)
-
-#define DIR_SET_FLAG(d,f) (d)->flags |= (f)
-#define DIR_CLEAR_FLAG(d,f) (d)->flags &= ~(f)
+enum
+ {
+ /* Directory structure is initialized (procdir called at least once). */
+ DIRF_INIT = 1 << 0,
+
+ /* Directory is mounted on nfs. */
+ DIRF_NFS = 1 << 1,
+
+ /* Directory is found on fs. */
+ DIRF_FOUND = 1 << 2,
+
+ /* Directory is new (not found in the previous dump). */
+ DIRF_NEW = 1 << 3,
+
+ /* Last target in a chain of renames.
+ A directory which is renamed from another one is recognized by its
+ orig member, which is not-NULL. This directory may eventually be
+ the source for another rename, in which case it will be pointed to by
+ the orig member of another directory structure. The last directory
+ in such a chain of renames (the one which is not pointed to by any
+ other orig) is marked with the DIRF_RENAMED flag. This marks a starting
+ point from which append_incremental_renames starts encoding renames for
+ this chain. */
+ DIRF_RENAMED= 1 << 4
+ };
struct dumpdir /* Dump directory listing */
{
char *name; /* file name of directory */
};
+static bool
+dir_is_inited (struct directory const *d)
+{
+ return !!(d->flags & DIRF_INIT);
+}
+static bool
+dir_is_nfs (struct directory const *d)
+{
+ return !!(d->flags & DIRF_NFS);
+}
+static bool
+dir_is_found (struct directory const *d)
+{
+ return !!(d->flags & DIRF_FOUND);
+}
+#if false
+/* FIXME: not used. */
+static bool
+dir_is_new (struct directory const *d)
+{
+ return !!(d->flags & DIRF_NEW);
+}
+#endif
+static bool
+dir_is_renamed (struct directory const *d)
+{
+ return !!(d->flags & DIRF_RENAMED);
+}
+static void
+dir_set_flag (struct directory *d, int f)
+{
+ d->flags |= f;
+}
+static void
+dir_clear_flag (struct directory *d, int f)
+{
+ d->flags &= ~f;
+}
+
static struct dumpdir *
dumpdir_create0 (const char *contents, const char *cmask)
{
static Hash_table *directory_table;
static Hash_table *directory_meta_table;
+static bool
+nfs_file_stat (struct stat const *st)
+{
#if HAVE_ST_FSTYPE_STRING
- static char const nfs_string[] = "nfs";
-# define NFS_FILE_STAT(st) (strcmp ((st).st_fstype, nfs_string) == 0)
+ return strcmp (st->st_fstype, "nfs") == 0;
#else
-# define ST_DEV_MSB(st) (~ (dev_t) 0 << (TYPE_WIDTH ((st).st_dev) - 1))
-# define NFS_FILE_STAT(st) (((st).st_dev & ST_DEV_MSB (st)) != 0)
+ return (st->st_dev >> (TYPE_WIDTH (st->st_dev) - 1)) & 1;
#endif
+}
/* Calculate the hash of a directory. */
static size_t
directory->inode_number = ino;
directory->children = CHANGED_CHILDREN;
if (nfs)
- DIR_SET_FLAG (directory, DIRF_NFS);
+ dir_set_flag (directory, DIRF_NFS);
if (found)
- DIR_SET_FLAG (directory, DIRF_FOUND);
+ dir_set_flag (directory, DIRF_FOUND);
if (contents)
directory->dump = dumpdir_create (contents);
else
}
}
-#define PD_FORCE_CHILDREN 0x10
-#define PD_FORCE_INIT 0x20
-#define PD_CHILDREN(f) ((f) & 3)
+enum
+ {
+ PD_FORCE_CHILDREN = 0x10,
+ PD_FORCE_INIT = 0x20,
+ };
+static enum children
+pd_children (int f)
+{
+ return f & 3;
+}
static struct directory *
procdir (const char *name_buffer, struct tar_stat_info *st,
{
struct directory *directory;
struct stat *stat_data = &st->stat;
- bool nfs = NFS_FILE_STAT (*stat_data);
+ bool nfs = nfs_file_stat (stat_data);
bool perhaps_renamed = false;
if ((directory = find_directory (name_buffer)) != NULL)
{
- if (DIR_IS_INITED (directory))
+ if (dir_is_inited (directory))
{
if (flag & PD_FORCE_INIT)
{
relying on the i-node to establish differences. */
if (! ((!check_device_option
- || (DIR_IS_NFS (directory) && nfs)
+ || (dir_is_nfs (directory) && nfs)
|| directory->device_number == stat_data->st_dev)
&& directory->inode_number == stat_data->st_ino))
{
quotearg_colon (name_buffer),
quote_n (1, d->name));
directory->orig = d;
- DIR_SET_FLAG (directory, DIRF_RENAMED);
- DIR_CLEAR_FLAG (d, DIRF_RENAMED);
+ dir_set_flag (directory, DIRF_RENAMED);
+ dir_clear_flag (d, DIRF_RENAMED);
dirlist_replace_prefix (d->name, name_buffer);
}
directory->children = CHANGED_CHILDREN;
directory->inode_number = stat_data->st_ino;
}
if (nfs)
- DIR_SET_FLAG (directory, DIRF_NFS);
+ dir_set_flag (directory, DIRF_NFS);
}
else
directory->children = CHANGED_CHILDREN;
- DIR_SET_FLAG (directory, DIRF_FOUND);
+ dir_set_flag (directory, DIRF_FOUND);
}
else
{
quotearg_colon (name_buffer),
quote_n (1, d->name));
directory->orig = d;
- DIR_SET_FLAG (directory, DIRF_RENAMED);
- DIR_CLEAR_FLAG (d, DIRF_RENAMED);
+ dir_set_flag (directory, DIRF_RENAMED);
+ dir_clear_flag (d, DIRF_RENAMED);
dirlist_replace_prefix (d->name, name_buffer);
}
directory->children = CHANGED_CHILDREN;
}
else
{
- DIR_SET_FLAG (directory, DIRF_NEW);
+ dir_set_flag (directory, DIRF_NEW);
warnopt (WARN_NEW_DIRECTORY, 0, _("%s: Directory is new"),
quotearg_colon (name_buffer));
directory->children =
else if (flag & PD_FORCE_CHILDREN)
{
- directory->children = PD_CHILDREN(flag);
+ directory->children = pd_children (flag);
if (directory->children == NO_CHILDREN)
*entry = 'N';
}
warnopt (WARN_RENAME_DIRECTORY, 0, _("%s: Directory has been renamed"),
quotearg_colon (name_buffer));
- DIR_SET_FLAG (directory, DIRF_INIT);
+ dir_set_flag (directory, DIRF_INIT);
if (directory->children != NO_CHILDREN)
{
size = 0;
for (dp = dirhead; dp; dp = dp->next)
- if (DIR_IS_RENAMED (dp))
+ if (dir_is_renamed (dp))
store_rename (dp, &stk);
/* FIXME: Is this the right thing to do when DIR is null? */
0 up to TAR_INCREMENTAL_VERSION, inclusive.
It is able to create only snapshots of TAR_INCREMENTAL_VERSION */
-#define TAR_INCREMENTAL_VERSION 2
+enum { TAR_INCREMENTAL_VERSION = 2 };
/* Read incremental snapshot formats 0 and 1 */
static void
struct directory const *directory = entry;
FILE *fp = data;
- if (DIR_IS_FOUND (directory))
+ if (dir_is_found (directory))
{
char buf[SYSINT_BUFSIZE];
char const *s;
- s = DIR_IS_NFS (directory) ? "1" : "0";
+ s = dir_is_nfs (directory) ? "1" : "0";
fwrite (s, 2, 1, fp);
s = timetostr (directory->mtime.tv_sec, buf);
fwrite (s, strlen (s) + 1, 1, fp);
{
if (*arc == 'X')
{
-#define TEMP_DIR_TEMPLATE "tar.XXXXXX"
+ static char const TEMP_DIR_TEMPLATE[] = "tar.XXXXXX";
size_t len = strlen (arc + 1);
temp_stub = xrealloc (temp_stub, len + 1 + sizeof TEMP_DIR_TEMPLATE);
memcpy (temp_stub, arc + 1, len);