|
|
e817e4 |
--- scrub-2.5.2.ori/src/scrub.c 2012-06-21 00:00:27.000000000 +0200
|
|
|
e817e4 |
+++ scrub-2.5.2/src/scrub.c 2021-08-09 18:25:00.355142963 +0200
|
|
|
e817e4 |
@@ -283,8 +283,8 @@
|
|
|
e817e4 |
}
|
|
|
e817e4 |
scrub_disk(filename, sopt, seq, bopt, Sopt, Topt);
|
|
|
e817e4 |
break;
|
|
|
e817e4 |
- case FILE_LINK:
|
|
|
e817e4 |
- if (Lopt) {
|
|
|
e817e4 |
+ case FILE_REGULAR:
|
|
|
e817e4 |
+ if (is_symlink(filename) && Lopt) {
|
|
|
e817e4 |
if (ropt) {
|
|
|
e817e4 |
printf("%s: unlinking %s\n", prog, filename);
|
|
|
e817e4 |
if (unlink(filename) != 0) {
|
|
|
e817e4 |
@@ -295,7 +295,6 @@
|
|
|
e817e4 |
}
|
|
|
e817e4 |
break;
|
|
|
e817e4 |
}
|
|
|
e817e4 |
- case FILE_REGULAR:
|
|
|
e817e4 |
if (access(filename, R_OK|W_OK) < 0) {
|
|
|
e817e4 |
fprintf(stderr, "%s: no rw access to %s\n", prog, filename);
|
|
|
e817e4 |
exit(1);
|
|
|
e817e4 |
@@ -570,7 +570,7 @@
|
|
|
e817e4 |
struct stat sb;
|
|
|
e817e4 |
filetype_t ftype = filetype(path);
|
|
|
e817e4 |
|
|
|
e817e4 |
- assert(ftype == FILE_REGULAR || ftype == FILE_LINK);
|
|
|
e817e4 |
+ assert(ftype == FILE_REGULAR);
|
|
|
e817e4 |
|
|
|
e817e4 |
if (stat(path, &sb) < 0) {
|
|
|
e817e4 |
fprintf(stderr, "%s: stat %s: %s\n", prog, path, strerror(errno));
|
|
|
e817e4 |
--- scrub-2.5.2.ori/src/util.c 2012-06-21 00:00:27.000000000 +0200
|
|
|
e817e4 |
+++ scrub-2.5.2/src/util.c 2021-08-10 15:38:26.748107704 +0200
|
|
|
e817e4 |
@@ -72,6 +72,15 @@
|
|
|
e817e4 |
return n;
|
|
|
e817e4 |
}
|
|
|
e817e4 |
|
|
|
e817e4 |
+/* Indicates whether the file represented by 'path' is a symlink.
|
|
|
e817e4 |
+ */
|
|
|
e817e4 |
+int
|
|
|
e817e4 |
+is_symlink(char *path)
|
|
|
e817e4 |
+{
|
|
|
e817e4 |
+ struct stat sb;
|
|
|
e817e4 |
+ return lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode);
|
|
|
e817e4 |
+}
|
|
|
e817e4 |
+
|
|
|
e817e4 |
/* Return the type of file represented by 'path'.
|
|
|
e817e4 |
*/
|
|
|
e817e4 |
filetype_t
|
|
|
e817e4 |
@@ -90,10 +90,6 @@
|
|
|
e817e4 |
|
|
|
e817e4 |
filetype_t res = FILE_NOEXIST;
|
|
|
e817e4 |
|
|
|
e817e4 |
- if (lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode)) {
|
|
|
e817e4 |
- return FILE_LINK;
|
|
|
e817e4 |
- }
|
|
|
e817e4 |
-
|
|
|
e817e4 |
if (stat(path, &sb) == 0) {
|
|
|
e817e4 |
if (S_ISREG(sb.st_mode))
|
|
|
e817e4 |
res = FILE_REGULAR;
|
|
|
e817e4 |
--- scrub-2.5.2.ori/src/util.h 2012-06-21 00:00:27.000000000 +0200
|
|
|
e817e4 |
+++ scrub-2.5.2/src/util.h 2021-08-16 16:12:25.306572001 +0200
|
|
|
e817e4 |
@@ -35,7 +35,6 @@
|
|
|
e817e4 |
FILE_REGULAR,
|
|
|
e817e4 |
FILE_CHAR,
|
|
|
e817e4 |
FILE_BLOCK,
|
|
|
e817e4 |
- FILE_LINK,
|
|
|
e817e4 |
FILE_OTHER,
|
|
|
e817e4 |
} filetype_t;
|
|
|
e817e4 |
|
|
|
e817e4 |
@@ -43,6 +42,7 @@
|
|
|
e817e4 |
|
|
|
e817e4 |
int read_all(int fd, unsigned char *buf, int count);
|
|
|
e817e4 |
int write_all(int fd, const unsigned char *buf, int count);
|
|
|
e817e4 |
+int is_symlink(char *path);
|
|
|
e817e4 |
filetype_t filetype(char *path);
|
|
|
e817e4 |
off_t blkalign(off_t offset, int blocksize, round_t rtype);
|
|
|
e817e4 |
void * alloc_buffer(int bufsize);
|