size_t i, total, ctsize, len;
char *p;
const char *q;
size_t i, total, ctsize, len;
char *p;
const char *q;
for (i = 0, total = 0, ctsize = 1, q = contents; *q; total++, q += len)
{
len = strlen (q) + 1;
for (i = 0, total = 0, ctsize = 1, q = contents; *q; total++, q += len)
{
len = strlen (q) + 1;
namelen--;
directory->name = xmalloc (namelen + 1);
memcpy (directory->name, name, namelen);
namelen--;
directory->name = xmalloc (namelen + 1);
memcpy (directory->name, name, namelen);
/* With NFS, the same file can have two different devices
if an NFS directory is mounted in multiple locations,
which is relatively common when automounting.
To avoid spurious incremental redumping of
directories, consider all NFS devices as equal,
relying on the i-node to establish differences. */
/* With NFS, the same file can have two different devices
if an NFS directory is mounted in multiple locations,
which is relatively common when automounting.
To avoid spurious incremental redumping of
directories, consider all NFS devices as equal,
relying on the i-node to establish differences. */
if (! ((!check_device_option
|| (DIR_IS_NFS (directory) && nfs)
|| directory->device_number == stat_data->st_dev)
if (! ((!check_device_option
|| (DIR_IS_NFS (directory) && nfs)
|| directory->device_number == stat_data->st_dev)
DIR_SET_FLAG (directory, DIRF_FOUND);
}
else
{
struct directory *d = find_directory_meta (stat_data->st_dev,
stat_data->st_ino);
DIR_SET_FLAG (directory, DIRF_FOUND);
}
else
{
struct directory *d = find_directory_meta (stat_data->st_dev,
stat_data->st_ino);
directory = note_directory (name_buffer,
get_stat_mtime(stat_data),
stat_data->st_dev,
directory = note_directory (name_buffer,
get_stat_mtime(stat_data),
stat_data->st_dev,
if (one_file_system_option && device != stat_data->st_dev
/* ... except if it was explicitely given in the command line */
&& !is_individual_file (name_buffer))
if (one_file_system_option && device != stat_data->st_dev
/* ... except if it was explicitely given in the command line */
&& !is_individual_file (name_buffer))
DIR_SET_FLAG (directory, DIRF_INIT);
if (directory->children != NO_CHILDREN)
DIR_SET_FLAG (directory, DIRF_INIT);
if (directory->children != NO_CHILDREN)
case exclusion_tag_under:
exclusion_tag_warning (name_buffer, tag_file_name,
_("contents not dumped"));
directory->tagfile = tag_file_name;
break;
case exclusion_tag_under:
exclusion_tag_warning (name_buffer, tag_file_name,
_("contents not dumped"));
directory->tagfile = tag_file_name;
break;
DIRECTORY->dump is replaced with the created template. Each entry is
prefixed with ' ' if it was present in DUMP and with 'Y' otherwise. */
DIRECTORY->dump is replaced with the created template. Each entry is
prefixed with ' ' if it was present in DUMP and with 'Y' otherwise. */
scan_directory (char *dir, dev_t device, bool cmdline)
{
char *dirp = savedir (dir); /* for scanning directory */
scan_directory (char *dir, dev_t device, bool cmdline)
{
char *dirp = savedir (dir); /* for scanning directory */
- char *name_buffer; /* directory, `/', and directory member */
- size_t name_buffer_size; /* allocated size of name_buffer, minus 2 */
- size_t name_length; /* used length in name_buffer */
+ namebuf_t nbuf;
+ char *tmp;
- name_buffer_size = strlen (dir) + NAME_FIELD_SIZE;
- name_buffer = xmalloc (name_buffer_size + 2);
- strcpy (name_buffer, dir);
- zap_slashes (name_buffer);
-
- if (deref_stat (dereference_option, name_buffer, &stat_data))
+ tmp = xstrdup (dir);
+ zap_slashes (tmp);
+
+ if (deref_stat (dereference_option, tmp, &stat_data))
- directory = procdir (name_buffer, &stat_data, device,
+ directory = procdir (tmp, &stat_data, device,
-
- name_length = strlen (name_buffer);
- if (! ISSLASH (name_buffer[name_length - 1]))
- {
- name_buffer[name_length] = DIRECTORY_SEPARATOR;
- /* name_buffer has been allocated an extra slot */
- name_buffer[++name_length] = 0;
- }
+
+ free (tmp);
+
+ nbuf = namebuf_create (dir);
- entrylen = strlen (entry);
- if (name_buffer_size <= entrylen - 1 + name_length)
- {
- do
- name_buffer_size += NAME_FIELD_SIZE;
- while (name_buffer_size <= entrylen - 1 + name_length);
- name_buffer = xrealloc (name_buffer, name_buffer_size + 2);
- }
- strcpy (name_buffer + name_length, entry + 1);
+ char *full_name = namebuf_name (nbuf, entry + 1);
- procdir (name_buffer, &stat_data, device, pd_flag, entry);
+ procdir (full_name, &stat_data, device, pd_flag, entry);
s = from[0] == 0 ? from :
safer_name_suffix (from, false, absolute_names_option);
s = from[0] == 0 ? from :
safer_name_suffix (from, false, absolute_names_option);
+ /* Consume the first name from the name list and reset the
+ list afterwards. This is done to change to the new
+ directory, if the first name is a chdir request (-C dir),
+ which is necessary to recreate absolute file names. */
+ name_from_list ();
+ blank_name_list ();
+
seek_error (listed_incremental_option);
if (sys_truncate (fileno (fp)) != 0)
truncate_error (listed_incremental_option);
seek_error (listed_incremental_option);
if (sys_truncate (fileno (fp)) != 0)
truncate_error (listed_incremental_option);