mirror of
https://github.com/falk-werner/webfuse
synced 2025-06-13 12:54:15 +00:00
removes default link, if it is broken
This commit is contained in:
parent
75c7ff4b69
commit
aa9a3319d0
@ -34,6 +34,13 @@ static char * wf_impl_filesystem_create_id(void)
|
||||
return strdup(id);
|
||||
}
|
||||
|
||||
static bool wf_impl_filesystem_is_link_broken(char const * path)
|
||||
{
|
||||
char buffer[PATH_MAX];
|
||||
ssize_t count = readlink(path, buffer, PATH_MAX);
|
||||
return (0 < count);
|
||||
}
|
||||
|
||||
static void wf_impl_filesystem_cleanup(
|
||||
struct wf_impl_filesystem * filesystem)
|
||||
{
|
||||
@ -50,6 +57,14 @@ static void wf_impl_filesystem_cleanup(
|
||||
snprintf(path, PATH_MAX, "%s/%s/%s", session->mount_point, filesystem->user_data.name, filesystem->id);
|
||||
rmdir(path);
|
||||
|
||||
snprintf(path, PATH_MAX, "%s/%s/default", session->mount_point, filesystem->user_data.name);
|
||||
rmdir(path);
|
||||
if (wf_impl_filesystem_is_link_broken(path))
|
||||
{
|
||||
unlink(path);
|
||||
// ToDo: recreate link, if any directory exists
|
||||
}
|
||||
|
||||
snprintf(path, PATH_MAX, "%s/%s", session->mount_point, filesystem->user_data.name);
|
||||
rmdir(path);
|
||||
|
||||
@ -84,6 +99,10 @@ static bool wf_impl_filesystem_init(
|
||||
snprintf(path, PATH_MAX, "%s/%s/%s", session->mount_point, name, filesystem->id);
|
||||
mkdir(path, 0755);
|
||||
|
||||
char defaultPath[PATH_MAX];
|
||||
snprintf(defaultPath, PATH_MAX, "%s/%s/default", session->mount_point, name);
|
||||
symlink(filesystem->id, defaultPath);
|
||||
|
||||
filesystem->session = fuse_session_new(
|
||||
&filesystem->args,
|
||||
&filesystem_operations,
|
||||
|
Loading…
Reference in New Issue
Block a user