diff options
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/common-utils.c | 103 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.h | 8 | ||||
-rw-r--r-- | libglusterfs/src/inode.h | 3 | ||||
-rw-r--r-- | libglusterfs/src/options.c | 3 | ||||
-rw-r--r-- | libglusterfs/src/options.h | 1 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 1 |
6 files changed, 116 insertions, 3 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 6eb886b3..bec3249f 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -787,12 +787,44 @@ gf_string2time (const char *str, uint32_t *n) if (errno == 0) errno = old_errno; - if (!((tail[0] == '\0') || + if (((tail[0] == '\0') || ((tail[0] == 's') && (tail[1] == '\0')) || ((tail[0] == 's') && (tail[1] == 'e') && (tail[2] == 'c') && (tail[3] == '\0')))) + goto out; + + else if (((tail[0] == 'm') && (tail[1] == '\0')) || + ((tail[0] == 'm') && (tail[1] == 'i') && + (tail[2] == 'n') && (tail[3] == '\0'))) { + value = value * GF_MINUTE_IN_SECONDS; + goto out; + } + + else if (((tail[0] == 'h') && (tail[1] == '\0')) || + ((tail[0] == 'h') && (tail[1] == 'r') && + (tail[2] == '\0'))) { + value = value * GF_HOUR_IN_SECONDS; + goto out; + } + + else if (((tail[0] == 'd') && (tail[1] == '\0')) || + ((tail[0] == 'd') && (tail[1] == 'a') && + (tail[2] == 'y') && (tail[3] == 's') && + (tail[4] == '\0'))) { + value = value * GF_DAY_IN_SECONDS; + goto out; + } + + else if (((tail[0] == 'w') && (tail[1] == '\0')) || + ((tail[0] == 'w') && (tail[1] == 'k') && + (tail[2] == '\0'))) { + value = value * GF_WEEK_IN_SECONDS; + goto out; + } else { return -1; + } +out: *n = value; return 0; @@ -2283,6 +2315,9 @@ gf_canonicalize_path (char *path) if (!path || *path != '/') goto out; + if (!strcmp (path, "/")) + return 0; + tmppath = gf_strdup (path); if (!tmppath) goto out; @@ -2807,3 +2842,69 @@ out: } +int +gf_get_soft_limit (char *limit, char **soft_limit) +{ + int colon_count = 0; + int i = 0; + int len = 0; + char *sl = NULL; + + len = strlen (limit); + for (i = 0; i < len; i++) { + if (limit[i] == ':') + colon_count++; + if (colon_count == 2) + break; + } + + if (colon_count != 2) { + gf_log ("common-utils", GF_LOG_DEBUG, "Soft-limit absent"); + return 0; + } + + sl = GF_CALLOC (len - i, sizeof (char), gf_common_mt_char); + if (!sl) + return -1; + strncpy (sl, &limit[i+1], len - i - 1); + *soft_limit = sl; + + return 1; +} + +int +gf_get_hard_limit (char *limit, char **hard_limit) +{ + int i = 0; + int hlbegin = 0; + int len = 0; + char *hl = NULL; + + len = strlen (limit); + + for (i = 0; i < len; i++) { + if (limit[i] == ':') + break; + } + + if (i == len) { + gf_log ("common-utils", GF_LOG_ERROR, "Hard limit not found"); + return -1; + } + + hlbegin = i + 1; + i++; + + while ((limit[i] != '\0') && (limit[i] != ':')) { + i++; + } + + hl = GF_CALLOC (i - hlbegin + 1, sizeof (char), gf_common_mt_char); + if (!hl) + return -1; + + strncpy (hl, &limit[hlbegin], i - hlbegin); + *hard_limit = hl; + + return 0; +} diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index bf41444d..f8db8e30 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -81,6 +81,11 @@ void trap (void); #define GF_NFS3_PORT 2049 #define GF_CLIENT_PORT_CEILING 1024 +#define GF_MINUTE_IN_SECONDS 60 +#define GF_HOUR_IN_SECONDS (60*60) +#define GF_DAY_IN_SECONDS (24*60*60) +#define GF_WEEK_IN_SECONDS (7*24*60*60) + enum _gf_boolean { _gf_false = 0, @@ -587,4 +592,7 @@ gf_boolean_t gf_is_local_addr (char *hostname); gf_boolean_t gf_is_same_address (char *host1, char *host2); void md5_wrapper(const unsigned char *data, size_t len, char *md5); +int gf_get_soft_limit (char *limit, char **soft_limit); +int gf_get_hard_limit (char *limit, char **hard_limit); + #endif /* _COMMON_UTILS_H */ diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index cf766a31..89a5f196 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -140,6 +140,9 @@ inode_rename (inode_table_t *table, inode_t *olddir, const char *oldname, inode_t *newdir, const char *newname, inode_t *inode, struct iatt *stbuf); +dentry_t * +__dentry_grep (inode_table_t *table, inode_t *parent, const char *name); + inode_t * inode_grep (inode_table_t *table, inode_t *parent, const char *name); diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index 842b6413..31e5a681 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -1110,7 +1110,7 @@ DEFINE_INIT_OPT(gf_boolean_t, bool, gf_string2boolean); DEFINE_INIT_OPT(xlator_t *, xlator, xl_by_name); DEFINE_INIT_OPT(char *, path, pass); DEFINE_INIT_OPT(double, double, gf_string2double); - +DEFINE_INIT_OPT(uint32_t, time, gf_string2time); DEFINE_RECONF_OPT(char *, str, pass); @@ -1125,3 +1125,4 @@ DEFINE_RECONF_OPT(gf_boolean_t, bool, gf_string2boolean); DEFINE_RECONF_OPT(xlator_t *, xlator, xl_by_name); DEFINE_RECONF_OPT(char *, path, pass); DEFINE_RECONF_OPT(double, double, gf_string2double); +DEFINE_RECONF_OPT(uint32_t, time, gf_string2time); diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h index e2a25baa..71a11c06 100644 --- a/libglusterfs/src/options.h +++ b/libglusterfs/src/options.h @@ -114,6 +114,7 @@ DECLARE_INIT_OPT(gf_boolean_t, bool); DECLARE_INIT_OPT(xlator_t *, xlator); DECLARE_INIT_OPT(char *, path); DECLARE_INIT_OPT(double, double); +DECLARE_INIT_OPT(uint32_t, time); #define DEFINE_INIT_OPT(type_t, type, conv) \ diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index b1c090c1..57360e1d 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -655,7 +655,6 @@ loc_copy (loc_t *dst, loc_t *src) uuid_copy (dst->gfid, src->gfid); uuid_copy (dst->pargfid, src->pargfid); - uuid_copy (dst->gfid, src->gfid); if (src->inode) dst->inode = inode_ref (src->inode); |