Deleted Added
sdiff udiff text old ( 18406 ) new ( 21149 )
full compact
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 90 unchanged lines hidden (view full) ---

99};
100
101/*
102 * Global variables for this file.
103 */
104static long seekpt;
105static FILE *df, *mf;
106static RST_DIR *dirp;
107static char dirfile[MAXPATHLEN] = "#"; /* No file */
108static char modefile[MAXPATHLEN] = "#"; /* No file */
109static char dot[2] = "."; /* So it can be modified */
110
111/*
112 * Format of old style directories.
113 */
114#define ODIRSIZ 14
115struct odirect {
116 u_short d_ino;
117 char d_name[ODIRSIZ];

--- 19 unchanged lines hidden (view full) ---

137void
138extractdirs(genmode)
139 int genmode;
140{
141 register int i;
142 register struct dinode *ip;
143 struct inotab *itp;
144 struct direct nulldir;
145 int fd;
146
147 vprintf(stdout, "Extract directories from tape\n");
148 (void) sprintf(dirfile, "%srstdir%d", _PATH_TMP, dumpdate);
149 if (command != 'r' && command != 'R') {
150 (void *) strcat(dirfile, "-XXXXXX");
151 fd = mkstemp(dirfile);
152 } else
153 fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666);
154 if (fd == -1 || (df = fdopen(fd, "w")) == NULL) {
155 if (fd != -1)
156 close(fd);
157 fprintf(stderr,
158 "restore: %s - cannot create directory temporary\n",
159 dirfile);
160 fprintf(stderr, "fopen: %s\n", strerror(errno));
161 done(1);
162 }
163 if (genmode != 0) {
164 (void) sprintf(modefile, "%srstmode%d", _PATH_TMP, dumpdate);
165 if (command != 'r' && command != 'R') {
166 (void *) strcat(modefile, "-XXXXXX");
167 fd = mkstemp(modefile);
168 } else
169 fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666);
170 if (fd == -1 || (mf = fdopen(fd, "w")) == NULL) {
171 if (fd != -1)
172 close(fd);
173 fprintf(stderr,
174 "restore: %s - cannot create modefile \n",
175 modefile);
176 fprintf(stderr, "fopen: %s\n", strerror(errno));
177 done(1);
178 }
179 }
180 nulldir.d_ino = 0;

--- 66 unchanged lines hidden (view full) ---

247 * Pname is a dumped directory name.
248 */
249 if ((*todo)(pname, ino, NODE) == FAIL)
250 return;
251 /*
252 * begin search through the directory
253 * skipping over "." and ".."
254 */
255 (void) strncpy(locname, pname, sizeof(locname) - 1);
256 locname[sizeof(locname) - 1] = '\0';
257 (void) strncat(locname, "/", sizeof(locname) - strlen(locname));
258 namelen = strlen(locname);
259 rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
260 dp = rst_readdir(dirp); /* "." */
261 if (dp != NULL && strcmp(dp->d_name, ".") == 0)
262 dp = rst_readdir(dirp); /* ".." */
263 else
264 fprintf(stderr, "Warning: `.' missing from directory %s\n",
265 pname);
266 if (dp != NULL && strcmp(dp->d_name, "..") == 0)
267 dp = rst_readdir(dirp); /* first real entry */
268 else
269 fprintf(stderr, "Warning: `..' missing from directory %s\n",
270 pname);
271 bpt = rst_telldir(dirp);
272 /*
273 * a zero inode signals end of directory
274 */
275 while (dp != NULL && dp->d_ino != 0) {
276 locname[namelen] = '\0';
277 if (namelen + dp->d_namlen >= sizeof(locname)) {
278 fprintf(stderr, "%s%s: name exceeds %d char\n",
279 locname, dp->d_name, sizeof(locname) - 1);
280 } else {
281 (void) strncat(locname, dp->d_name, (int)dp->d_namlen);
282 treescan(locname, dp->d_ino, todo);
283 rst_seekdir(dirp, bpt, itp->t_seekpt);
284 }
285 dp = rst_readdir(dirp);
286 bpt = rst_telldir(dirp);
287 }

--- 306 unchanged lines hidden (view full) ---

594 int flags;
595{
596 FILE *mf;
597 struct modeinfo node;
598 struct entry *ep;
599 char *cp;
600
601 vprintf(stdout, "Set directory mode, owner, and times.\n");
602 if (command == 'r' || command == 'R')
603 (void) sprintf(modefile, "%srstmode%d", _PATH_TMP, dumpdate);
604 if (modefile[0] == '#') {
605 panic("modefile not defined\n");
606 fprintf(stderr, "directory mode, owner, and times not set\n");
607 return;
608 }
609 mf = fopen(modefile, "r");
610 if (mf == NULL) {
611 fprintf(stderr, "fopen: %s\n", strerror(errno));
612 fprintf(stderr, "cannot open mode file %s\n", modefile);
613 fprintf(stderr, "directory mode, owner, and times not set\n");
614 return;
615 }
616 clearerr(mf);

--- 38 unchanged lines hidden (view full) ---

655{
656 register struct inotab *itp;
657 int ofile, dp, i, size;
658 char buf[BUFSIZ];
659
660 itp = inotablookup(ino);
661 if (itp == NULL)
662 panic("Cannot find directory inode %d named %s\n", ino, name);
663 if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
664 fprintf(stderr, "%s: ", name);
665 (void) fflush(stderr);
666 fprintf(stderr, "cannot create file: %s\n", strerror(errno));
667 return (FAIL);
668 }
669 rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt);
670 dp = dup(dirp->dd_fd);
671 for (i = itp->t_size; i > 0; i -= BUFSIZ) {

--- 100 unchanged lines hidden ---