diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-11-03 16:44:32 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-11-03 16:44:32 +0200 |
commit | 38290e9dde947f2d46e06e594d7d81644f423cd7 (patch) | |
tree | e5cd091c02e55f7126bbc7d4cf4be31f8b35d616 /src/util.c | |
parent | 068f5dbd006c02f9e70558a2b19e61becb5ed652 (diff) | |
download | cpio-38290e9dde947f2d46e06e594d7d81644f423cd7.tar.gz cpio-38290e9dde947f2d46e06e594d7d81644f423cd7.tar.bz2 |
Remove HPUX CDF support
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 182 |
1 files changed, 1 insertions, 181 deletions
@@ -601,20 +601,8 @@ void create_all_directories (char *name) { char *dir; -#ifdef HPUX_CDF - int cdf; -#endif dir = dir_name (name); -#ifdef HPUX_CDF - cdf = islastparentcdf (name); - if (cdf) - { - dir [strlen (dir) - 1] = '\0'; /* remove final + */ - mode = 04700; - } - -#endif if (dir == NULL) error (PAXEXIT_FAILURE, 0, _("virtual memory exhausted")); @@ -1003,146 +991,6 @@ umasked_symlink (char *name1, char *name2, int mode) } #endif /* SYMLINK_USES_UMASK */ -#ifdef HPUX_CDF -/* When we create a cpio archive we mark CDF's by putting an extra `/' - after their component name so we can distinguish the CDF's when we - extract the archive (in case the "hidden" directory's files appear - in the archive before the directory itself). E.g., in the path - "a/b+/c", if b+ is a CDF, we will write this path as "a/b+//c" in - the archive so when we extract the archive we will know that b+ - is actually a CDF, and not an ordinary directory whose name happens - to end in `+'. We also do the same thing internally in copypass.c. */ - - -/* Take an input pathname and check it for CDF's. Insert an extra - `/' in the pathname after each "hidden" directory. If we add - any `/'s, return a malloced string instead of the original input - string. - FIXME: This creates a memory leak. -*/ - -char * -add_cdf_double_slashes (char *input_name) -{ - static char *ret_name = NULL; /* re-usuable return buffer (malloc'ed) */ - static int ret_size = -1; /* size of return buffer. */ - char *p; - char *q; - int n; - struct stat dir_stat; - - /* Search for a `/' preceeded by a `+'. */ - - for (p = input_name; *p != '\0'; ++p) - { - if ( (*p == '+') && (*(p + 1) == '/') ) - break; - } - - /* If we didn't find a `/' preceeded by a `+' then there are - no CDF's in this pathname. Return the original pathname. */ - - if (*p == '\0') - return input_name; - - /* There was a `/' preceeded by a `+' in the pathname. If it is a CDF - then we will need to copy the input pathname to our return - buffer so we can insert the extra `/'s. Since we can't tell - yet whether or not it is a CDF we will just always copy the - string to the return buffer. First we have to make sure the - buffer is large enough to hold the string and any number of - extra `/'s we might add. */ - - n = 2 * (strlen (input_name) + 1); - if (n >= ret_size) - { - if (ret_size < 0) - ret_name = (char *) malloc (n); - else - ret_name = (char *)realloc (ret_name, n); - ret_size = n; - } - - /* Clear the `/' after this component, so we can stat the pathname - up to and including this component. */ - ++p; - *p = '\0'; - if ((*xstat) (input_name, &dir_stat) < 0) - { - stat_error (input_name); - return input_name; - } - - /* Now put back the `/' after this component and copy the pathname up to - and including this component and its trailing `/' to the return - buffer. */ - *p++ = '/'; - strncpy (ret_name, input_name, p - input_name); - q = ret_name + (p - input_name); - - /* If it was a CDF, add another `/'. */ - if (S_ISDIR (dir_stat.st_mode) && (dir_stat.st_mode & 04000) ) - *q++ = '/'; - - /* Go through the rest of the input pathname, copying it to the - return buffer, and adding an extra `/' after each CDF. */ - while (*p != '\0') - { - if ( (*p == '+') && (*(p + 1) == '/') ) - { - *q++ = *p++; - - *p = '\0'; - if ((*xstat) (input_name, &dir_stat) < 0) - { - stat_error (input_name); - return input_name; - } - *p = '/'; - - if (S_ISDIR (dir_stat.st_mode) && (dir_stat.st_mode & 04000) ) - *q++ = '/'; - } - *q++ = *p++; - } - *q = '\0'; - - return ret_name; -} - -/* Is the last parent directory (e.g., c in a/b/c/d) a CDF? If the - directory name ends in `+' and is followed by 2 `/'s instead of 1 - then it is. This is only the case for cpio archives, but we don't - have to worry about tar because tar always has the directory before - its files (or else we lose). */ -int -islastparentcdf (char *path) -{ - char *newpath; - char *slash; - int slash_count; - int length; /* Length of result, not including NUL. */ - - slash = strrchr (path, '/'); - if (slash == 0) - return 0; - else - { - slash_count = 0; - while (slash > path && *slash == '/') - { - ++slash_count; - --slash; - } - - - if ( (*slash == '+') && (slash_count >= 2) ) - return 1; - } - return 0; -} -#endif - #define DISKBLOCKSIZE (512) static int @@ -1382,12 +1230,6 @@ set_perms (int fd, struct cpio_file_stat *header) /* chown may have turned off some permissions we wanted. */ if (fchmod_or_chmod (fd, header->c_name, header->c_mode) < 0) chmod_error_details (header->c_name, header->c_mode); -#ifdef HPUX_CDF - if ((header->c_mode & CP_IFMT) && cdf_flag) - /* Once we "hide" the directory with the chmod(), - we have to refer to it using name+ instead of name. */ - file_hdr->c_name [cdf_char] = '+'; -#endif if (retain_time_flag) set_file_times (fd, header->c_name, header->c_mtime, header->c_mtime); } @@ -1592,10 +1434,6 @@ int cpio_create_dir (struct cpio_file_stat *file_hdr, int existing_dir) { int res; /* Result of various function calls. */ -#ifdef HPUX_CDF - int cdf_flag; /* True if file is a CDF. */ - int cdf_char; /* Index of `+' char indicating a CDF. */ -#endif int setstat_delayed = 0; if (to_stdout_option) @@ -1614,26 +1452,8 @@ cpio_create_dir (struct cpio_file_stat *file_hdr, int existing_dir) return 0; } -#ifdef HPUX_CDF - cdf_flag = 0; -#endif if (!existing_dir) - { -#ifdef HPUX_CDF - /* If the directory name ends in a + and is SUID, - then it is a CDF. Strip the trailing + from - the name before creating it. */ - cdf_char = strlen (file_hdr->c_name) - 1; - if ( (cdf_char > 0) && - (file_hdr->c_mode & 04000) && - (file_hdr->c_name [cdf_char] == '+') ) - { - file_hdr->c_name [cdf_char] = '\0'; - cdf_flag = 1; - } -#endif - res = cpio_mkdir (file_hdr, &setstat_delayed); - } + res = cpio_mkdir (file_hdr, &setstat_delayed); else res = 0; if (res < 0 && create_dir_flag) |