]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Revert "s3/vfs_glusterfs_fuse: Dynamically determine NAME_MAX"
authorGünther Deschner <gd@samba.org>
Mon, 3 Jun 2019 12:27:44 +0000 (14:27 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 21 Jun 2019 07:56:16 +0000 (07:56 +0000)
This reverts commit e28d172b00cadf492c22bd892e2dda3bf2fe2d70.

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/modules/vfs_glusterfs_fuse.c

index 0b1de9fcdb22c65165ba580df8caaf5dd54e1473..8855cd18d0192b3cef43fcf5f2775cf638c38bd9 100644 (file)
@@ -28,35 +28,19 @@ static int vfs_gluster_fuse_get_real_filename(struct vfs_handle_struct *handle,
                                              char **_found_name)
 {
        int ret;
-       char *key_buf = NULL, *val_buf = NULL;
-       long name_max;
+       char key_buf[NAME_MAX + 64];
+       char val_buf[NAME_MAX + 1];
        char *found_name = NULL;
 
-       name_max = pathconf(path, _PC_NAME_MAX);
-       if ((name_max + 1) < 1) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       if (strlen(name) >= name_max) {
+       if (strlen(name) >= NAME_MAX) {
                errno = ENAMETOOLONG;
                return -1;
        }
 
-       key_buf = talloc_asprintf(mem_ctx, "glusterfs.get_real_filename:%s",
-                                 name);
-       if (key_buf == NULL) {
-               errno = ENOMEM;
-               return -1;
-       }
-
-       val_buf = talloc_zero_array(mem_ctx, char, name_max + 1);
-       if (val_buf == NULL) {
-               errno = ENOMEM;
-               return -1;
-       }
+       snprintf(key_buf, NAME_MAX + 64,
+                "glusterfs.get_real_filename:%s", name);
 
-       ret = getxattr(path, key_buf, val_buf, name_max + 1);
+       ret = getxattr(path, key_buf, val_buf, NAME_MAX + 1);
        if (ret == -1) {
                if (errno == ENOATTR) {
                        errno = EOPNOTSUPP;
@@ -70,10 +54,6 @@ static int vfs_gluster_fuse_get_real_filename(struct vfs_handle_struct *handle,
                return -1;
        }
        *_found_name = found_name;
-
-       TALLOC_FREE(key_buf);
-       TALLOC_FREE(val_buf);
-
        return 0;
 }