| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
2 |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
#include "config.h" |
| 39 |
#include "optr.h" |
| 40 |
|
| 41 |
#include <sys/param.h> |
| 42 |
#include <sys/wait.h> |
| 43 |
#include <time.h> |
| 44 |
|
| 45 |
#include <errno.h> |
| 46 |
#include <mntent.h> |
| 47 |
#include <paths.h> |
| 48 |
#include <grp.h> |
| 49 |
#include <stdbool.h> |
| 50 |
#include <stdio.h> |
| 51 |
#include <stdlib.h> |
| 52 |
#include <string.h> |
| 53 |
#include <stdarg.h> |
| 54 |
#include <unistd.h> |
| 55 |
#include <utmp.h> |
| 56 |
#include <sys/stat.h> |
| 57 |
#include <stdint.h> |
| 58 |
|
| 59 |
#include "compat/include/bsdcompat.h" |
| 60 |
#include <signal.h> |
| 61 |
|
| 62 |
#include "main.h" |
| 63 |
#include "tape.h" |
| 64 |
#include "traverse.h" |
| 65 |
#include "itime.h" |
| 66 |
#include "compat/include/bylabel.h" |
| 67 |
|
| 68 |
#include "dump_globals.h" |
| 69 |
|
| 70 |
static void alarmcatch (int); |
| 71 |
int datesort (const void *, const void *); |
| 72 |
static void sendmes (const char *, const char *); |
| 73 |
|
| 74 |
|
| 75 |
static const struct Fstypes { |
| 76 |
const char* type; |
| 77 |
int isfuse; |
| 78 |
} fstypes[] = { |
| 79 |
{"ext2", 0}, |
| 80 |
{"ext3", 0}, |
| 81 |
{"ext4", 0}, |
| 82 |
{"fuse.ext4", 1}, |
| 83 |
{"InterMezzo", 0}, |
| 84 |
{NULL, 0} |
| 85 |
}; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
static int timeout; |
| 99 |
static const char *attnmessage; |
| 100 |
|
| 101 |
int |
| 102 |
query(const char *question) |
| 103 |
{ |
| 104 |
char replybuffer[64]; |
| 105 |
int back, errcount; |
| 106 |
FILE *mytty; |
| 107 |
time_t firstprompt, when_answered; |
| 108 |
|
| 109 |
if (qflag) { |
| 110 |
msg("%s - forced abort\n", question); |
| 111 |
dumpabort(0); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
firstprompt = time(NULL); |
| 116 |
|
| 117 |
if ((mytty = fopen(_PATH_TTY, "r")) == NULL) |
| 118 |
quit("fopen on %s fails: %s\n", _PATH_TTY, strerror(errno)); |
| 119 |
attnmessage = question; |
| 120 |
timeout = 0; |
| 121 |
alarmcatch(0); |
| 122 |
back = -1; |
| 123 |
errcount = 0; |
| 124 |
do { |
| 125 |
if (fgets(replybuffer, 63, mytty) == NULL) { |
| 126 |
clearerr(mytty); |
| 127 |
if (++errcount > 30) |
| 128 |
quit("excessive operator query failures\n"); |
| 129 |
} else if (replybuffer[0] == 'y' || replybuffer[0] == 'Y') { |
| 130 |
back = 1; |
| 131 |
} else if (replybuffer[0] == 'n' || replybuffer[0] == 'N') { |
| 132 |
back = 0; |
| 133 |
} else { |
| 134 |
(void) fprintf(stderr, |
| 135 |
" DUMP: \"Yes\" or \"No\"?\n"); |
| 136 |
(void) fprintf(stderr, |
| 137 |
" DUMP: %s: (\"yes\" or \"no\") ", question); |
| 138 |
} |
| 139 |
} while (back < 0); |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
(void) alarm(0); |
| 145 |
if (signal(SIGALRM, sig) == SIG_IGN) |
| 146 |
signal(SIGALRM, SIG_IGN); |
| 147 |
(void) fclose(mytty); |
| 148 |
when_answered = time(NULL); |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
if (tstart_writing != 0) |
| 154 |
tstart_writing += (when_answered - firstprompt); |
| 155 |
return(back); |
| 156 |
} |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
static void |
| 163 |
alarmcatch(UNUSED(int signo)) |
| 164 |
{ |
| 165 |
int save_errno = errno; |
| 166 |
if (notify == 0) { |
| 167 |
if (timeout == 0) |
| 168 |
(void) fprintf(stderr, |
| 169 |
" DUMP: %s: (\"yes\" or \"no\") ", |
| 170 |
attnmessage); |
| 171 |
else |
| 172 |
msgtail("\7\7"); |
| 173 |
} else { |
| 174 |
if (timeout) { |
| 175 |
msgtail("\n"); |
| 176 |
broadcast(""); |
| 177 |
} |
| 178 |
(void) fprintf(stderr," DUMP: %s: (\"yes\" or \"no\") ", |
| 179 |
attnmessage); |
| 180 |
} |
| 181 |
signal(SIGALRM, alarmcatch); |
| 182 |
(void) alarm(120); |
| 183 |
timeout = 1; |
| 184 |
errno = save_errno; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
void |
| 191 |
interrupt(UNUSED(int signo)) |
| 192 |
{ |
| 193 |
msg("Interrupt received.\n"); |
| 194 |
if (query("Do you want to abort dump?")) |
| 195 |
dumpabort(0); |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
static struct group *gp; |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
void |
| 209 |
set_operators(void) |
| 210 |
{ |
| 211 |
if (!notify) |
| 212 |
return; |
| 213 |
gp = getgrnam(OPGRENT); |
| 214 |
(void) endgrent(); |
| 215 |
if (gp == NULL) { |
| 216 |
msg("No group entry for %s.\n", OPGRENT); |
| 217 |
notify = 0; |
| 218 |
return; |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
static struct tm *localclock; |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
void |
| 229 |
broadcast(const char *message) |
| 230 |
{ |
| 231 |
time_t clock; |
| 232 |
FILE *f_utmp; |
| 233 |
struct utmp utmp; |
| 234 |
char **np; |
| 235 |
int pid, s; |
| 236 |
|
| 237 |
if (!notify || gp == NULL) |
| 238 |
return; |
| 239 |
|
| 240 |
switch (pid = fork()) { |
| 241 |
case -1: |
| 242 |
return; |
| 243 |
case 0: |
| 244 |
break; |
| 245 |
default: |
| 246 |
while (wait(&s) != pid) |
| 247 |
continue; |
| 248 |
return; |
| 249 |
} |
| 250 |
|
| 251 |
clock = time(NULL); |
| 252 |
localclock = localtime(&clock); |
| 253 |
|
| 254 |
if ((f_utmp = fopen(_PATH_UTMP, "r")) == NULL) { |
| 255 |
msg("Cannot open %s: %s\n", _PATH_UTMP, strerror(errno)); |
| 256 |
return; |
| 257 |
} |
| 258 |
|
| 259 |
while (!feof(f_utmp)) { |
| 260 |
if (fread((char *) &utmp, sizeof (struct utmp), 1, f_utmp) != 1) |
| 261 |
break; |
| 262 |
if (utmp.ut_name[0] == 0) |
| 263 |
continue; |
| 264 |
for (np = gp->gr_mem; *np; np++) { |
| 265 |
if (strncmp(*np, utmp.ut_name, sizeof(utmp.ut_name)) != 0) |
| 266 |
continue; |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
if (strncmp(utmp.ut_line, DIALUP, strlen(DIALUP)) == 0) |
| 271 |
continue; |
| 272 |
#ifdef DEBUG |
| 273 |
msg("Message to %s at %s\n", *np, utmp.ut_line); |
| 274 |
#endif |
| 275 |
sendmes(utmp.ut_line, message); |
| 276 |
} |
| 277 |
} |
| 278 |
(void) fclose(f_utmp); |
| 279 |
Exit(0); |
| 280 |
} |
| 281 |
|
| 282 |
static void |
| 283 |
sendmes(const char *tty, const char *message) |
| 284 |
{ |
| 285 |
char t[MAXPATHLEN], buf[BUFSIZ]; |
| 286 |
const char *cp; |
| 287 |
int lmsg = 1; |
| 288 |
FILE *f_tty; |
| 289 |
|
| 290 |
(void) strcpy(t, _PATH_DEV); |
| 291 |
(void) strncat(t, tty, sizeof t - strlen(_PATH_DEV) - 1); |
| 292 |
|
| 293 |
if ((f_tty = fopen(t, "w")) != NULL) { |
| 294 |
setbuf(f_tty, buf); |
| 295 |
(void) fprintf(f_tty, |
| 296 |
"\n\ |
| 297 |
\7\7\7Message from the dump program to all operators at %d:%02d ...\r\n\n\ |
| 298 |
DUMP: NEEDS ATTENTION: ", |
| 299 |
localclock->tm_hour, localclock->tm_min); |
| 300 |
for (cp = lastmsg; ; cp++) { |
| 301 |
if (*cp == '\0') { |
| 302 |
if (lmsg) { |
| 303 |
cp = message; |
| 304 |
if (!(cp && *cp != '\0')) |
| 305 |
break; |
| 306 |
lmsg = 0; |
| 307 |
} else |
| 308 |
break; |
| 309 |
} |
| 310 |
if (*cp == '\n') |
| 311 |
(void) putc('\r', f_tty); |
| 312 |
(void) putc(*cp, f_tty); |
| 313 |
} |
| 314 |
(void) fclose(f_tty); |
| 315 |
} |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
static time_t tschedule = 0; |
| 323 |
|
| 324 |
void |
| 325 |
timeest(void) |
| 326 |
{ |
| 327 |
time_t tnow = time(NULL); |
| 328 |
|
| 329 |
if (tnow >= tschedule) { |
| 330 |
char *buf = mktimeest(tnow); |
| 331 |
tschedule = tnow + 300; |
| 332 |
if (buf) { |
| 333 |
fprintf(stderr, " DUMP: "); |
| 334 |
fwrite(buf, strlen(buf), 1, stderr); |
| 335 |
fflush(stderr); |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 340 |
void |
| 341 |
quit(const char *fmt, ...) |
| 342 |
{ |
| 343 |
va_list ap; |
| 344 |
|
| 345 |
(void) fprintf(stderr," DUMP: "); |
| 346 |
Dmsg(TDEBUG, "pid=%d ", getpid()); |
| 347 |
va_start(ap, fmt); |
| 348 |
(void) vfprintf(stderr, fmt, ap); |
| 349 |
va_end(ap); |
| 350 |
(void) fflush(stdout); |
| 351 |
(void) fflush(stderr); |
| 352 |
dumpabort(0); |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
struct pfstab { |
| 361 |
struct pfstab *pf_next; |
| 362 |
struct dumpdates *pf_dd; |
| 363 |
struct mntent *pf_mntent; |
| 364 |
}; |
| 365 |
|
| 366 |
static struct pfstab *table; |
| 367 |
|
| 368 |
static void cleanup_ptr(char**p) { |
| 369 |
free(*p); |
| 370 |
} |
| 371 |
|
| 372 |
static struct mntent * |
| 373 |
allocfsent(struct mntent *fs) |
| 374 |
{ |
| 375 |
struct mntent *new; |
| 376 |
const char *disk; |
| 377 |
struct stat buf, tabbuf; |
| 378 |
struct pfstab *tabpf; |
| 379 |
struct mntent *tabfs; |
| 380 |
const struct Fstypes *type; |
| 381 |
bool known_fs; |
| 382 |
bool fuse_fs; |
| 383 |
|
| 384 |
|
| 385 |
if (fs->mnt_type == NULL) |
| 386 |
return NULL; |
| 387 |
|
| 388 |
known_fs = false; |
| 389 |
for (type = fstypes; type->type != NULL && known_fs == false; ++type) { |
| 390 |
known_fs = (strcmp(fs->mnt_type, type->type) == 0); |
| 391 |
fuse_fs = type->isfuse; |
| 392 |
} |
| 393 |
if (!known_fs) |
| 394 |
return NULL; |
| 395 |
|
| 396 |
new = (struct mntent *)malloc(sizeof (*fs)); |
| 397 |
if (new == NULL) |
| 398 |
quit("%s\n", strerror(errno)); |
| 399 |
|
| 400 |
|
| 401 |
disk = get_device_name(fs->mnt_fsname); |
| 402 |
if (disk == NULL) |
| 403 |
disk = strdup(fs->mnt_fsname); |
| 404 |
|
| 405 |
|
| 406 |
if (stat(disk, &buf) != 0 || (!fuse_fs && !S_ISBLK(buf.st_mode)) || (fuse_fs && !S_ISREG(buf.st_mode))) { |
| 407 |
free(new); |
| 408 |
free((char*)(uintptr_t)disk); |
| 409 |
return NULL; |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
for (tabpf = table; tabpf != NULL; tabpf = tabpf->pf_next) { |
| 414 |
tabfs = tabpf->pf_mntent; |
| 415 |
if (stat(tabfs->mnt_fsname, &tabbuf) != 0) |
| 416 |
|
| 417 |
quit("Cannot access %s\n", tabfs->mnt_fsname); |
| 418 |
|
| 419 |
char* resolve_disk __attribute__((cleanup(cleanup_ptr))) = realpath(disk, NULL); |
| 420 |
char* resolve_dev __attribute__((cleanup(cleanup_ptr))) = realpath(tabfs->mnt_fsname, NULL); |
| 421 |
char* resolve_fs_mntdir __attribute__((cleanup(cleanup_ptr))) = realpath(fs->mnt_dir, NULL); |
| 422 |
char* resolve_tabfs_mntdir __attribute__((cleanup(cleanup_ptr))) = realpath(tabfs->mnt_dir, NULL); |
| 423 |
if (!resolve_disk || !resolve_dev || !resolve_fs_mntdir || !resolve_tabfs_mntdir) |
| 424 |
quit("%s\n", strerror(errno)); |
| 425 |
if (((tabbuf.st_rdev == buf.st_rdev && !fuse_fs) || strcmp(resolve_disk, resolve_dev) == 0) |
| 426 |
&& strcmp(resolve_fs_mntdir, resolve_tabfs_mntdir) == 0) { |
| 427 |
free(new); |
| 428 |
|
| 429 |
|
| 430 |
if (!tabfs->mnt_passno) |
| 431 |
tabfs->mnt_passno = fs->mnt_passno; |
| 432 |
if (!tabfs->mnt_freq) |
| 433 |
tabfs->mnt_freq = fs->mnt_freq; |
| 434 |
if (tabfs->mnt_freq > 3659) |
| 435 |
quit("Dump frequency in fstab/mtab for %s is too big: %d > 3659\n", |
| 436 |
tabfs->mnt_fsname, tabfs->mnt_freq); |
| 437 |
return NULL; |
| 438 |
} |
| 439 |
} |
| 440 |
|
| 441 |
if (strlen(fs->mnt_dir) > 1 && fs->mnt_dir[strlen(fs->mnt_dir) - 1] == '/') |
| 442 |
fs->mnt_dir[strlen(fs->mnt_dir) - 1] = '\0'; |
| 443 |
if ((new->mnt_dir = strdup(fs->mnt_dir)) == NULL || |
| 444 |
(new->mnt_type = strdup(fs->mnt_type)) == NULL || |
| 445 |
(new->mnt_opts = strdup(fs->mnt_opts)) == NULL || |
| 446 |
(new->mnt_fsname = strdup(disk)) == NULL) |
| 447 |
quit("%s\n", strerror(errno)); |
| 448 |
new->mnt_passno = fs->mnt_passno; |
| 449 |
new->mnt_freq = fs->mnt_freq; |
| 450 |
if (new->mnt_freq > 3659) |
| 451 |
quit("Dump frequency in fstab/mtab for %s %s is too big: %d > 3659\n", |
| 452 |
new->mnt_dir, new->mnt_fsname, new->mnt_freq); |
| 453 |
free((char*)(uintptr_t)disk); |
| 454 |
return (new); |
| 455 |
} |
| 456 |
|
| 457 |
void |
| 458 |
getfstab(void) |
| 459 |
{ |
| 460 |
struct mntent *fs; |
| 461 |
struct pfstab *pf; |
| 462 |
struct pfstab *pfold = NULL; |
| 463 |
FILE *mntfp; |
| 464 |
const char *mnttables[] = { _PATH_MOUNTED, _PATH_MNTTAB, 0 }; |
| 465 |
int i; |
| 466 |
|
| 467 |
for (i = 0; mnttables[i]; i++) { |
| 468 |
mntfp = setmntent(mnttables[i], "r"); |
| 469 |
if (mntfp == NULL) { |
| 470 |
msg("Can't open %s for dump table information: %s\n", |
| 471 |
mnttables[i], strerror(errno)); |
| 472 |
continue; |
| 473 |
} |
| 474 |
while ((fs = getmntent(mntfp)) != NULL) { |
| 475 |
fs = allocfsent(fs); |
| 476 |
if (!fs) |
| 477 |
continue; |
| 478 |
fs->mnt_passno = 0; |
| 479 |
if ((pf = (struct pfstab *)malloc(sizeof (*pf))) == NULL) |
| 480 |
quit("%s\n", strerror(errno)); |
| 481 |
pf->pf_mntent = fs; |
| 482 |
pf->pf_next = NULL; |
| 483 |
|
| 484 |
|
| 485 |
if (pfold) { |
| 486 |
pfold->pf_next = pf; |
| 487 |
pfold = pf; |
| 488 |
} else |
| 489 |
pfold = table = pf; |
| 490 |
} |
| 491 |
(void) endmntent(mntfp); |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
struct mntent * |
| 507 |
fstabsearch(const char *key) |
| 508 |
{ |
| 509 |
struct pfstab *pf; |
| 510 |
struct mntent *fs; |
| 511 |
|
| 512 |
for (pf = table; pf != NULL; pf = pf->pf_next) { |
| 513 |
fs = pf->pf_mntent; |
| 514 |
if (strcmp(fs->mnt_dir, key) == 0 || |
| 515 |
strcmp(fs->mnt_fsname, key) == 0) |
| 516 |
return (fs); |
| 517 |
if (fs->mnt_fsname != NULL && strcmp(fs->mnt_fsname, key) == 0) |
| 518 |
return (fs); |
| 519 |
if (key[0] != '/') { |
| 520 |
if (*fs->mnt_fsname == '/' && |
| 521 |
strcmp(fs->mnt_fsname + 1, key) == 0) |
| 522 |
return (fs); |
| 523 |
if (*fs->mnt_dir == '/' && |
| 524 |
strcmp(fs->mnt_dir + 1, key) == 0) |
| 525 |
return (fs); |
| 526 |
} |
| 527 |
} |
| 528 |
return (NULL); |
| 529 |
} |
| 530 |
|
| 531 |
struct mntent * |
| 532 |
fstabsearchdir(const char *key, char *directory) |
| 533 |
{ |
| 534 |
struct pfstab *pf; |
| 535 |
struct mntent *fs; |
| 536 |
struct mntent *found_fs = NULL; |
| 537 |
unsigned int size = 0; |
| 538 |
struct stat buf; |
| 539 |
|
| 540 |
if (stat(key, &buf) == 0 && (S_ISBLK(buf.st_mode) || (S_ISREG(buf.st_mode) && is_dump_fs(key)))) |
| 541 |
return NULL; |
| 542 |
|
| 543 |
for (pf = table; pf != NULL; pf = pf->pf_next) { |
| 544 |
fs = pf->pf_mntent; |
| 545 |
if (strlen(fs->mnt_dir) > size && |
| 546 |
strlen(key) > strlen(fs->mnt_dir) && |
| 547 |
strncmp(fs->mnt_dir, key, strlen(fs->mnt_dir)) == 0 && |
| 548 |
(key[strlen(fs->mnt_dir)] == '/' || |
| 549 |
fs->mnt_dir[strlen(fs->mnt_dir) - 1] == '/')) { |
| 550 |
found_fs = fs; |
| 551 |
size = strlen(fs->mnt_dir); |
| 552 |
} |
| 553 |
} |
| 554 |
if (found_fs != NULL) { |
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
strcpy(directory, key + size); |
| 562 |
} |
| 563 |
return(found_fs); |
| 564 |
} |
| 565 |
|
| 566 |
static void |
| 567 |
print_wmsg(char arg, int dumpme, const char *dev, int level, |
| 568 |
const char *mtpt, time_t ddate) |
| 569 |
{ |
| 570 |
Dmsg(FDEBUG, "checking dev %s: lvl %d, mtpt %s\n", dev, level, mtpt); |
| 571 |
if (!dumpme && arg == 'w') |
| 572 |
return; |
| 573 |
|
| 574 |
(void) printf("%c %8s\t(%6s) Last dump: ", |
| 575 |
dumpme && (arg != 'w') ? '>' : ' ', |
| 576 |
dev, |
| 577 |
mtpt ? mtpt : ""); |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
if (level >= 0 && ddate > 365) { |
| 584 |
char *date, *d; |
| 585 |
|
| 586 |
date = (char *)ctime(&ddate); |
| 587 |
d = strchr(date, '\n'); |
| 588 |
if (d) *d = '\0'; |
| 589 |
printf("Level %d, Date %s\n", level, date); |
| 590 |
} else |
| 591 |
printf("never\n"); |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
void |
| 598 |
lastdump(char arg) |
| 599 |
{ |
| 600 |
struct pfstab *pf; |
| 601 |
time_t tnow; |
| 602 |
|
| 603 |
tnow = time(NULL); |
| 604 |
getfstab(); |
| 605 |
initdumptimes(0); |
| 606 |
if (ddatev == NULL && table == NULL) { |
| 607 |
(void) printf("No %s or %s file found\n", |
| 608 |
_PATH_MNTTAB, dumpdates); |
| 609 |
return; |
| 610 |
} |
| 611 |
|
| 612 |
if (arg == 'w') |
| 613 |
(void) printf("Dump these file systems:\n"); |
| 614 |
else |
| 615 |
(void) printf("Last dump(s) done (Dump '>' file systems):\n"); |
| 616 |
|
| 617 |
|
| 618 |
if (ddatev != NULL) { |
| 619 |
struct dumpdates *dtwalk = NULL; |
| 620 |
int i; |
| 621 |
const char *lastname; |
| 622 |
|
| 623 |
qsort((char *) ddatev, nddates, sizeof(struct dumpdates *), datesort); |
| 624 |
|
| 625 |
lastname = "??"; |
| 626 |
ITITERATE(i, dtwalk) { |
| 627 |
struct mntent *dt; |
| 628 |
if (strncmp(lastname, dtwalk->dd_name, |
| 629 |
sizeof(dtwalk->dd_name)) == 0) |
| 630 |
continue; |
| 631 |
lastname = dtwalk->dd_name; |
| 632 |
if ((dt = dtwalk->dd_fstab) != NULL) { |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
dt->mnt_passno = dtwalk->dd_ddate; |
| 652 |
if (dt->mnt_freq > 0 && (dtwalk->dd_ddate < |
| 653 |
tnow - (dt->mnt_freq * 86400))) |
| 654 |
dt->mnt_freq = 3660 + dtwalk->dd_level; |
| 655 |
else |
| 656 |
dt->mnt_freq = -dtwalk->dd_level - 1; |
| 657 |
Dmsg(FDEBUG, "%s fs_freq set to %d\n", lastname, |
| 658 |
dt->mnt_freq); |
| 659 |
} |
| 660 |
} |
| 661 |
} |
| 662 |
|
| 663 |
|
| 664 |
for (pf = table; pf != NULL; pf = pf->pf_next) { |
| 665 |
struct mntent *dt = pf->pf_mntent; |
| 666 |
const struct Fstypes *type; |
| 667 |
|
| 668 |
|
| 669 |
if (dt->mnt_type == NULL) |
| 670 |
continue; |
| 671 |
|
| 672 |
for (type = fstypes; type->type != NULL; type++) { |
| 673 |
if (strcmp(dt->mnt_type, type->type) == 0) { |
| 674 |
const char *disk = get_device_name(dt->mnt_fsname); |
| 675 |
print_wmsg(arg, dt->mnt_freq > 0, |
| 676 |
disk ? disk : dt->mnt_fsname, |
| 677 |
(dt->mnt_freq < 0 ? -dt->mnt_freq - 1 : |
| 678 |
dt->mnt_freq < 3660 ? -1 : |
| 679 |
dt->mnt_freq - 3660), |
| 680 |
dt->mnt_dir, |
| 681 |
dt->mnt_passno); |
| 682 |
} |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
|
| 687 |
if (ddatev != NULL) { |
| 688 |
struct dumpdates *dtwalk = NULL; |
| 689 |
const char *lastname; |
| 690 |
int i; |
| 691 |
|
| 692 |
lastname = "??"; |
| 693 |
ITITERATE(i, dtwalk) { |
| 694 |
if (strncmp(lastname, dtwalk->dd_name, |
| 695 |
sizeof(dtwalk->dd_name)) == 0 || |
| 696 |
dtwalk->dd_fstab != NULL) |
| 697 |
continue; |
| 698 |
lastname = dtwalk->dd_name; |
| 699 |
print_wmsg(arg, 0, dtwalk->dd_name, |
| 700 |
dtwalk->dd_level, NULL, dtwalk->dd_ddate); |
| 701 |
} |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
int |
| 706 |
datesort(const void *a1, const void *a2) |
| 707 |
{ |
| 708 |
const struct dumpdates *d1 = *(const struct dumpdates *const*)a1; |
| 709 |
const struct dumpdates *d2 = *(const struct dumpdates *const*)a2; |
| 710 |
int diff; |
| 711 |
|
| 712 |
diff = strncmp(d1->dd_name, d2->dd_name, sizeof(d1->dd_name)); |
| 713 |
if (diff == 0) |
| 714 |
return (d2->dd_ddate - d1->dd_ddate); |
| 715 |
return (diff); |
| 716 |
} |