Support the case of an empty symlink

There is the report of a such condition in Windows.
This commit is contained in:
Andrea Mazzoleni 2015-12-18 19:41:49 +01:00
parent db679dc276
commit d5c0a8c2f3
3 changed files with 19 additions and 4 deletions

View file

@ -3,6 +3,7 @@ SnapRAID HISTORY
9.2 2015/12
===========
* Allows symlinks pointing to an empty target.
* Adds UUID support to Btrfs filesystems. It's available only if the
libblkid library is available on the system.

View file

@ -1325,6 +1325,8 @@ static int scan_dir(struct snapraid_scan* scan, int level, int is_diff, const ch
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (ret == 0)
log_fatal("WARNING! Empty symbolic link '%s'.\n", path_next);
/* readlink doesn't put the final 0 */
subnew[ret] = 0;

View file

@ -1738,6 +1738,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
if (!*sub) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Internal inconsistency for null file!\n");
os_abort();
/* LCOV_EXCL_STOP */
}
@ -2100,15 +2101,16 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
ret = sgetbs(f, linkto, sizeof(linkto));
if (ret < 0) {
if (!*sub) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Internal inconsistency for null symlink!\n");
os_abort();
/* LCOV_EXCL_STOP */
}
if (!*sub || !*linkto) {
ret = sgetbs(f, linkto, sizeof(linkto));
if (ret < 0) {
/* LCOV_EXCL_START */
decoding_error(path, f);
os_abort();
@ -2150,6 +2152,14 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
if (!*sub) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Internal inconsistency for null hardlink!\n");
os_abort();
/* LCOV_EXCL_STOP */
}
ret = sgetbs(f, linkto, sizeof(linkto));
if (ret < 0) {
/* LCOV_EXCL_START */
@ -2158,9 +2168,10 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
/* LCOV_EXCL_STOP */
}
if (!*sub || !*linkto) {
if (!*linkto) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Internal inconsistency for empty hardlink '%s'!\n", sub);
os_abort();
/* LCOV_EXCL_STOP */
}
@ -2202,6 +2213,7 @@ static void state_read_content(struct snapraid_state* state, const char* path, S
if (!*sub) {
/* LCOV_EXCL_START */
decoding_error(path, f);
log_fatal("Internal inconsistency for null dir!\n");
os_abort();
/* LCOV_EXCL_STOP */
}