]>
git.wh0rd.org - dump.git/blob - restore/dirs.c
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <stelian@popies.net>, 1999-2000
6 * Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
10 * Copyright (c) 1983, 1993
11 * The Regents of the University of California. All rights reserved.
12 * (c) UNIX System Laboratories, Inc.
13 * All or some portions of this file are derived from material licensed
14 * to the University of California by American Telephone and Telegraph
15 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
16 * the permission of UNIX System Laboratories, Inc.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. Neither the name of the University nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 static const char rcsid
[] =
45 "$Id: dirs.c,v 1.36 2010/06/11 11:19:17 stelian Exp $";
49 #include <compatlfs.h>
50 #include <sys/types.h>
51 #include <sys/param.h>
56 #ifdef HAVE_EXT2FS_EXT2_FS_H
57 #include <ext2fs/ext2_fs.h>
59 #include <linux/ext2_fs.h>
61 #include <bsdcompat.h>
64 #include <sys/fcntl.h>
65 #include <bsdcompat.h>
67 #include <ufs/ufs/dinode.h>
68 #include <ufs/ufs/dir.h>
70 #endif /* __linux__ */
71 #include <protocols/dumprestore.h>
73 #include <compaterr.h>
84 #include <arpa/nameser_compat.h>
86 #include <machine/endian.h>
90 #include "pathnames.h"
95 * Symbol table of directories read from tape.
98 #define INOHASH(val) (val % HASHSIZE)
100 struct inotab
*t_next
;
105 static struct inotab
*inotab
[HASHSIZE
];
108 * Information retained about directories.
112 struct timeval timep
[2];
121 * Definitions for library routines operating on directories.
124 #define DIRBLKSIZ 1024
129 char dd_buf
[DIRBLKSIZ
];
133 * Global variables for this file.
136 static FILE *df
, *mf
;
137 static RST_DIR
*dirp
;
138 static char dirfile
[MAXPATHLEN
] = "#"; /* No file */
139 static char modefile
[MAXPATHLEN
] = "#"; /* No file */
140 static char dot
[2] = "."; /* So it can be modified */
143 * Format of old style directories.
148 char d_name
[ODIRSIZ
];
151 #if defined(__linux__) || defined(sunos)
152 static struct inotab
*allocinotab
__P((dump_ino_t
, OFF_T
));
153 static void savemodeinfo
__P((dump_ino_t
, struct new_bsd_inode
*, char *));
155 static struct inotab
*allocinotab
__P((dump_ino_t
, OFF_T
));
156 static void savemodeinfo
__P((dump_ino_t
, struct dinode
*, char *));
158 static void dcvt
__P((struct odirect
*, struct direct
*));
159 static void flushent
__P((void));
160 static struct inotab
*inotablookup
__P((dump_ino_t
));
161 static RST_DIR
*opendirfile
__P((const char *));
162 static void putdir
__P((char *, size_t));
163 static void putent
__P((struct direct
*));
164 static void rst_seekdir
__P((RST_DIR
*, OFF_T
, OFF_T
));
165 static OFF_T rst_telldir
__P((RST_DIR
*));
166 static struct direct
*searchdir
__P((dump_ino_t
, char *));
173 * Extract directory contents, building up a directory structure
174 * on disk for extraction by name.
175 * If genmode is requested, save mode, owner, and times for all
176 * directories on the tape.
179 extractdirs(int genmode
)
182 #if defined(__linux__) || defined(sunos)
183 struct new_bsd_inode ip
;
188 struct direct nulldir
;
190 char xattr
[XATTR_MAXSIZE
];
194 Vprintf(stdout
, "Extract directories from tape\n");
195 (void) snprintf(dirfile
, sizeof(dirfile
), "%s/rstdir%ld", tmpdir
,
197 if (command
!= 'r' && command
!= 'R') {
198 (void) strncat(dirfile
, "-XXXXXX",
199 sizeof(dirfile
) - strlen(dirfile
));
200 fd
= MKSTEMP(dirfile
);
202 fd
= OPEN(dirfile
, O_RDWR
|O_CREAT
|O_EXCL
, 0666);
203 if (fd
== -1 || (df
= fdopen(fd
, "w")) == NULL
) {
206 err(1, "cannot create directory temporary %s", dirfile
);
209 (void) snprintf(modefile
, sizeof(modefile
), "%s/rstmode%ld", tmpdir
, (long)dumpdate
);
210 if (command
!= 'r' && command
!= 'R') {
211 (void) strncat(modefile
, "-XXXXXX",
212 sizeof(modefile
) - strlen(modefile
));
213 fd
= MKSTEMP(modefile
);
215 fd
= OPEN(modefile
, O_RDWR
|O_CREAT
|O_EXCL
, 0666);
216 if (fd
== -1 || (mf
= fdopen(fd
, "w")) == NULL
) {
219 err(1, "cannot create modefile %s", modefile
);
223 nulldir
.d_type
= DT_DIR
;
224 nulldir
.d_namlen
= 1;
225 nulldir
.d_name
[0] = '/';
226 nulldir
.d_name
[1] = '\0';
227 nulldir
.d_reclen
= DIRSIZ(0, &nulldir
);
229 curfile
.name
= "<directory file - name unknown>";
230 curfile
.action
= USING
;
232 if (curfile
.dip
== NULL
|| (curfile
.dip
->di_mode
& IFMT
) != IFDIR
) {
233 if ( fclose(df
) == EOF
)
234 err(1, "cannot write to file %s", dirfile
);
235 dirp
= opendirfile(dirfile
);
238 if (mf
!= NULL
&& fclose(mf
) == EOF
)
239 err(1, "cannot write to file %s", dirfile
);
242 panic("Root directory is not on tape\n");
245 memcpy(&ip
, curfile
.dip
, sizeof(ip
));
246 itp
= allocinotab(ino
, seekpt
);
247 getfile(putdir
, xtrnull
);
249 while (spcl
.c_flags
& DR_EXTATTRIBUTES
) {
250 switch (spcl
.c_extattributes
) {
251 case EXT_MACOSFNDRINFO
:
252 msg("MacOSX attributes not supported, skipping\n");
255 case EXT_MACOSRESFORK
:
256 msg("MacOSX attributes not supported, skipping\n");
260 if (readxattr(xattr
) == GOOD
)
266 savemodeinfo(ino
, &ip
, xattr
);
268 savemodeinfo(ino
, &ip
, NULL
);
271 itp
->t_size
= seekpt
- itp
->t_seekpt
;
276 * skip over all the directories on the tape
282 while (curfile
.dip
&& (curfile
.dip
->di_mode
& IFMT
) == IFDIR
) {
288 * Recursively find names and inumbers of all files in subtree
289 * pname and pass them off to be processed.
292 treescan(char *pname
, dump_ino_t ino
, long (*todo
) __P((char *, dump_ino_t
, int)))
298 char locname
[MAXPATHLEN
+ 1];
300 itp
= inotablookup(ino
);
303 * Pname is name of a simple file or an unchanged directory.
305 (void) (*todo
)(pname
, ino
, LEAF
);
309 * Pname is a dumped directory name.
311 if ((*todo
)(pname
, ino
, NODE
) == FAIL
)
314 * begin search through the directory
315 * skipping over "." and ".."
317 namelen
= snprintf(locname
, sizeof(locname
), "%s/", pname
);
318 if (namelen
>= (int)sizeof(locname
))
319 namelen
= sizeof(locname
) - 1;
320 rst_seekdir(dirp
, itp
->t_seekpt
, itp
->t_seekpt
);
321 dp
= rst_readdir(dirp
); /* "." */
322 if (dp
!= NULL
&& strcmp(dp
->d_name
, ".") == 0)
323 dp
= rst_readdir(dirp
); /* ".." */
325 fprintf(stderr
, "Warning: `.' missing from directory %s\n",
327 if (dp
!= NULL
&& strcmp(dp
->d_name
, "..") == 0)
328 dp
= rst_readdir(dirp
); /* first real entry */
330 fprintf(stderr
, "Warning: `..' missing from directory %s\n",
332 bpt
= rst_telldir(dirp
);
334 * a zero inode signals end of directory
337 locname
[namelen
] = '\0';
338 if (namelen
+ dp
->d_namlen
>= (int)sizeof(locname
)) {
339 fprintf(stderr
, "%s%s: name exceeds %ld char\n",
340 locname
, dp
->d_name
, (long)sizeof(locname
) - 1);
342 (void) strncat(locname
, dp
->d_name
, (int)dp
->d_namlen
);
343 treescan(locname
, dp
->d_ino
, todo
);
344 rst_seekdir(dirp
, bpt
, itp
->t_seekpt
);
346 dp
= rst_readdir(dirp
);
347 bpt
= rst_telldir(dirp
);
352 * Lookup a pathname which is always assumed to start from the ROOTINO.
355 pathsearch(const char *pathname
)
359 char *path
, *name
, buffer
[MAXPATHLEN
];
361 strcpy(buffer
, pathname
);
368 while ((name
= strsep(&path
, "/")) != NULL
&& *name
/* != NULL */) {
370 while ((name
= strtok_r(NULL
, "/", &path
)) != NULL
&& *name
/* != NULL */) {
372 if ((dp
= searchdir(ino
, name
)) == NULL
)
380 * Lookup the requested name in directory inum.
381 * Return its inode number if found, zero if it does not exist.
383 static struct direct
*
384 searchdir(dump_ino_t inum
, char *name
)
390 itp
= inotablookup(inum
);
393 rst_seekdir(dirp
, itp
->t_seekpt
, itp
->t_seekpt
);
396 dp
= rst_readdir(dirp
);
399 } while (dp
->d_namlen
!= len
|| strncmp(dp
->d_name
, name
, len
) != 0);
404 * Put the directory entries in the directory file
407 putdir(char *buf
, size_t size
)
409 struct direct cvtbuf
;
411 struct odirect
*eodp
;
415 if (cvtflag
&& !ufs2flag
) {
416 eodp
= (struct odirect
*)&buf
[size
];
417 for (odp
= (struct odirect
*)buf
; odp
< eodp
; odp
++)
418 if (odp
->d_ino
!= 0) {
423 for (loc
= 0; loc
< (long)size
; ) {
424 dp
= (struct direct
*)(buf
+ loc
);
426 printf ("reclen = %d, namlen = %d, type = %d\n",
427 dp
->d_reclen
, dp
->d_namlen
, dp
->d_type
);
430 swabst((u_char
*)"is", (u_char
*) dp
);
431 if (oldinofmt
&& dp
->d_ino
!= 0) {
432 # if BYTE_ORDER == BIG_ENDIAN
434 dp
->d_namlen
= dp
->d_type
;
437 dp
->d_namlen
= dp
->d_type
;
439 if (dp
->d_namlen
== 0 && dp
->d_type
!= 0)
440 dp
->d_namlen
= dp
->d_type
;
441 dp
->d_type
= DT_UNKNOWN
;
444 printf ("reclen = %d, namlen = %d, type = %d\n",
445 dp
->d_reclen
, dp
->d_namlen
, dp
->d_type
);
447 i
= DIRBLKSIZ
- (loc
& (DIRBLKSIZ
- 1));
448 if ((dp
->d_reclen
& 0x3) != 0 ||
450 dp
->d_reclen
< DIRSIZ(0, dp
)
452 || dp
->d_namlen
> MAXNAMLEN
455 Vprintf(stdout
, "Mangled directory: ");
456 if ((dp
->d_reclen
& 0x3) != 0)
458 "reclen not multiple of 4 ");
459 if (dp
->d_reclen
< DIRSIZ(0, dp
))
461 "reclen less than DIRSIZ (%d < %d) ",
462 dp
->d_reclen
, DIRSIZ(0, dp
));
464 if (dp
->d_namlen
> MAXNAMLEN
)
466 "reclen name too big (%d > %d) ",
467 dp
->d_namlen
, MAXNAMLEN
);
469 Vprintf(stdout
, "\n");
474 if (dp
->d_ino
!= 0) {
482 * These variables are "local" to the following two functions.
484 static char dirbuf
[DIRBLKSIZ
];
485 static long dirloc
= 0;
486 static long prev
= 0;
489 * add a new directory entry to a file.
492 putent(struct direct
*dp
)
494 dp
->d_reclen
= DIRSIZ(0, dp
);
495 if (dirloc
+ dp
->d_reclen
> DIRBLKSIZ
) {
496 ((struct direct
*)(dirbuf
+ prev
))->d_reclen
=
498 if ( fwrite(dirbuf
, DIRBLKSIZ
, 1, df
) != 1 )
499 err(1,"cannot write to file %s", dirfile
);
502 memmove(dirbuf
+ dirloc
, dp
, (size_t)dp
->d_reclen
);
504 dirloc
+= dp
->d_reclen
;
508 * flush out a directory that is finished.
513 ((struct direct
*)(dirbuf
+ prev
))->d_reclen
= DIRBLKSIZ
- prev
;
514 if ( fwrite(dirbuf
, (int)dirloc
, 1, df
) != 1 )
515 err(1, "cannot write to file %s", dirfile
);
518 err(1, "cannot write to file %s", dirfile
);
523 dcvt(struct odirect
*odp
, struct direct
*ndp
)
526 memset(ndp
, 0, (size_t)(sizeof *ndp
));
527 ndp
->d_ino
= odp
->d_ino
;
528 ndp
->d_type
= DT_UNKNOWN
;
529 (void) strncpy(ndp
->d_name
, odp
->d_name
, ODIRSIZ
);
530 ndp
->d_namlen
= strlen(ndp
->d_name
);
531 ndp
->d_reclen
= DIRSIZ(0, ndp
);
535 * Seek to an entry in a directory.
536 * Only values returned by rst_telldir should be passed to rst_seekdir.
537 * This routine handles many directories in a single file.
538 * It takes the base of the directory in the file, plus
539 * the desired seek offset into it.
542 rst_seekdir(RST_DIR
*dirp
, OFF_T loc
, OFF_T base
)
545 if (loc
== rst_telldir(dirp
))
549 fprintf(stderr
, "bad seek pointer to rst_seekdir %lld\n", (long long int)loc
);
550 (void) LSEEK(dirp
->dd_fd
, base
+ (loc
& ~(DIRBLKSIZ
- 1)), SEEK_SET
);
551 dirp
->dd_loc
= loc
& (DIRBLKSIZ
- 1);
552 if (dirp
->dd_loc
!= 0)
553 dirp
->dd_size
= read(dirp
->dd_fd
, dirp
->dd_buf
, DIRBLKSIZ
);
557 * get next entry in a directory.
560 rst_readdir(RST_DIR
*dirp
)
565 if (dirp
->dd_loc
== 0) {
566 dirp
->dd_size
= read(dirp
->dd_fd
, dirp
->dd_buf
,
568 if (dirp
->dd_size
<= 0) {
569 Dprintf(stderr
, "error reading directory\n");
573 if (dirp
->dd_loc
>= dirp
->dd_size
) {
577 dp
= (struct direct
*)(dirp
->dd_buf
+ dirp
->dd_loc
);
578 if (dp
->d_reclen
== 0 ||
579 dp
->d_reclen
> DIRBLKSIZ
+ 1 - dirp
->dd_loc
) {
580 Dprintf(stderr
, "corrupted directory: bad reclen %d\n",
584 dirp
->dd_loc
+= dp
->d_reclen
;
585 if (dp
->d_ino
== 0 && strcmp(dp
->d_name
, "/") == 0)
587 if (dp
->d_ino
>= maxino
) {
588 Dprintf(stderr
, "corrupted directory: bad inum %d\n",
597 * Simulate the opening of a directory
600 rst_opendir(const char *name
)
606 if ((ino
= dirlookup(name
)) > 0 &&
607 (itp
= inotablookup(ino
)) != NULL
) {
608 dirp
= opendirfile(dirfile
);
609 rst_seekdir(dirp
, itp
->t_seekpt
, itp
->t_seekpt
);
616 * In our case, there is nothing to do when closing a directory.
619 rst_closedir(RST_DIR
*dirp
)
622 (void)close(dirp
->dd_fd
);
628 * Simulate finding the current offset in the directory.
631 rst_telldir(RST_DIR
*dirp
)
633 return ((OFF_T
)LSEEK(dirp
->dd_fd
,
634 (OFF_T
)0, SEEK_CUR
) - dirp
->dd_size
+ dirp
->dd_loc
);
638 * Open a directory file.
641 opendirfile(const char *name
)
646 if ((fd
= OPEN(name
, O_RDONLY
)) == -1)
648 if ((dirp
= malloc(sizeof(RST_DIR
))) == NULL
) {
658 * Set the mode, owner, and times for all new or changed directories
661 setdirmodes(int flags
)
664 struct modeinfo node
;
668 Vprintf(stdout
, "Set directory mode, owner, and times.\n");
669 if (command
== 'r' || command
== 'R')
670 (void) snprintf(modefile
, sizeof(modefile
), "%s/rstmode%lu", tmpdir
, (long)dumpdate
);
671 if (modefile
[0] == '#') {
672 panic("modefile not defined\n");
673 fprintf(stderr
, "directory mode, owner, and times not set\n");
676 mf
= FOPEN(modefile
, "r");
679 fprintf(stderr
, "cannot open mode file %s\n", modefile
);
680 fprintf(stderr
, "directory mode, owner, and times not set\n");
685 char xattr
[XATTR_MAXSIZE
];
686 if (fread((char *)&node
, sizeof(struct modeinfo
), 1, mf
) != 1) {
692 if (fread(xattr
, XATTR_MAXSIZE
, 1, mf
) != 1) {
698 ep
= lookupino(node
.ino
);
699 if (command
== 'i' || command
== 'x') {
702 if ((flags
& FORCE
) == 0 && ep
->e_flags
& EXISTED
) {
706 if ((flags
& FORCE
) == 0 &&
707 node
.ino
== ROOTINO
&&
708 reply("set owner/mode for '.'") == FAIL
)
712 panic("cannot find directory inode %d\n", node
.ino
);
715 if (chown(cp
, node
.uid
, node
.gid
) < 0)
717 (void) chmod(cp
, node
.mode
);
718 utimes(cp
, node
.timep
);
720 xattr_extract(cp
, xattr
);
724 (void) lsetflags(cp
, node
.flags
);
728 (void) chflags(cp
, node
.flags
);
734 panic("error setting directory modes\n");
739 * In restore -C mode, tests the attributes for all directories
742 comparedirmodes(void)
745 struct modeinfo node
;
749 Vprintf(stdout
, "Compare directories modes, owner, attributes.\n");
750 if (modefile
[0] == '#') {
751 panic("modefile not defined\n");
752 fprintf(stderr
, "directory mode, owner, and times not set\n");
755 mf
= FOPEN(modefile
, "r");
758 fprintf(stderr
, "cannot open mode file %s\n", modefile
);
759 fprintf(stderr
, "directory mode, owner, and times not set\n");
764 char xattr
[XATTR_MAXSIZE
];
765 if (fread((char *)&node
, sizeof(struct modeinfo
), 1, mf
) != 1) {
771 if (fread(xattr
, XATTR_MAXSIZE
, 1, mf
) != 1) {
777 ep
= lookupino(node
.ino
);
779 panic("cannot find directory inode %d\n", node
.ino
);
782 unsigned long newflags
;
785 if (LSTAT(cp
, &sb
) < 0) {
786 warn("unable to stat %s", cp
);
791 Vprintf(stdout
, "comparing directory %s\n", cp
);
793 if (sb
.st_mode
!= node
.mode
) {
794 fprintf(stderr
, "%s: mode changed from 0%o to 0%o.\n",
795 cp
, node
.mode
& 07777, sb
.st_mode
& 07777);
798 if (sb
.st_uid
!= node
.uid
) {
799 fprintf(stderr
, "%s: uid changed from %d to %d.\n",
800 cp
, node
.uid
, sb
.st_uid
);
803 if (sb
.st_gid
!= node
.gid
) {
804 fprintf(stderr
, "%s: gid changed from %d to %d.\n",
805 cp
, node
.gid
, sb
.st_gid
);
809 if (lgetflags(cp
, &newflags
) < 0) {
810 if (node
.flags
!= 0) {
811 warn("%s: lgetflags failed", cp
);
816 if (newflags
!= node
.flags
) {
817 fprintf(stderr
, "%s: flags changed from 0x%08x to 0x%08lx.\n",
818 cp
, node
.flags
, newflags
);
824 if (xattr_compare(cp
, xattr
) == FAIL
)
828 if (xattr_compare(cp
, NULL
) == FAIL
)
835 panic("error setting directory modes\n");
840 * Generate a literal copy of a directory.
843 genliteraldir(char *name
, dump_ino_t ino
)
846 int ofile
, dp
, i
, size
;
849 itp
= inotablookup(ino
);
851 panic("Cannot find directory inode %d named %s\n", ino
, name
);
852 if ((ofile
= open(name
, O_WRONLY
| O_CREAT
| O_TRUNC
, 0666)) < 0) {
853 warn("%s: cannot create file\n", name
);
856 rst_seekdir(dirp
, itp
->t_seekpt
, itp
->t_seekpt
);
857 dp
= dup(dirp
->dd_fd
);
858 for (i
= itp
->t_size
; i
> 0; i
-= BUFSIZ
) {
859 size
= i
< BUFSIZ
? i
: BUFSIZ
;
860 if (read(dp
, buf
, (int) size
) == -1) {
861 warnx("write error extracting inode %lu, name %s\n",
862 (unsigned long)curfile
.ino
, curfile
.name
);
865 if (!Nflag
&& write(ofile
, buf
, (int) size
) == -1) {
866 warnx("write error extracting inode %lu, name %s\n",
867 (unsigned long)curfile
.ino
, curfile
.name
);
877 * Determine the type of an inode
880 inodetype(dump_ino_t ino
)
884 itp
= inotablookup(ino
);
891 * Allocate and initialize a directory inode entry.
892 * If requested, save its pertinent mode, owner, and time info.
894 static struct inotab
*
895 #if defined(__linux__) || defined(sunos)
896 allocinotab(dump_ino_t ino
, OFF_T seekpt
)
898 allocinotab(dump_ino_t ino
, OFF_T seekpt
)
903 itp
= calloc(1, sizeof(struct inotab
));
905 panic("no memory directory table\n");
906 itp
->t_next
= inotab
[INOHASH(ino
)];
907 inotab
[INOHASH(ino
)] = itp
;
909 itp
->t_seekpt
= seekpt
;
914 #if defined(__linux__) || defined(sunos)
915 savemodeinfo(dump_ino_t ino
, struct new_bsd_inode
*dip
, char *xattr
) {
917 savemodeinfo(dump_ino_t ino
, struct dinode
*dip
, char *xattr
) {
919 struct modeinfo node
;
924 #if defined(__linux__) || defined(sunos)
925 node
.timep
[0].tv_sec
= dip
->di_atime
.tv_sec
;
926 node
.timep
[0].tv_usec
= dip
->di_atime
.tv_usec
;
927 node
.timep
[1].tv_sec
= dip
->di_mtime
.tv_sec
;
928 node
.timep
[1].tv_usec
= dip
->di_mtime
.tv_usec
;
929 #else /* __linux__ || sunos */
930 node
.timep
[0].tv_sec
= dip
->di_atime
;
931 node
.timep
[0].tv_usec
= dip
->di_atimensec
/ 1000;
932 node
.timep
[1].tv_sec
= dip
->di_mtime
;
933 node
.timep
[1].tv_usec
= dip
->di_mtimensec
/ 1000;
934 #endif /* __linux__ || sunos */
935 node
.mode
= dip
->di_mode
;
936 node
.flags
= dip
->di_flags
;
937 node
.uid
= dip
->di_uid
;
938 node
.gid
= dip
->di_gid
;
939 node
.xattr
= xattr
? 1 : 0;
940 if ( fwrite((char *)&node
, sizeof(struct modeinfo
), 1, mf
) != 1 )
941 err(1,"cannot write to file %s", modefile
);
943 if ( fwrite(xattr
, XATTR_MAXSIZE
, 1, mf
) != 1 )
944 err(1,"cannot write to file %s", modefile
);
948 * Look up an inode in the table of directories
950 static struct inotab
*
951 inotablookup(dump_ino_t ino
)
955 for (itp
= inotab
[INOHASH(ino
)]; itp
!= NULL
; itp
= itp
->t_next
)
956 if (itp
->t_ino
== ino
)
968 if (modefile
[0] != '#')
969 (void) unlink(modefile
);
970 if (dirfile
[0] != '#')
971 (void) unlink(dirfile
);