mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-26 01:46:32 -05:00
Excludes handling of error condition from the coverage test.
This commit is contained in:
parent
f0cecf55c8
commit
24fd5ab318
17 changed files with 841 additions and 5 deletions
20
pool.c
20
pool.c
|
|
@ -32,8 +32,10 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
|
||||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
|
@ -46,8 +48,10 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
errno = 0;
|
||||
dd = readdir(d);
|
||||
if (dd == 0 && errno != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (dd == 0 && errno == 0) {
|
||||
break; /* finished */
|
||||
|
|
@ -66,8 +70,10 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
#else
|
||||
/* get lstat info about the file */
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -77,8 +83,10 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
/* delete the link */
|
||||
ret = remove(path_next);
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing symlink '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
/* recurse */
|
||||
|
|
@ -99,8 +107,10 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -116,8 +126,10 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
|
|||
}
|
||||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
return ignored;
|
||||
|
|
@ -148,7 +160,9 @@ static void make_link(const char* pool_dir, const char* share_dir, struct snapra
|
|||
/* create the ancestor directories */
|
||||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* convert back slashes */
|
||||
|
|
@ -161,12 +175,16 @@ static void make_link(const char* pool_dir, const char* share_dir, struct snapra
|
|||
fprintf(stderr, "WARNING! Duplicate pooling for '%s'\n", path);
|
||||
#ifdef _WIN32
|
||||
} else if (errno == EPERM) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "You must run as Adminstrator to be able to create symlinks.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
#endif
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Error writing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -179,8 +197,10 @@ void state_pool(struct snapraid_state* state)
|
|||
unsigned count;
|
||||
|
||||
if (state->pool[0] == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "To use the 'pool' command you must set the pool directory in the configuration file\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
printf("Cleaning...\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue