mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-10 15:56:25 -04:00
main: various fixes/cleanups in error handling
Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
This commit is contained in:
parent
c2dd76c6d7
commit
ce14965ae8
29
main.c
29
main.c
@ -375,7 +375,7 @@ read_mappings (const char *str)
|
|||||||
|
|
||||||
tmp = malloc (sizeof (*tmp));
|
tmp = malloc (sizeof (*tmp));
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return NULL;
|
error (EXIT_FAILURE, errno, "cannot allocate memory");
|
||||||
tmp->next = ret;
|
tmp->next = ret;
|
||||||
tmp->host = a;
|
tmp->host = a;
|
||||||
tmp->to = b;
|
tmp->to = b;
|
||||||
@ -3102,6 +3102,10 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
|
|||||||
{
|
{
|
||||||
size_t current_size = PATH_MAX + 1;
|
size_t current_size = PATH_MAX + 1;
|
||||||
cleanup_free char *p = malloc (current_size);
|
cleanup_free char *p = malloc (current_size);
|
||||||
|
if (p == NULL) {
|
||||||
|
ret = -1;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -3115,8 +3119,10 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
|
|||||||
|
|
||||||
current_size = current_size * 2;
|
current_size = current_size * 2;
|
||||||
new = realloc (p, current_size);
|
new = realloc (p, current_size);
|
||||||
if (new == NULL)
|
if (new == NULL) {
|
||||||
|
ret = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
p = new;
|
p = new;
|
||||||
}
|
}
|
||||||
p[ret] = '\0';
|
p[ret] = '\0';
|
||||||
@ -3142,8 +3148,10 @@ copyup (struct ovl_data *lo, struct ovl_node *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = malloc (buf_size);
|
buf = malloc (buf_size);
|
||||||
if (buf == NULL)
|
if (buf == NULL) {
|
||||||
|
ret = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (support_reflinks)
|
if (support_reflinks)
|
||||||
{
|
{
|
||||||
@ -4755,12 +4763,10 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
|||||||
|
|
||||||
node->loaded = 0;
|
node->loaded = 0;
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
fuse_reply_err (req, 0);
|
fuse_reply_err (req, 0);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
ret = -1;
|
|
||||||
fuse_reply_err (req, errno);
|
fuse_reply_err (req, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5536,6 +5542,10 @@ fuse_opt_proc (void *data, const char *arg, int key, struct fuse_args *outargs)
|
|||||||
free (ovl_data->mountpoint);
|
free (ovl_data->mountpoint);
|
||||||
|
|
||||||
ovl_data->mountpoint = strdup (arg);
|
ovl_data->mountpoint = strdup (arg);
|
||||||
|
if (ovl_data->mountpoint == NULL) {
|
||||||
|
fprintf (stderr, "cannot allocate memory\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Ignore unknown arguments. */
|
/* Ignore unknown arguments. */
|
||||||
@ -5589,6 +5599,8 @@ load_default_plugins ()
|
|||||||
{
|
{
|
||||||
DIR *dp = NULL;
|
DIR *dp = NULL;
|
||||||
char *plugins = strdup ("");
|
char *plugins = strdup ("");
|
||||||
|
if (plugins == NULL)
|
||||||
|
error (EXIT_FAILURE, errno, "cannot allocate memory");
|
||||||
|
|
||||||
dp = opendir (PKGLIBEXECDIR);
|
dp = opendir (PKGLIBEXECDIR);
|
||||||
if (dp == NULL)
|
if (dp == NULL)
|
||||||
@ -5839,8 +5851,10 @@ main (int argc, char *argv[])
|
|||||||
cleanup_free char *path = NULL;
|
cleanup_free char *path = NULL;
|
||||||
|
|
||||||
path = realpath (lo.workdir, NULL);
|
path = realpath (lo.workdir, NULL);
|
||||||
if (path == NULL)
|
if (path == NULL) {
|
||||||
|
ret = -1;
|
||||||
goto err_out1;
|
goto err_out1;
|
||||||
|
}
|
||||||
mkdir (path, 0700);
|
mkdir (path, 0700);
|
||||||
path = realloc (path, strlen (path) + strlen ("/work") + 1);
|
path = realloc (path, strlen (path) + strlen ("/work") + 1);
|
||||||
if (! path)
|
if (! path)
|
||||||
@ -5870,11 +5884,13 @@ main (int argc, char *argv[])
|
|||||||
if (se == NULL)
|
if (se == NULL)
|
||||||
{
|
{
|
||||||
error (0, errno, "cannot create FUSE session");
|
error (0, errno, "cannot create FUSE session");
|
||||||
|
ret = -1;
|
||||||
goto err_out1;
|
goto err_out1;
|
||||||
}
|
}
|
||||||
if (fuse_set_signal_handlers (se) != 0)
|
if (fuse_set_signal_handlers (se) != 0)
|
||||||
{
|
{
|
||||||
error (0, errno, "cannot set signal handler");
|
error (0, errno, "cannot set signal handler");
|
||||||
|
ret = -1;
|
||||||
goto err_out2;
|
goto err_out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5883,6 +5899,7 @@ main (int argc, char *argv[])
|
|||||||
if (fuse_session_mount (se, lo.mountpoint) != 0)
|
if (fuse_session_mount (se, lo.mountpoint) != 0)
|
||||||
{
|
{
|
||||||
error (0, errno, "cannot mount");
|
error (0, errno, "cannot mount");
|
||||||
|
ret = -1;
|
||||||
goto err_out3;
|
goto err_out3;
|
||||||
}
|
}
|
||||||
fuse_daemonize (opts.foreground);
|
fuse_daemonize (opts.foreground);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user