Deleted Added
full compact
main.c (128073) main.c (128175)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

33 The Regents of the University of California. All rights reserved.\n";
34#endif /* not lint */
35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95";
39#endif
40static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

33 The Regents of the University of California. All rights reserved.\n";
34#endif /* not lint */
35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95";
39#endif
40static const char rcsid[] =
41 "$FreeBSD: head/sbin/restore/main.c 128073 2004-04-09 19:58:40Z markm $";
41 "$FreeBSD: head/sbin/restore/main.c 128175 2004-04-13 02:58:06Z green $";
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/stat.h>
46
47#include <ufs/ufs/dinode.h>
48#include <protocols/dumprestore.h>
49

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

57#include <unistd.h>
58
59#include "restore.h"
60#include "extern.h"
61
62int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
63int hflag = 1, mflag = 1, Nflag = 0;
64int uflag = 0;
42#endif /* not lint */
43
44#include <sys/param.h>
45#include <sys/stat.h>
46
47#include <ufs/ufs/dinode.h>
48#include <protocols/dumprestore.h>
49

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

57#include <unistd.h>
58
59#include "restore.h"
60#include "extern.h"
61
62int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
63int hflag = 1, mflag = 1, Nflag = 0;
64int uflag = 0;
65int pipecmd = 0;
65char command = '\0';
66long dumpnum = 1;
67long volno = 0;
68long ntrec;
69char *dumpmap;
70char *usedinomap;
71ino_t maxino;
72time_t dumptime;

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

88 /* Temp files should *not* be readable. We set permissions later. */
89 (void) umask(077);
90
91 if (argc < 2)
92 usage();
93
94 (void)setlocale(LC_ALL, "");
95
66char command = '\0';
67long dumpnum = 1;
68long volno = 0;
69long ntrec;
70char *dumpmap;
71char *usedinomap;
72ino_t maxino;
73time_t dumptime;

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

89 /* Temp files should *not* be readable. We set permissions later. */
90 (void) umask(077);
91
92 if (argc < 2)
93 usage();
94
95 (void)setlocale(LC_ALL, "");
96
96 if ((inputdev = getenv("TAPE")) == NULL)
97 inputdev = _PATH_DEFTAPE;
97 inputdev = NULL;
98 obsolete(&argc, &argv);
98 obsolete(&argc, &argv);
99 while ((ch = getopt(argc, argv, "b:df:himNRrs:tuvxy")) != -1)
99 while ((ch = getopt(argc, argv, "b:df:himNP:Rrs:tuvxy")) != -1)
100 switch(ch) {
101 case 'b':
102 /* Change default tape blocksize. */
103 bflag = 1;
104 ntrec = strtol(optarg, &p, 10);
105 if (*p)
106 errx(1, "illegal blocksize -- %s", optarg);
107 if (ntrec <= 0)
108 errx(1, "block size must be greater than 0");
109 break;
110 case 'd':
111 dflag = 1;
112 break;
113 case 'f':
100 switch(ch) {
101 case 'b':
102 /* Change default tape blocksize. */
103 bflag = 1;
104 ntrec = strtol(optarg, &p, 10);
105 if (*p)
106 errx(1, "illegal blocksize -- %s", optarg);
107 if (ntrec <= 0)
108 errx(1, "block size must be greater than 0");
109 break;
110 case 'd':
111 dflag = 1;
112 break;
113 case 'f':
114 if (pipecmd)
115 errx(1,
116 "-P and -f options are mutually exclusive");
114 inputdev = optarg;
115 break;
117 inputdev = optarg;
118 break;
119 case 'P':
120 if (!pipecmd && inputdev)
121 errx(1,
122 "-P and -f options are mutually exclusive");
123 inputdev = optarg;
124 pipecmd = 1;
125 break;
116 case 'h':
117 hflag = 0;
118 break;
119 case 'i':
120 case 'R':
121 case 'r':
122 case 't':
123 case 'x':

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

160 errx(1, "none of i, R, r, t or x options specified");
161
162 if (signal(SIGINT, onintr) == SIG_IGN)
163 (void) signal(SIGINT, SIG_IGN);
164 if (signal(SIGTERM, onintr) == SIG_IGN)
165 (void) signal(SIGTERM, SIG_IGN);
166 setlinebuf(stderr);
167
126 case 'h':
127 hflag = 0;
128 break;
129 case 'i':
130 case 'R':
131 case 'r':
132 case 't':
133 case 'x':

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

170 errx(1, "none of i, R, r, t or x options specified");
171
172 if (signal(SIGINT, onintr) == SIG_IGN)
173 (void) signal(SIGINT, SIG_IGN);
174 if (signal(SIGTERM, onintr) == SIG_IGN)
175 (void) signal(SIGTERM, SIG_IGN);
176 setlinebuf(stderr);
177
168 setinput(inputdev);
178 if (inputdev == NULL && (inputdev = getenv("TAPE")) == NULL)
179 inputdev = _PATH_DEFTAPE;
180 setinput(inputdev, pipecmd);
169
170 if (argc == 0) {
171 argc = 1;
172 *--argv = ".";
173 }
174
175 switch (command) {
176 /*

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

272 }
273 done(0);
274 /* NOTREACHED */
275}
276
277static void
278usage()
279{
181
182 if (argc == 0) {
183 argc = 1;
184 *--argv = ".";
185 }
186
187 switch (command) {
188 /*

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

284 }
285 done(0);
286 /* NOTREACHED */
287}
288
289static void
290usage()
291{
280 (void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
281 "restore -i [-cdhmNuvy] [-b blocksize] [-f file] [-s fileno]",
282 "restore -r [-cdNuvy] [-b blocksize] [-f file] [-s fileno]",
283 "restore -R [-cdNuvy] [-b blocksize] [-f file] [-s fileno]",
284 "restore -x [-cdhmNuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
285 "restore -t [-cdhNuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
292 const char *const common =
293 "[-b blocksize] [-P pipecmd | -f file] [-s fileno]";
294 const char *const fileell = "[file ...]";
295
296 (void)fprintf(stderr, "usage:\t%s %s\n\t%s %s\n\t%s %s\n"
297 "\t%s %s %s\n\t%s %s %s\n",
298 "restore -i [-cdhmNuvy]", common,
299 "restore -r [-cdNuvy]", common,
300 "restore -R [-cdNuvy]", common,
301 "restore -x [-cdhmNuvy]", common, fileell,
302 "restore -t [-cdhNuvy]", common, fileell);
286 done(1);
287}
288
289/*
290 * obsolete --
291 * Change set of key letters and ordered arguments into something
292 * getopt(3) will like.
293 */

--- 62 unchanged lines hidden ---
303 done(1);
304}
305
306/*
307 * obsolete --
308 * Change set of key letters and ordered arguments into something
309 * getopt(3) will like.
310 */

--- 62 unchanged lines hidden ---