scripts/cfs_utils.py scripts/cloudfsd.py scripts/views
by Jeff Darcy
scripts/cfs_utils.py | 8 ++++----
scripts/cloudfsd.py | 7 ++++---
scripts/views/volumes.html | 3 ++-
3 files changed, 10 insertions(+), 8 deletions(-)
New commits:
commit 3dae2dc365599c9f733094b3e1c8ac89f8c6bba8
Author: Kaleb S. KEITHLEY <kkeithle(a)redhat.com>
Date: Thu Jun 9 12:01:14 2011 -0400
fix nit issues in the UI in preparation for adding UI to specify uid/gid
ranges per tenant.
cfs_utils.py: fix use_sudo (fmt string); don't make_remote when host
is local; use IP addr for localhost's name like all other nodes; sort
node_list, maybe just (semantic) sugar, but will be nice for long
lists of nodes and mounts
cloudfsd.py: glue between cfs_utils sorted node list and printing
nodes-and-mounts in sorted order
views/volumes.html: utilize sorted node_list to print nodes-and-mounts
in order
diff --git a/scripts/cfs_utils.py b/scripts/cfs_utils.py
index 39a36e0..ed6c6c4 100644
--- a/scripts/cfs_utils.py
+++ b/scripts/cfs_utils.py
@@ -40,8 +40,8 @@ def run_cmd (program, args, host=None, filters=[]):
for prog2, args2 in filters:
cmd = "%s | %s %s" % (cmd, get_path(prog2), args2)
if use_sudo:
- cmd = "%s %s" % cmd
- if host:
+ cmd = "sudo %s" % cmd
+ if host and host not in local_addrs:
cmd = make_remote(host,cmd)
if len(filters):
#print "executing %s using shell" % cmd
@@ -70,12 +70,12 @@ for line in run_cmd("ip","addr").stdout:
def get_members ():
peer_ips = run_cmd("gluster","peer status",
filters=[("grep","Hostname:")]).stdout
- my_ip = socket.gethostbyname(socket.gethostname())
- node_list = [socket.gethostbyaddr(my_ip)[0]]
+ node_list = [socket.gethostbyname(socket.gethostname())]
# For each line: strip off the trailing newline, split at colon, take
# item #1
for peer in [line[:-1].split(": ")[1] for line in peer_ips]:
node_list.append(peer)
+ node_list.sort()
return node_list
# A brick list looks something like this:
diff --git a/scripts/cloudfsd.py b/scripts/cloudfsd.py
index 8255a44..145f51f 100755
--- a/scripts/cloudfsd.py
+++ b/scripts/cloudfsd.py
@@ -48,8 +48,9 @@ def add_node():
def show_volumes():
brick_list = cfs_utils.get_bricks()
mount_list = cfs_utils.get_mounts(brick_list)
+ node_list = cfs_utils.get_members()
# TBD: allow adding arbitrary directories instead of just mountpoints
- return dict(bricks=brick_list,mounts=mount_list)
+ return dict(bricks=brick_list,mounts=mount_list,nodes=node_list)
@post("/volumes/add_directory")
def add_directory ():
@@ -133,10 +134,10 @@ def delete_tenant_local (tn_name):
def show_tenant_volumes (tn_name):
db_obj = cfs_utils.open_db()
all_vols = [v[3:] for v in db_obj.keys() if v.startswith("vt_")]
- print all_vols
+ # print all_vols
active = db_obj["tv_"+tn_name].split(",")
active.sort()
- print active
+ # print active
return dict(tn_name=tn_name,all_vols=all_vols,active=active)
@post("/tenants/:tn_name/enable")
diff --git a/scripts/views/volumes.html b/scripts/views/volumes.html
index cc54f92..12ef314 100644
--- a/scripts/views/volumes.html
+++ b/scripts/views/volumes.html
@@ -40,7 +40,8 @@
<form method="post" name="provision" action="/volumes/add_volume">
<table>
%color_index = 0
- %for node, mount_list in mounts.iteritems():
+ %for node in nodes:
+ %mount_list = mounts[node]
%color = "d%d" % color_index
%color_index = (color_index + 1) % 2
<tr class="{{color}}">
12 years, 5 months
Branch 'cloudfsd' - scripts/cfs_utils.py scripts/cloudfsd.py scripts/views
by Kaleb KEITHLEY
scripts/cfs_utils.py | 8 ++++----
scripts/cloudfsd.py | 7 ++++---
scripts/views/volumes.html | 3 ++-
3 files changed, 10 insertions(+), 8 deletions(-)
New commits:
commit 93ea5ceac3e784671fc33927c5960c5300de5daf
Author: Kaleb S. KEITHLEY <kkeithle(a)redhat.com>
Date: Thu Jun 9 12:01:14 2011 -0400
fix nit issues in the UI in preparation for adding UI to specify uid/gid
ranges per tenant.
cfs_utils.py: fix use_sudo (fmt string); don't make_remote when host
is local; use IP addr for localhost's name like all other nodes; sort
node_list, maybe just (semantic) sugar, but will be nice for long
lists of nodes and mounts
cloudfsd.py: glue between cfs_utils sorted node list and printing
nodes-and-mounts in sorted order
views/volumes.html: utilize sorted node_list to print nodes-and-mounts
in order
diff --git a/scripts/cfs_utils.py b/scripts/cfs_utils.py
index 21db9ec..6a63dfd 100644
--- a/scripts/cfs_utils.py
+++ b/scripts/cfs_utils.py
@@ -45,8 +45,8 @@ def run_cmd (program, args, host=None, filters=[]):
for prog2, args2 in filters:
cmd = "%s | %s %s" % (cmd, get_path(prog2), args2)
if use_sudo:
- cmd = "%s %s" % cmd
- if host:
+ cmd = "sudo %s" % cmd
+ if host and host not in local_addrs:
cmd = make_remote(host,cmd)
if len(filters):
#print "executing %s using shell" % cmd
@@ -75,12 +75,12 @@ for line in run_cmd("ip","addr").stdout:
def get_members ():
peer_ips = run_cmd("gluster","peer status",
filters=[("grep","Hostname:")]).stdout
- my_ip = socket.gethostbyname(socket.gethostname())
- node_list = [socket.gethostbyaddr(my_ip)[0]]
+ node_list = [socket.gethostbyname(socket.gethostname())]
# For each line: strip off the trailing newline, split at colon, take
# item #1
for peer in [line[:-1].split(": ")[1] for line in peer_ips]:
node_list.append(peer)
+ node_list.sort()
return node_list
# A brick list looks something like this:
diff --git a/scripts/cloudfsd.py b/scripts/cloudfsd.py
index d081aed..2ccef28 100755
--- a/scripts/cloudfsd.py
+++ b/scripts/cloudfsd.py
@@ -73,8 +73,9 @@ def show_volumes():
abort(401,"Forbidden")
brick_list = cfs_utils.get_bricks()
mount_list = cfs_utils.get_mounts(brick_list)
+ node_list = cfs_utils.get_members()
# TBD: allow adding arbitrary directories instead of just mountpoints
- return dict(bricks=brick_list,mounts=mount_list)
+ return dict(bricks=brick_list,mounts=mount_list,nodes=node_list)
@post("/volumes/add_directory")
def add_directory ():
@@ -194,10 +195,10 @@ def show_tenant_volumes (tn_name):
abort(401,"Forbidden")
db_obj = cfs_utils.open_db()
all_vols = [v[3:] for v in db_obj.keys() if v.startswith("vt_")]
- print all_vols
+ # print all_vols
active = db_obj["tv_"+tn_name].split(",")
active.sort()
- print active
+ # print active
return dict(tn_name=tn_name,all_vols=all_vols,active=active)
@post("/tenants/:tn_name/enable")
diff --git a/scripts/views/volumes.html b/scripts/views/volumes.html
index cc54f92..12ef314 100644
--- a/scripts/views/volumes.html
+++ b/scripts/views/volumes.html
@@ -40,7 +40,8 @@
<form method="post" name="provision" action="/volumes/add_volume">
<table>
%color_index = 0
- %for node, mount_list in mounts.iteritems():
+ %for node in nodes:
+ %mount_list = mounts[node]
%color = "d%d" % color_index
%color_index = (color_index + 1) % 2
<tr class="{{color}}">
12 years, 5 months
2 commits - xlators/features
by Jeff Darcy
xlators/features/uidmap/src/rbmap.c | 14
xlators/features/uidmap/src/uidmap.c | 2617 +++++++++++++++++------------------
2 files changed, 1347 insertions(+), 1284 deletions(-)
New commits:
commit 08d79e2084424ab4cdd7deb29be0e9d89d0f1e96
Author: Jeff Darcy <jdarcy(a)redhat.com>
Date: Wed Jun 8 21:57:53 2011 -0400
Map UID/GID 0 regardless of root_squash.
Clients should never ever be able to "escape" into the server's own UID/GID
space, especially not for UID/GID 0. Also, the UID and GID should be
mapped (to CLOUDFS_NOBODY) separately when root_squash is set, because they
might not be zero at the same times.
diff --git a/xlators/features/uidmap/src/rbmap.c b/xlators/features/uidmap/src/rbmap.c
index 49b3500..030cac5 100644
--- a/xlators/features/uidmap/src/rbmap.c
+++ b/xlators/features/uidmap/src/rbmap.c
@@ -288,13 +288,12 @@ map(struct _call_stack_t *stack, char *name)
if (mapping == NULL) {
return -1;
}
- if (stack->uid == 0 && mapping->root_squash) {
- stack->uid = stack->gid = CLOUDFS_NOBODY;
- return 0;
- }
do {
pthread_mutex_lock(&mapping->mtx);
- if (stack->uid != 0) {
+ if (stack->uid == 0 && mapping->root_squash) {
+ stack->uid = CLOUDFS_NOBODY;
+ }
+ else {
/* look for an existing match */
union tuple *new_map, tneedle;
tneedle.u1 = stack->uid;
@@ -347,7 +346,10 @@ map(struct _call_stack_t *stack, char *name)
}
stack->uid = new_map->u2;
}
- if (stack->gid != 0) {
+ if (stack->gid == 0 && mapping->root_squash) {
+ stack->gid = CLOUDFS_NOBODY;
+ }
+ else {
/* look for an existing match */
union tuple *new_map, tneedle;
tneedle.g1 = stack->gid;
commit 680bd6c453664f4e6ae9cbc16f9ac7f9d0220e18
Author: Jeff Darcy <jdarcy(a)redhat.com>
Date: Wed Jun 8 21:34:18 2011 -0400
Fix style issues
Indentation, assignment within conditional, braces and parens, etc.
diff --git a/xlators/features/uidmap/src/uidmap.c b/xlators/features/uidmap/src/uidmap.c
index 550314f..72d03f1 100644
--- a/xlators/features/uidmap/src/uidmap.c
+++ b/xlators/features/uidmap/src/uidmap.c
@@ -40,47 +40,47 @@
#define CFS_GID_HIGH_DEFAULT 19999
typedef struct uid_map_entry {
- uid_t me_client_uid;
- uid_t me_server_uid;
+ uid_t me_client_uid;
+ uid_t me_server_uid;
} uid_map_entry_t;
typedef struct gid_map_entry {
- uid_t me_client_gid;
- uid_t me_server_gid;
+ uid_t me_client_gid;
+ uid_t me_server_gid;
} gid_map_entry_t;
typedef struct {
- char *name;
- uid_map_entry_t *uid_map;
- unsigned short uid_map_len;
- uid_t uid_low;
- uid_t uid_high;
- uid_t uid_next;
- gid_map_entry_t *gid_map;
- unsigned short gid_map_len;
- gid_t gid_low;
- gid_t gid_high;
- gid_t gid_next;
- short root_squash;
- pthread_mutex_t mtx;
+ char *name;
+ uid_map_entry_t *uid_map;
+ unsigned short uid_map_len;
+ uid_t uid_low;
+ uid_t uid_high;
+ uid_t uid_next;
+ gid_map_entry_t *gid_map;
+ unsigned short gid_map_len;
+ gid_t gid_low;
+ gid_t gid_high;
+ gid_t gid_next;
+ short root_squash;
+ pthread_mutex_t mtx;
} mapping_t;
static unsigned short uidmap_num_mappings = 0;
static mapping_t* uidmap_mappings; /* = {
- .im_name = NULL,
- .im_uid_map = NULL,
- .im_uid_map_len = 0,
- .im_uid_low = CFS_UID_LOW_DEFAULT,
- .im_uid_high = CFS_UID_HIGH_DEFAULT,
- .im_uid_next = CFS_UID_LOW_DEFAULT,
- .im_gid_map = NULL,
- .im_gid_map_len = 0,
- .im_gid_low = CFS_UID_LOW_DEFAULT,
- .im_gid_high = CFS_UID_HIGH_DEFAULT,
- .im_gid_next = CFS_UID_LOW_DEFAULT,
- .im_root_squash = 0,
- .im_mtx = PTHREAD_MUTEX_INITIALIZER
+ .im_name = NULL,
+ .im_uid_map = NULL,
+ .im_uid_map_len = 0,
+ .im_uid_low = CFS_UID_LOW_DEFAULT,
+ .im_uid_high = CFS_UID_HIGH_DEFAULT,
+ .im_uid_next = CFS_UID_LOW_DEFAULT,
+ .im_gid_map = NULL,
+ .im_gid_map_len = 0,
+ .im_gid_low = CFS_UID_LOW_DEFAULT,
+ .im_gid_high = CFS_UID_HIGH_DEFAULT,
+ .im_gid_next = CFS_UID_LOW_DEFAULT,
+ .im_root_squash = 0,
+ .im_mtx = PTHREAD_MUTEX_INITIALIZER
}; */
#define CFS_SIGNATURE "cloudfs map: default\n"
@@ -107,374 +107,383 @@ static mapping_t* uidmap_mappings; /* = {
static void
uidmap_serialize_default(char *tenant, mapping_t *map)
{
- char fname[128], lkname[128];
- FILE *file = NULL;
- int lockfd = -1;
- (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, tenant);
- (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, tenant);
-
- do {
- int status;
- unsigned short i;
- lockfd = open(lkname, O_CREAT|O_WRONLY, 0644);
- if (lockfd == -1) {
- gf_log(tenant, GF_LOG_CRITICAL,
- "open %s: %s", lkname, strerror(errno));
- break;
- }
- status = flock(lockfd, LOCK_EX);
- if (status == -1) {
- gf_log(tenant, GF_LOG_CRITICAL,
- "flock failed %s", strerror(errno));
- break;
- }
- file = fopen(fname, "w");
- if (file == NULL) {
- (void) flock(lockfd, LOCK_UN);
- gf_log(tenant, GF_LOG_CRITICAL,
- "fopen failed %s", strerror(errno));
- break;
- }
- (void) fprintf(file, CFS_SIGNATURE);
- for (i = 0; i < map->uid_map_len; i++) {
- (void) fprintf(file, "%s %u %u\n",
- CFS_UID_MAP_ENTRY,
- map->uid_map[i].me_client_uid,
- map->uid_map[i].me_server_uid);
- }
- (void) fprintf(file, "%s %u\n",
- CFS_UID_LOW, map->uid_low);
- (void) fprintf(file, "%s %u\n",
- CFS_UID_HIGH, map->uid_high);
- (void) fprintf(file, "%s %u\n",
- CFS_UID_NEXT, map->uid_next);
- for (i = 0; i < map->gid_map_len; i++) {
- (void) fprintf(file, "%s %u %u\n", CFS_GID_MAP_ENTRY,
- map->gid_map[i].me_client_gid,
- map->gid_map[i].me_server_gid);
- }
- (void) fprintf(file, "%s %u\n", CFS_GID_LOW,
- map->gid_low);
- (void) fprintf(file, "%s %u\n", CFS_GID_HIGH,
- map->gid_high);
- (void) fprintf(file, "%s %u\n", CFS_GID_NEXT,
- map->gid_next);
- } while (0);
- if (file != NULL) {
- (void) fclose(file);
- }
- if (lockfd != -1) {
- (void) flock(lockfd, LOCK_UN);
- (void) close(lockfd);
- }
+ char fname[128], lkname[128];
+ FILE *file = NULL;
+ int lockfd = -1;
+ (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, tenant);
+ (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, tenant);
+
+ do {
+ int status;
+ unsigned short i;
+ lockfd = open(lkname, O_CREAT|O_WRONLY, 0644);
+ if (lockfd == -1) {
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "open %s: %s", lkname, strerror(errno));
+ break;
+ }
+ status = flock(lockfd, LOCK_EX);
+ if (status == -1) {
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "flock failed %s", strerror(errno));
+ break;
+ }
+ file = fopen(fname, "w");
+ if (file == NULL) {
+ (void) flock(lockfd, LOCK_UN);
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "fopen failed %s", strerror(errno));
+ break;
+ }
+ (void) fprintf(file, CFS_SIGNATURE);
+ for (i = 0; i < map->uid_map_len; i++) {
+ (void) fprintf(file, "%s %u %u\n",
+ CFS_UID_MAP_ENTRY,
+ map->uid_map[i].me_client_uid,
+ map->uid_map[i].me_server_uid);
+ }
+ (void) fprintf(file, "%s %u\n",
+ CFS_UID_LOW, map->uid_low);
+ (void) fprintf(file, "%s %u\n",
+ CFS_UID_HIGH, map->uid_high);
+ (void) fprintf(file, "%s %u\n",
+ CFS_UID_NEXT, map->uid_next);
+ for (i = 0; i < map->gid_map_len; i++) {
+ (void) fprintf(file, "%s %u %u\n", CFS_GID_MAP_ENTRY,
+ map->gid_map[i].me_client_gid,
+ map->gid_map[i].me_server_gid);
+ }
+ (void) fprintf(file, "%s %u\n", CFS_GID_LOW,
+ map->gid_low);
+ (void) fprintf(file, "%s %u\n", CFS_GID_HIGH,
+ map->gid_high);
+ (void) fprintf(file, "%s %u\n", CFS_GID_NEXT,
+ map->gid_next);
+ } while (0);
+ if (file != NULL) {
+ (void) fclose(file);
+ }
+ if (lockfd != -1) {
+ (void) flock(lockfd, LOCK_UN);
+ (void) close(lockfd);
+ }
}
static int
uidmap_adduidentry(mapping_t *map, uid_t server_uid, uid_t client_uid)
{
- uid_map_entry_t *uid_map_entry = NULL;
- map->uid_map = REALLOC(map->uid_map,
- sizeof(uid_map_entry_t) * (map->uid_map_len + 1));
- if (map->uid_map == NULL) {
- return -1;
- }
- uid_map_entry = &map->uid_map[map->uid_map_len++];
- uid_map_entry->me_client_uid = client_uid;
- uid_map_entry->me_server_uid = server_uid;
- return 0;
+ uid_map_entry_t *uid_map_entry = NULL;
+ map->uid_map = REALLOC(map->uid_map,
+ sizeof(uid_map_entry_t) * (map->uid_map_len + 1));
+ if (map->uid_map == NULL) {
+ return -1;
+ }
+ uid_map_entry = &map->uid_map[map->uid_map_len++];
+ uid_map_entry->me_client_uid = client_uid;
+ uid_map_entry->me_server_uid = server_uid;
+ return 0;
}
static int
uidmap_addgidentry(mapping_t *map, uid_t server_gid, uid_t client_gid)
{
- gid_map_entry_t *gid_map_entry = NULL;
- map->gid_map = REALLOC(map->gid_map,
- sizeof(gid_map_entry_t) * (map->gid_map_len + 1));
- if (map->gid_map == NULL) {
- return -1;
- }
- gid_map_entry = &map->gid_map[map->gid_map_len++];
- gid_map_entry->me_client_gid = client_gid;
- gid_map_entry->me_server_gid = server_gid;
- return 0;
+ gid_map_entry_t *gid_map_entry = NULL;
+ map->gid_map = REALLOC(map->gid_map,
+ sizeof(gid_map_entry_t) * (map->gid_map_len + 1));
+ if (map->gid_map == NULL) {
+ return -1;
+ }
+ gid_map_entry = &map->gid_map[map->gid_map_len++];
+ gid_map_entry->me_client_gid = client_gid;
+ gid_map_entry->me_server_gid = server_gid;
+ return 0;
}
static int
uidmap_readmapfile(mapping_t *map, FILE *file)
{
- char* sts;
- char scratch[128];
- while ((sts = fgets(scratch, sizeof scratch, file)) != (char *) EOF && sts != NULL) {
- if (strncmp(scratch, CFS_UID_MAP_ENTRY, CFS_UID_MAP_ENTRY_LEN) == 0) {
- uid_t server_uid;
- uid_t client_uid;
- int num = sscanf(&scratch[CFS_UID_MAP_ENTRY_LEN+1],
- " %u %u", &client_uid, &server_uid);
- if (num == 2) {
- if (uidmap_adduidentry(map, server_uid, client_uid) == -1) {
- return -1;
- }
- }
- } else if (strncmp(scratch, CFS_UID_LOW, CFS_UID_LOW_LEN) == 0) {
- map->uid_low = (uid_t) strtoul(&scratch[CFS_UID_LOW_LEN+1], NULL, 10);
- } else if (strncmp(scratch, CFS_UID_HIGH, CFS_UID_HIGH_LEN) == 0) {
- map->uid_high = (uid_t) strtoul(&scratch[CFS_UID_HIGH_LEN+1], NULL, 10);
- } else if (strncmp(scratch, CFS_UID_NEXT, CFS_UID_NEXT_LEN) == 0) {
- map->uid_next = (uid_t) strtoul(&scratch[CFS_UID_NEXT_LEN+1], NULL, 10);
- } else if (strncmp(scratch, CFS_GID_MAP_ENTRY, CFS_GID_MAP_ENTRY_LEN) == 0) {
- gid_t server_gid;
- gid_t client_gid;
- int num = sscanf(&scratch[CFS_GID_MAP_ENTRY_LEN+1],
- " %u %u", &client_gid, &server_gid);
- if (num == 2) {
- if (uidmap_addgidentry(map, server_gid, client_gid) == -1) {
- return -1;
- }
- }
- } else if (strncmp(scratch, CFS_GID_LOW, CFS_GID_LOW_LEN) == 0) {
- map->gid_low = (uid_t) strtoul(&scratch[CFS_GID_LOW_LEN+1], NULL, 10);
- } else if (strncmp(scratch, CFS_GID_HIGH, CFS_GID_HIGH_LEN) == 0) {
- map->gid_high = (uid_t) strtoul(&scratch[CFS_GID_HIGH_LEN+1], NULL, 10);
- } else if (strncmp(scratch, CFS_GID_NEXT, CFS_GID_NEXT_LEN) == 0) {
- map->gid_next = (uid_t) strtoul(&scratch[CFS_GID_NEXT_LEN+1], NULL, 10);
- }
- }
- return 0;
+ char* sts;
+ char scratch[128];
+
+ for (;;) {
+ sts = fgets(scratch, sizeof scratch, file);
+ if ((sts == (char *) EOF) || (sts != NULL)) {
+ break;
+ }
+ if (strncmp(scratch, CFS_UID_MAP_ENTRY, CFS_UID_MAP_ENTRY_LEN) == 0) {
+ uid_t server_uid;
+ uid_t client_uid;
+ int num = sscanf(&scratch[CFS_UID_MAP_ENTRY_LEN+1],
+ " %u %u", &client_uid, &server_uid);
+ if (num == 2) {
+ if (uidmap_adduidentry(map, server_uid, client_uid) == -1) {
+ return -1;
+ }
+ }
+ } else if (strncmp(scratch, CFS_UID_LOW, CFS_UID_LOW_LEN) == 0) {
+ map->uid_low = (uid_t) strtoul(&scratch[CFS_UID_LOW_LEN+1], NULL, 10);
+ } else if (strncmp(scratch, CFS_UID_HIGH, CFS_UID_HIGH_LEN) == 0) {
+ map->uid_high = (uid_t) strtoul(&scratch[CFS_UID_HIGH_LEN+1], NULL, 10);
+ } else if (strncmp(scratch, CFS_UID_NEXT, CFS_UID_NEXT_LEN) == 0) {
+ map->uid_next = (uid_t) strtoul(&scratch[CFS_UID_NEXT_LEN+1], NULL, 10);
+ } else if (strncmp(scratch, CFS_GID_MAP_ENTRY, CFS_GID_MAP_ENTRY_LEN) == 0) {
+ gid_t server_gid;
+ gid_t client_gid;
+ int num = sscanf(&scratch[CFS_GID_MAP_ENTRY_LEN+1],
+ " %u %u", &client_gid, &server_gid);
+ if (num == 2) {
+ if (uidmap_addgidentry(map, server_gid, client_gid) == -1) {
+ return -1;
+ }
+ }
+ } else if (strncmp(scratch, CFS_GID_LOW, CFS_GID_LOW_LEN) == 0) {
+ map->gid_low = (uid_t) strtoul(&scratch[CFS_GID_LOW_LEN+1], NULL, 10);
+ } else if (strncmp(scratch, CFS_GID_HIGH, CFS_GID_HIGH_LEN) == 0) {
+ map->gid_high = (uid_t) strtoul(&scratch[CFS_GID_HIGH_LEN+1], NULL, 10);
+ } else if (strncmp(scratch, CFS_GID_NEXT, CFS_GID_NEXT_LEN) == 0) {
+ map->gid_next = (uid_t) strtoul(&scratch[CFS_GID_NEXT_LEN+1], NULL, 10);
+ }
+ }
+ return 0;
}
static int
uidmap_deserialize_default(char *tenant, uid_t uid_low, uid_t uid_high, gid_t gid_low, gid_t gid_high, short root_squash)
{
- char fname[128], lkname[128];
- FILE* file = NULL;
- int lockfd = -1;
- int ret = 0;
- (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, tenant);
- (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, tenant);
-
- do {
- char scratch[128];
- mapping_t *map;
- char* sts;
- int status;
-
- uidmap_mappings = REALLOC(uidmap_mappings,
- sizeof(mapping_t) * uidmap_num_mappings);
- if (uidmap_mappings == NULL) {
- break;
- }
- map = &uidmap_mappings[uidmap_num_mappings];
- map->name = strdup(tenant);
- map->uid_map = NULL,
- map->uid_map_len = 0,
- map->uid_low = uid_low,
- map->uid_high = uid_high,
- map->uid_next = uid_low,
- map->gid_map = NULL,
- map->gid_map_len = 0,
- map->gid_low = gid_low,
- map->gid_high = gid_high,
- map->gid_next = gid_low,
- map->root_squash = root_squash,
- (void) pthread_mutex_init(&map->mtx, NULL);
- uidmap_num_mappings++;
-
- lockfd = open(lkname, O_CREAT|O_RDONLY, 0644);
- if (lockfd == -1) {
- gf_log(tenant, GF_LOG_CRITICAL,
- "open %s: %s", lkname, strerror(errno));
- break;
- }
- status = flock(lockfd, LOCK_EX);
- if (status == -1) {
- gf_log(tenant, GF_LOG_CRITICAL,
- "flock: %s", strerror(errno));
- break;
- }
- file = fopen(fname, "r");
- if (file == NULL) {
- gf_log(tenant, GF_LOG_INFO,
- "fopen failed: %s", strerror(errno));
- break;
- }
- /* read the first line (signature) of the file) */
- if ((sts = fgets(scratch, sizeof scratch, file)) == (char *) EOF || sts == NULL) {
- gf_log(tenant, GF_LOG_CRITICAL,
- "fgets signature failed: %s", strerror(errno));
- break;
- }
- if (strcmp(CFS_SIGNATURE, scratch) != 0) {
- gf_log(tenant, GF_LOG_CRITICAL,
- "signature mismatch: %s", scratch);
- break;
- }
- ret = uidmap_readmapfile(map, file);
- } while (0);
- if (file != NULL) {
- (void) fclose(file);
- }
- if (lockfd != -1) {
- (void) flock(lockfd, LOCK_UN);
- (void) close(lockfd);
- }
- return ret;
+ char fname[128], lkname[128];
+ FILE* file = NULL;
+ int lockfd = -1;
+ int ret = 0;
+ (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, tenant);
+ (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, tenant);
+
+ do {
+ char scratch[128];
+ mapping_t *map;
+ char* sts;
+ int status;
+
+ uidmap_mappings = REALLOC(uidmap_mappings,
+ sizeof(mapping_t) * uidmap_num_mappings);
+ if (uidmap_mappings == NULL) {
+ break;
+ }
+ map = &uidmap_mappings[uidmap_num_mappings];
+ map->name = strdup(tenant);
+ map->uid_map = NULL,
+ map->uid_map_len = 0,
+ map->uid_low = uid_low,
+ map->uid_high = uid_high,
+ map->uid_next = uid_low,
+ map->gid_map = NULL,
+ map->gid_map_len = 0,
+ map->gid_low = gid_low,
+ map->gid_high = gid_high,
+ map->gid_next = gid_low,
+ map->root_squash = root_squash,
+ (void) pthread_mutex_init(&map->mtx, NULL);
+ uidmap_num_mappings++;
+
+ lockfd = open(lkname, O_CREAT|O_RDONLY, 0644);
+ if (lockfd == -1) {
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "open %s: %s", lkname, strerror(errno));
+ break;
+ }
+ status = flock(lockfd, LOCK_EX);
+ if (status == -1) {
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "flock: %s", strerror(errno));
+ break;
+ }
+ file = fopen(fname, "r");
+ if (file == NULL) {
+ gf_log(tenant, GF_LOG_INFO,
+ "fopen failed: %s", strerror(errno));
+ break;
+ }
+ /* read the first line (signature) of the file) */
+ sts = fgets(scratch, sizeof scratch, file);
+ if ((sts == (char *) EOF) || (sts == NULL)) {
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "fgets signature failed: %s", strerror(errno));
+ break;
+ }
+ if (strcmp(CFS_SIGNATURE, scratch) != 0) {
+ gf_log(tenant, GF_LOG_CRITICAL,
+ "signature mismatch: %s", scratch);
+ break;
+ }
+ ret = uidmap_readmapfile(map, file);
+ } while (0);
+ if (file != NULL) {
+ (void) fclose(file);
+ }
+ if (lockfd != -1) {
+ (void) flock(lockfd, LOCK_UN);
+ (void) close(lockfd);
+ }
+ return ret;
}
static int
uidmap_map_default(struct _call_stack_t *stack, char *name)
{
- mapping_t *map = uidmap_mappings;
- int do_persist = 0;
- unsigned short i = 0;
- /* assert(uid_num_mappings > 0) */
- for (; i < uidmap_num_mappings; i++, map++) {
- if (strcmp(map->name, name) == 0) {
- break;
- }
- }
- if (stack->uid == 0 && map->root_squash) {
- stack->uid = stack->gid = CLOUDFS_NOBODY;
- return 0;
- }
- pthread_mutex_lock(&map->mtx);
- do {
- unsigned short index = 0;
- if (stack->uid != 0) {
- /* look for an existing match */
- uid_map_entry_t *uid_map_entry = NULL;
- for (; index < map->uid_map_len; index++) {
- if (map->uid_map[index].me_client_uid == stack->uid) {
- uid_map_entry = &map->uid_map[index];
- break;
- }
- }
- if (uid_map_entry == NULL) {
- /* couldn't find one, make a new one */
- if (map->uid_next > map->uid_high) {
- gf_log(name, GF_LOG_CRITICAL,
- "no uids in range %u-%u",
- map->uid_low, map->uid_high);
- pthread_mutex_unlock(&map->mtx);
- return -1;
- }
- uid_map_entry_t *tmpmap =
- REALLOC(map->uid_map, sizeof(uid_map_entry_t) * (map->uid_map_len + 1));
- if (tmpmap == NULL) {
- pthread_mutex_unlock(&map->mtx);
- return -1;
- }
- do_persist = 1;
- map->uid_map = tmpmap;
- uid_map_entry = &map->uid_map[map->uid_map_len++];
- uid_map_entry->me_client_uid = stack->uid;
- uid_map_entry->me_server_uid = map->uid_next++;
- gf_log(name, CFS_LOG_LEVEL,
- "added new uid mapping %u -> %u",
- stack->uid, uid_map_entry->me_server_uid);
- if (map->uid_next > map->uid_high) {
- gf_log(name, GF_LOG_CRITICAL,
- "exhausted uids in range %u-%u",
- map->uid_low, map->uid_high);
- }
- }
- stack->uid = uid_map_entry->me_server_uid;
- }
- if (stack->gid != 0) {
- gid_map_entry_t *gid_map_entry = NULL;
- for (index = 0; index < map->gid_map_len; index++) {
- if (map->gid_map[index].me_client_gid == stack->gid) {
- gid_map_entry = &map->gid_map[index];
- break;
- }
- }
- if (gid_map_entry == NULL) {
- /* couldn't find one, make a new one */
- if (map->gid_next > map->gid_high) {
- gf_log(name, GF_LOG_CRITICAL,
- "no gids in range %u-%u",
- map->gid_low, map->gid_high);
- pthread_mutex_unlock(&map->mtx);
- return -1;
- }
- gid_map_entry_t *tmpmap =
- REALLOC(map->gid_map, sizeof(gid_map_entry_t) * (map->gid_map_len + 1));
- if (tmpmap == NULL) {
- pthread_mutex_unlock(&map->mtx);
- return -1;
- }
- do_persist = 1;
- map->gid_map = tmpmap;
- gid_map_entry = &map->gid_map[map->gid_map_len++];
- gid_map_entry->me_client_gid = stack->gid;
- gid_map_entry->me_server_gid = map->gid_next++;
- gf_log(name, CFS_LOG_LEVEL,
- "added new gid mapping %u -> %u",
- stack->gid, gid_map_entry->me_server_gid);
- if (map->gid_next > map->gid_high) {
- gf_log(name, GF_LOG_CRITICAL,
- "exhausted gids in range %u-%u",
- map->gid_low, map->gid_high);
- }
- }
- stack->gid = gid_map_entry->me_server_gid;
- }
- } while (0);
- if (do_persist > 0)
- uidmap_serialize_default(name, map);
- pthread_mutex_unlock(&map->mtx);
- return 0;
+ mapping_t *map = uidmap_mappings;
+ int do_persist = 0;
+ unsigned short i = 0;
+ /* assert(uid_num_mappings > 0) */
+ for (; i < uidmap_num_mappings; i++, map++) {
+ if (strcmp(map->name, name) == 0) {
+ break;
+ }
+ }
+ if ((stack->uid == 0) && (map->root_squash)) {
+ stack->uid = stack->gid = CLOUDFS_NOBODY;
+ return 0;
+ }
+ pthread_mutex_lock(&map->mtx);
+ do {
+ unsigned short index = 0;
+ if (stack->uid != 0) {
+ /* look for an existing match */
+ uid_map_entry_t *uid_map_entry = NULL;
+ for (; index < map->uid_map_len; index++) {
+ if (map->uid_map[index].me_client_uid == stack->uid) {
+ uid_map_entry = &map->uid_map[index];
+ break;
+ }
+ }
+ if (uid_map_entry == NULL) {
+ /* couldn't find one, make a new one */
+ if (map->uid_next > map->uid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "no uids in range %u-%u",
+ map->uid_low, map->uid_high);
+ pthread_mutex_unlock(&map->mtx);
+ return -1;
+ }
+ uid_map_entry_t *tmpmap =
+ REALLOC(map->uid_map, sizeof(uid_map_entry_t) * (map->uid_map_len + 1));
+ if (tmpmap == NULL) {
+ pthread_mutex_unlock(&map->mtx);
+ return -1;
+ }
+ do_persist = 1;
+ map->uid_map = tmpmap;
+ uid_map_entry = &map->uid_map[map->uid_map_len++];
+ uid_map_entry->me_client_uid = stack->uid;
+ uid_map_entry->me_server_uid = map->uid_next++;
+ gf_log(name, CFS_LOG_LEVEL,
+ "added new uid mapping %u -> %u",
+ stack->uid, uid_map_entry->me_server_uid);
+ if (map->uid_next > map->uid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "exhausted uids in range %u-%u",
+ map->uid_low, map->uid_high);
+ }
+ }
+ stack->uid = uid_map_entry->me_server_uid;
+ }
+ if (stack->gid != 0) {
+ gid_map_entry_t *gid_map_entry = NULL;
+ for (index = 0; index < map->gid_map_len; index++) {
+ if (map->gid_map[index].me_client_gid == stack->gid) {
+ gid_map_entry = &map->gid_map[index];
+ break;
+ }
+ }
+ if (gid_map_entry == NULL) {
+ /* couldn't find one, make a new one */
+ if (map->gid_next > map->gid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "no gids in range %u-%u",
+ map->gid_low, map->gid_high);
+ pthread_mutex_unlock(&map->mtx);
+ return -1;
+ }
+ gid_map_entry_t *tmpmap =
+ REALLOC(map->gid_map, sizeof(gid_map_entry_t) * (map->gid_map_len + 1));
+ if (tmpmap == NULL) {
+ pthread_mutex_unlock(&map->mtx);
+ return -1;
+ }
+ do_persist = 1;
+ map->gid_map = tmpmap;
+ gid_map_entry = &map->gid_map[map->gid_map_len++];
+ gid_map_entry->me_client_gid = stack->gid;
+ gid_map_entry->me_server_gid = map->gid_next++;
+ gf_log(name, CFS_LOG_LEVEL,
+ "added new gid mapping %u -> %u",
+ stack->gid, gid_map_entry->me_server_gid);
+ if (map->gid_next > map->gid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "exhausted gids in range %u-%u",
+ map->gid_low, map->gid_high);
+ }
+ }
+ stack->gid = gid_map_entry->me_server_gid;
+ }
+ } while (0);
+ if (do_persist > 0) {
+ uidmap_serialize_default(name, map);
+ }
+ pthread_mutex_unlock(&map->mtx);
+ return 0;
}
static void
uidmap_revmap_default(uid_t *uid, gid_t *gid, char *name)
{
- uid_map_entry_t *uid_map_entry;
- gid_map_entry_t *gid_map_entry;
- mapping_t *map = uidmap_mappings;
- unsigned int index = 0;
- unsigned short i = 0;
-
- /* assert(uid_num_mappings > 0) */
- for (; i < uidmap_num_mappings; i++, map++) {
- if (strcmp(map->name, name) == 0) {
- break;
- }
- }
-
- switch (*uid) {
- case 0:
- /* break; */
- case CLOUDFS_NOBODY:
- *uid = 0;
- break;
- default:
- uid_map_entry = map->uid_map;
- for (; index < map->uid_map_len; index++, uid_map_entry++) {
- if (*uid == uid_map_entry->me_server_uid)
- *uid = uid_map_entry->me_client_uid;
- }
- break;
- }
- switch (*gid) {
- case 0:
- /* break; */
- case CLOUDFS_NOBODY:
- *uid = 0;
- break;
- default:
- gid_map_entry = map->gid_map;
- for (index = 0; index < map->gid_map_len; index++, gid_map_entry++) {
- if (*gid == gid_map_entry->me_server_gid)
- *gid = gid_map_entry->me_client_gid;
- }
- break;
- }
+ uid_map_entry_t *uid_map_entry;
+ gid_map_entry_t *gid_map_entry;
+ mapping_t *map = uidmap_mappings;
+ unsigned int index = 0;
+ unsigned short i = 0;
+
+ /* assert(uid_num_mappings > 0) */
+ for (; i < uidmap_num_mappings; i++, map++) {
+ if (strcmp(map->name, name) == 0) {
+ break;
+ }
+ }
+
+ switch (*uid) {
+ case 0:
+ /* break; */
+ case CLOUDFS_NOBODY:
+ *uid = 0;
+ break;
+ default:
+ uid_map_entry = map->uid_map;
+ for (; index < map->uid_map_len; index++, uid_map_entry++) {
+ if (*uid == uid_map_entry->me_server_uid) {
+ *uid = uid_map_entry->me_client_uid;
+ }
+ }
+ break;
+ }
+ switch (*gid) {
+ case 0:
+ /* break; */
+ case CLOUDFS_NOBODY:
+ *uid = 0;
+ break;
+ default:
+ gid_map_entry = map->gid_map;
+ for (index = 0; index < map->gid_map_len; index++, gid_map_entry++) {
+ if (*gid == gid_map_entry->me_server_gid) {
+ *gid = gid_map_entry->me_client_gid;
+ }
+ }
+ break;
+ }
}
@@ -485,1358 +494,1395 @@ static fini_fn uidmap_plugin_fini = NULL;
int
uidmap_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd,
- inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno, fd_t *fd,
+ inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf,
+ preparent, postparent);
+ return 0;
}
int
uidmap_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd)
+ int32_t op_ret, int32_t op_errno, fd_t *fd)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d, *fd=%p)",
- frame->root->unique, op_ret, op_errno, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d, *fd=%p)",
+ frame->root->unique, op_ret, op_errno, fd);
- STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd);
- return 0;
+ STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd);
+ return 0;
}
int
uidmap_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf)
+ int32_t op_ret, int32_t op_errno, struct iatt *buf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(stat, frame, op_ret, op_errno, buf);
- return 0;
+ STACK_UNWIND_STRICT(stat, frame, op_ret, op_errno, buf);
+ return 0;
}
int
uidmap_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count, struct iatt *buf, struct iobref *iobref)
+ int32_t op_ret, int32_t op_errno, struct iovec *vector,
+ int32_t count, struct iatt *buf, struct iobref *iobref)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count,
- buf, iobref);
- return 0;
+ STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count,
+ buf, iobref);
+ return 0;
}
int
uidmap_writev_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf);
- return 0;
+ STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf);
+ return 0;
}
int
uidmap_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, gf_dirent_t *buf)
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *buf)
{
- struct _gf_dirent_t *entry;
+ struct _gf_dirent_t *entry;
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64" :(op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64" :(op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid, this->name);
- list_for_each_entry(entry, &buf->list, list) {
- (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid, this->name);
- }
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid, this->name);
+ list_for_each_entry(entry, &buf->list, list) {
+ (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid, this->name);
+ }
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(readdir, frame, op_ret, op_errno, buf);
+ STACK_UNWIND_STRICT(readdir, frame, op_ret, op_errno, buf);
- return 0;
+ return 0;
}
int
uidmap_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, gf_dirent_t *buf)
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *buf)
{
- struct _gf_dirent_t *entry = NULL;
+ struct _gf_dirent_t *entry = NULL;
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64" :(op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64" :(op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid, this->name);
- list_for_each_entry(entry, &buf->list, list) {
- (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid, this->name);
- }
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid, this->name);
+ list_for_each_entry(entry, &buf->list, list) {
+ (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid, this->name);
+ }
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, buf);
+ STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, buf);
- return 0;
+ return 0;
}
int
uidmap_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(fsync, frame, op_ret, op_errno, prebuf, postbuf);
+ STACK_UNWIND_STRICT(fsync, frame, op_ret, op_errno, prebuf, postbuf);
- return 0;
+ return 0;
}
int
uidmap_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *statpre, struct iatt *statpost)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *statpre, struct iatt *statpost)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid, this->name);
- (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid, this->name);
+ (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(setattr, frame, op_ret, op_errno, statpre, statpost);
- return 0;
+ STACK_UNWIND_STRICT(setattr, frame, op_ret, op_errno, statpre, statpost);
+ return 0;
}
int
uidmap_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *statpre, struct iatt *statpost)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *statpre, struct iatt *statpost)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid, this->name);
- (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid, this->name);
+ (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(fsetattr, frame, op_ret, op_errno,
- statpre, statpost);
- return 0;
+ STACK_UNWIND_STRICT(fsetattr, frame, op_ret, op_errno,
+ statpre, statpost);
+ return 0;
}
int
uidmap_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno,
+ preparent, postparent);
+ return 0;
}
int
uidmap_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- struct iatt *preoldparent, struct iatt *postoldparent,
- struct iatt *prenewparent, struct iatt *postnewparent)
+ int32_t op_ret, int32_t op_errno, struct iatt *buf,
+ struct iatt *preoldparent, struct iatt *postoldparent,
+ struct iatt *prenewparent, struct iatt *postnewparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&preoldparent->ia_uid, &preoldparent->ia_gid, this->name);
- (*uidmap_revmap)(&postoldparent->ia_uid, &postoldparent->ia_gid, this->name);
- (*uidmap_revmap)(&prenewparent->ia_uid, &prenewparent->ia_gid, this->name);
- (*uidmap_revmap)(&postnewparent->ia_uid, &postnewparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preoldparent->ia_uid, &preoldparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postoldparent->ia_uid, &postoldparent->ia_gid, this->name);
+ (*uidmap_revmap)(&prenewparent->ia_uid, &prenewparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postnewparent->ia_uid, &postnewparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(rename, frame, op_ret, op_errno, buf,
- preoldparent, postoldparent,
- prenewparent, postnewparent);
- return 0;
+ STACK_UNWIND_STRICT(rename, frame, op_ret, op_errno, buf,
+ preoldparent, postoldparent,
+ prenewparent, postnewparent);
+ return 0;
}
int
uidmap_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- const char *buf, struct iatt *stbuf)
+ int32_t op_ret, int32_t op_errno,
+ const char *buf, struct iatt *stbuf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&stbuf->ia_uid, &stbuf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&stbuf->ia_uid, &stbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(readlink, frame, op_ret, op_errno, buf, stbuf);
- return 0;
+ STACK_UNWIND_STRICT(readlink, frame, op_ret, op_errno, buf, stbuf);
+ return 0;
}
int
uidmap_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf,
- dict_t *xattr, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf,
+ dict_t *xattr, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf,
- xattr, postparent);
- return 0;
+ STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf,
+ xattr, postparent);
+ return 0;
}
int
uidmap_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(symlink, frame, op_ret, op_errno, inode, buf,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(symlink, frame, op_ret, op_errno, inode, buf,
+ preparent, postparent);
+ return 0;
}
int
uidmap_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(mknod, frame, op_ret, op_errno, inode, buf,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(mknod, frame, op_ret, op_errno, inode, buf,
+ preparent, postparent);
+ return 0;
}
int
uidmap_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(mkdir, frame, op_ret, op_errno, inode, buf,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(mkdir, frame, op_ret, op_errno, inode, buf,
+ preparent, postparent);
+ return 0;
}
int
uidmap_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, buf,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, buf,
+ preparent, postparent);
+ return 0;
}
int
uidmap_flush_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(flush, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(flush, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd)
+ int32_t op_ret, int32_t op_errno, fd_t *fd)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d, fd=%p)",
- frame->root->unique, op_ret, op_errno, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d, fd=%p)",
+ frame->root->unique, op_ret, op_errno, fd);
- STACK_UNWIND_STRICT(opendir, frame, op_ret, op_errno, fd);
- return 0;
+ STACK_UNWIND_STRICT(opendir, frame, op_ret, op_errno, fd);
+ return 0;
}
int
uidmap_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *preparent, struct iatt *postparent)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *preparent, struct iatt *postparent)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(rmdir, frame, op_ret, op_errno,
- preparent, postparent);
- return 0;
+ STACK_UNWIND_STRICT(rmdir, frame, op_ret, op_errno,
+ preparent, postparent);
+ return 0;
}
int
uidmap_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf);
- return 0;
+ STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf);
+ return 0;
}
int
uidmap_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct statvfs *buf)
+ int32_t op_ret, int32_t op_errno, struct statvfs *buf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(statfs, frame, op_ret, op_errno, buf);
- return 0;
+ STACK_UNWIND_STRICT(statfs, frame, op_ret, op_errno, buf);
+ return 0;
}
int
uidmap_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict)
+ int32_t op_ret, int32_t op_errno, dict_t *dict)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d, dict=%p)",
- frame->root->unique, op_ret, op_errno, dict);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d, dict=%p)",
+ frame->root->unique, op_ret, op_errno, dict);
- STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, dict);
+ STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, dict);
- return 0;
+ return 0;
}
int
uidmap_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(removexattr, frame, op_ret, op_errno);
+ STACK_UNWIND_STRICT(removexattr, frame, op_ret, op_errno);
- return 0;
+ return 0;
}
int
uidmap_fsyncdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(fsyncdir, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(fsyncdir, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_access_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(access, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(access, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf)
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf);
- return 0;
+ STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf);
+ return 0;
}
int
uidmap_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf)
+ int32_t op_ret, int32_t op_errno, struct iatt *buf)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(fstat, frame, op_ret, op_errno, buf);
- return 0;
+ STACK_UNWIND_STRICT(fstat, frame, op_ret, op_errno, buf);
+ return 0;
}
int
uidmap_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct gf_flock *lock)
+ int32_t op_ret, int32_t op_errno, struct gf_flock *lock)
{
- uid_t uid;
- gid_t gid;
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ uid_t uid;
+ gid_t gid;
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&uid, &gid, this->name);
- lock->l_owner = uid;
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
+ (*uidmap_revmap)(&uid, &gid, this->name);
+ lock->l_owner = uid;
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
- STACK_UNWIND_STRICT(lk, frame, op_ret, op_errno, lock);
- return 0;
+ STACK_UNWIND_STRICT(lk, frame, op_ret, op_errno, lock);
+ return 0;
}
int
uidmap_entrylk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": op_ret=%d, op_errno=%d",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": op_ret=%d, op_errno=%d",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(entrylk, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(entrylk, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_fentrylk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": op_ret=%d, op_errno=%d",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": op_ret=%d, op_errno=%d",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(entrylk, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(entrylk, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict)
+ int32_t op_ret, int32_t op_errno, dict_t *dict)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(xattrop, frame, op_ret, op_errno, dict);
- return 0;
+ STACK_UNWIND_STRICT(xattrop, frame, op_ret, op_errno, dict);
+ return 0;
}
int
uidmap_fxattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict)
+ int32_t op_ret, int32_t op_errno, dict_t *dict)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (op_ret=%d, op_errno=%d)",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (op_ret=%d, op_errno=%d)",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(fxattrop, frame, op_ret, op_errno, dict);
- return 0;
+ STACK_UNWIND_STRICT(fxattrop, frame, op_ret, op_errno, dict);
+ return 0;
}
int
uidmap_inodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": op_ret=%d, op_errno=%d",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": op_ret=%d, op_errno=%d",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(inodelk, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(inodelk, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_finodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno)
+ int32_t op_ret, int32_t op_errno)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": op_ret=%d, op_errno=%d",
- frame->root->unique, op_ret, op_errno);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": op_ret=%d, op_errno=%d",
+ frame->root->unique, op_ret, op_errno);
- STACK_UNWIND_STRICT(finodelk, frame, op_ret, op_errno);
- return 0;
+ STACK_UNWIND_STRICT(finodelk, frame, op_ret, op_errno);
+ return 0;
}
int
uidmap_entrylk(call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, const char *basename,
- entrylk_cmd cmd, entrylk_type type)
+ const char *volume, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": volume=%s, (loc= {path=%s, ino=%"PRIu64"} basename=%s, cmd=%s, type=%s)",
- frame->root->unique, volume, loc->path, loc->inode->ino, basename,
- ((cmd == ENTRYLK_LOCK) ? "ENTRYLK_LOCK" : "ENTRYLK_UNLOCK"),
- ((type == ENTRYLK_RDLCK) ? "ENTRYLK_RDLCK" : "ENTRYLK_WRLCK"));
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": volume=%s, (loc= {path=%s, ino=%"PRIu64"} basename=%s, cmd=%s, type=%s)",
+ frame->root->unique, volume, loc->path, loc->inode->ino, basename,
+ ((cmd == ENTRYLK_LOCK) ? "ENTRYLK_LOCK" : "ENTRYLK_UNLOCK"),
+ ((type == ENTRYLK_RDLCK) ? "ENTRYLK_RDLCK" : "ENTRYLK_WRLCK"));
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_entrylk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->entrylk,
- volume, loc, basename, cmd, type);
- return 0;
+ STACK_WIND(frame, uidmap_entrylk_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->entrylk,
+ volume, loc, basename, cmd, type);
+ return 0;
}
int
uidmap_fentrylk(call_frame_t *frame, xlator_t *this,
- const char *volume, fd_t *fd, const char *basename,
- entrylk_cmd cmd, entrylk_type type)
+ const char *volume, fd_t *fd, const char *basename,
+ entrylk_cmd cmd, entrylk_type type)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": volume=%s, fd=%p, basename=%s, cmd=%s, type=%s)",
- frame->root->unique, volume, fd, basename,
- ((cmd == ENTRYLK_LOCK) ? "ENTRYLK_LOCK" : "ENTRYLK_UNLOCK"),
- ((type == ENTRYLK_RDLCK) ? "ENTRYLK_RDLCK" : "ENTRYLK_WRLCK"));
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": volume=%s, fd=%p, basename=%s, cmd=%s, type=%s)",
+ frame->root->unique, volume, fd, basename,
+ ((cmd == ENTRYLK_LOCK) ? "ENTRYLK_LOCK" : "ENTRYLK_UNLOCK"),
+ ((type == ENTRYLK_RDLCK) ? "ENTRYLK_RDLCK" : "ENTRYLK_WRLCK"));
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_fentrylk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fentrylk,
- volume, fd, basename, cmd, type);
- return 0;
+ STACK_WIND(frame, uidmap_fentrylk_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fentrylk,
+ volume, fd, basename, cmd, type);
+ return 0;
}
int
uidmap_inodelk(call_frame_t *frame, xlator_t *this, const char *volume,
- loc_t *loc, int32_t cmd, struct gf_flock *flock)
+ loc_t *loc, int32_t cmd, struct gf_flock *flock)
{
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_inodelk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->inodelk,
- volume, loc, cmd, flock);
- return 0;
+ STACK_WIND(frame, uidmap_inodelk_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->inodelk,
+ volume, loc, cmd, flock);
+ return 0;
}
int
uidmap_finodelk(call_frame_t *frame, xlator_t *this, const char *volume,
- fd_t *fd, int32_t cmd, struct gf_flock *flock)
+ fd_t *fd, int32_t cmd, struct gf_flock *flock)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (volume=%s, fd=%p, cmd=%d)",
- frame->root->unique, volume, fd, cmd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (volume=%s, fd=%p, cmd=%d)",
+ frame->root->unique, volume, fd, cmd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_finodelk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->finodelk,
- volume, fd, cmd, flock);
- return 0;
+ STACK_WIND(frame, uidmap_finodelk_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->finodelk,
+ volume, fd, cmd, flock);
+ return 0;
}
int
uidmap_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc,
- gf_xattrop_flags_t flags, dict_t *dict)
+ gf_xattrop_flags_t flags, dict_t *dict)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (path=%s, ino=%"PRIu64" flags=%d)",
- frame->root->unique, loc->path, loc->inode->ino, flags);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (path=%s, ino=%"PRIu64" flags=%d)",
+ frame->root->unique, loc->path, loc->inode->ino, flags);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_xattrop_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->xattrop,
- loc, flags, dict);
+ STACK_WIND(frame, uidmap_xattrop_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->xattrop,
+ loc, flags, dict);
- return 0;
+ return 0;
}
int
uidmap_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd,
- gf_xattrop_flags_t flags, dict_t *dict)
+ gf_xattrop_flags_t flags, dict_t *dict)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (fd=%p, flags=%d)",
- frame->root->unique, fd, flags);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (fd=%p, flags=%d)",
+ frame->root->unique, fd, flags);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_fxattrop_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fxattrop,
- fd, flags, dict);
+ STACK_WIND(frame, uidmap_fxattrop_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fxattrop,
+ fd, flags, dict);
- return 0;
+ return 0;
}
int
uidmap_lookup(call_frame_t *frame, xlator_t *this,
- loc_t *loc, dict_t *xattr_req)
+ loc_t *loc, dict_t *xattr_req)
{
- /* TODO: print all the keys mentioned in xattr_req */
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
- frame->root->unique, loc->path,
- loc->inode->ino);
+ /* TODO: print all the keys mentioned in xattr_req */
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
+ frame->root->unique, loc->path,
+ loc->inode->ino);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_lookup_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lookup,
- loc, xattr_req);
+ STACK_WIND(frame, uidmap_lookup_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup,
+ loc, xattr_req);
- return 0;
+ return 0;
}
int
uidmap_stat(call_frame_t *frame, xlator_t *this, loc_t *loc)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
- frame->root->unique, loc->path, loc->inode->ino);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
+ frame->root->unique, loc->path, loc->inode->ino);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_stat_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->stat,
- loc);
+ STACK_WIND(frame, uidmap_stat_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat,
+ loc);
- return 0;
+ return 0;
}
int
uidmap_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, size=%"GF_PRI_SIZET")",
- frame->root->unique, loc->path, loc->inode->ino, size);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, size=%"GF_PRI_SIZET")",
+ frame->root->unique, loc->path, loc->inode->ino, size);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_readlink_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readlink,
- loc, size);
+ STACK_WIND(frame, uidmap_readlink_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readlink,
+ loc, size);
- return 0;
+ return 0;
}
int
uidmap_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc,
- mode_t mode, dev_t dev, dict_t *params)
+ mode_t mode, dev_t dev, dict_t *params)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, mode=%d, dev=%"GF_PRI_DEV")",
- frame->root->unique, loc->path, loc->inode->ino, mode, dev);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, mode=%d, dev=%"GF_PRI_DEV")",
+ frame->root->unique, loc->path, loc->inode->ino, mode, dev);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_mknod_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->mknod,
- loc, mode, dev, params);
+ STACK_WIND(frame, uidmap_mknod_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mknod,
+ loc, mode, dev, params);
- return 0;
+ return 0;
}
int
uidmap_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
- dict_t *params)
+ dict_t *params)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (path=%s, ino=%"PRIu64", mode=%d)",
- frame->root->unique, loc->path,
- ((loc->inode)? loc->inode->ino : 0), mode);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (path=%s, ino=%"PRIu64", mode=%d)",
+ frame->root->unique, loc->path,
+ ((loc->inode)? loc->inode->ino : 0), mode);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_mkdir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->mkdir,
- loc, mode, params);
- return 0;
+ STACK_WIND(frame, uidmap_mkdir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mkdir,
+ loc, mode, params);
+ return 0;
}
int
uidmap_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
- frame->root->unique, loc->path, loc->inode->ino);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
+ frame->root->unique, loc->path, loc->inode->ino);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_unlink_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->unlink,
- loc);
- return 0;
+ STACK_WIND(frame, uidmap_unlink_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->unlink,
+ loc);
+ return 0;
}
int
uidmap_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=%d)",
- frame->root->unique, loc->path, loc->inode->ino, flags);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=%d)",
+ frame->root->unique, loc->path, loc->inode->ino, flags);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_rmdir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->rmdir,
- loc, flags);
+ STACK_WIND(frame, uidmap_rmdir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rmdir,
+ loc, flags);
- return 0;
+ return 0;
}
int
uidmap_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath,
- loc_t *loc, dict_t *params)
+ loc_t *loc, dict_t *params)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (linkpath=%s, loc {path=%s, ino=%"PRIu64"})",
- frame->root->unique, linkpath, loc->path,
- ((loc->inode)? loc->inode->ino : 0));
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (linkpath=%s, loc {path=%s, ino=%"PRIu64"})",
+ frame->root->unique, linkpath, loc->path,
+ ((loc->inode)? loc->inode->ino : 0));
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_symlink_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->symlink,
- linkpath, loc, params);
+ STACK_WIND(frame, uidmap_symlink_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->symlink,
+ linkpath, loc, params);
- return 0;
+ return 0;
}
int
uidmap_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (oldloc {path=%s, ino=%"PRIu64"}, "
- "newloc{path=%s, ino=%"PRIu64"})",
- frame->root->unique, oldloc->path, oldloc->ino,
- newloc->path, newloc->ino);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (oldloc {path=%s, ino=%"PRIu64"}, "
+ "newloc{path=%s, ino=%"PRIu64"})",
+ frame->root->unique, oldloc->path, oldloc->ino,
+ newloc->path, newloc->ino);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_rename_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->rename,
- oldloc, newloc);
+ STACK_WIND(frame, uidmap_rename_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rename,
+ oldloc, newloc);
- return 0;
+ return 0;
}
int
uidmap_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (oldloc {path=%s, ino=%"PRIu64"}, "
- "newloc {path=%s, ino=%"PRIu64"})",
- frame->root->unique, oldloc->path, oldloc->inode->ino,
- newloc->path, newloc->inode->ino);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (oldloc {path=%s, ino=%"PRIu64"}, "
+ "newloc {path=%s, ino=%"PRIu64"})",
+ frame->root->unique, oldloc->path, oldloc->inode->ino,
+ newloc->path, newloc->inode->ino);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_link_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->link,
- oldloc, newloc);
- return 0;
+ STACK_WIND(frame, uidmap_link_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->link,
+ oldloc, newloc);
+ return 0;
}
int
uidmap_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid)
+ struct iatt *stbuf, int32_t valid)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": loc {path=%s, ino=%"PRIu64"}, valid=%d",
- frame->root->unique, loc->path, loc->inode->ino, valid);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": loc {path=%s, ino=%"PRIu64"}, valid=%d",
+ frame->root->unique, loc->path, loc->inode->ino, valid);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_setattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->setattr,
- loc, stbuf, valid);
+ STACK_WIND(frame, uidmap_setattr_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setattr,
+ loc, stbuf, valid);
- return 0;
+ return 0;
}
int
uidmap_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iatt *stbuf, int32_t valid)
+ struct iatt *stbuf, int32_t valid)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (fd=%p, valid=%d)",
- frame->root->unique, fd, valid);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (fd=%p, valid=%d)",
+ frame->root->unique, fd, valid);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_fsetattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsetattr,
- fd, stbuf, valid);
+ STACK_WIND(frame, uidmap_fsetattr_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetattr,
+ fd, stbuf, valid);
- return 0;
+ return 0;
}
int
uidmap_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc,
- off_t offset)
+ off_t offset)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, offset=%"PRId64")",
- frame->root->unique, loc->path, loc->inode->ino, offset);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, offset=%"PRId64")",
+ frame->root->unique, loc->path, loc->inode->ino, offset);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_truncate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->truncate,
- loc, offset);
+ STACK_WIND(frame, uidmap_truncate_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate,
+ loc, offset);
- return 0;
+ return 0;
}
int
uidmap_open(call_frame_t *frame, xlator_t *this, loc_t *loc,
- int32_t flags, fd_t *fd, int32_t wbflags)
+ int32_t flags, fd_t *fd, int32_t wbflags)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=%d, "
- "fd=%p, wbflags=%d)",
- frame->root->unique, loc->path, loc->inode->ino, flags,
- fd, wbflags);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=%d, "
+ "fd=%p, wbflags=%d)",
+ frame->root->unique, loc->path, loc->inode->ino, flags,
+ fd, wbflags);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_open_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->open,
- loc, flags, fd, wbflags);
- return 0;
+ STACK_WIND(frame, uidmap_open_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open,
+ loc, flags, fd, wbflags);
+ return 0;
}
int
uidmap_create(call_frame_t *frame, xlator_t *this, loc_t *loc,
- int32_t flags, mode_t mode, fd_t *fd, dict_t *params)
+ int32_t flags, mode_t mode, fd_t *fd, dict_t *params)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=0%o mode=0%o)",
- frame->root->unique, loc->path, loc->inode->ino, flags, mode);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=0%o mode=0%o)",
+ frame->root->unique, loc->path, loc->inode->ino, flags, mode);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_create_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->create,
- loc, flags, mode, fd, params);
- return 0;
+ STACK_WIND(frame, uidmap_create_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->create,
+ loc, flags, mode, fd, params);
+ return 0;
}
int
uidmap_readv(call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t offset)
+ size_t size, off_t offset)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (*fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
- frame->root->unique, fd, size, offset);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (*fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
+ frame->root->unique, fd, size, offset);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_readv_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readv,
- fd, size, offset);
- return 0;
+ STACK_WIND(frame, uidmap_readv_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv,
+ fd, size, offset);
+ return 0;
}
int
uidmap_writev(call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iovec *vector, int32_t count,
- off_t offset, struct iobref *iobref)
+ struct iovec *vector, int32_t count,
+ off_t offset, struct iobref *iobref)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (*fd=%p, *vector=%p, count=%d, offset=%"PRId64")",
- frame->root->unique, fd, vector, count, offset);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (*fd=%p, *vector=%p, count=%d, offset=%"PRId64")",
+ frame->root->unique, fd, vector, count, offset);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_writev_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->writev,
- fd, vector, count, offset, iobref);
- return 0;
+ STACK_WIND(frame, uidmap_writev_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev,
+ fd, vector, count, offset, iobref);
+ return 0;
}
int
uidmap_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
- frame->root->unique, loc->path,
- ((loc->inode)? loc->inode->ino : 0));
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
+ frame->root->unique, loc->path,
+ ((loc->inode)? loc->inode->ino : 0));
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_statfs_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->statfs,
- loc);
- return 0;
+ STACK_WIND(frame, uidmap_statfs_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->statfs,
+ loc);
+ return 0;
}
int
uidmap_flush(call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (*fd=%p)", frame->root->unique, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (*fd=%p)", frame->root->unique, fd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_flush_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->flush,
- fd);
- return 0;
+ STACK_WIND(frame, uidmap_flush_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->flush,
+ fd);
+ return 0;
}
int
uidmap_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (flags=%d, *fd=%p)", frame->root->unique, flags, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (flags=%d, *fd=%p)", frame->root->unique, flags, fd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_fsync_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsync,
- fd, flags);
- return 0;
+ STACK_WIND(frame, uidmap_fsync_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync,
+ fd, flags);
+ return 0;
}
int
uidmap_setxattr(call_frame_t *frame, xlator_t *this,
- loc_t *loc, dict_t *dict, int32_t flags)
+ loc_t *loc, dict_t *dict, int32_t flags)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, dict=%p, flags=%d)",
- frame->root->unique, loc->path,
- ((loc->inode)? loc->inode->ino : 0), dict, flags);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, dict=%p, flags=%d)",
+ frame->root->unique, loc->path,
+ ((loc->inode)? loc->inode->ino : 0), dict, flags);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_setxattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->setxattr,
- loc, dict, flags);
- return 0;
+ STACK_WIND(frame, uidmap_setxattr_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setxattr,
+ loc, dict, flags);
+ return 0;
}
int
uidmap_getxattr(call_frame_t *frame, xlator_t *this,
- loc_t *loc, const char *name)
+ loc_t *loc, const char *name)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}), name=%s",
- frame->root->unique, loc->path,
- ((loc->inode)? loc->inode->ino : 0), name);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}), name=%s",
+ frame->root->unique, loc->path,
+ ((loc->inode)? loc->inode->ino : 0), name);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_getxattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->getxattr,
- loc, name);
- return 0;
+ STACK_WIND(frame, uidmap_getxattr_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr,
+ loc, name);
+ return 0;
}
int
uidmap_removexattr(call_frame_t *frame, xlator_t *this,
- loc_t *loc, const char *name)
+ loc_t *loc, const char *name)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, name=%s)",
- frame->root->unique, loc->path,
- ((loc->inode)? loc->inode->ino : 0), name);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (loc {path=%s, ino=%"PRIu64"}, name=%s)",
+ frame->root->unique, loc->path,
+ ((loc->inode)? loc->inode->ino : 0), name);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_removexattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->removexattr,
- loc, name);
+ STACK_WIND(frame, uidmap_removexattr_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->removexattr,
+ loc, name);
- return 0;
+ return 0;
}
int
uidmap_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64":( loc {path=%s, ino=%"PRIu64"}, fd=%p)",
- frame->root->unique, loc->path, loc->inode->ino, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64":( loc {path=%s, ino=%"PRIu64"}, fd=%p)",
+ frame->root->unique, loc->path, loc->inode->ino, fd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_opendir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->opendir,
- loc, fd);
- return 0;
+ STACK_WIND(frame, uidmap_opendir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->opendir,
+ loc, fd);
+ return 0;
}
int
uidmap_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset)
+ off_t offset)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
- frame->root->unique, fd, size, offset);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
+ frame->root->unique, fd, size, offset);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_readdirp_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp,
- fd, size, offset);
+ STACK_WIND(frame, uidmap_readdirp_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp,
+ fd, size, offset);
- return 0;
+ return 0;
}
int
uidmap_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t offset)
+ size_t size, off_t offset)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
- frame->root->unique, fd, size, offset);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
+ frame->root->unique, fd, size, offset);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_readdir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdir,
- fd, size, offset);
+ STACK_WIND(frame, uidmap_readdir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdir,
+ fd, size, offset);
- return 0;
+ return 0;
}
int
uidmap_fsyncdir(call_frame_t *frame, xlator_t *this,
- fd_t *fd, int32_t datasync)
+ fd_t *fd, int32_t datasync)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (datasync=%d, *fd=%p)",
- frame->root->unique, datasync, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (datasync=%d, *fd=%p)",
+ frame->root->unique, datasync, fd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_fsyncdir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsyncdir,
- fd, datasync);
- return 0;
+ STACK_WIND(frame, uidmap_fsyncdir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsyncdir,
+ fd, datasync);
+ return 0;
}
int
uidmap_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (*loc {path=%s, ino=%"PRIu64"}, mask=0%o)",
- frame->root->unique, loc->path,
- ((loc->inode)? loc->inode->ino : 0), mask);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (*loc {path=%s, ino=%"PRIu64"}, mask=0%o)",
+ frame->root->unique, loc->path,
+ ((loc->inode)? loc->inode->ino : 0), mask);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_access_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->access,
- loc, mask);
- return 0;
+ STACK_WIND(frame, uidmap_access_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->access,
+ loc, mask);
+ return 0;
}
int
uidmap_ftruncate(call_frame_t *frame, xlator_t *this,
- fd_t *fd, off_t offset)
+ fd_t *fd, off_t offset)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (offset=%"PRId64", *fd=%p)",
- frame->root->unique, offset, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (offset=%"PRId64", *fd=%p)",
+ frame->root->unique, offset, fd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_ftruncate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->ftruncate,
- fd, offset);
+ STACK_WIND(frame, uidmap_ftruncate_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate,
+ fd, offset);
- return 0;
+ return 0;
}
int
uidmap_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (*fd=%p)", frame->root->unique, fd);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (*fd=%p)", frame->root->unique, fd);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_fstat_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fstat,
- fd);
- return 0;
+ STACK_WIND(frame, uidmap_fstat_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat,
+ fd);
+ return 0;
}
int
uidmap_lk(call_frame_t *frame, xlator_t *this, fd_t *fd,
- int32_t cmd, struct gf_flock *lock)
+ int32_t cmd, struct gf_flock *lock)
{
- gf_log(this->name, CFS_LOG_LEVEL,
- "%"PRId64": (*fd=%p, cmd=%d, lock {l_type=%d, l_whence=%d, "
- "l_start=%"PRId64", l_len=%"PRId64", l_pid=%u})",
- frame->root->unique, fd, cmd, lock->l_type, lock->l_whence,
- lock->l_start, lock->l_len, lock->l_pid);
+ gf_log(this->name, CFS_LOG_LEVEL,
+ "%"PRId64": (*fd=%p, cmd=%d, lock {l_type=%d, l_whence=%d, "
+ "l_start=%"PRId64", l_len=%"PRId64", l_pid=%u})",
+ frame->root->unique, fd, cmd, lock->l_type, lock->l_whence,
+ lock->l_start, lock->l_len, lock->l_pid);
- if ((*uidmap_map)(frame->root, this->name) == -1)
- return -1;
+ if ((*uidmap_map)(frame->root, this->name) == -1) {
+ return -1;
+ }
- STACK_WIND(frame, uidmap_lk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lk,
- fd, cmd, lock);
- return 0;
+ STACK_WIND(frame, uidmap_lk_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lk,
+ fd, cmd, lock);
+ return 0;
}
static init_fn
uidmap_loadsharedlib(char* xltrname, char *libname)
{
- init_fn plugin_init = NULL;
- void *handle = NULL;
+ init_fn plugin_init = NULL;
+ void *handle = NULL;
char *plugin_path = NULL;
int ret = -1;
@@ -1848,224 +1894,239 @@ uidmap_loadsharedlib(char* xltrname, char *libname)
libname);
if (ret < 0) {
gf_log(xltrname,GF_LOG_ERROR,
- "could not construct plugin path for %s",
- libname);
+ "could not construct plugin path for %s",
+ libname);
return NULL;
}
}
gf_log(xltrname, CFS_LOG_LEVEL, "loading %s (%s)", plugin_path,
- (plugin_path == libname) ? "given" : "constructed");
+ (plugin_path == libname) ? "given" : "constructed");
- handle = dlopen(plugin_path, RTLD_NOW|RTLD_NODELETE);
+ handle = dlopen(plugin_path, RTLD_NOW|RTLD_NODELETE);
if (!handle) {
gf_log(xltrname, GF_LOG_ERROR, "dlopen failed (%s)", dlerror());
return NULL;
}
- if ((uidmap_map = (map_fn) dlsym(handle, "map")) == NULL) {
+ uidmap_map = (map_fn) dlsym(handle, "map");
+ if (uidmap_map == NULL) {
gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing map: %s", dlerror());
+ "plugin missing map: %s", dlerror());
goto close_it;
}
- if ((uidmap_revmap = (revmap_fn) dlsym(handle, "revmap")) == NULL) {
+ uidmap_revmap = (revmap_fn) dlsym(handle, "revmap");
+ if (uidmap_revmap == NULL) {
gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing revmap: %s", dlerror());
+ "plugin missing revmap: %s", dlerror());
goto close_it;
}
- if ((uidmap_plugin_fini = (fini_fn) dlsym(handle, "fini")) == NULL) {
+ uidmap_plugin_fini = (fini_fn) dlsym(handle, "fini");
+ if (uidmap_plugin_fini == NULL) {
gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing fini: %s", dlerror());
+ "plugin missing fini: %s", dlerror());
goto close_it;
}
- if ((plugin_init = (init_fn) dlsym(handle, "init")) == NULL) {
+ plugin_init = (init_fn) dlsym(handle, "init");
+ if (plugin_init == NULL) {
gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing init: %s", dlerror());
+ "plugin missing init: %s", dlerror());
}
close_it:
if (dlclose(handle)) {
gf_log(xltrname, CFS_LOG_LEVEL,
- "dlclose plugin: %s", dlerror());
+ "dlclose plugin: %s", dlerror());
}
if (plugin_path != libname) {
GF_FREE(plugin_path);
}
- return plugin_init;
+ return plugin_init;
}
int32_t
init(xlator_t *this)
{
- char *uid_range = NULL, *gid_range = NULL;
- char *plugin = NULL;
- init_fn plugin_init = NULL;
- uid_t low_uid = CFS_UID_LOW_DEFAULT;
- uid_t high_uid = CFS_UID_HIGH_DEFAULT;
- gid_t low_gid = CFS_UID_LOW_DEFAULT;
- gid_t high_gid = CFS_UID_HIGH_DEFAULT;
- short root_squash = 0;
- data_t *data;
-
- if (!this)
- return -1;
-
- if (!this->children || this->children->next) {
- gf_log(this->name, GF_LOG_ERROR,
- "uidmap translator requires one subvolume");
- return -1;
- }
- if (!this->parents) {
- gf_log(this->name, GF_LOG_WARNING,
- "dangling volume. check volfile ");
- }
-
- if ((data = dict_get(this->options, "uid-range")) != NULL) {
- uid_range = data_to_str(data);
- if (uid_range != NULL && *uid_range != 0) {
- if (sscanf(uid_range, "%u-%u", &low_uid, &high_uid) == 2) {
- /* uidmap_mapping.uid_low =
- uidmap_mapping.uid_next = low;
- uidmap_mapping.uid_high = hi; */
- } else {
- gf_log(this->name, GF_LOG_ERROR,
- "invalid uid-range in config");
- }
- }
- } else {
- gf_log(this->name, GF_LOG_ERROR,
- "you must specify the uid-range in the config");
- return -1;
- }
-
- if ((data = dict_get(this->options, "gid-range")) != NULL) {
- gid_range = data_to_str(data);
- if (gid_range != NULL && *gid_range != 0) {
- if (sscanf(gid_range, "%u-%u", &low_gid, &high_gid) == 2) {
- /* uidmap_mapping.gid_low =
- uidmap_mapping.gid_next = low;
- uidmap_mapping.gid_high = hi; */
- } else {
- gf_log(this->name, GF_LOG_ERROR,
- "invalid gid-range in config");
- }
- }
- } else {
- gf_log(this->name, GF_LOG_ERROR,
- "you must specify the gid-range in the config");
- return -1;
- }
-
- if ((data = dict_get(this->options, "root-squash")) != NULL) {
- char *rt_sqsh = data_to_str(data);
- if (rt_sqsh != NULL && *rt_sqsh != 0) {
- char* ptr = rt_sqsh;
- for (; *ptr != 0; ptr++)
- *ptr = tolower(*ptr);
- if (strcmp(rt_sqsh, "yes") == 0)
- root_squash = 1;
- }
- }
-
- if ((data = dict_get(this->options, "uidmap-plugin")) != NULL) {
- plugin = data_to_str(data);
- if (plugin != NULL && *plugin != 0) {
- if ((plugin_init = uidmap_loadsharedlib(this->name, plugin)) != NULL) {
- if ((*plugin_init)(this, low_uid, high_uid,
- low_gid, high_gid,
- root_squash) != 0) {
- gf_log(this->name, GF_LOG_CRITICAL,
- "plugin init error");
- }
- }
- }
- }
- if (uidmap_map == NULL) {
- if (uidmap_deserialize_default(this->name, low_uid, high_uid, low_gid, high_gid, root_squash) == -1)
- return -1;
- uidmap_serialize_default(this->name, uidmap_mappings);
- uidmap_map = uidmap_map_default;
- uidmap_revmap = uidmap_revmap_default;
- }
-
- return 0;
+ char *uid_range = NULL, *gid_range = NULL;
+ char *plugin = NULL;
+ init_fn plugin_init = NULL;
+ uid_t low_uid = CFS_UID_LOW_DEFAULT;
+ uid_t high_uid = CFS_UID_HIGH_DEFAULT;
+ gid_t low_gid = CFS_UID_LOW_DEFAULT;
+ gid_t high_gid = CFS_UID_HIGH_DEFAULT;
+ short root_squash = 0;
+ data_t *data;
+
+ if (!this) {
+ return -1;
+ }
+
+ if (!this->children || this->children->next) {
+ gf_log(this->name, GF_LOG_ERROR,
+ "uidmap translator requires one subvolume");
+ return -1;
+ }
+ if (!this->parents) {
+ gf_log(this->name, GF_LOG_WARNING,
+ "dangling volume. check volfile ");
+ }
+
+ data = dict_get(this->options, "uid-range");
+ if (data != NULL) {
+ uid_range = data_to_str(data);
+ if ((uid_range != NULL) && (*uid_range != 0)) {
+ if (sscanf(uid_range, "%u-%u", &low_uid, &high_uid) == 2) {
+ /* uidmap_mapping.uid_low =
+ uidmap_mapping.uid_next = low;
+ uidmap_mapping.uid_high = hi; */
+ } else {
+ gf_log(this->name, GF_LOG_ERROR,
+ "invalid uid-range in config");
+ }
+ }
+ } else {
+ gf_log(this->name, GF_LOG_ERROR,
+ "you must specify the uid-range in the config");
+ return -1;
+ }
+
+ data = dict_get(this->options, "gid-range");
+ if (data != NULL) {
+ gid_range = data_to_str(data);
+ if ((gid_range != NULL) && (*gid_range != 0)) {
+ if (sscanf(gid_range, "%u-%u", &low_gid, &high_gid) == 2) {
+ /* uidmap_mapping.gid_low =
+ uidmap_mapping.gid_next = low;
+ uidmap_mapping.gid_high = hi; */
+ } else {
+ gf_log(this->name, GF_LOG_ERROR,
+ "invalid gid-range in config");
+ }
+ }
+ } else {
+ gf_log(this->name, GF_LOG_ERROR,
+ "you must specify the gid-range in the config");
+ return -1;
+ }
+
+ data = dict_get(this->options, "root-squash");
+ if (data != NULL) {
+ char *rt_sqsh = data_to_str(data);
+ if ((rt_sqsh != NULL) && (*rt_sqsh != 0)) {
+ char* ptr = rt_sqsh;
+ for (; *ptr != 0; ptr++) {
+ *ptr = tolower(*ptr);
+ }
+ if (strcmp(rt_sqsh, "yes") == 0) {
+ root_squash = 1;
+ }
+ }
+ }
+
+ data = dict_get(this->options, "uidmap-plugin");
+ if (data != NULL) {
+ plugin = data_to_str(data);
+ if ((plugin != NULL) && (*plugin != 0)) {
+ plugin_init = uidmap_loadsharedlib(this->name, plugin);
+ if (plugin_init != NULL) {
+ if ((*plugin_init)(this, low_uid, high_uid,
+ low_gid, high_gid,
+ root_squash) != 0) {
+ gf_log(this->name, GF_LOG_CRITICAL,
+ "plugin init error");
+ }
+ }
+ }
+ }
+ if (uidmap_map == NULL) {
+ if (uidmap_deserialize_default(this->name, low_uid, high_uid, low_gid, high_gid, root_squash) == -1) {
+ return -1;
+ }
+ uidmap_serialize_default(this->name, uidmap_mappings);
+ uidmap_map = uidmap_map_default;
+ uidmap_revmap = uidmap_revmap_default;
+ }
+
+ return 0;
}
void
fini(xlator_t *this)
{
- if (!this)
- return;
+ if (!this) {
+ return;
+ }
- if (uidmap_plugin_fini)
- uidmap_plugin_fini(this);
+ if (uidmap_plugin_fini) {
+ uidmap_plugin_fini(this);
+ }
- gf_log(this->name, CFS_LOG_LEVEL, "uidmap translator unloaded");
- return;
+ gf_log(this->name, CFS_LOG_LEVEL, "uidmap translator unloaded");
+ return;
}
struct xlator_fops fops = {
- .lookup = uidmap_lookup,
- .stat = uidmap_stat,
- .fstat = uidmap_fstat,
- .truncate = uidmap_truncate,
- .ftruncate = uidmap_ftruncate,
- .access = uidmap_access,
- .readlink = uidmap_readlink,
- .mknod = uidmap_mknod,
- .mkdir = uidmap_mkdir,
- .unlink = uidmap_unlink,
- .rmdir = uidmap_rmdir,
- .symlink = uidmap_symlink,
- .rename = uidmap_rename,
- .link = uidmap_link,
- .create = uidmap_create,
- .open = uidmap_open,
- .readv = uidmap_readv,
- .writev = uidmap_writev,
- .flush = uidmap_flush,
- .fsync = uidmap_fsync,
- .opendir = uidmap_opendir,
- .readdir = uidmap_readdir,
- .readdirp = uidmap_readdirp,
- .fsyncdir = uidmap_fsyncdir,
- .statfs = uidmap_statfs,
- .setxattr = uidmap_setxattr,
- .getxattr = uidmap_getxattr,
- .removexattr = uidmap_removexattr,
- .lk = uidmap_lk,
- .inodelk = uidmap_inodelk,
- .finodelk = uidmap_finodelk,
- .entrylk = uidmap_entrylk,
- .fentrylk = uidmap_fentrylk,
- /* .rchecksum = uidmap_rchecksum, */
- .xattrop = uidmap_xattrop,
- .fxattrop = uidmap_fxattrop,
- .setattr = uidmap_setattr,
- .fsetattr = uidmap_fsetattr,
- /* .getspec = uidmap_getspec, */
+ .lookup = uidmap_lookup,
+ .stat = uidmap_stat,
+ .fstat = uidmap_fstat,
+ .truncate = uidmap_truncate,
+ .ftruncate = uidmap_ftruncate,
+ .access = uidmap_access,
+ .readlink = uidmap_readlink,
+ .mknod = uidmap_mknod,
+ .mkdir = uidmap_mkdir,
+ .unlink = uidmap_unlink,
+ .rmdir = uidmap_rmdir,
+ .symlink = uidmap_symlink,
+ .rename = uidmap_rename,
+ .link = uidmap_link,
+ .create = uidmap_create,
+ .open = uidmap_open,
+ .readv = uidmap_readv,
+ .writev = uidmap_writev,
+ .flush = uidmap_flush,
+ .fsync = uidmap_fsync,
+ .opendir = uidmap_opendir,
+ .readdir = uidmap_readdir,
+ .readdirp = uidmap_readdirp,
+ .fsyncdir = uidmap_fsyncdir,
+ .statfs = uidmap_statfs,
+ .setxattr = uidmap_setxattr,
+ .getxattr = uidmap_getxattr,
+ .removexattr = uidmap_removexattr,
+ .lk = uidmap_lk,
+ .inodelk = uidmap_inodelk,
+ .finodelk = uidmap_finodelk,
+ .entrylk = uidmap_entrylk,
+ .fentrylk = uidmap_fentrylk,
+ /* .rchecksum = uidmap_rchecksum, */
+ .xattrop = uidmap_xattrop,
+ .fxattrop = uidmap_fxattrop,
+ .setattr = uidmap_setattr,
+ .fsetattr = uidmap_fsetattr,
+ /* .getspec = uidmap_getspec, */
};
struct xlator_cbks cbks = {
};
struct volume_options options[] = {
- { .key = {"uidmap-plugin", "plugin"},
- .type = GF_OPTION_TYPE_PATH,
- },
- { .key = {"root-squash"},
- .type = GF_OPTION_TYPE_STR,
- .value = { "yes", "no"}
- },
- { .key = {"uid-range"},
- .type = GF_OPTION_TYPE_STR,
- },
- { .key = {"gid-range"},
- .type = GF_OPTION_TYPE_STR,
- },
- { .key = {NULL} },
+ { .key = {"uidmap-plugin", "plugin"},
+ .type = GF_OPTION_TYPE_PATH,
+ },
+ { .key = {"root-squash"},
+ .type = GF_OPTION_TYPE_STR,
+ .value = { "yes", "no"}
+ },
+ { .key = {"uid-range"},
+ .type = GF_OPTION_TYPE_STR,
+ },
+ { .key = {"gid-range"},
+ .type = GF_OPTION_TYPE_STR,
+ },
+ { .key = {NULL} },
};
12 years, 5 months
Coding guidelines
by Jeff Darcy
I really hate having to deal with coding-style issues. Generally I'll
accept anything that conforms to the Gluster [1] and/or Linux [2] coding
standards, and a whole lot that doesn't. However, I do believe that
consistency with existing code is important, and some practices are
demonstrably bad for readability and maintainability [3]. So, here are
some rough guidelines.
* Tabs are eight spaces, and indents should be eight spaces as well.
Don't use indent=4 or pure spaces.
* Lines should *generally* be wrapped at 80 columns. An occasional
hard-to-avoid long line is OK, but code with a high density of
> 80-column lines becomes unreadable.
* Don't do assignments within conditions.
* Don't rely on precedence of boolean/arithmetic/comparisons (pretty
much any binary operation besides selection). Fully parenthesize nested
expressions involving these.
* Do put braces around if/else/for/while blocks, even if they only
contain a single statement.
* If you're going to use a goto-like flow of control for exception
handling, use a real goto. Break statements in a "do ... while (0)" are
just label-less gotos, which is less readable and can cause unexpected
breakage if the form is nested.
I'm not going to demand that existing code be changed, and I'm generally
not going to clean them up myself (though I will be pushing a patch for
some of this in the uidmap code shortly), but as we move forward I'd
appreciate it if people could try to follow these guidelines. Thanks.
[1]
http://download.gluster.com/pub/gluster/glusterfs/doc/coding-standard.pdf
[2] http://www.kernel.org/doc/Documentation/CodingStyle
[3] http://www.arrestedcomputing.com/pubs/readability-tse.pdf
12 years, 6 months
Branch 'uidmap' - scripts/cfs_start_volume.py xlators/features
by Kaleb KEITHLEY
scripts/cfs_start_volume.py | 2 +-
xlators/features/uidmap/src/uidmap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 4677605356ac4127fd7da45b40b2e1c537320ad8
Author: Kaleb S. KEITHLEY <kkeithle(a)cloudfs-node01.kkeithle.redhat.com>
Date: Wed Jun 8 10:07:20 2011 -0400
scripts/cfs_start_volume.py: using FQ path to lib seems like it's not
agnostic wrt packaging differences, i.e. gluster packaging vs.
fedora packaging.
xlators/feators/uidmap/src/uidmap.c: fix a bug and eliminate the compile-
time warning for call to gf_asprintf(). Namely arg 1 is a char**,
not char*.
diff --git a/scripts/cfs_start_volume.py b/scripts/cfs_start_volume.py
index 70918db..1c60935 100755
--- a/scripts/cfs_start_volume.py
+++ b/scripts/cfs_start_volume.py
@@ -128,7 +128,7 @@ def cloudify_server (input, output, users, port):
last.subvols = []
for user, pw in users:
uidmap_opts[user] = dict()
- uidmap_opts[user]["uidmap-plugin"] = "/usr/lib64/glusterfs/3.1.3git/xlator/features/libmaprbtree.so"
+ uidmap_opts[user]["uidmap-plugin"] = "libmaprbtree.so"
uidmap_opts[user]["uid-range"] = "%d-%d" % (uid_base, uid_base + uid_incr - 1)
uidmap_opts[user]["gid-range"] = "%d-%d" % (gid_base, gid_base + uid_incr - 1)
uid_base = uid_base + uid_incr
diff --git a/xlators/features/uidmap/src/uidmap.c b/xlators/features/uidmap/src/uidmap.c
index d675d54..550314f 100644
--- a/xlators/features/uidmap/src/uidmap.c
+++ b/xlators/features/uidmap/src/uidmap.c
@@ -1844,7 +1844,7 @@ uidmap_loadsharedlib(char* xltrname, char *libname)
plugin_path = libname;
}
else {
- ret = gf_asprintf(plugin_path,"%s/%s",UIDMAP_PLUGIN_DIR,
+ ret = gf_asprintf(&plugin_path, "%s/%s", UIDMAP_PLUGIN_DIR,
libname);
if (ret < 0) {
gf_log(xltrname,GF_LOG_ERROR,
12 years, 6 months
scripts/cfs_start_volume.py xlators/features
by Jeff Darcy
scripts/cfs_start_volume.py | 2 +-
xlators/features/uidmap/src/uidmap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 4677605356ac4127fd7da45b40b2e1c537320ad8
Author: Kaleb S. KEITHLEY <kkeithle(a)cloudfs-node01.kkeithle.redhat.com>
Date: Wed Jun 8 10:07:20 2011 -0400
scripts/cfs_start_volume.py: using FQ path to lib seems like it's not
agnostic wrt packaging differences, i.e. gluster packaging vs.
fedora packaging.
xlators/feators/uidmap/src/uidmap.c: fix a bug and eliminate the compile-
time warning for call to gf_asprintf(). Namely arg 1 is a char**,
not char*.
diff --git a/scripts/cfs_start_volume.py b/scripts/cfs_start_volume.py
index 70918db..1c60935 100755
--- a/scripts/cfs_start_volume.py
+++ b/scripts/cfs_start_volume.py
@@ -128,7 +128,7 @@ def cloudify_server (input, output, users, port):
last.subvols = []
for user, pw in users:
uidmap_opts[user] = dict()
- uidmap_opts[user]["uidmap-plugin"] = "/usr/lib64/glusterfs/3.1.3git/xlator/features/libmaprbtree.so"
+ uidmap_opts[user]["uidmap-plugin"] = "libmaprbtree.so"
uidmap_opts[user]["uid-range"] = "%d-%d" % (uid_base, uid_base + uid_incr - 1)
uidmap_opts[user]["gid-range"] = "%d-%d" % (gid_base, gid_base + uid_incr - 1)
uid_base = uid_base + uid_incr
diff --git a/xlators/features/uidmap/src/uidmap.c b/xlators/features/uidmap/src/uidmap.c
index d675d54..550314f 100644
--- a/xlators/features/uidmap/src/uidmap.c
+++ b/xlators/features/uidmap/src/uidmap.c
@@ -1844,7 +1844,7 @@ uidmap_loadsharedlib(char* xltrname, char *libname)
plugin_path = libname;
}
else {
- ret = gf_asprintf(plugin_path,"%s/%s",UIDMAP_PLUGIN_DIR,
+ ret = gf_asprintf(&plugin_path, "%s/%s", UIDMAP_PLUGIN_DIR,
libname);
if (ret < 0) {
gf_log(xltrname,GF_LOG_ERROR,
12 years, 6 months
Uidmap merged to master
by Jeff Darcy
I discarded the commit email because it was long and contained no
information that hadn't been in other messages, but you can see it in
the git tree. Thank you, Kaleb, for all of your hard work on this.
12 years, 6 months
Branch 'uidmap' - pkg/cloudfs.spec.in pkg/configure.ac xlators/cluster xlators/encryption xlators/features
by Jeff Darcy
pkg/cloudfs.spec.in | 20 ++++--
pkg/configure.ac | 12 +++-
xlators/cluster/cloud/src/Makefile.am | 4 -
xlators/cluster/login/src/Makefile.am | 4 -
xlators/encryption/crypt/src/Makefile.am | 4 -
xlators/features/oplock/src/Makefile.am | 4 -
xlators/features/uidmap/src/Makefile.am | 7 +-
xlators/features/uidmap/src/uidmap.c | 93 +++++++++++++++++++------------
8 files changed, 95 insertions(+), 53 deletions(-)
New commits:
commit 9357521bdf651abd4ccf91776adf4bb4c27d8943
Author: Jeff Darcy <jdarcy(a)redhat.com>
Date: Tue Jun 7 15:51:07 2011 -0400
Enable building against either Gluster/Fedora RPM.
Mostly this is in the specfile, configure.ac, and makefiles. Also added
code in uidmap.c to look for plugins in the package-specific directory if
the given option is just a name rather than a path. Switching between
Fedora and Gluster packages should just be a matter of changing the
GLUSTER_LIBS line in configure.ac and some Build/BuildRequires lines in
cloudfs.spec.in; to build against a different *version* (independent of
packaging) change GLUSTER_VERSION in configure.ac instead.
diff --git a/pkg/cloudfs.spec.in b/pkg/cloudfs.spec.in
index 809a623..ee49c52 100644
--- a/pkg/cloudfs.spec.in
+++ b/pkg/cloudfs.spec.in
@@ -16,10 +16,16 @@ URL: http://cloudfs.org
Source0: http://cloudfs.org/dist/0.6/cloudfs-0.6.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+# Gluster way
+#Requires: glusterfs-core = @GLUSTER_VERSION@
+#Requires: glusterfs-fuse = @GLUSTER_VERSION@
+
+# Fedora way
Requires: glusterfs = @GLUSTER_VERSION@
+BuildRequires: glusterfs-devel = @GLUSTER_VERSION@
+
Requires: openssl
Requires: python
-BuildRequires: glusterfs-devel = @GLUSTER_VERSION@
BuildRequires: bison flex
BuildRequires: gcc make
BuildRequires: openssl-devel
@@ -43,9 +49,9 @@ with additional authentication/encryption/multi-tenancy features.
%{__make} install DESTDIR=%{buildroot}
# Remove unwanted files from all the shared libraries
-find %{buildroot}%{_libdir} -name '*.a' -delete
-find %{buildroot}%{_libdir} -name '*.la' -delete
-find %{buildroot}%{_libdir} -name '*.so.0.0.0' | xargs strip
+find %{buildroot}@GLUSTER_XLATORS@ -name '*.a' -delete
+find %{buildroot}@GLUSTER_XLATORS@ -name '*.la' -delete
+#find %{buildroot}@GLUSTER_XLATORS@ -name '*.so.0.0.0' | xargs strip
%clean
%{__rm} -rf %{buildroot}
@@ -53,9 +59,9 @@ find %{buildroot}%{_libdir} -name '*.so.0.0.0' | xargs strip
%files
%defattr(-,root,root)
%doc COPYING
-%{_libdir}/glusterfs/@GLUSTER_VERSION(a)/xlator/cluster/*.so*
-%{_libdir}/glusterfs/@GLUSTER_VERSION(a)/xlator/encryption/*.so*
-%{_libdir}/glusterfs/@GLUSTER_VERSION(a)/xlator/features/*.so*
+@GLUSTER_XLATORS(a)/cluster/*.so*
+@GLUSTER_XLATORS(a)/encryption/*.so*
+@GLUSTER_XLATORS(a)/features/*.so*
%{python_sitelib}/volfilter.py*
%{_bindir}/cloudfs
diff --git a/pkg/configure.ac b/pkg/configure.ac
index c185be5..d8641ca 100644
--- a/pkg/configure.ac
+++ b/pkg/configure.ac
@@ -65,7 +65,7 @@ if test "x${have_spinlock}" = "xyes"; then
AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
fi
-GLUSTER_VERSION=3.1.3git
+GLUSTER_VERSION="3.1.3"
GF_HOST_OS=""
GF_LDFLAGS="-rdynamic"
GF_HOST_OS="GF_LINUX_HOST_OS"
@@ -74,6 +74,14 @@ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
GF_LDADD=""
INCLUDES=""
+# Gluster packaging puts stuff in versioned dirs under /opt
+#GLUSTER_LIBS="/opt/glusterfs/${GLUSTER_VERSION}/lib64"
+# Sane packaging puts stuff here
+GLUSTER_LIBS="/usr/lib64"
+
+# Translators specify the version again. Ick.
+GLUSTER_XLATORS="${GLUSTER_LIBS}/glusterfs/${GLUSTER_VERSION}/xlator"
+
AC_SUBST(GF_DISTRIBUTION)
AC_SUBST(GLUSTER_VERSION)
AC_SUBST(GF_HOST_OS)
@@ -83,5 +91,7 @@ AC_SUBST(GF_LDFLAGS)
AC_SUBST(GF_LDADD)
AC_SUBST(INCLUDES)
AC_SUBST(HAVE_SPINLOCK)
+AC_SUBST(GLUSTER_LIBS)
+AC_SUBST(GLUSTER_XLATORS)
AC_OUTPUT
diff --git a/xlators/cluster/cloud/src/Makefile.am b/xlators/cluster/cloud/src/Makefile.am
index 2477932..87cd919 100644
--- a/xlators/cluster/cloud/src/Makefile.am
+++ b/xlators/cluster/cloud/src/Makefile.am
@@ -1,8 +1,8 @@
xlator_LTLIBRARIES = cloud.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/cluster
+xlatordir = @GLUSTER_XLATORS@/cluster
-cloud_la_LDFLAGS = -module -avoidversion -lglusterfs
+cloud_la_LDFLAGS = -module -avoidversion -L@GLUSTER_LIBS@ -lglusterfs
cloud_la_SOURCES = cloud.c
#cloud_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/cluster/login/src/Makefile.am b/xlators/cluster/login/src/Makefile.am
index b3a5fdf..43bde3d 100644
--- a/xlators/cluster/login/src/Makefile.am
+++ b/xlators/cluster/login/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = login.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/cluster
+xlatordir = @GLUSTER_XLATORS@/cluster
-login_la_LDFLAGS = -module -avoidversion -lglusterfs
+login_la_LDFLAGS = -module -avoidversion -L@GLUSTER_LIBS@ -lglusterfs
login_la_SOURCES = login.c
#login_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/encryption/crypt/src/Makefile.am b/xlators/encryption/crypt/src/Makefile.am
index a558228..19d8e0b 100644
--- a/xlators/encryption/crypt/src/Makefile.am
+++ b/xlators/encryption/crypt/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = crypt.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/encryption
+xlatordir = @GLUSTER_XLATORS@/encryption
-crypt_la_LDFLAGS = -module -avoidversion -lssl -lglusterfs
+crypt_la_LDFLAGS = -module -avoidversion -lssl -L@GLUSTER_LIBS@ -lglusterfs
crypt_la_SOURCES = crypt.c
#crypt_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/features/oplock/src/Makefile.am b/xlators/features/oplock/src/Makefile.am
index 5122e91..74dbdef 100644
--- a/xlators/features/oplock/src/Makefile.am
+++ b/xlators/features/oplock/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = oplock.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/features
+xlatordir = @GLUSTER_XLATORS@/features
-oplock_la_LDFLAGS = -module -avoidversion -lglusterfs
+oplock_la_LDFLAGS = -module -avoidversion -L@GLUSTER_LIBS@ -lglusterfs
oplock_la_SOURCES = oplock.c
#oplock_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/features/uidmap/src/Makefile.am b/xlators/features/uidmap/src/Makefile.am
index fd58a37..56d5225 100644
--- a/xlators/features/uidmap/src/Makefile.am
+++ b/xlators/features/uidmap/src/Makefile.am
@@ -1,12 +1,12 @@
xlator_LTLIBRARIES = uidmap.la libmaprbtree.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/features
+xlatordir = @GLUSTER_XLATORS@/features
-uidmap_la_LDFLAGS = -module -avoidversion -lglusterfs
+uidmap_la_LDFLAGS = -module -avoidversion -L@GLUSTER_LIBS@ -lglusterfs
uidmap_la_SOURCES = uidmap.c
-libmaprbtree_la_LDFLAGS = -module -avoidversion -lglusterfs
+libmaprbtree_la_LDFLAGS = -module -avoidversion -L@GLUSTER_LIBS@ -lglusterfs
libmaprbtree_la_SOURCES = rbmap.c
@@ -16,6 +16,7 @@ GLUSTERDIR=$(includedir)/glusterfs
AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \
-I$(GLUSTERDIR) -I$(GLUSTERDIR)/rpc -I$(GLUSTERDIR)/server \
+ -DUIDMAP_PLUGIN_DIR=\"$(xlatordir)\" \
-shared -nostartfiles $(GF_CFLAGS)
CLEANFILES =
diff --git a/xlators/features/uidmap/src/uidmap.c b/xlators/features/uidmap/src/uidmap.c
index 9241203..d675d54 100644
--- a/xlators/features/uidmap/src/uidmap.c
+++ b/xlators/features/uidmap/src/uidmap.c
@@ -1835,41 +1835,66 @@ uidmap_lk(call_frame_t *frame, xlator_t *this, fd_t *fd,
static init_fn
uidmap_loadsharedlib(char* xltrname, char *libname)
{
- init_fn plugin_init = NULL;
- void *handle = NULL;
-
- gf_log(xltrname, CFS_LOG_LEVEL, "loading: %s", libname);
- if ((handle = dlopen(libname, RTLD_NOW|RTLD_NODELETE)) != NULL) {
- do {
- if ((uidmap_map = (map_fn) dlsym(handle, "map")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing map: %s", dlerror());
- break;
- }
-
- if ((uidmap_revmap = (revmap_fn) dlsym(handle, "revmap")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing revmap: %s", dlerror());
- break;
- }
-
- if ((uidmap_plugin_fini = (fini_fn) dlsym(handle, "fini")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing fini: %s", dlerror());
- break;
- }
+ init_fn plugin_init = NULL;
+ void *handle = NULL;
+ char *plugin_path = NULL;
+ int ret = -1;
+
+ if (strchr(libname,'/')) {
+ plugin_path = libname;
+ }
+ else {
+ ret = gf_asprintf(plugin_path,"%s/%s",UIDMAP_PLUGIN_DIR,
+ libname);
+ if (ret < 0) {
+ gf_log(xltrname,GF_LOG_ERROR,
+ "could not construct plugin path for %s",
+ libname);
+ return NULL;
+ }
+ }
+ gf_log(xltrname, CFS_LOG_LEVEL, "loading %s (%s)", plugin_path,
+ (plugin_path == libname) ? "given" : "constructed");
+
+ handle = dlopen(plugin_path, RTLD_NOW|RTLD_NODELETE);
+ if (!handle) {
+ gf_log(xltrname, GF_LOG_ERROR, "dlopen failed (%s)", dlerror());
+ return NULL;
+ }
+
+ if ((uidmap_map = (map_fn) dlsym(handle, "map")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing map: %s", dlerror());
+ goto close_it;
+ }
+
+ if ((uidmap_revmap = (revmap_fn) dlsym(handle, "revmap")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing revmap: %s", dlerror());
+ goto close_it;
+ }
+
+ if ((uidmap_plugin_fini = (fini_fn) dlsym(handle, "fini")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing fini: %s", dlerror());
+ goto close_it;
+ }
+
+ if ((plugin_init = (init_fn) dlsym(handle, "init")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing init: %s", dlerror());
+ }
+
+close_it:
+ if (dlclose(handle)) {
+ gf_log(xltrname, CFS_LOG_LEVEL,
+ "dlclose plugin: %s", dlerror());
+ }
+
+ if (plugin_path != libname) {
+ GF_FREE(plugin_path);
+ }
- if ((plugin_init = (init_fn) dlsym(handle, "init")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing init: %s", dlerror());
- }
- } while (0);
-
- if (dlclose(handle)) {
- gf_log(xltrname, CFS_LOG_LEVEL,
- "dlclose plugin: %s", dlerror());
- }
- }
return plugin_init;
}
12 years, 6 months
Branch 'uidmap' - scripts/cfs_start_volume.py xlators/features
by Kaleb KEITHLEY
scripts/cfs_start_volume.py | 18 -
xlators/features/uidmap/src/Makefile.am | 2
xlators/features/uidmap/src/rbmap.c | 268 +++++++++------
xlators/features/uidmap/src/uidmap.c | 570 ++++++++++++++++----------------
xlators/features/uidmap/src/uidmap.h | 8
5 files changed, 470 insertions(+), 396 deletions(-)
New commits:
commit f1d83347f755642d4e4bd297f680bfc965e56158
Author: Kaleb S. KEITHLEY <kkeithle(a)cloudfs-node01.kkeithle.redhat.com>
Date: Tue Jun 7 10:01:00 2011 -0400
scripts/cfs_start_volume.py: use proper option name, not the deprecated one
xlators/features/uidmap/src/Makefile.am: turns out the gluster rb(tree) is
in /usr/lib(64)/libglusterfs.so, so there's no need to compile it into
our own lib
xlators/features/uidmap/src/{rbmap,uidmap}.[ch]: properly deal with multi-
tenancy, i.e. maintain separate mappings for each tenant and persist
(pickle) the mappings in their own file(s) in /usr/lib/cloudfs
diff --git a/scripts/cfs_start_volume.py b/scripts/cfs_start_volume.py
index b51b653..70918db 100755
--- a/scripts/cfs_start_volume.py
+++ b/scripts/cfs_start_volume.py
@@ -119,16 +119,22 @@ def cloudify_server (input, output, users, port):
print "# stripping auth option %s = %s" % (opt, last.opts[opt])
del last.opts[opt]
- default_uidmap_opts = dict()
- default_uidmap_opts["uid-range"] = "10000-19999"
- default_uidmap_opts["gid-range"] = "10000-19999"
- default_uidmap_opts["tenant"] = "ChangeMe"
- default_uidmap_opts["plugin"] = "/usr/lib64/glusterfs/3.1.3git/xlator/features/libmaprbtree.so"
+ uid_base = 10000
+ uid_incr = 1000
+ gid_base = 10000
+ gid_incr = 1000
+ uidmap_opts = dict()
last.subvols = []
for user, pw in users:
+ uidmap_opts[user] = dict()
+ uidmap_opts[user]["uidmap-plugin"] = "/usr/lib64/glusterfs/3.1.3git/xlator/features/libmaprbtree.so"
+ uidmap_opts[user]["uid-range"] = "%d-%d" % (uid_base, uid_base + uid_incr - 1)
+ uidmap_opts[user]["gid-range"] = "%d-%d" % (gid_base, gid_base + uid_incr - 1)
+ uid_base = uid_base + uid_incr
+ gid_base = gid_base + gid_incr
new_stack = volfilter.copy_stack(old_stack,user)
- volfilter.push_filter(graph, new_stack, "features/uidmap", default_uidmap_opts)
+ volfilter.push_filter(graph, new_stack, "features/uidmap", uidmap_opts[user])
last.subvols.append(new_stack)
last.opts["auth.login.%s.allow"%new_stack.name] = user
last.opts["auth.login.%s.password"%user] = pw
diff --git a/xlators/features/uidmap/src/Makefile.am b/xlators/features/uidmap/src/Makefile.am
index d0da92c..fd58a37 100644
--- a/xlators/features/uidmap/src/Makefile.am
+++ b/xlators/features/uidmap/src/Makefile.am
@@ -8,7 +8,7 @@ uidmap_la_SOURCES = uidmap.c
libmaprbtree_la_LDFLAGS = -module -avoidversion -lglusterfs
-libmaprbtree_la_SOURCES = rb.c rbmap.c
+libmaprbtree_la_SOURCES = rbmap.c
noinst_HEADERS = uidmap.h rb.h
diff --git a/xlators/features/uidmap/src/rbmap.c b/xlators/features/uidmap/src/rbmap.c
index 7c2f810..49b3500 100644
--- a/xlators/features/uidmap/src/rbmap.c
+++ b/xlators/features/uidmap/src/rbmap.c
@@ -1,5 +1,5 @@
-/*
- Copyright © 2011, Red Hat, Inc.
+/*
+ Copyright 2011, Red Hat, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -24,7 +24,8 @@
#include "uidmap.h"
#include "rb.h"
-static struct {
+typedef struct {
+ char *name;
uid_t uid_low;
uid_t uid_high;
uid_t uid_next;
@@ -35,10 +36,9 @@ static struct {
struct rb_table *uid_revmap;
struct rb_table *gid_map;
struct rb_table *gid_revmap;
- char* tenant;
int root_squash;
pthread_mutex_t mtx;
-} rbmap;
+} mapping_t;
union tuple {
struct {
@@ -71,15 +71,18 @@ union tuple {
#define RBMAP_LOG_LEVEL GF_LOG_DEBUG
+static struct rb_table *mappings;
+static pthread_mutex_t mappings_mtx = PTHREAD_MUTEX_INITIALIZER;
+
/* serialize and persist */
static void
-rbmap_serialize(char *tenant)
+rbmap_serialize(mapping_t *mapping)
{
char fname[128], lkname[128];
FILE *file = NULL;
int lockfd = -1;
- (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, tenant);
- (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, tenant);
+ (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, mapping->name);
+ (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, mapping->name);
do {
int status;
@@ -87,44 +90,44 @@ rbmap_serialize(char *tenant)
union tuple *data;
lockfd = open(lkname, O_CREAT|O_WRONLY, 0644);
if (lockfd == -1) {
- gf_log("serialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"open %s: %s", lkname, strerror(errno));
break;
}
status = flock(lockfd, LOCK_EX);
if (status == -1) {
- gf_log("serialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"flock failed %s", strerror(errno));
break;
}
file = fopen(fname, "w");
if (file == NULL) {
(void) flock(lockfd, LOCK_UN);
- gf_log("serialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"fopen failed %s", strerror(errno));
break;
}
(void) fprintf(file, RBMAP_SIGNATURE);
- data = (union tuple *) rb_t_first(&trav, rbmap.uid_map);
+ data = (union tuple *) rb_t_first(&trav, mapping->uid_map);
while (data != NULL) {
(void) fprintf(file, "%s %u %u\n",
RBMAP_UID_MAP_ENTRY,
data->u1, data->u2);
data = (union tuple *) rb_t_next(&trav);
}
- (void) fprintf(file, "%s %u\n", RBMAP_UID_LOW, rbmap.uid_low);
- (void) fprintf(file, "%s %u\n", RBMAP_UID_HIGH, rbmap.uid_high);
- (void) fprintf(file, "%s %u\n", RBMAP_UID_NEXT, rbmap.uid_next);
- data = (union tuple *) rb_t_first(&trav, rbmap.gid_map);
+ (void) fprintf(file, "%s %u\n", RBMAP_UID_LOW, mapping->uid_low);
+ (void) fprintf(file, "%s %u\n", RBMAP_UID_HIGH, mapping->uid_high);
+ (void) fprintf(file, "%s %u\n", RBMAP_UID_NEXT, mapping->uid_next);
+ data = (union tuple *) rb_t_first(&trav, mapping->gid_map);
while (data != NULL) {
(void) fprintf(file, "%s %u %u\n",
RBMAP_GID_MAP_ENTRY,
data->g1, data->g2);
data = (union tuple *) rb_t_next(&trav);
}
- (void) fprintf(file, "%s %u\n", RBMAP_GID_LOW, rbmap.gid_low);
- (void) fprintf(file, "%s %u\n", RBMAP_GID_HIGH, rbmap.gid_high);
- (void) fprintf(file, "%s %u\n", RBMAP_GID_NEXT, rbmap.gid_next);
+ (void) fprintf(file, "%s %u\n", RBMAP_GID_LOW, mapping->gid_low);
+ (void) fprintf(file, "%s %u\n", RBMAP_GID_HIGH, mapping->gid_high);
+ (void) fprintf(file, "%s %u\n", RBMAP_GID_NEXT, mapping->gid_next);
} while (0);
if (file != NULL) {
(void) fclose(file);
@@ -137,7 +140,7 @@ rbmap_serialize(char *tenant)
static int
-rbmap_readmapfile(FILE *file)
+rbmap_readmapfile(mapping_t *mapping, FILE *file)
{
char scratch[128];
char* sts;
@@ -155,10 +158,10 @@ rbmap_readmapfile(FILE *file)
int num = sscanf(&scratch[RBMAP_UID_MAP_ENTRY_LEN+1],
" %u %u", &map_data->u1, &map_data->u2);
if (num == 2) {
- rb_insert(rbmap.uid_map, map_data);
+ rb_insert(mapping->uid_map, map_data);
revmap_data->u1 = map_data->u2;
revmap_data->u2 = map_data->u1;
- rb_insert(rbmap.uid_revmap, revmap_data);
+ rb_insert(mapping->uid_revmap, revmap_data);
} else {
(void) free(map_data);
(void) free(revmap_data);
@@ -169,13 +172,13 @@ rbmap_readmapfile(FILE *file)
return -1;
}
} else if (strncmp(scratch, RBMAP_UID_LOW, RBMAP_UID_LOW_LEN) == 0) {
- rbmap.uid_low =
+ mapping->uid_low =
(uid_t) strtoul(&scratch[RBMAP_UID_LOW_LEN+1], NULL, 10);
} else if (strncmp(scratch, RBMAP_UID_HIGH, RBMAP_UID_HIGH_LEN) == 0) {
- rbmap.uid_high =
+ mapping->uid_high =
(uid_t) strtoul(&scratch[RBMAP_UID_HIGH_LEN+1], NULL, 10);
} else if (strncmp(scratch, RBMAP_UID_NEXT, RBMAP_UID_NEXT_LEN) == 0) {
- rbmap.uid_next =
+ mapping->uid_next =
(uid_t) strtoul(&scratch[RBMAP_UID_NEXT_LEN+1], NULL, 10);
} else if (strncmp(scratch, RBMAP_GID_MAP_ENTRY, RBMAP_GID_MAP_ENTRY_LEN) == 0) {
union tuple *map_data;
@@ -190,10 +193,10 @@ rbmap_readmapfile(FILE *file)
int num = sscanf(&scratch[RBMAP_GID_MAP_ENTRY_LEN+1],
" %u %u", &map_data->g1, &map_data->g2);
if (num == 2) {
- rb_insert(rbmap.gid_map, map_data);
+ rb_insert(mapping->gid_map, map_data);
revmap_data->g1 = map_data->g2;
revmap_data->g2 = map_data->g1;
- rb_insert(rbmap.gid_revmap, revmap_data);
+ rb_insert(mapping->gid_revmap, revmap_data);
} else {
(void) free(map_data);
(void) free(revmap_data);
@@ -204,13 +207,13 @@ rbmap_readmapfile(FILE *file)
return -1;
}
} else if (strncmp(scratch, RBMAP_GID_LOW, RBMAP_GID_LOW_LEN) == 0) {
- rbmap.gid_low =
+ mapping->gid_low =
(uid_t) strtoul(&scratch[RBMAP_GID_LOW_LEN+1], NULL, 10);
} else if (strncmp(scratch, RBMAP_GID_HIGH, RBMAP_GID_HIGH_LEN) == 0) {
- rbmap.gid_high =
+ mapping->gid_high =
(uid_t) strtoul(&scratch[RBMAP_GID_HIGH_LEN+1], NULL, 10);
} else if (strncmp(scratch, RBMAP_GID_NEXT, RBMAP_GID_NEXT_LEN) == 0) {
- rbmap.gid_next =
+ mapping->gid_next =
(uid_t) strtoul(&scratch[RBMAP_GID_NEXT_LEN+1], NULL, 10);
}
}
@@ -218,13 +221,13 @@ rbmap_readmapfile(FILE *file)
}
static int
-rbmap_deserialize(char *tenant)
+rbmap_deserialize(mapping_t *mapping)
{
char fname[128], lkname[128];
- FILE* file = NULL;
+ FILE *file = NULL;
int lockfd = -1;
- (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, tenant);
- (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, tenant);
+ (void) snprintf(lkname, sizeof lkname, UIDMAP_MAP_LOCK_FILE, mapping->name);
+ (void) snprintf(fname, sizeof fname, UIDMAP_MAP_FILE, mapping->name);
do {
char scratch[128];
@@ -232,34 +235,34 @@ rbmap_deserialize(char *tenant)
int status;
lockfd = open(lkname, O_CREAT|O_RDONLY, 0644);
if (lockfd == -1) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"open %s: %s", lkname, strerror(errno));
break;
}
status = flock(lockfd, LOCK_EX);
if (status == -1) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"flock: %s", strerror(errno));
break;
}
file = fopen(fname, "r");
if (file == NULL) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_INFO,
"fopen failed: %s", strerror(errno));
break;
}
/* read the first line (signature) of the file) */
if ((sts = fgets(scratch, sizeof scratch, file)) == (char *) EOF || sts == NULL) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"fgets signature failed: %s", strerror(errno));
break;
}
if (strcmp(RBMAP_SIGNATURE, scratch) != 0) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(mapping->name, GF_LOG_CRITICAL,
"signature mismatch: %s", scratch);
break;
}
- if (rbmap_readmapfile(file) == -1) {
+ if (rbmap_readmapfile(mapping, file) == -1) {
return -1;
}
} while (0);
@@ -275,125 +278,148 @@ rbmap_deserialize(char *tenant)
int
-map(struct _call_stack_t *stack, struct _xlator *xlator)
+map(struct _call_stack_t *stack, char *name)
{
- char *tenant = rbmap.tenant ? rbmap.tenant : "unknown";
int do_persist = 0;
- if (stack->uid == 0 && rbmap.root_squash) {
+ mapping_t *mapping, mneedle;
+ mneedle.name = name;
+ mapping = (mapping_t *) rb_find(mappings, &mneedle);
+ /* assert(mapping != NULL); */
+ if (mapping == NULL) {
+ return -1;
+ }
+ if (stack->uid == 0 && mapping->root_squash) {
stack->uid = stack->gid = CLOUDFS_NOBODY;
return 0;
}
- pthread_mutex_lock(&rbmap.mtx);
do {
+ pthread_mutex_lock(&mapping->mtx);
if (stack->uid != 0) {
/* look for an existing match */
- union tuple *new_map, needle;
- needle.u1 = stack->uid;
- new_map = (union tuple *) rb_find(rbmap.uid_map, &needle);
+ union tuple *new_map, tneedle;
+ tneedle.u1 = stack->uid;
+ new_map = (union tuple *) rb_find(mapping->uid_map, &tneedle);
if (new_map == NULL) {
union tuple *new_revmap = NULL;
/* couldn't find one, make a new one */
- if (rbmap.uid_next > rbmap.uid_high) {
- gf_log("map uid", GF_LOG_CRITICAL,
- "exhausted uids in range %u-%u",
- rbmap.uid_low, rbmap.uid_high);
- pthread_mutex_unlock(&rbmap.mtx);
+ if (mapping->uid_next > mapping->uid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "no uids in range %u-%u",
+ mapping->uid_low, mapping->uid_high);
+ pthread_mutex_unlock(&mapping->mtx);
return -1;
}
new_map = (union tuple *) malloc(sizeof(union tuple));
new_revmap =
(union tuple *) malloc(sizeof(union tuple));
if (new_map == NULL || new_revmap == NULL) {
- pthread_mutex_unlock(&rbmap.mtx);
+ pthread_mutex_unlock(&mapping->mtx);
if (new_map != NULL) (void) free(new_map);
if (new_revmap != NULL) (void) free(new_revmap);
return -1;
}
do_persist = 1;
new_map->u1 = stack->uid;
- new_map->u2 = rbmap.uid_next++;
+ new_map->u2 = mapping->uid_next++;
new_revmap->u1 = new_map->u2;
new_revmap->u2 = new_map->u1;
- if (rb_probe(rbmap.uid_map, new_map) == NULL) {
- pthread_mutex_unlock(&rbmap.mtx);
+ if (rb_probe(mapping->uid_map, new_map) == NULL) {
+ pthread_mutex_unlock(&mapping->mtx);
(void) free(new_map);
(void) free(new_revmap);
return -1;
}
- if (rb_probe(rbmap.uid_revmap, new_revmap) == NULL) {
- pthread_mutex_unlock(&rbmap.mtx);
- (void) rb_delete(rbmap.uid_map, new_map);
+ if (rb_probe(mapping->uid_revmap, new_revmap) == NULL) {
+ pthread_mutex_unlock(&mapping->mtx);
+ (void) rb_delete(mapping->uid_map, new_map);
(void) free(new_map);
(void) free(new_revmap);
return -1;
}
- gf_log("map uid", GF_LOG_TRACE,
- "added new uid mapping for %s %u -> %u",
- tenant, stack->uid, new_map->u2);
+ gf_log(name, RBMAP_LOG_LEVEL,
+ "added new uid mapping %u -> %u",
+ stack->uid, new_map->u2);
+ if (mapping->uid_next > mapping->uid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "exhausted uids in range %u-%u",
+ mapping->uid_low, mapping->uid_high);
+ }
}
stack->uid = new_map->u2;
}
if (stack->gid != 0) {
/* look for an existing match */
- union tuple *new_map, needle;
- needle.g1 = stack->gid;
- new_map = (union tuple *) rb_find(rbmap.gid_map, &needle);
+ union tuple *new_map, tneedle;
+ tneedle.g1 = stack->gid;
+ new_map = (union tuple *) rb_find(mapping->gid_map, &tneedle);
if (new_map == NULL) {
union tuple *new_revmap = NULL;
/* couldn't find one, make a new one */
- if (rbmap.gid_next > rbmap.gid_high) {
- gf_log("map gid", GF_LOG_CRITICAL,
- "exhausted gids in range %u-%u",
- rbmap.gid_low, rbmap.gid_high);
- pthread_mutex_unlock(&rbmap.mtx);
+ if (mapping->gid_next > mapping->gid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "no gids in range %u-%u",
+ mapping->gid_low, mapping->gid_high);
+ pthread_mutex_unlock(&mapping->mtx);
return -1;
}
new_map = (union tuple *) malloc(sizeof(union tuple));
new_revmap =
(union tuple *) malloc(sizeof(union tuple));
if (new_map == NULL || new_revmap == NULL) {
- pthread_mutex_unlock(&rbmap.mtx);
+ pthread_mutex_unlock(&mapping->mtx);
if (new_map != NULL) (void) free(new_map);
if (new_revmap != NULL) (void) free(new_revmap);
return -1;
}
do_persist = 1;
new_map->g1 = stack->gid;
- new_map->g2 = rbmap.gid_next++;
+ new_map->g2 = mapping->gid_next++;
new_revmap->g1 = new_map->g2;
new_revmap->g2 = new_map->g1;
- if (rb_probe(rbmap.gid_map, new_map) == NULL) {
- pthread_mutex_unlock(&rbmap.mtx);
+ if (rb_probe(mapping->gid_map, new_map) == NULL) {
+ pthread_mutex_unlock(&mapping->mtx);
(void) free(new_map);
(void) free(new_revmap);
return -1;
}
- if (rb_probe(rbmap.gid_revmap, new_revmap) == NULL) {
- pthread_mutex_unlock(&rbmap.mtx);
- (void) rb_delete(rbmap.gid_map, new_map);
+ if (rb_probe(mapping->gid_revmap, new_revmap) == NULL) {
+ pthread_mutex_unlock(&mapping->mtx);
+ (void) rb_delete(mapping->gid_map, new_map);
(void) free(new_map);
(void) free(new_revmap);
return -1;
}
- gf_log("map gid", GF_LOG_TRACE,
- "added new gid mapping for %s %u -> %u",
- tenant, stack->gid, new_map->g2);
+ gf_log(name, RBMAP_LOG_LEVEL,
+ "added new gid mapping %u -> %u",
+ stack->gid, new_map->g2);
+ if (mapping->gid_next > mapping->gid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "exhausted gids in range %u-%u",
+ mapping->gid_low, mapping->gid_high);
+ }
}
stack->gid = new_map->g2;
}
+ if (do_persist > 0)
+ rbmap_serialize(mapping);
+ pthread_mutex_unlock(&mapping->mtx);
} while (0);
- if (do_persist > 0)
- rbmap_serialize(tenant);
- pthread_mutex_unlock(&rbmap.mtx);
return 0;
}
void
-revmap(uid_t *uid, gid_t *gid)
+revmap(uid_t *uid, gid_t *gid, char *name)
{
- union tuple *found, needle;
+ union tuple *tuple, tneedle;
+ mapping_t *mapping, mneedle;
+ mneedle.name = name;
+ mapping = (mapping_t *) rb_find(mappings, &mneedle);
+ /* assert(mapping != NULL); */
+ if (mapping == NULL) {
+ return;
+ }
switch (*uid) {
case 0:
/* break; */
@@ -401,10 +427,10 @@ revmap(uid_t *uid, gid_t *gid)
*uid = 0;
break;
default:
- needle.u1 = *uid;
- found = (union tuple *) rb_find(rbmap.uid_revmap, &needle);
- if (found != NULL) {
- *uid = found->u2;
+ tneedle.u1 = *uid;
+ tuple = (union tuple *) rb_find(mapping->uid_revmap, &tneedle);
+ if (tuple != NULL) {
+ *uid = tuple->u2;
}
break;
}
@@ -415,10 +441,10 @@ revmap(uid_t *uid, gid_t *gid)
*uid = 0;
break;
default:
- needle.g1 = *gid;
- found = (union tuple *) rb_find(rbmap.gid_revmap, &needle);
- if (found != NULL) {
- *gid = found->g2;
+ tneedle.g1 = *gid;
+ tuple = (union tuple *) rb_find(mapping->gid_revmap, &tneedle);
+ if (tuple != NULL) {
+ *gid = tuple->g2;
}
break;
}
@@ -452,23 +478,51 @@ rbmap_compare_gid(const void *rb_a, const void *rb_b, void *rb_param)
return ret;
}
+static int
+rbmap_compare_tenantname(const void *rb_a, const void *rb_b, void *rb_param)
+{
+ mapping_t *needle = (mapping_t *) rb_a;
+ mapping_t *haystack = (mapping_t *) rb_b;
+ return strcmp(haystack->name, needle->name);
+}
+
int32_t
-init(struct _xlator *xlator, char *tenant, uid_t uid_low, uid_t uid_hi, gid_t gid_low, gid_t gid_hi, int root_squash)
+init(struct _xlator *xlator,
+ uid_t uid_low, uid_t uid_high, gid_t gid_low, gid_t gid_high,
+ int root_squash)
{
- pthread_mutex_init(&rbmap.mtx, NULL);
- rbmap.tenant = strdup(tenant);
- rbmap.root_squash = root_squash;
- rbmap.uid_low = rbmap.uid_next = uid_low;
- rbmap.uid_high = uid_hi;
- rbmap.gid_low = rbmap.gid_next = gid_low;
- rbmap.gid_high = gid_hi;
- rbmap.uid_map = rb_create(rbmap_compare_uid, NULL, NULL);
- rbmap.uid_revmap = rb_create(rbmap_compare_uid, NULL, NULL);
- rbmap.gid_map = rb_create(rbmap_compare_gid, NULL, NULL);
- rbmap.gid_revmap = rb_create(rbmap_compare_gid, NULL, NULL);
-
- return rbmap_deserialize(tenant);
+ mapping_t *newmapping;
+ int ret = 0;
+ pthread_mutex_lock(&mappings_mtx);
+ if (mappings == NULL) {
+ mappings = rb_create(rbmap_compare_tenantname, NULL, NULL);
+ }
+ pthread_mutex_unlock(&mappings_mtx);
+ if (mappings == NULL) {
+ return -1;
+ }
+ newmapping = (mapping_t *) malloc(sizeof(mapping_t));
+ if (newmapping == NULL) {
+ return -1;
+ }
+ pthread_mutex_init(&newmapping->mtx, NULL);
+ newmapping->name = strdup(xlator->name);
+ newmapping->root_squash = root_squash;
+ newmapping->uid_low = newmapping->uid_next = uid_low;
+ newmapping->uid_high = uid_high;
+ newmapping->gid_low = newmapping->gid_next = gid_low;
+ newmapping->gid_high = gid_high;
+ newmapping->uid_map = rb_create(rbmap_compare_uid, NULL, NULL);
+ newmapping->uid_revmap = rb_create(rbmap_compare_uid, NULL, NULL);
+ newmapping->gid_map = rb_create(rbmap_compare_gid, NULL, NULL);
+ newmapping->gid_revmap = rb_create(rbmap_compare_gid, NULL, NULL);
+ if ((ret = rbmap_deserialize(newmapping)) != -1) {
+ pthread_mutex_lock(&mappings_mtx);
+ rb_insert(mappings, newmapping);
+ pthread_mutex_unlock(&mappings_mtx);
+ }
+ return ret;
}
void
diff --git a/xlators/features/uidmap/src/uidmap.c b/xlators/features/uidmap/src/uidmap.c
index 18dbdaa..9241203 100644
--- a/xlators/features/uidmap/src/uidmap.c
+++ b/xlators/features/uidmap/src/uidmap.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Red Hat, Inc.
+ * Copyright 2011 Red Hat, Inc.
*
* This file is part of CloudFS.
*
@@ -39,9 +39,6 @@
#define CFS_GID_LOW_DEFAULT 10000
#define CFS_GID_HIGH_DEFAULT 19999
-static short uidmap_root_squash = 0;
-static char *uidmap_tenant = NULL;
-
typedef struct uid_map_entry {
uid_t me_client_uid;
uid_t me_server_uid;
@@ -52,22 +49,26 @@ typedef struct gid_map_entry {
uid_t me_server_gid;
} gid_map_entry_t;
-typedef struct id_mapping {
- uid_map_entry_t *im_uid_map;
- unsigned short im_uid_map_len;
- uid_t im_uid_low;
- uid_t im_uid_high;
- uid_t im_uid_next;
- gid_map_entry_t *im_gid_map;
- unsigned short im_gid_map_len;
- gid_t im_gid_low;
- gid_t im_gid_high;
- gid_t im_gid_next;
-
- pthread_mutex_t im_mtx;
-} id_mapping_t;
-
-static id_mapping_t uidmap_mapping = {
+typedef struct {
+ char *name;
+ uid_map_entry_t *uid_map;
+ unsigned short uid_map_len;
+ uid_t uid_low;
+ uid_t uid_high;
+ uid_t uid_next;
+ gid_map_entry_t *gid_map;
+ unsigned short gid_map_len;
+ gid_t gid_low;
+ gid_t gid_high;
+ gid_t gid_next;
+ short root_squash;
+ pthread_mutex_t mtx;
+} mapping_t;
+
+static unsigned short uidmap_num_mappings = 0;
+
+static mapping_t* uidmap_mappings; /* = {
+ .im_name = NULL,
.im_uid_map = NULL,
.im_uid_map_len = 0,
.im_uid_low = CFS_UID_LOW_DEFAULT,
@@ -78,8 +79,9 @@ static id_mapping_t uidmap_mapping = {
.im_gid_low = CFS_UID_LOW_DEFAULT,
.im_gid_high = CFS_UID_HIGH_DEFAULT,
.im_gid_next = CFS_UID_LOW_DEFAULT,
+ .im_root_squash = 0,
.im_mtx = PTHREAD_MUTEX_INITIALIZER
-};
+}; */
#define CFS_SIGNATURE "cloudfs map: default\n"
#define CFS_UID_MAP_ENTRY "uid_map_entry:"
@@ -103,7 +105,7 @@ static id_mapping_t uidmap_mapping = {
/* serialize and persist */
static void
-uidmap_serialize_default(char *tenant)
+uidmap_serialize_default(char *tenant, mapping_t *map)
{
char fname[128], lkname[128];
FILE *file = NULL;
@@ -116,47 +118,47 @@ uidmap_serialize_default(char *tenant)
unsigned short i;
lockfd = open(lkname, O_CREAT|O_WRONLY, 0644);
if (lockfd == -1) {
- gf_log("serialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"open %s: %s", lkname, strerror(errno));
break;
}
status = flock(lockfd, LOCK_EX);
if (status == -1) {
- gf_log("serialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"flock failed %s", strerror(errno));
break;
}
file = fopen(fname, "w");
if (file == NULL) {
(void) flock(lockfd, LOCK_UN);
- gf_log("serialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"fopen failed %s", strerror(errno));
break;
}
(void) fprintf(file, CFS_SIGNATURE);
- for (i = 0; i < uidmap_mapping.im_uid_map_len; i++) {
+ for (i = 0; i < map->uid_map_len; i++) {
(void) fprintf(file, "%s %u %u\n",
CFS_UID_MAP_ENTRY,
- uidmap_mapping.im_uid_map[i].me_client_uid,
- uidmap_mapping.im_uid_map[i].me_server_uid);
+ map->uid_map[i].me_client_uid,
+ map->uid_map[i].me_server_uid);
}
(void) fprintf(file, "%s %u\n",
- CFS_UID_LOW, uidmap_mapping.im_uid_low);
+ CFS_UID_LOW, map->uid_low);
(void) fprintf(file, "%s %u\n",
- CFS_UID_HIGH, uidmap_mapping.im_uid_high);
+ CFS_UID_HIGH, map->uid_high);
(void) fprintf(file, "%s %u\n",
- CFS_UID_NEXT, uidmap_mapping.im_uid_next);
- for (i = 0; i < uidmap_mapping.im_gid_map_len; i++) {
+ CFS_UID_NEXT, map->uid_next);
+ for (i = 0; i < map->gid_map_len; i++) {
(void) fprintf(file, "%s %u %u\n", CFS_GID_MAP_ENTRY,
- uidmap_mapping.im_gid_map[i].me_client_gid,
- uidmap_mapping.im_gid_map[i].me_server_gid);
+ map->gid_map[i].me_client_gid,
+ map->gid_map[i].me_server_gid);
}
(void) fprintf(file, "%s %u\n", CFS_GID_LOW,
- uidmap_mapping.im_gid_low);
+ map->gid_low);
(void) fprintf(file, "%s %u\n", CFS_GID_HIGH,
- uidmap_mapping.im_gid_high);
+ map->gid_high);
(void) fprintf(file, "%s %u\n", CFS_GID_NEXT,
- uidmap_mapping.im_gid_next);
+ map->gid_next);
} while (0);
if (file != NULL) {
(void) fclose(file);
@@ -169,17 +171,15 @@ uidmap_serialize_default(char *tenant)
static int
-uidmap_adduidentry(uid_t server_uid, uid_t client_uid)
+uidmap_adduidentry(mapping_t *map, uid_t server_uid, uid_t client_uid)
{
uid_map_entry_t *uid_map_entry = NULL;
- uidmap_mapping.im_uid_map =
- REALLOC(uidmap_mapping.im_uid_map,
- sizeof(uid_map_entry_t) * (uidmap_mapping.im_uid_map_len + 1));
- if (uidmap_mapping.im_uid_map == NULL) {
+ map->uid_map = REALLOC(map->uid_map,
+ sizeof(uid_map_entry_t) * (map->uid_map_len + 1));
+ if (map->uid_map == NULL) {
return -1;
}
- uid_map_entry =
- &uidmap_mapping.im_uid_map[uidmap_mapping.im_uid_map_len++];
+ uid_map_entry = &map->uid_map[map->uid_map_len++];
uid_map_entry->me_client_uid = client_uid;
uid_map_entry->me_server_uid = server_uid;
return 0;
@@ -187,17 +187,15 @@ uidmap_adduidentry(uid_t server_uid, uid_t client_uid)
static int
-uidmap_addgidentry(uid_t server_gid, uid_t client_gid)
+uidmap_addgidentry(mapping_t *map, uid_t server_gid, uid_t client_gid)
{
gid_map_entry_t *gid_map_entry = NULL;
- uidmap_mapping.im_gid_map =
- REALLOC(uidmap_mapping.im_gid_map,
- sizeof(gid_map_entry_t) * (uidmap_mapping.im_gid_map_len + 1));
- if (uidmap_mapping.im_gid_map == NULL) {
+ map->gid_map = REALLOC(map->gid_map,
+ sizeof(gid_map_entry_t) * (map->gid_map_len + 1));
+ if (map->gid_map == NULL) {
return -1;
}
- gid_map_entry =
- &uidmap_mapping.im_gid_map[uidmap_mapping.im_gid_map_len++];
+ gid_map_entry = &map->gid_map[map->gid_map_len++];
gid_map_entry->me_client_gid = client_gid;
gid_map_entry->me_server_gid = server_gid;
return 0;
@@ -205,7 +203,7 @@ uidmap_addgidentry(uid_t server_gid, uid_t client_gid)
static int
-uidmap_readmapfile(FILE *file)
+uidmap_readmapfile(mapping_t *map, FILE *file)
{
char* sts;
char scratch[128];
@@ -216,46 +214,40 @@ uidmap_readmapfile(FILE *file)
int num = sscanf(&scratch[CFS_UID_MAP_ENTRY_LEN+1],
" %u %u", &client_uid, &server_uid);
if (num == 2) {
- if (uidmap_adduidentry(server_uid, client_uid) == -1) {
+ if (uidmap_adduidentry(map, server_uid, client_uid) == -1) {
return -1;
}
}
} else if (strncmp(scratch, CFS_UID_LOW, CFS_UID_LOW_LEN) == 0) {
- uidmap_mapping.im_uid_low =
- (uid_t) strtoul(&scratch[CFS_UID_LOW_LEN+1], NULL, 10);
+ map->uid_low = (uid_t) strtoul(&scratch[CFS_UID_LOW_LEN+1], NULL, 10);
} else if (strncmp(scratch, CFS_UID_HIGH, CFS_UID_HIGH_LEN) == 0) {
- uidmap_mapping.im_uid_high =
- (uid_t) strtoul(&scratch[CFS_UID_HIGH_LEN+1], NULL, 10);
+ map->uid_high = (uid_t) strtoul(&scratch[CFS_UID_HIGH_LEN+1], NULL, 10);
} else if (strncmp(scratch, CFS_UID_NEXT, CFS_UID_NEXT_LEN) == 0) {
- uidmap_mapping.im_uid_next =
- (uid_t) strtoul(&scratch[CFS_UID_NEXT_LEN+1], NULL, 10);
+ map->uid_next = (uid_t) strtoul(&scratch[CFS_UID_NEXT_LEN+1], NULL, 10);
} else if (strncmp(scratch, CFS_GID_MAP_ENTRY, CFS_GID_MAP_ENTRY_LEN) == 0) {
gid_t server_gid;
gid_t client_gid;
int num = sscanf(&scratch[CFS_GID_MAP_ENTRY_LEN+1],
" %u %u", &client_gid, &server_gid);
if (num == 2) {
- if (uidmap_addgidentry(server_gid, client_gid) == -1) {
+ if (uidmap_addgidentry(map, server_gid, client_gid) == -1) {
return -1;
}
}
} else if (strncmp(scratch, CFS_GID_LOW, CFS_GID_LOW_LEN) == 0) {
- uidmap_mapping.im_gid_low =
- (uid_t) strtoul(&scratch[CFS_GID_LOW_LEN+1], NULL, 10);
+ map->gid_low = (uid_t) strtoul(&scratch[CFS_GID_LOW_LEN+1], NULL, 10);
} else if (strncmp(scratch, CFS_GID_HIGH, CFS_GID_HIGH_LEN) == 0) {
- uidmap_mapping.im_gid_high =
- (uid_t) strtoul(&scratch[CFS_GID_HIGH_LEN+1], NULL, 10);
+ map->gid_high = (uid_t) strtoul(&scratch[CFS_GID_HIGH_LEN+1], NULL, 10);
} else if (strncmp(scratch, CFS_GID_NEXT, CFS_GID_NEXT_LEN) == 0) {
- uidmap_mapping.im_gid_next =
- (uid_t) strtoul(&scratch[CFS_GID_NEXT_LEN+1], NULL, 10);
+ map->gid_next = (uid_t) strtoul(&scratch[CFS_GID_NEXT_LEN+1], NULL, 10);
}
}
- return 0;
+ return 0;
}
static int
-uidmap_deserialize_default(char *tenant)
+uidmap_deserialize_default(char *tenant, uid_t uid_low, uid_t uid_high, gid_t gid_low, gid_t gid_high, short root_squash)
{
char fname[128], lkname[128];
FILE* file = NULL;
@@ -266,38 +258,61 @@ uidmap_deserialize_default(char *tenant)
do {
char scratch[128];
+ mapping_t *map;
char* sts;
int status;
+
+ uidmap_mappings = REALLOC(uidmap_mappings,
+ sizeof(mapping_t) * uidmap_num_mappings);
+ if (uidmap_mappings == NULL) {
+ break;
+ }
+ map = &uidmap_mappings[uidmap_num_mappings];
+ map->name = strdup(tenant);
+ map->uid_map = NULL,
+ map->uid_map_len = 0,
+ map->uid_low = uid_low,
+ map->uid_high = uid_high,
+ map->uid_next = uid_low,
+ map->gid_map = NULL,
+ map->gid_map_len = 0,
+ map->gid_low = gid_low,
+ map->gid_high = gid_high,
+ map->gid_next = gid_low,
+ map->root_squash = root_squash,
+ (void) pthread_mutex_init(&map->mtx, NULL);
+ uidmap_num_mappings++;
+
lockfd = open(lkname, O_CREAT|O_RDONLY, 0644);
if (lockfd == -1) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"open %s: %s", lkname, strerror(errno));
break;
}
status = flock(lockfd, LOCK_EX);
if (status == -1) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"flock: %s", strerror(errno));
break;
}
file = fopen(fname, "r");
if (file == NULL) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_INFO,
"fopen failed: %s", strerror(errno));
break;
}
/* read the first line (signature) of the file) */
if ((sts = fgets(scratch, sizeof scratch, file)) == (char *) EOF || sts == NULL) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"fgets signature failed: %s", strerror(errno));
break;
}
if (strcmp(CFS_SIGNATURE, scratch) != 0) {
- gf_log("deserialize", GF_LOG_CRITICAL,
+ gf_log(tenant, GF_LOG_CRITICAL,
"signature mismatch: %s", scratch);
break;
}
- ret = uidmap_readmapfile(file);
+ ret = uidmap_readmapfile(map, file);
} while (0);
if (file != NULL) {
(void) fclose(file);
@@ -311,106 +326,126 @@ uidmap_deserialize_default(char *tenant)
static int
-uidmap_map_default(struct _call_stack_t *stack, struct _xlator *xlator)
+uidmap_map_default(struct _call_stack_t *stack, char *name)
{
- char *tenant = uidmap_tenant ? uidmap_tenant : "unknown";
+ mapping_t *map = uidmap_mappings;
int do_persist = 0;
- if (stack->uid == 0 && uidmap_root_squash) {
+ unsigned short i = 0;
+ /* assert(uid_num_mappings > 0) */
+ for (; i < uidmap_num_mappings; i++, map++) {
+ if (strcmp(map->name, name) == 0) {
+ break;
+ }
+ }
+ if (stack->uid == 0 && map->root_squash) {
stack->uid = stack->gid = CLOUDFS_NOBODY;
return 0;
}
- pthread_mutex_lock(&uidmap_mapping.im_mtx);
+ pthread_mutex_lock(&map->mtx);
do {
unsigned short index = 0;
if (stack->uid != 0) {
/* look for an existing match */
uid_map_entry_t *uid_map_entry = NULL;
- for (; index < uidmap_mapping.im_uid_map_len; index++) {
- if (uidmap_mapping.im_uid_map[index].me_client_uid == stack->uid) {
- uid_map_entry = &uidmap_mapping.im_uid_map[index];
+ for (; index < map->uid_map_len; index++) {
+ if (map->uid_map[index].me_client_uid == stack->uid) {
+ uid_map_entry = &map->uid_map[index];
break;
}
}
if (uid_map_entry == NULL) {
/* couldn't find one, make a new one */
- if (uidmap_mapping.im_uid_next > uidmap_mapping.im_uid_high) {
- gf_log("map uid", GF_LOG_CRITICAL,
- "exhausted uids in range %u-%u",
- uidmap_mapping.im_uid_low,
- uidmap_mapping.im_uid_high);
- pthread_mutex_unlock(&uidmap_mapping.im_mtx);
+ if (map->uid_next > map->uid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "no uids in range %u-%u",
+ map->uid_low, map->uid_high);
+ pthread_mutex_unlock(&map->mtx);
return -1;
}
- uid_map_entry_t *tmpmap = REALLOC(uidmap_mapping.im_uid_map, sizeof(uid_map_entry_t) * (uidmap_mapping.im_uid_map_len + 1));
+ uid_map_entry_t *tmpmap =
+ REALLOC(map->uid_map, sizeof(uid_map_entry_t) * (map->uid_map_len + 1));
if (tmpmap == NULL) {
- pthread_mutex_unlock(&uidmap_mapping.im_mtx);
+ pthread_mutex_unlock(&map->mtx);
return -1;
}
do_persist = 1;
- uidmap_mapping.im_uid_map = tmpmap;
- uid_map_entry = &uidmap_mapping.im_uid_map[uidmap_mapping.im_uid_map_len++];
+ map->uid_map = tmpmap;
+ uid_map_entry = &map->uid_map[map->uid_map_len++];
uid_map_entry->me_client_uid = stack->uid;
- uid_map_entry->me_server_uid = uidmap_mapping.im_uid_next++;
- gf_log("map uid", GF_LOG_TRACE,
- "added new uid mapping for %s %u -> %u",
- tenant, stack->uid, uid_map_entry->me_server_uid);
+ uid_map_entry->me_server_uid = map->uid_next++;
+ gf_log(name, CFS_LOG_LEVEL,
+ "added new uid mapping %u -> %u",
+ stack->uid, uid_map_entry->me_server_uid);
+ if (map->uid_next > map->uid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "exhausted uids in range %u-%u",
+ map->uid_low, map->uid_high);
+ }
}
stack->uid = uid_map_entry->me_server_uid;
}
if (stack->gid != 0) {
gid_map_entry_t *gid_map_entry = NULL;
- for (index = 0; index < uidmap_mapping.im_gid_map_len; index++) {
- if (uidmap_mapping.im_gid_map[index].me_client_gid == stack->gid) {
- gid_map_entry = &uidmap_mapping.im_gid_map[index];
+ for (index = 0; index < map->gid_map_len; index++) {
+ if (map->gid_map[index].me_client_gid == stack->gid) {
+ gid_map_entry = &map->gid_map[index];
break;
}
}
if (gid_map_entry == NULL) {
/* couldn't find one, make a new one */
- if (uidmap_mapping.im_gid_next > uidmap_mapping.im_gid_high) {
- gf_log("map uid", GF_LOG_CRITICAL,
- "exhausted gids in range %u-%u",
- uidmap_mapping.im_gid_low,
- uidmap_mapping.im_gid_high);
- pthread_mutex_unlock(&uidmap_mapping.im_mtx);
+ if (map->gid_next > map->gid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
+ "no gids in range %u-%u",
+ map->gid_low, map->gid_high);
+ pthread_mutex_unlock(&map->mtx);
return -1;
}
- gid_map_entry_t *tmpmap = REALLOC(uidmap_mapping.im_gid_map, sizeof(gid_map_entry_t) * (uidmap_mapping.im_gid_map_len + 1));
+ gid_map_entry_t *tmpmap =
+ REALLOC(map->gid_map, sizeof(gid_map_entry_t) * (map->gid_map_len + 1));
if (tmpmap == NULL) {
- pthread_mutex_unlock(&uidmap_mapping.im_mtx);
+ pthread_mutex_unlock(&map->mtx);
return -1;
}
do_persist = 1;
- uidmap_mapping.im_gid_map = tmpmap;
- gid_map_entry = &uidmap_mapping.im_gid_map[uidmap_mapping.im_gid_map_len++];
+ map->gid_map = tmpmap;
+ gid_map_entry = &map->gid_map[map->gid_map_len++];
gid_map_entry->me_client_gid = stack->gid;
- gid_map_entry->me_server_gid = uidmap_mapping.im_gid_next++;
- gf_log("map gid", GF_LOG_TRACE,
- "added new gid mapping for %s %u -> %u",
- tenant, stack->gid, gid_map_entry->me_server_gid);
- if (uidmap_mapping.im_gid_next > uidmap_mapping.im_gid_high) {
- gf_log("map gid", GF_LOG_CRITICAL,
+ gid_map_entry->me_server_gid = map->gid_next++;
+ gf_log(name, CFS_LOG_LEVEL,
+ "added new gid mapping %u -> %u",
+ stack->gid, gid_map_entry->me_server_gid);
+ if (map->gid_next > map->gid_high) {
+ gf_log(name, GF_LOG_CRITICAL,
"exhausted gids in range %u-%u",
- uidmap_mapping.im_gid_low,
- uidmap_mapping.im_gid_high);
+ map->gid_low, map->gid_high);
}
}
stack->gid = gid_map_entry->me_server_gid;
}
} while (0);
if (do_persist > 0)
- uidmap_serialize_default(tenant);
- pthread_mutex_unlock(&uidmap_mapping.im_mtx);
+ uidmap_serialize_default(name, map);
+ pthread_mutex_unlock(&map->mtx);
return 0;
}
static void
-uidmap_revmap_default(uid_t *uid, gid_t *gid)
+uidmap_revmap_default(uid_t *uid, gid_t *gid, char *name)
{
- unsigned int index = 0;
uid_map_entry_t *uid_map_entry;
gid_map_entry_t *gid_map_entry;
+ mapping_t *map = uidmap_mappings;
+ unsigned int index = 0;
+ unsigned short i = 0;
+
+ /* assert(uid_num_mappings > 0) */
+ for (; i < uidmap_num_mappings; i++, map++) {
+ if (strcmp(map->name, name) == 0) {
+ break;
+ }
+ }
switch (*uid) {
case 0:
@@ -419,8 +454,8 @@ uidmap_revmap_default(uid_t *uid, gid_t *gid)
*uid = 0;
break;
default:
- uid_map_entry = uidmap_mapping.im_uid_map;
- for (; index < uidmap_mapping.im_uid_map_len; index++, uid_map_entry++) {
+ uid_map_entry = map->uid_map;
+ for (; index < map->uid_map_len; index++, uid_map_entry++) {
if (*uid == uid_map_entry->me_server_uid)
*uid = uid_map_entry->me_client_uid;
}
@@ -433,8 +468,8 @@ uidmap_revmap_default(uid_t *uid, gid_t *gid)
*uid = 0;
break;
default:
- gid_map_entry = uidmap_mapping.im_gid_map;
- for (index = 0; index < uidmap_mapping.im_gid_map_len; index++, gid_map_entry++) {
+ gid_map_entry = map->gid_map;
+ for (index = 0; index < map->gid_map_len; index++, gid_map_entry++) {
if (*gid == gid_map_entry->me_server_gid)
*gid = gid_map_entry->me_client_gid;
}
@@ -458,10 +493,10 @@ uidmap_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf,
preparent, postparent);
@@ -491,8 +526,8 @@ uidmap_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(stat, frame, op_ret, op_errno, buf);
return 0;
@@ -508,8 +543,8 @@ uidmap_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count,
buf, iobref);
@@ -526,9 +561,9 @@ uidmap_writev_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf);
return 0;
@@ -546,11 +581,11 @@ uidmap_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64" :(op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid);
+ (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid, this->name);
list_for_each_entry(entry, &buf->list, list) {
- (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid);
+ (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid, this->name);
}
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(readdir, frame, op_ret, op_errno, buf);
@@ -568,11 +603,11 @@ uidmap_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64" :(op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid);
+ (*uidmap_revmap)(&buf->d_stat.ia_uid, &buf->d_stat.ia_gid, this->name);
list_for_each_entry(entry, &buf->list, list) {
- (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid);
+ (*uidmap_revmap)(&entry->d_stat.ia_uid, &entry->d_stat.ia_gid, this->name);
}
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, buf);
@@ -589,9 +624,9 @@ uidmap_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(fsync, frame, op_ret, op_errno, prebuf, postbuf);
@@ -608,9 +643,9 @@ uidmap_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid);
- (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid, this->name);
+ (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(setattr, frame, op_ret, op_errno, statpre, statpost);
return 0;
@@ -626,9 +661,9 @@ uidmap_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid);
- (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&statpre->ia_uid, &statpre->ia_gid, this->name);
+ (*uidmap_revmap)(&statpost->ia_uid, &statpost->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(fsetattr, frame, op_ret, op_errno,
statpre, statpost);
@@ -645,9 +680,9 @@ uidmap_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno,
preparent, postparent);
@@ -665,12 +700,12 @@ uidmap_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&preoldparent->ia_uid, &preoldparent->ia_gid);
- (*uidmap_revmap)(&postoldparent->ia_uid, &postoldparent->ia_gid);
- (*uidmap_revmap)(&prenewparent->ia_uid, &prenewparent->ia_gid);
- (*uidmap_revmap)(&postnewparent->ia_uid, &postnewparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preoldparent->ia_uid, &preoldparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postoldparent->ia_uid, &postoldparent->ia_gid, this->name);
+ (*uidmap_revmap)(&prenewparent->ia_uid, &prenewparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postnewparent->ia_uid, &postnewparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(rename, frame, op_ret, op_errno, buf,
preoldparent, postoldparent,
@@ -688,8 +723,8 @@ uidmap_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&stbuf->ia_uid, &stbuf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&stbuf->ia_uid, &stbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(readlink, frame, op_ret, op_errno, buf, stbuf);
return 0;
@@ -706,9 +741,9 @@ uidmap_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf,
xattr, postparent);
@@ -726,10 +761,10 @@ uidmap_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(symlink, frame, op_ret, op_errno, inode, buf,
preparent, postparent);
@@ -747,10 +782,10 @@ uidmap_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(mknod, frame, op_ret, op_errno, inode, buf,
preparent, postparent);
@@ -768,10 +803,10 @@ uidmap_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(mkdir, frame, op_ret, op_errno, inode, buf,
preparent, postparent);
@@ -789,10 +824,10 @@ uidmap_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, buf,
preparent, postparent);
@@ -835,9 +870,9 @@ uidmap_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid);
- (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&preparent->ia_uid, &preparent->ia_gid, this->name);
+ (*uidmap_revmap)(&postparent->ia_uid, &postparent->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(rmdir, frame, op_ret, op_errno,
preparent, postparent);
@@ -854,9 +889,9 @@ uidmap_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf);
return 0;
@@ -952,9 +987,9 @@ uidmap_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid);
- (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&prebuf->ia_uid, &prebuf->ia_gid, this->name);
+ (*uidmap_revmap)(&postbuf->ia_uid, &postbuf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf);
return 0;
@@ -969,8 +1004,8 @@ uidmap_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid);
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&buf->ia_uid, &buf->ia_gid, this->name);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(fstat, frame, op_ret, op_errno, buf);
return 0;
@@ -987,9 +1022,9 @@ uidmap_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
"%"PRId64": (op_ret=%d, op_errno=%d)",
frame->root->unique, op_ret, op_errno);
- (*uidmap_revmap)(&uid, &gid);
+ (*uidmap_revmap)(&uid, &gid, this->name);
lock->l_owner = uid;
- (*uidmap_revmap)(&frame->root->uid, &frame->root->gid);
+ (*uidmap_revmap)(&frame->root->uid, &frame->root->gid, this->name);
STACK_UNWIND_STRICT(lk, frame, op_ret, op_errno, lock);
return 0;
@@ -1086,7 +1121,7 @@ uidmap_entrylk(call_frame_t *frame, xlator_t *this,
((cmd == ENTRYLK_LOCK) ? "ENTRYLK_LOCK" : "ENTRYLK_UNLOCK"),
((type == ENTRYLK_RDLCK) ? "ENTRYLK_RDLCK" : "ENTRYLK_WRLCK"));
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_entrylk_cbk,
@@ -1108,7 +1143,7 @@ uidmap_fentrylk(call_frame_t *frame, xlator_t *this,
((cmd == ENTRYLK_LOCK) ? "ENTRYLK_LOCK" : "ENTRYLK_UNLOCK"),
((type == ENTRYLK_RDLCK) ? "ENTRYLK_RDLCK" : "ENTRYLK_WRLCK"));
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_fentrylk_cbk,
@@ -1123,7 +1158,7 @@ int
uidmap_inodelk(call_frame_t *frame, xlator_t *this, const char *volume,
loc_t *loc, int32_t cmd, struct gf_flock *flock)
{
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_inodelk_cbk,
@@ -1142,7 +1177,7 @@ uidmap_finodelk(call_frame_t *frame, xlator_t *this, const char *volume,
"%"PRId64": (volume=%s, fd=%p, cmd=%d)",
frame->root->unique, volume, fd, cmd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_finodelk_cbk,
@@ -1161,7 +1196,7 @@ uidmap_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc,
"%"PRId64": (path=%s, ino=%"PRIu64" flags=%d)",
frame->root->unique, loc->path, loc->inode->ino, flags);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_xattrop_cbk,
@@ -1181,7 +1216,7 @@ uidmap_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd,
"%"PRId64": (fd=%p, flags=%d)",
frame->root->unique, fd, flags);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_fxattrop_cbk,
@@ -1203,7 +1238,7 @@ uidmap_lookup(call_frame_t *frame, xlator_t *this,
frame->root->unique, loc->path,
loc->inode->ino);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_lookup_cbk,
@@ -1222,7 +1257,7 @@ uidmap_stat(call_frame_t *frame, xlator_t *this, loc_t *loc)
"%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
frame->root->unique, loc->path, loc->inode->ino);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_stat_cbk,
@@ -1241,7 +1276,7 @@ uidmap_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size)
"%"PRId64": (loc {path=%s, ino=%"PRIu64"}, size=%"GF_PRI_SIZET")",
frame->root->unique, loc->path, loc->inode->ino, size);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_readlink_cbk,
@@ -1261,7 +1296,7 @@ uidmap_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc,
"%"PRId64": (loc {path=%s, ino=%"PRIu64"}, mode=%d, dev=%"GF_PRI_DEV")",
frame->root->unique, loc->path, loc->inode->ino, mode, dev);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_mknod_cbk,
@@ -1282,7 +1317,7 @@ uidmap_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
frame->root->unique, loc->path,
((loc->inode)? loc->inode->ino : 0), mode);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_mkdir_cbk,
@@ -1300,7 +1335,7 @@ uidmap_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc)
"%"PRId64": (loc {path=%s, ino=%"PRIu64"})",
frame->root->unique, loc->path, loc->inode->ino);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_unlink_cbk,
@@ -1318,7 +1353,7 @@ uidmap_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags)
"%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=%d)",
frame->root->unique, loc->path, loc->inode->ino, flags);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_rmdir_cbk,
@@ -1339,7 +1374,7 @@ uidmap_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath,
frame->root->unique, linkpath, loc->path,
((loc->inode)? loc->inode->ino : 0));
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_symlink_cbk,
@@ -1360,7 +1395,7 @@ uidmap_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
frame->root->unique, oldloc->path, oldloc->ino,
newloc->path, newloc->ino);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_rename_cbk,
@@ -1381,7 +1416,7 @@ uidmap_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
frame->root->unique, oldloc->path, oldloc->inode->ino,
newloc->path, newloc->inode->ino);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_link_cbk,
@@ -1400,7 +1435,7 @@ uidmap_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
"%"PRId64": loc {path=%s, ino=%"PRIu64"}, valid=%d",
frame->root->unique, loc->path, loc->inode->ino, valid);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_setattr_cbk,
@@ -1420,7 +1455,7 @@ uidmap_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
"%"PRId64": (fd=%p, valid=%d)",
frame->root->unique, fd, valid);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_fsetattr_cbk,
@@ -1440,7 +1475,7 @@ uidmap_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc,
"%"PRId64": (loc {path=%s, ino=%"PRIu64"}, offset=%"PRId64")",
frame->root->unique, loc->path, loc->inode->ino, offset);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_truncate_cbk,
@@ -1462,7 +1497,7 @@ uidmap_open(call_frame_t *frame, xlator_t *this, loc_t *loc,
frame->root->unique, loc->path, loc->inode->ino, flags,
fd, wbflags);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_open_cbk,
@@ -1481,7 +1516,7 @@ uidmap_create(call_frame_t *frame, xlator_t *this, loc_t *loc,
"%"PRId64": (loc {path=%s, ino=%"PRIu64"}, flags=0%o mode=0%o)",
frame->root->unique, loc->path, loc->inode->ino, flags, mode);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_create_cbk,
@@ -1500,7 +1535,7 @@ uidmap_readv(call_frame_t *frame, xlator_t *this, fd_t *fd,
"%"PRId64": (*fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
frame->root->unique, fd, size, offset);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_readv_cbk,
@@ -1520,7 +1555,7 @@ uidmap_writev(call_frame_t *frame, xlator_t *this, fd_t *fd,
"%"PRId64": (*fd=%p, *vector=%p, count=%d, offset=%"PRId64")",
frame->root->unique, fd, vector, count, offset);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_writev_cbk,
@@ -1539,7 +1574,7 @@ uidmap_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc)
frame->root->unique, loc->path,
((loc->inode)? loc->inode->ino : 0));
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_statfs_cbk,
@@ -1556,7 +1591,7 @@ uidmap_flush(call_frame_t *frame, xlator_t *this, fd_t *fd)
gf_log(this->name, CFS_LOG_LEVEL,
"%"PRId64": (*fd=%p)", frame->root->unique, fd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_flush_cbk,
@@ -1573,7 +1608,7 @@ uidmap_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
gf_log(this->name, CFS_LOG_LEVEL,
"%"PRId64": (flags=%d, *fd=%p)", frame->root->unique, flags, fd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_fsync_cbk,
@@ -1593,7 +1628,7 @@ uidmap_setxattr(call_frame_t *frame, xlator_t *this,
frame->root->unique, loc->path,
((loc->inode)? loc->inode->ino : 0), dict, flags);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_setxattr_cbk,
@@ -1613,7 +1648,7 @@ uidmap_getxattr(call_frame_t *frame, xlator_t *this,
frame->root->unique, loc->path,
((loc->inode)? loc->inode->ino : 0), name);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_getxattr_cbk,
@@ -1633,7 +1668,7 @@ uidmap_removexattr(call_frame_t *frame, xlator_t *this,
frame->root->unique, loc->path,
((loc->inode)? loc->inode->ino : 0), name);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_removexattr_cbk,
@@ -1652,7 +1687,7 @@ uidmap_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd)
"%"PRId64":( loc {path=%s, ino=%"PRIu64"}, fd=%p)",
frame->root->unique, loc->path, loc->inode->ino, fd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_opendir_cbk,
@@ -1670,7 +1705,7 @@ uidmap_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
"%"PRId64": (fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
frame->root->unique, fd, size, offset);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_readdirp_cbk,
@@ -1690,7 +1725,7 @@ uidmap_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd,
"%"PRId64": (fd=%p, size=%"GF_PRI_SIZET", offset=%"PRId64")",
frame->root->unique, fd, size, offset);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_readdir_cbk,
@@ -1710,7 +1745,7 @@ uidmap_fsyncdir(call_frame_t *frame, xlator_t *this,
"%"PRId64": (datasync=%d, *fd=%p)",
frame->root->unique, datasync, fd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_fsyncdir_cbk,
@@ -1729,7 +1764,7 @@ uidmap_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
frame->root->unique, loc->path,
((loc->inode)? loc->inode->ino : 0), mask);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_access_cbk,
@@ -1748,7 +1783,7 @@ uidmap_ftruncate(call_frame_t *frame, xlator_t *this,
"%"PRId64": (offset=%"PRId64", *fd=%p)",
frame->root->unique, offset, fd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_ftruncate_cbk,
@@ -1766,7 +1801,7 @@ uidmap_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd)
gf_log(this->name, CFS_LOG_LEVEL,
"%"PRId64": (*fd=%p)", frame->root->unique, fd);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_fstat_cbk,
@@ -1787,7 +1822,7 @@ uidmap_lk(call_frame_t *frame, xlator_t *this, fd_t *fd,
frame->root->unique, fd, cmd, lock->l_type, lock->l_whence,
lock->l_start, lock->l_len, lock->l_pid);
- if ((*uidmap_map)(frame->root, this) == -1)
+ if ((*uidmap_map)(frame->root, this->name) == -1)
return -1;
STACK_WIND(frame, uidmap_lk_cbk,
@@ -1831,32 +1866,29 @@ uidmap_loadsharedlib(char* xltrname, char *libname)
} while (0);
if (dlclose(handle)) {
- gf_log(xltrname, GF_LOG_ERROR,
+ gf_log(xltrname, CFS_LOG_LEVEL,
"dlclose plugin: %s", dlerror());
}
}
- return plugin_init;
+ return plugin_init;
}
int32_t
init(xlator_t *this)
{
char *uid_range = NULL, *gid_range = NULL;
- char *root_squash = NULL;
- char *plugin = NULL;
- char *tenant = NULL;
- init_fn plugin_init = NULL;
- uid_t uidmap_low_uid = CFS_UID_LOW_DEFAULT;
- uid_t uidmap_hi_uid = CFS_UID_HIGH_DEFAULT;
- gid_t uidmap_low_gid = CFS_UID_LOW_DEFAULT;
- gid_t uidmap_hi_gid = CFS_UID_HIGH_DEFAULT;
+ char *plugin = NULL;
+ init_fn plugin_init = NULL;
+ uid_t low_uid = CFS_UID_LOW_DEFAULT;
+ uid_t high_uid = CFS_UID_HIGH_DEFAULT;
+ gid_t low_gid = CFS_UID_LOW_DEFAULT;
+ gid_t high_gid = CFS_UID_HIGH_DEFAULT;
+ short root_squash = 0;
data_t *data;
if (!this)
return -1;
- /* gf_log_set_loglevel(GF_LOG_NORMAL); */
-
if (!this->children || this->children->next) {
gf_log(this->name, GF_LOG_ERROR,
"uidmap translator requires one subvolume");
@@ -1870,12 +1902,10 @@ init(xlator_t *this)
if ((data = dict_get(this->options, "uid-range")) != NULL) {
uid_range = data_to_str(data);
if (uid_range != NULL && *uid_range != 0) {
- uid_t low, hi;
- if (sscanf(uid_range, "%u-%u", &low, &hi) == 2) {
- uidmap_low_uid = low; uidmap_hi_uid = hi;
- uidmap_mapping.im_uid_low =
- uidmap_mapping.im_uid_next = low;
- uidmap_mapping.im_uid_high = hi;
+ if (sscanf(uid_range, "%u-%u", &low_uid, &high_uid) == 2) {
+ /* uidmap_mapping.uid_low =
+ uidmap_mapping.uid_next = low;
+ uidmap_mapping.uid_high = hi; */
} else {
gf_log(this->name, GF_LOG_ERROR,
"invalid uid-range in config");
@@ -1890,12 +1920,10 @@ init(xlator_t *this)
if ((data = dict_get(this->options, "gid-range")) != NULL) {
gid_range = data_to_str(data);
if (gid_range != NULL && *gid_range != 0) {
- gid_t low, hi;
- if (sscanf(gid_range, "%u-%u", &low, &hi) == 2) {
- uidmap_low_gid = low; uidmap_hi_gid = hi;
- uidmap_mapping.im_gid_low =
- uidmap_mapping.im_gid_next = low;
- uidmap_mapping.im_gid_high = hi;
+ if (sscanf(gid_range, "%u-%u", &low_gid, &high_gid) == 2) {
+ /* uidmap_mapping.gid_low =
+ uidmap_mapping.gid_next = low;
+ uidmap_mapping.gid_high = hi; */
} else {
gf_log(this->name, GF_LOG_ERROR,
"invalid gid-range in config");
@@ -1908,35 +1936,23 @@ init(xlator_t *this)
}
if ((data = dict_get(this->options, "root-squash")) != NULL) {
- root_squash = data_to_str(data);
- if (root_squash != NULL && *root_squash != 0) {
- char* ptr = root_squash;
+ char *rt_sqsh = data_to_str(data);
+ if (rt_sqsh != NULL && *rt_sqsh != 0) {
+ char* ptr = rt_sqsh;
for (; *ptr != 0; ptr++)
*ptr = tolower(*ptr);
- if (strcmp(root_squash, "yes") == 0)
- uidmap_root_squash = 1;
+ if (strcmp(rt_sqsh, "yes") == 0)
+ root_squash = 1;
}
}
- if ((data = dict_get(this->options, "tenant")) != NULL) {
- tenant = data_to_str(data);
- if (tenant != NULL) {
- uidmap_tenant = strdup(tenant);
- }
- } else {
- gf_log(this->name, GF_LOG_ERROR,
- "you must specify a tenant name in the config");
- return -1;
- }
-
if ((data = dict_get(this->options, "uidmap-plugin")) != NULL) {
plugin = data_to_str(data);
if (plugin != NULL && *plugin != 0) {
if ((plugin_init = uidmap_loadsharedlib(this->name, plugin)) != NULL) {
- if ((*plugin_init)(this, uidmap_tenant,
- uidmap_low_uid, uidmap_hi_uid,
- uidmap_low_gid, uidmap_hi_gid,
- uidmap_root_squash) != 0) {
+ if ((*plugin_init)(this, low_uid, high_uid,
+ low_gid, high_gid,
+ root_squash) != 0) {
gf_log(this->name, GF_LOG_CRITICAL,
"plugin init error");
}
@@ -1944,8 +1960,9 @@ init(xlator_t *this)
}
}
if (uidmap_map == NULL) {
- if (uidmap_deserialize_default(uidmap_tenant ? uidmap_tenant : "unknown") == -1)
+ if (uidmap_deserialize_default(this->name, low_uid, high_uid, low_gid, high_gid, root_squash) == -1)
return -1;
+ uidmap_serialize_default(this->name, uidmap_mappings);
uidmap_map = uidmap_map_default;
uidmap_revmap = uidmap_revmap_default;
}
@@ -2019,9 +2036,6 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_STR,
.value = { "yes", "no"}
},
- { .key = {"tenant"},
- .type = GF_OPTION_TYPE_STR
- },
{ .key = {"uid-range"},
.type = GF_OPTION_TYPE_STR,
},
diff --git a/xlators/features/uidmap/src/uidmap.h b/xlators/features/uidmap/src/uidmap.h
index 5de9322..d4d0dfb 100644
--- a/xlators/features/uidmap/src/uidmap.h
+++ b/xlators/features/uidmap/src/uidmap.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Red Hat, Inc.
+ * Copyright 2011 Red Hat, Inc.
*
* This file is part of CloudFS.
*
@@ -22,9 +22,9 @@
#include <sys/types.h>
-typedef int (* map_fn)(struct _call_stack_t *, struct _xlator *);
-typedef void (* revmap_fn)(uid_t *, gid_t *);
-typedef int32_t (* init_fn)(struct _xlator *, char *, uid_t, uid_t, gid_t, gid_t, int);
+typedef int (* map_fn)(struct _call_stack_t *, char *);
+typedef void (* revmap_fn)(uid_t *, gid_t *, char *);
+typedef int32_t (* init_fn)(struct _xlator *, uid_t, uid_t, gid_t, gid_t, int);
typedef void (* fini_fn)(struct _xlator *);
#define UIDMAP_MAP_LOCK_FILE "/var/lib/cloudfs/map_%s.lck"
12 years, 6 months