ftree.c revision 108533
11556Srgrimes/*- 21556Srgrimes * Copyright (c) 1992 Keith Muller. 31556Srgrimes * Copyright (c) 1992, 1993 41556Srgrimes * The Regents of the University of California. All rights reserved. 51556Srgrimes * 61556Srgrimes * This code is derived from software contributed to Berkeley by 71556Srgrimes * Keith Muller of the University of California, San Diego. 81556Srgrimes * 91556Srgrimes * Redistribution and use in source and binary forms, with or without 101556Srgrimes * modification, are permitted provided that the following conditions 111556Srgrimes * are met: 121556Srgrimes * 1. Redistributions of source code must retain the above copyright 131556Srgrimes * notice, this list of conditions and the following disclaimer. 141556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151556Srgrimes * notice, this list of conditions and the following disclaimer in the 161556Srgrimes * documentation and/or other materials provided with the distribution. 171556Srgrimes * 3. All advertising materials mentioning features or use of this software 181556Srgrimes * must display the following acknowledgement: 191556Srgrimes * This product includes software developed by the University of 201556Srgrimes * California, Berkeley and its contributors. 211556Srgrimes * 4. Neither the name of the University nor the names of its contributors 221556Srgrimes * may be used to endorse or promote products derived from this software 231556Srgrimes * without specific prior written permission. 241556Srgrimes * 251556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 261556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 291556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 321556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 331556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 341556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 351556Srgrimes * SUCH DAMAGE. 361556Srgrimes */ 371556Srgrimes 381556Srgrimes#ifndef lint 3936049Scharnier#if 0 4036049Scharnierstatic char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94"; 4136049Scharnier#endif 421556Srgrimes#endif /* not lint */ 4399110Sobrien#include <sys/cdefs.h> 4499110Sobrien__FBSDID("$FreeBSD: head/bin/pax/ftree.c 108533 2003-01-01 18:49:04Z schweikh $"); 451556Srgrimes 461556Srgrimes#include <sys/types.h> 471556Srgrimes#include <sys/time.h> 481556Srgrimes#include <sys/stat.h> 491556Srgrimes#include <unistd.h> 501556Srgrimes#include <string.h> 511556Srgrimes#include <stdio.h> 521556Srgrimes#include <errno.h> 531556Srgrimes#include <stdlib.h> 541556Srgrimes#include <fts.h> 551556Srgrimes#include "pax.h" 561556Srgrimes#include "ftree.h" 571556Srgrimes#include "extern.h" 581556Srgrimes 591556Srgrimes/* 601556Srgrimes * routines to interface with the fts library function. 611556Srgrimes * 621556Srgrimes * file args supplied to pax are stored on a single linked list (of type FTREE) 631556Srgrimes * and given to fts to be processed one at a time. pax "selects" files from 641556Srgrimes * the expansion of each arg into the corresponding file tree (if the arg is a 651556Srgrimes * directory, otherwise the node itself is just passed to pax). The selection 661556Srgrimes * is modified by the -n and -u flags. The user is informed when a specific 671556Srgrimes * file arg does not generate any selected files. -n keeps expanding the file 681556Srgrimes * tree arg until one of its files is selected, then skips to the next file 691556Srgrimes * arg. when the user does not supply the file trees as command line args to 701556Srgrimes * pax, they are read from stdin 711556Srgrimes */ 721556Srgrimes 7346684Skrisstatic FTS *ftsp = NULL; /* current FTS handle */ 741556Srgrimesstatic int ftsopts; /* options to be used on fts_open */ 751556Srgrimesstatic char *farray[2]; /* array for passing each arg to fts */ 761556Srgrimesstatic FTREE *fthead = NULL; /* head of linked list of file args */ 771556Srgrimesstatic FTREE *fttail = NULL; /* tail of linked list of file args */ 781556Srgrimesstatic FTREE *ftcur = NULL; /* current file arg being processed */ 791556Srgrimesstatic FTSENT *ftent = NULL; /* current file tree entry */ 801556Srgrimesstatic int ftree_skip; /* when set skip to next file arg */ 811556Srgrimes 8290110Simpstatic int ftree_arg(void); 831556Srgrimes 841556Srgrimes/* 851556Srgrimes * ftree_start() 861556Srgrimes * initialize the options passed to fts_open() during this run of pax 871556Srgrimes * options are based on the selection of pax options by the user 881556Srgrimes * fts_start() also calls fts_arg() to open the first valid file arg. We 891556Srgrimes * also attempt to reset directory access times when -t (tflag) is set. 901556Srgrimes * Return: 911556Srgrimes * 0 if there is at least one valid file arg to process, -1 otherwise 921556Srgrimes */ 931556Srgrimes 941556Srgrimesint 951556Srgrimesftree_start(void) 961556Srgrimes{ 971556Srgrimes /* 98100012Skeramida * Set up the operation mode of fts, open the first file arg. We must 991556Srgrimes * use FTS_NOCHDIR, as the user may have to open multiple archives and 1001556Srgrimes * if fts did a chdir off into the boondocks, we may create an archive 101100012Skeramida * volume in a place where the user did not expect to. 1021556Srgrimes */ 1031556Srgrimes ftsopts = FTS_NOCHDIR; 1041556Srgrimes 1051556Srgrimes /* 1061556Srgrimes * optional user flags that effect file traversal 1071556Srgrimes * -H command line symlink follow only (half follow) 1081556Srgrimes * -L follow sylinks (logical) 1091556Srgrimes * -P do not follow sylinks (physical). This is the default. 1101556Srgrimes * -X do not cross over mount points 1111556Srgrimes * -t preserve access times on files read. 1121556Srgrimes * -n select only the first member of a file tree when a match is found 1131556Srgrimes * -d do not extract subtrees rooted at a directory arg. 1141556Srgrimes */ 1151556Srgrimes if (Lflag) 1161556Srgrimes ftsopts |= FTS_LOGICAL; 1171556Srgrimes else 1181556Srgrimes ftsopts |= FTS_PHYSICAL; 1191556Srgrimes if (Hflag) 1201556Srgrimes# ifdef NET2_FTS 12176017Skris paxwarn(0, "The -H flag is not supported on this version"); 1221556Srgrimes# else 1231556Srgrimes ftsopts |= FTS_COMFOLLOW; 1241556Srgrimes# endif 1251556Srgrimes if (Xflag) 1261556Srgrimes ftsopts |= FTS_XDEV; 1271556Srgrimes 1281556Srgrimes if ((fthead == NULL) && ((farray[0] = malloc(PAXPATHLEN+2)) == NULL)) { 12976017Skris paxwarn(1, "Unable to allocate memory for file name buffer"); 1301556Srgrimes return(-1); 1311556Srgrimes } 1321556Srgrimes 1331556Srgrimes if (ftree_arg() < 0) 1341556Srgrimes return(-1); 1351556Srgrimes if (tflag && (atdir_start() < 0)) 1361556Srgrimes return(-1); 1371556Srgrimes return(0); 1381556Srgrimes} 1391556Srgrimes 1401556Srgrimes/* 1411556Srgrimes * ftree_add() 1421556Srgrimes * add the arg to the linked list of files to process. Each will be 1431556Srgrimes * processed by fts one at a time 1441556Srgrimes * Return: 1451556Srgrimes * 0 if added to the linked list, -1 if failed 1461556Srgrimes */ 1471556Srgrimes 1481556Srgrimesint 14990113Simpftree_add(char *str, int chflg) 1501556Srgrimes{ 15190113Simp FTREE *ft; 15290113Simp int len; 1531556Srgrimes 1541556Srgrimes /* 1551556Srgrimes * simple check for bad args 1561556Srgrimes */ 1571556Srgrimes if ((str == NULL) || (*str == '\0')) { 15876017Skris paxwarn(0, "Invalid file name argument"); 1591556Srgrimes return(-1); 1601556Srgrimes } 1611556Srgrimes 1621556Srgrimes /* 1631556Srgrimes * allocate FTREE node and add to the end of the linked list (args are 1641556Srgrimes * processed in the same order they were passed to pax). Get rid of any 1651556Srgrimes * trailing / the user may pass us. (watch out for / by itself). 1661556Srgrimes */ 1671556Srgrimes if ((ft = (FTREE *)malloc(sizeof(FTREE))) == NULL) { 16876017Skris paxwarn(0, "Unable to allocate memory for filename"); 1691556Srgrimes return(-1); 1701556Srgrimes } 1711556Srgrimes 1721556Srgrimes if (((len = strlen(str) - 1) > 0) && (str[len] == '/')) 1731556Srgrimes str[len] = '\0'; 1741556Srgrimes ft->fname = str; 1751556Srgrimes ft->refcnt = 0; 17676351Skris ft->chflg = chflg; 1771556Srgrimes ft->fow = NULL; 1781556Srgrimes if (fthead == NULL) { 1791556Srgrimes fttail = fthead = ft; 1801556Srgrimes return(0); 1811556Srgrimes } 1821556Srgrimes fttail->fow = ft; 1831556Srgrimes fttail = ft; 1841556Srgrimes return(0); 1851556Srgrimes} 1861556Srgrimes 1871556Srgrimes/* 1881556Srgrimes * ftree_sel() 1891556Srgrimes * this entry has been selected by pax. bump up reference count and handle 1901556Srgrimes * -n and -d processing. 1911556Srgrimes */ 1921556Srgrimes 1931556Srgrimesvoid 19490113Simpftree_sel(ARCHD *arcn) 1951556Srgrimes{ 1961556Srgrimes /* 1971556Srgrimes * set reference bit for this pattern. This linked list is only used 1981556Srgrimes * when file trees are supplied pax as args. The list is not used when 1991556Srgrimes * the trees are read from stdin. 2001556Srgrimes */ 2018855Srgrimes if (ftcur != NULL) 2021556Srgrimes ftcur->refcnt = 1; 2031556Srgrimes 2041556Srgrimes /* 2051556Srgrimes * if -n we are done with this arg, force a skip to the next arg when 2061556Srgrimes * pax asks for the next file in next_file(). 2071556Srgrimes * if -d we tell fts only to match the directory (if the arg is a dir) 2081556Srgrimes * and not the entire file tree rooted at that point. 2091556Srgrimes */ 2101556Srgrimes if (nflag) 2111556Srgrimes ftree_skip = 1; 2121556Srgrimes 2131556Srgrimes if (!dflag || (arcn->type != PAX_DIR)) 2141556Srgrimes return; 2151556Srgrimes 2161556Srgrimes if (ftent != NULL) 2171556Srgrimes (void)fts_set(ftsp, ftent, FTS_SKIP); 2181556Srgrimes} 2191556Srgrimes 2201556Srgrimes/* 2211556Srgrimes * ftree_chk() 2221556Srgrimes * called at end on pax execution. Prints all those file args that did not 2231556Srgrimes * have a selected member (reference count still 0) 2241556Srgrimes */ 2251556Srgrimes 2261556Srgrimesvoid 2271556Srgrimesftree_chk(void) 2281556Srgrimes{ 22990113Simp FTREE *ft; 23090113Simp int wban = 0; 2311556Srgrimes 2321556Srgrimes /* 2331556Srgrimes * make sure all dir access times were reset. 2341556Srgrimes */ 2351556Srgrimes if (tflag) 2361556Srgrimes atdir_end(); 2371556Srgrimes 2381556Srgrimes /* 2391556Srgrimes * walk down list and check reference count. Print out those members 2401556Srgrimes * that never had a match 2411556Srgrimes */ 2421556Srgrimes for (ft = fthead; ft != NULL; ft = ft->fow) { 24376351Skris if ((ft->refcnt > 0) || ft->chflg) 2441556Srgrimes continue; 2451556Srgrimes if (wban == 0) { 24676017Skris paxwarn(1,"WARNING! These file names were not selected:"); 2471556Srgrimes ++wban; 2481556Srgrimes } 2491556Srgrimes (void)fprintf(stderr, "%s\n", ft->fname); 2501556Srgrimes } 2511556Srgrimes} 2521556Srgrimes 2531556Srgrimes/* 2541556Srgrimes * ftree_arg() 2551556Srgrimes * Get the next file arg for fts to process. Can be from either the linked 2561556Srgrimes * list or read from stdin when the user did not them as args to pax. Each 2571556Srgrimes * arg is processed until the first successful fts_open(). 2581556Srgrimes * Return: 2591556Srgrimes * 0 when the next arg is ready to go, -1 if out of file args (or EOF on 2601556Srgrimes * stdin). 2611556Srgrimes */ 2621556Srgrimes 2631556Srgrimesstatic int 2641556Srgrimesftree_arg(void) 2651556Srgrimes{ 26690113Simp char *pt; 2671556Srgrimes 2681556Srgrimes /* 2691556Srgrimes * close off the current file tree 2701556Srgrimes */ 2711556Srgrimes if (ftsp != NULL) { 2721556Srgrimes (void)fts_close(ftsp); 2731556Srgrimes ftsp = NULL; 2741556Srgrimes } 2751556Srgrimes 2761556Srgrimes /* 2771556Srgrimes * keep looping until we get a valid file tree to process. Stop when we 2781556Srgrimes * reach the end of the list (or get an eof on stdin) 2791556Srgrimes */ 2801556Srgrimes for(;;) { 2811556Srgrimes if (fthead == NULL) { 2821556Srgrimes /* 2831556Srgrimes * the user didn't supply any args, get the file trees 2848855Srgrimes * to process from stdin; 2851556Srgrimes */ 2861556Srgrimes if (fgets(farray[0], PAXPATHLEN+1, stdin) == NULL) 2871556Srgrimes return(-1); 2881556Srgrimes if ((pt = strchr(farray[0], '\n')) != NULL) 2891556Srgrimes *pt = '\0'; 2901556Srgrimes } else { 2911556Srgrimes /* 29276017Skris * the user supplied the file args as arguments to pax 2931556Srgrimes */ 2941556Srgrimes if (ftcur == NULL) 2951556Srgrimes ftcur = fthead; 2961556Srgrimes else if ((ftcur = ftcur->fow) == NULL) 2971556Srgrimes return(-1); 29876351Skris if (ftcur->chflg) { 29976351Skris /* First fchdir() back... */ 30076351Skris if (fchdir(cwdfd) < 0) { 30176351Skris syswarn(1, errno, 30276351Skris "Can't fchdir to starting directory"); 30376351Skris return(-1); 30476351Skris } 30576351Skris if (chdir(ftcur->fname) < 0) { 30676351Skris syswarn(1, errno, "Can't chdir to %s", 30776351Skris ftcur->fname); 30876351Skris return(-1); 30976351Skris } 31076351Skris continue; 31176351Skris } else 31276351Skris farray[0] = ftcur->fname; 3131556Srgrimes } 3141556Srgrimes 3151556Srgrimes /* 316108533Sschweikh * Watch it, fts wants the file arg stored in an array of char 317108533Sschweikh * ptrs, with the last one a null. We use a two element array 3181556Srgrimes * and set farray[0] to point at the buffer with the file name 31946684Skris * in it. We cannot pass all the file args to fts at one shot 3201556Srgrimes * as we need to keep a handle on which file arg generates what 3211556Srgrimes * files (the -n and -d flags need this). If the open is 3221556Srgrimes * successful, return a 0. 3231556Srgrimes */ 3241556Srgrimes if ((ftsp = fts_open(farray, ftsopts, NULL)) != NULL) 3251556Srgrimes break; 3261556Srgrimes } 3271556Srgrimes return(0); 3281556Srgrimes} 3291556Srgrimes 3301556Srgrimes/* 3311556Srgrimes * next_file() 3321556Srgrimes * supplies the next file to process in the supplied archd structure. 3331556Srgrimes * Return: 3341556Srgrimes * 0 when contents of arcn have been set with the next file, -1 when done. 3351556Srgrimes */ 3361556Srgrimes 3371556Srgrimesint 33890113Simpnext_file(ARCHD *arcn) 3391556Srgrimes{ 34090113Simp int cnt; 3411556Srgrimes time_t atime; 3421556Srgrimes time_t mtime; 3431556Srgrimes 3441556Srgrimes /* 3451556Srgrimes * ftree_sel() might have set the ftree_skip flag if the user has the 3461556Srgrimes * -n option and a file was selected from this file arg tree. (-n says 3478855Srgrimes * only one member is matched for each pattern) ftree_skip being 1 3481556Srgrimes * forces us to go to the next arg now. 3491556Srgrimes */ 3501556Srgrimes if (ftree_skip) { 3511556Srgrimes /* 3521556Srgrimes * clear and go to next arg 3531556Srgrimes */ 3541556Srgrimes ftree_skip = 0; 3551556Srgrimes if (ftree_arg() < 0) 3561556Srgrimes return(-1); 3571556Srgrimes } 3581556Srgrimes 3591556Srgrimes /* 3601556Srgrimes * loop until we get a valid file to process 3611556Srgrimes */ 3621556Srgrimes for(;;) { 3631556Srgrimes if ((ftent = fts_read(ftsp)) == NULL) { 3641556Srgrimes /* 3651556Srgrimes * out of files in this tree, go to next arg, if none 3661556Srgrimes * we are done 3671556Srgrimes */ 3681556Srgrimes if (ftree_arg() < 0) 3691556Srgrimes return(-1); 3701556Srgrimes continue; 3711556Srgrimes } 3721556Srgrimes 3731556Srgrimes /* 3741556Srgrimes * handle each type of fts_read() flag 3751556Srgrimes */ 3761556Srgrimes switch(ftent->fts_info) { 3771556Srgrimes case FTS_D: 3781556Srgrimes case FTS_DEFAULT: 3791556Srgrimes case FTS_F: 3801556Srgrimes case FTS_SL: 3811556Srgrimes case FTS_SLNONE: 3821556Srgrimes /* 3831556Srgrimes * these are all ok 3841556Srgrimes */ 3851556Srgrimes break; 3861556Srgrimes case FTS_DP: 3871556Srgrimes /* 3881556Srgrimes * already saw this directory. If the user wants file 3891556Srgrimes * access times reset, we use this to restore the 3901556Srgrimes * access time for this directory since this is the 3911556Srgrimes * last time we will see it in this file subtree 3921556Srgrimes * remember to force the time (this is -t on a read 3931556Srgrimes * directory, not a created directory). 3941556Srgrimes */ 3951556Srgrimes# ifdef NET2_FTS 3961556Srgrimes if (!tflag || (get_atdir(ftent->fts_statb.st_dev, 3971556Srgrimes ftent->fts_statb.st_ino, &mtime, &atime) < 0)) 3981556Srgrimes# else 3991556Srgrimes if (!tflag || (get_atdir(ftent->fts_statp->st_dev, 4001556Srgrimes ftent->fts_statp->st_ino, &mtime, &atime) < 0)) 4011556Srgrimes# endif 4021556Srgrimes continue; 4031556Srgrimes set_ftime(ftent->fts_path, mtime, atime, 1); 4041556Srgrimes continue; 4051556Srgrimes case FTS_DC: 4061556Srgrimes /* 407102230Strhodes * fts claims a file system cycle 4081556Srgrimes */ 40976017Skris paxwarn(1,"File system cycle found at %s",ftent->fts_path); 4101556Srgrimes continue; 4111556Srgrimes case FTS_DNR: 4121556Srgrimes# ifdef NET2_FTS 41376017Skris syswarn(1, errno, 4141556Srgrimes# else 41576017Skris syswarn(1, ftent->fts_errno, 4161556Srgrimes# endif 4171556Srgrimes "Unable to read directory %s", ftent->fts_path); 4181556Srgrimes continue; 4191556Srgrimes case FTS_ERR: 4201556Srgrimes# ifdef NET2_FTS 42176017Skris syswarn(1, errno, 4221556Srgrimes# else 42376017Skris syswarn(1, ftent->fts_errno, 4241556Srgrimes# endif 4251556Srgrimes "File system traversal error"); 4261556Srgrimes continue; 4271556Srgrimes case FTS_NS: 4281556Srgrimes case FTS_NSOK: 4291556Srgrimes# ifdef NET2_FTS 43076017Skris syswarn(1, errno, 4311556Srgrimes# else 43276017Skris syswarn(1, ftent->fts_errno, 4331556Srgrimes# endif 4341556Srgrimes "Unable to access %s", ftent->fts_path); 4351556Srgrimes continue; 4361556Srgrimes } 4371556Srgrimes 4381556Srgrimes /* 4391556Srgrimes * ok got a file tree node to process. copy info into arcn 4401556Srgrimes * structure (initialize as required) 4411556Srgrimes */ 4421556Srgrimes arcn->skip = 0; 4431556Srgrimes arcn->pad = 0; 4441556Srgrimes arcn->ln_nlen = 0; 4451556Srgrimes arcn->ln_name[0] = '\0'; 4461556Srgrimes# ifdef NET2_FTS 4471556Srgrimes arcn->sb = ftent->fts_statb; 4481556Srgrimes# else 4491556Srgrimes arcn->sb = *(ftent->fts_statp); 4501556Srgrimes# endif 4511556Srgrimes 4521556Srgrimes /* 4531556Srgrimes * file type based set up and copy into the arcn struct 4541556Srgrimes * SIDE NOTE: 4551556Srgrimes * we try to reset the access time on all files and directories 4561556Srgrimes * we may read when the -t flag is specified. files are reset 4571556Srgrimes * when we close them after copying. we reset the directories 4581556Srgrimes * when we are done with their file tree (we also clean up at 4591556Srgrimes * end in case we cut short a file tree traversal). However 4601556Srgrimes * there is no way to reset access times on symlinks. 4611556Srgrimes */ 4621556Srgrimes switch(S_IFMT & arcn->sb.st_mode) { 4631556Srgrimes case S_IFDIR: 4641556Srgrimes arcn->type = PAX_DIR; 4651556Srgrimes if (!tflag) 4661556Srgrimes break; 4671556Srgrimes add_atdir(ftent->fts_path, arcn->sb.st_dev, 4681556Srgrimes arcn->sb.st_ino, arcn->sb.st_mtime, 4691556Srgrimes arcn->sb.st_atime); 4701556Srgrimes break; 4711556Srgrimes case S_IFCHR: 4721556Srgrimes arcn->type = PAX_CHR; 4731556Srgrimes break; 4741556Srgrimes case S_IFBLK: 4751556Srgrimes arcn->type = PAX_BLK; 4761556Srgrimes break; 4771556Srgrimes case S_IFREG: 4781556Srgrimes /* 4791556Srgrimes * only regular files with have data to store on the 4801556Srgrimes * archive. all others will store a zero length skip. 4811556Srgrimes * the skip field is used by pax for actual data it has 4821556Srgrimes * to read (or skip over). 4831556Srgrimes */ 4841556Srgrimes arcn->type = PAX_REG; 4851556Srgrimes arcn->skip = arcn->sb.st_size; 4861556Srgrimes break; 4871556Srgrimes case S_IFLNK: 4881556Srgrimes arcn->type = PAX_SLK; 4891556Srgrimes /* 4901556Srgrimes * have to read the symlink path from the file 4911556Srgrimes */ 4921556Srgrimes if ((cnt = readlink(ftent->fts_path, arcn->ln_name, 49336784Simp PAXPATHLEN - 1)) < 0) { 49476017Skris syswarn(1, errno, "Unable to read symlink %s", 4951556Srgrimes ftent->fts_path); 4961556Srgrimes continue; 4971556Srgrimes } 4981556Srgrimes /* 4991556Srgrimes * set link name length, watch out readlink does not 50046684Skris * always NUL terminate the link path 5011556Srgrimes */ 5021556Srgrimes arcn->ln_name[cnt] = '\0'; 5031556Srgrimes arcn->ln_nlen = cnt; 5041556Srgrimes break; 5051556Srgrimes case S_IFSOCK: 5061556Srgrimes /* 5071556Srgrimes * under BSD storing a socket is senseless but we will 5081556Srgrimes * let the format specific write function make the 5091556Srgrimes * decision of what to do with it. 5101556Srgrimes */ 5111556Srgrimes arcn->type = PAX_SCK; 5121556Srgrimes break; 5131556Srgrimes case S_IFIFO: 5141556Srgrimes arcn->type = PAX_FIF; 5151556Srgrimes break; 5161556Srgrimes } 5171556Srgrimes break; 5181556Srgrimes } 5191556Srgrimes 5201556Srgrimes /* 5211556Srgrimes * copy file name, set file name length 5221556Srgrimes */ 52376351Skris arcn->nlen = l_strncpy(arcn->name, ftent->fts_path, sizeof(arcn->name) - 1); 5241556Srgrimes arcn->name[arcn->nlen] = '\0'; 5251556Srgrimes arcn->org_name = ftent->fts_path; 5261556Srgrimes return(0); 5271556Srgrimes} 528