Skip to content
Snippets Groups Projects
Commit cdae6186 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

replace create_live function by create_live_state function

parent 0a4e6810
No related branches found
No related tags found
No related merge requests found
/*
* create_live.c
* create_live_state.c
*
* Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org>
*
......@@ -13,7 +13,6 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <oblibs/log.h>
......@@ -21,43 +20,36 @@
#include <oblibs/types.h>
#include <oblibs/directory.h>
#include <skalibs/types.h>
#include <66/ssexec.h>
#include <66/utils.h>
#include <66/tree.h>
#include <66/resolve.h>
#include <66/constants.h>
int create_live(ssexec_t *info)
int create_live_state(ssexec_t *info, char const *treename)
{
log_flow() ;
int r ;
char ownerstr[UID_FMT] ;
size_t ownerlen = uid_fmt(ownerstr,info->owner) ;
size_t stelen = info->live.len + SS_STATE_LEN + 1 + ownerlen + 1 + info->treename.len ;
gid_t gidowner ;
char ste[stelen + 1] ;
ownerstr[ownerlen] = 0 ;
size_t treenamelen = strlen(treename) ;
char ste[info->live.len + SS_STATE_LEN + 1 + info->ownerlen + 1 + treenamelen + 1] ;
if (!yourgid(&gidowner,info->owner))
log_warnusys_return(LOG_EXIT_ZERO, "get gid of: ", ownerstr) ;
if (!yourgid(&gidowner, info->owner))
log_warnusys_return(LOG_EXIT_ZERO, "get gid of: ", info->ownerstr) ;
auto_strings(ste, info->live.s, SS_STATE + 1, "/", ownerstr, "/", info->treename.s) ;
auto_strings(ste, info->live.s, SS_STATE + 1, "/", info->ownerstr, "/", treename) ;
r = scan_mode(ste, S_IFDIR) ;
if (r < 0) return 0 ;
if (r < 0)
log_warnsys_return(LOG_EXIT_ZERO, "conflicting format for: ", ste) ;
if (!r) {
r = dir_create_parent(ste, 0700) ;
if (!r)
log_warnusys_return(LOG_EXIT_ZERO, "create directory: ", ste) ;
ste[info->live.len + SS_STATE_LEN + ownerlen + 1] = 0 ;
if (chown(ste,info->owner,gidowner) < 0)
ste[info->live.len + SS_STATE_LEN + info->ownerlen + 1] = 0 ;
if (chown(ste, info->owner, gidowner) < 0)
log_warnusys_return(LOG_EXIT_ZERO, "chown: ", ste) ;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment