char * normalize_filename (int cdidx, const char *name) { char *copy = NULL; if (IS_RELATIVE_FILE_NAME (name)) { /* Set COPY to the absolute path for this name. FIXME: There should be no need to get the absolute file name. tar_getcdpath does not return a true "canonical" path, so this following approach may lead to situations where the same file or directory is processed twice under different absolute paths without that duplication being detected. Perhaps we should use dev+ino pairs instead of names? */ const char *cdpath = tar_getcdpath (cdidx); size_t copylen; bool need_separator; if (!cdpath) call_arg_fatal ("getcwd", "."); copylen = strlen (cdpath); need_separator = ! (DOUBLE_SLASH_IS_DISTINCT_ROOT && copylen == 2 && ISSLASH (cdpath[1])); copy = xmalloc (copylen + need_separator + strlen (name) + 1); strcpy (copy, cdpath); copy[copylen] = DIRECTORY_SEPARATOR; strcpy (copy + copylen + need_separator, name); } if (!copy) copy = xstrdup (name); normalize_filename_x (copy); return copy; }
/* Fork, aborting if unsuccessful. */ pid_t xfork (void) { pid_t p = fork (); if (p == (pid_t) -1) call_arg_fatal ("fork", _("child process")); return p; }
/* Create a pipe, aborting if unsuccessful. */ void xpipe (int fd[2]) { if (pipe (fd) < 0) call_arg_fatal ("pipe", _("interprocess channel")); }
void write_fatal (char const *name) { call_arg_fatal ("write", name); }
void read_fatal (char const *name) { call_arg_fatal ("read", name); }
void open_fatal (char const *name) { call_arg_fatal ("open", name); }
void exec_fatal (char const *name) { call_arg_fatal ("exec", name); }
void chdir_fatal (char const *name) { call_arg_fatal ("chdir", name); }
void stat_fatal (char const *name) { call_arg_fatal ("stat", name); }