From fa4b05698c995516474ea153adf0d75a9fd18320 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Mon, 20 Jun 2022 11:42:07 +1100 Subject: [PATCH] add create_live_tree function --- src/lib66/utils/create_live_tree.c | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/lib66/utils/create_live_tree.c diff --git a/src/lib66/utils/create_live_tree.c b/src/lib66/utils/create_live_tree.c new file mode 100644 index 00000000..a5edc61b --- /dev/null +++ b/src/lib66/utils/create_live_tree.c @@ -0,0 +1,46 @@ +/* + * create_live_tree.c + * + * Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org> + * + * All rights reserved. + * + * This file is part of Obarun. It is subject to the license terms in + * the LICENSE file found in the top-level directory of this + * distribution. + * This file may not be copied, modified, propagated, or distributed + * except according to the terms contained in the LICENSE file./ + */ + +#include <sys/types.h> +#include <unistd.h> + +#include <oblibs/log.h> +#include <oblibs/string.h> +#include <oblibs/types.h> +#include <oblibs/directory.h> + +#include <66/ssexec.h> +#include <66/utils.h> +#include <66/constants.h> + +int create_live_tree(ssexec_t *info) +{ + log_flow() ; + + int r = scan_mode(info->livetree.s, S_IFDIR) ; + if (r < 0) + log_warn_return(LOG_EXIT_ZERO, "conflicting format for: ", info->livetree.s) ; + if (!r) { + + log_trace("create directory: ", info->livetree.s) ; + if (!dir_create(info->livetree.s, 0700)) + log_warnusys_return(LOG_EXIT_ZERO, "create directory: ", info->livetree.s) ; + + log_trace("chown directory: ", info->livetree.s) ; + if (chown(info->livetree.s,info->owner,gidowner) < 0) + log_warnusys_return(LOG_EXIT_SYS, "chown directory: ", info->livetree.s) ; + } + + return 1 ; +} -- GitLab