diff options
-rw-r--r-- | src/volumefs.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/volumefs.c b/src/volumefs.c index bc36ba3..392db8f 100644 --- a/src/volumefs.c +++ b/src/volumefs.c @@ -103,9 +103,10 @@ static int volumesfs_getattr(const char *path, struct stat *stbuf) stbuf->st_nlink = 2; } else { G_LOCK(mounts); - const gchar *mountpoint = g_hash_table_lookup(mounts, path + 1); + int mount_exists = g_hash_table_lookup(mounts, path + 1) != NULL; G_UNLOCK(mounts); - if (mountpoint) { + + if (mount_exists) { stbuf->st_mode = S_IFLNK | 0444; stbuf->st_nlink = 1; } else { @@ -147,13 +148,20 @@ static int volumesfs_readlink(const char *path, char *buf, size_t size) if (strcmp(path, "/") == 0) { return -EINVAL; } + if (size == 0) { + return -EINVAL; + } G_LOCK(mounts); + int mount_exists = 0; gchar *mountpoint = g_hash_table_lookup(mounts, path + 1); + if (mountpoint) { + g_strlcpy(buf, mountpoint, size); + mount_exists = 1; + } G_UNLOCK(mounts); - if (mountpoint) { - strcpy(buf, mountpoint); + if (mount_exists) { return 0; } else { return -ENOENT; |