All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] chunkd: Don't hardcode the prefix length of object pathname
@ 2010-01-11 12:25 Akinobu Mita
  2010-01-11 12:25 ` [PATCH 2/6] chunkd: change the prefix length of object pathname from 4 to 3 Akinobu Mita
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Akinobu Mita @ 2010-01-11 12:25 UTC (permalink / raw)
  To: hail-devel; +Cc: Akinobu Mita

Define PREFIX_LEN instead of hardcoded prefix length of object pathname
in fs_obj_pathname()

This makes easier to change the prefix length.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 server/be-fs.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/server/be-fs.c b/server/be-fs.c
index 8f72da5..aa8f008 100644
--- a/server/be-fs.c
+++ b/server/be-fs.c
@@ -204,10 +204,12 @@ static struct fs_obj *fs_obj_alloc(void)
 	return obj;
 }
 
+#define PREFIX_LEN 4
+
 static char *fs_obj_pathname(uint32_t table_id,const void *key, size_t key_len)
 {
 	char *s = NULL;
-	char prefix[5] = "";
+	char prefix[PREFIX_LEN + 1] = "";
 	struct stat st;
 	size_t slen;
 	unsigned char md[SHA256_DIGEST_LENGTH];
@@ -219,7 +221,7 @@ static char *fs_obj_pathname(uint32_t table_id,const void *key, size_t key_len)
 	SHA256(key, key_len, md);
 	hexstr(md, SHA256_DIGEST_LENGTH, mdstr);
 
-	memcpy(prefix, mdstr, 4);
+	memcpy(prefix, mdstr, PREFIX_LEN);
 
 	slen = strlen(chunkd_srv.vol_path) + 1 +	/* volume */
 	       16 +					/* table id */
@@ -253,7 +255,7 @@ static char *fs_obj_pathname(uint32_t table_id,const void *key, size_t key_len)
 	}
 
 	sprintf(s, MDB_TPATH_FMT "/%s/%s", chunkd_srv.vol_path, table_id,
-		prefix, mdstr + 4);
+		prefix, mdstr + PREFIX_LEN);
 
 	return s;
 
@@ -725,7 +727,7 @@ again:
 
 		if (de->d_name[0] == '.')
 			goto again;
-		if (strlen(de->d_name) != 4)
+		if (strlen(de->d_name) != PREFIX_LEN)
 			goto again;
 
 		if (asprintf(&t->sub, "%s/%s", t->table_path, de->d_name) < 0)
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-01-13 10:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-11 12:25 [PATCH 1/6] chunkd: Don't hardcode the prefix length of object pathname Akinobu Mita
2010-01-11 12:25 ` [PATCH 2/6] chunkd: change the prefix length of object pathname from 4 to 3 Akinobu Mita
2010-01-12  2:55   ` Jeff Garzik
2010-01-12  8:28     ` Akinobu Mita
2010-01-12 11:27       ` Jeff Garzik
2010-01-13  3:50         ` Akinobu Mita
2010-01-13 10:52           ` Jeff Garzik
2010-01-11 12:25 ` [PATCH 3/6] chunkd: Don't return positive value on stc_get_recv failure Akinobu Mita
2010-01-11 12:25 ` [PATCH 4/6] chcli: Add -i option to read value from file Akinobu Mita
2010-01-11 12:25 ` [PATCH 5/6] chcli: fix error handling for write() Akinobu Mita
2010-01-11 12:25 ` [PATCH 6/6] chunkd: fix PUT/GET for more than 2GB values Akinobu Mita
2010-01-12 14:40   ` Jeff Garzik
2010-01-12 14:38 ` [PATCH 1/6] chunkd: Don't hardcode the prefix length of object pathname Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.