Deleted Added
full compact
utilities.c (70166) utilities.c (75927)
1/*
2 * Copyright (c) 1980, 1986, 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

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

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
37#endif
38static const char rcsid[] =
1/*
2 * Copyright (c) 1980, 1986, 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

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

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
37#endif
38static const char rcsid[] =
39 "$FreeBSD: head/sbin/fsck_ffs/utilities.c 70166 2000-12-18 21:14:25Z phk $";
39 "$FreeBSD: head/sbin/fsck_ffs/utilities.c 75927 2001-04-24 22:38:08Z mckusick $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/types.h>
44#include <sys/stat.h>
45
46#include <ufs/ufs/dinode.h>
47#include <ufs/ufs/dir.h>
48#include <ufs/ffs/fs.h>
49
50#include <err.h>
51#include <errno.h>
52#include <string.h>
53#include <ctype.h>
54#include <fstab.h>
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/types.h>
44#include <sys/stat.h>
45
46#include <ufs/ufs/dinode.h>
47#include <ufs/ufs/dir.h>
48#include <ufs/ffs/fs.h>
49
50#include <err.h>
51#include <errno.h>
52#include <string.h>
53#include <ctype.h>
54#include <fstab.h>
55#include <paths.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <unistd.h>
58
59#include "fsck.h"
60
61
62char *
63blockcheck(origname)
64 char *origname;
65{
66 struct stat stslash, stblock, stchar;
56#include <stdio.h>
57#include <stdlib.h>
58#include <unistd.h>
59
60#include "fsck.h"
61
62
63char *
64blockcheck(origname)
65 char *origname;
66{
67 struct stat stslash, stblock, stchar;
67 char *newname, *raw;
68 char *newname, *raw, *cp;
68 struct fstab *fsinfo;
69 int retried = 0, len;
69 struct fstab *fsinfo;
70 int retried = 0, len;
71 static char device[MAXPATHLEN];
70
71 newname = origname;
72
73 newname = origname;
74 if (stat(newname, &stblock) < 0) {
75 cp = strrchr(newname, '/');
76 if (cp == 0) {
77 (void)snprintf(device, sizeof(device), "%s%s",
78 _PATH_DEV, newname);
79 newname = device;
80 }
81 }
72retry:
73 if (stat(newname, &stblock) < 0) {
74 printf("Can't stat %s: %s\n", newname, strerror(errno));
75 return (origname);
76 }
77 switch(stblock.st_mode & S_IFMT) {
78 case S_IFCHR:
79 case S_IFBLK:

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

85 len = strlen(origname) - 1;
86 if (len > 0 && origname[len] == '/')
87 /* remove trailing slash */
88 origname[len] = '\0';
89 if ((fsinfo = getfsfile(origname)) == NULL) {
90 printf(
91 "Can't resolve %s to character special device.\n",
92 origname);
82retry:
83 if (stat(newname, &stblock) < 0) {
84 printf("Can't stat %s: %s\n", newname, strerror(errno));
85 return (origname);
86 }
87 switch(stblock.st_mode & S_IFMT) {
88 case S_IFCHR:
89 case S_IFBLK:

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

95 len = strlen(origname) - 1;
96 if (len > 0 && origname[len] == '/')
97 /* remove trailing slash */
98 origname[len] = '\0';
99 if ((fsinfo = getfsfile(origname)) == NULL) {
100 printf(
101 "Can't resolve %s to character special device.\n",
102 origname);
93 return (0);
103 return (origname);
94 }
95 newname = fsinfo->fs_spec;
96 retried++;
97 goto retry;
98 }
99 /*
100 * Not a block or character device, just return name and
101 * let the user decide whether to use it.
102 */
103 return (origname);
104}
105
106void
107infohandler(sig)
108 int sig;
109{
110 got_siginfo = 1;
111}
104 }
105 newname = fsinfo->fs_spec;
106 retried++;
107 goto retry;
108 }
109 /*
110 * Not a block or character device, just return name and
111 * let the user decide whether to use it.
112 */
113 return (origname);
114}
115
116void
117infohandler(sig)
118 int sig;
119{
120 got_siginfo = 1;
121}