diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2021-06-26 15:04:05 +0200 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2021-06-28 15:29:19 +0200 |
commit | 18b0de19830e7286ad5eecbba23013e835739cdc (patch) | |
tree | 6c7f1cadb2c1fd4a19c388c1e42ac94700a568aa /src/ipcpd/ipcp.c | |
parent | cb70b78c443de5f8b95c4469dd8eb7f77af880ed (diff) | |
download | ouroboros-18b0de19830e7286ad5eecbba23013e835739cdc.tar.gz ouroboros-18b0de19830e7286ad5eecbba23013e835739cdc.zip |
lib: Remove struct stat from RIB API
The RIB API had a struct stat in the getattr() function, which made
all components that exposed variables via the RIB dependent on
<sys/stat.h>. The rib now has its own struct rib_attr to set
attributes such as size and last modified time.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r-- | src/ipcpd/ipcp.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 56cdb5d2..65a28d61 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -24,7 +24,6 @@ #define _DEFAULT_SOURCE #else #define _POSIX_C_SOURCE 200112L -#define __XSI_VISIBLE 500 #endif #if defined(__linux__) && !defined(DISABLE_CORE_LOCK) @@ -32,13 +31,6 @@ #define NPROC (sysconf(_SC_NPROCESSORS_ONLN)) #endif -#if defined(__linux__) || defined(__CYGWIN__) -#define _DEFAULT_SOURCE -#else -#define _POSIX_C_SOURCE 200112L -#define __XSI_VISIBLE 500 -#endif - #include "config.h" #define OUROBOROS_PREFIX "ipcpd/ipcp" @@ -107,9 +99,9 @@ void ipcp_hash_str(char * buf, buf[2 * i] = '\0'; } -static int ipcp_stat_read(const char * path, - char * buf, - size_t len) +static int ipcp_rib_read(const char * path, + char * buf, + size_t len) { if (len < LAYER_NAME_SIZE + 2) /* trailing \n */ return 0; @@ -158,7 +150,7 @@ static int ipcp_stat_read(const char * path, return strlen(buf); } -static int ipcp_stat_readdir(char *** buf) +static int ipcp_rib_readdir(char *** buf) { int i = 0; @@ -188,24 +180,20 @@ static int ipcp_stat_readdir(char *** buf) return -1; } -static int ipcp_stat_getattr(const char * path, - struct stat * st) +static int ipcp_rib_getattr(const char * path, + struct rib_attr * attr) { (void) path; - st->st_mode = S_IFREG | 0755; - st->st_nlink = 1; - st->st_uid = getuid(); - st->st_gid = getgid(); - st->st_size = LAYER_NAME_SIZE; + attr->size = LAYER_NAME_SIZE; return 0; } static struct rib_ops r_ops = { - .read = ipcp_stat_read, - .readdir = ipcp_stat_readdir, - .getattr = ipcp_stat_getattr + .read = ipcp_rib_read, + .readdir = ipcp_rib_readdir, + .getattr = ipcp_rib_getattr }; static void * acceptloop(void * o) |