[sheepdog] [PATCH v3 2/4] util: move def_fmode and def_dmode to libsheepdog.a
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Wed Apr 17 11:04:42 CEST 2013
For avoiding duplicate declaration, this patch moves def_fmode and
def_dmode to libsheepdog.a. The new names are sd_def_fmode and
sd_def_dmode.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
include/util.h | 3 +++
lib/util.c | 3 +++
sheep/config.c | 2 +-
sheep/journal.c | 2 +-
sheep/md.c | 2 +-
sheep/object_cache.c | 14 +++++++-------
sheep/plain_store.c | 6 +++---
sheep/sheep_priv.h | 2 --
sheep/store.c | 9 +++------
9 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/include/util.h b/include/util.h
index 38efb8b..4274850 100644
--- a/include/util.h
+++ b/include/util.h
@@ -159,4 +159,7 @@ static inline bool is_stdout_console(void)
return isatty(STDOUT_FILENO);
}
+extern mode_t sd_def_fmode;
+extern mode_t sd_def_dmode;
+
#endif
diff --git a/lib/util.c b/lib/util.c
index aac0fa9..8338bac 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -26,6 +26,9 @@
#include "util.h"
#include "logger.h"
+mode_t sd_def_dmode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP;
+mode_t sd_def_fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+
static void do_nothing(size_t size)
{
}
diff --git a/sheep/config.c b/sheep/config.c
index 49916e7..71e8a7a 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -37,7 +37,7 @@ static int write_config(void)
{
int fd, ret;
- fd = open(config_path, O_RDWR | O_CREAT | O_DSYNC, def_fmode);
+ fd = open(config_path, O_RDWR | O_CREAT | O_DSYNC, sd_def_fmode);
if (fd < 0) {
sd_eprintf("failed to open config file, %m");
return SD_RES_EIO;
diff --git a/sheep/journal.c b/sheep/journal.c
index aa07721..aafa6c2 100644
--- a/sheep/journal.c
+++ b/sheep/journal.c
@@ -164,7 +164,7 @@ static int replay_journal_entry(struct journal_descriptor *jd)
flags |= O_CREAT;
journal_get_path(jd, path);
- fd = open(path, flags, def_fmode);
+ fd = open(path, flags, sd_def_fmode);
if (fd < 0) {
sd_eprintf("open %m");
return -1;
diff --git a/sheep/md.c b/sheep/md.c
index 4da23c4..eaf7c4a 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -142,7 +142,7 @@ void md_add_disk(char *path)
return;
}
- if (xmkdir(path, def_dmode) < 0) {
+ if (xmkdir(path, sd_def_dmode) < 0) {
sd_eprintf("can't mkdir for %s, %m", path);
return;
}
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 1b80a41..4eb8e9b 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -291,7 +291,7 @@ static int read_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
if (sys->object_cache_directio && !idx_has_vdi_bit(idx))
flags |= O_DIRECT;
- fd = open(p, flags, def_fmode);
+ fd = open(p, flags, sd_def_fmode);
if (fd < 0) {
sd_eprintf("%m");
ret = SD_RES_EIO;
@@ -325,7 +325,7 @@ static int write_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
if (sys->object_cache_directio && !idx_has_vdi_bit(idx))
flags |= O_DIRECT;
- fd = open(p, flags, def_fmode);
+ fd = open(p, flags, sd_def_fmode);
if (fd < 0) {
sd_eprintf("%m");
ret = SD_RES_EIO;
@@ -561,7 +561,7 @@ static int create_dir_for(uint32_t vid)
char p[PATH_MAX];
snprintf(p, sizeof(p), "%s/%06"PRIx32, object_cache_dir, vid);
- if (xmkdir(p, def_dmode) < 0) {
+ if (xmkdir(p, sd_def_dmode) < 0) {
sd_eprintf("%s, %m", p);
ret = -1;
}
@@ -691,7 +691,7 @@ static int object_cache_lookup(struct object_cache *oc, uint32_t idx,
return lookup_path(path);
flags |= O_CREAT | O_TRUNC;
- fd = open(path, flags, def_fmode);
+ fd = open(path, flags, sd_def_fmode);
if (fd < 0) {
sd_dprintf("%s, %m", path);
ret = SD_RES_EIO;
@@ -720,7 +720,7 @@ static int create_cache_object(struct object_cache *oc, uint32_t idx,
snprintf(tmp_path, sizeof(tmp_path), "%s/%06"PRIx32"/%08"PRIx32".tmp",
object_cache_dir, oc->vid, idx);
- fd = open(tmp_path, flags, def_fmode);
+ fd = open(tmp_path, flags, sd_def_fmode);
if (fd < 0) {
if (errno == EEXIST) {
sd_dprintf("%08"PRIx32" already created", idx);
@@ -1250,13 +1250,13 @@ int object_cache_init(const char *p)
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, p);
- if (xmkdir(buf.buf, def_dmode) < 0) {
+ if (xmkdir(buf.buf, sd_def_dmode) < 0) {
sd_eprintf("%s %m", buf.buf);
ret = -1;
goto err;
}
strbuf_addstr(&buf, "/cache");
- if (xmkdir(buf.buf, def_dmode) < 0) {
+ if (xmkdir(buf.buf, sd_def_dmode) < 0) {
sd_eprintf("%s %m", buf.buf);
ret = -1;
goto err;
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index b5bb395..adfd923 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -105,7 +105,7 @@ int default_write(uint64_t oid, const struct siocb *iocb)
sync();
}
- fd = open(path, flags, def_fmode);
+ fd = open(path, flags, sd_def_fmode);
if (fd < 0)
return err_to_sderr(path, oid, errno);
@@ -127,7 +127,7 @@ static int make_stale_dir(char *path)
char p[PATH_MAX];
snprintf(p, PATH_MAX, "%s/.stale", path);
- if (xmkdir(p, def_dmode) < 0) {
+ if (xmkdir(p, sd_def_dmode) < 0) {
sd_eprintf("%s failed, %m", p);
return SD_RES_EIO;
}
@@ -301,7 +301,7 @@ int default_create_and_write(uint64_t oid, const struct siocb *iocb)
sync();
}
- fd = open(tmp_path, flags, def_fmode);
+ fd = open(tmp_path, flags, sd_def_fmode);
if (fd < 0) {
if (errno == EEXIST) {
/*
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 4a3cd2e..1119230 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -206,8 +206,6 @@ extern struct cluster_info *sys;
extern struct store_driver *sd_store;
extern char *obj_path;
extern char *epoch_path;
-extern mode_t def_fmode;
-extern mode_t def_dmode;
/* One should call this function to get sys->epoch outside main thread */
static inline uint32_t sys_epoch(void)
diff --git a/sheep/store.c b/sheep/store.c
index d95eb01..e6beb4b 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -31,9 +31,6 @@
char *obj_path;
char *epoch_path;
-mode_t def_dmode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP;
-mode_t def_fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
-
struct store_driver *sd_store;
LIST_HEAD(store_drivers);
@@ -65,7 +62,7 @@ int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes)
if (uatomic_is_true(&sys->use_journal))
flags &= ~O_DSYNC;
- fd = open(path, flags, def_fmode);
+ fd = open(path, flags, sd_def_fmode);
if (fd < 0) {
free(buf);
return -1;
@@ -203,7 +200,7 @@ again:
return 1;
}
- ret = mkdir(d, def_dmode);
+ ret = mkdir(d, sd_def_dmode);
if (ret) {
sd_eprintf("cannot create the directory %s: %m", d);
return 1;
@@ -234,7 +231,7 @@ static int lock_base_dir(const char *d)
lock_path = xzalloc(len);
snprintf(lock_path, len, "%s" LOCK_PATH, d);
- fd = open(lock_path, O_WRONLY|O_CREAT, def_fmode);
+ fd = open(lock_path, O_WRONLY|O_CREAT, sd_def_fmode);
if (fd < 0) {
sd_eprintf("failed to open lock file %s (%m)", lock_path);
ret = -1;
--
1.7.2.5
More information about the sheepdog
mailing list