From 508075b079d731f7aa5fa36d7295fceeef2c3c1d Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Thu, 25 Feb 2010 15:37:48 +0000 Subject: core: New function: gf_dirent_for_namelen Given the length of a name that needs to be stored in d_name, the new function allocates enough space for a gf_dirent_t and returns a ref. Signed-off-by: Shehjar Tikoo Signed-off-by: Anand V. Avati BUG: 597 (miscellaneous fixes for xlators to work well with NFS xlator) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=597 --- libglusterfs/src/gf-dirent.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libglusterfs/src/gf-dirent.c') diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c index cd31464ff..0a3436949 100644 --- a/libglusterfs/src/gf-dirent.c +++ b/libglusterfs/src/gf-dirent.c @@ -49,6 +49,25 @@ gf_dirent_nb_size (gf_dirent_t *entries) return (sizeof (struct gf_dirent_nb) + strlen (entries->d_name) + 1); } +gf_dirent_t * +gf_dirent_for_namelen (int len) +{ + gf_dirent_t *gf_dirent = NULL; + + /* TODO: use mem-pool */ + gf_dirent = CALLOC (len, sizeof(char)); + if (!gf_dirent) + return NULL; + + INIT_LIST_HEAD (&gf_dirent->list); + + gf_dirent->d_off = 0; + gf_dirent->d_ino = -1; + gf_dirent->d_type = 0; + + return gf_dirent; +} + gf_dirent_t * gf_dirent_for_name (const char *name) -- cgit