#include <glusterfs/api/glfs.h>
#include "lib/util/dlinklist.h"
#include "lib/util/tevent_unix.h"
+#include "lib/util/util_file.h"
#include "smbd/globals.h"
#include "lib/util/sys_rw.h"
#include "smbprofile.h"
glfs_fini(entry->fs);
talloc_free(entry);
+ break;
}
}
}
/*
* file_lines_parse() plays horrible tricks with
- * the passed-in talloc pointers and the hierarcy
+ * the passed-in talloc pointers and the hierarchy
* which makes freeing hard to get right.
*
* As we know mem_ctx is freed by the caller, after
uint32_t attributes)
{
glfs_fd_t *glfd = NULL;
- struct smb_filename *full_fname = NULL;
- struct smb_filename *smb_fname_dot = NULL;
-
- smb_fname_dot = synthetic_smb_fname(fsp->fsp_name,
- ".",
- NULL,
- NULL,
- 0,
- 0);
-
- if (smb_fname_dot == NULL) {
- return NULL;
- }
- full_fname = full_path_from_dirfsp_atname(talloc_tos(),
- fsp,
- smb_fname_dot);
- if (full_fname == NULL) {
- TALLOC_FREE(smb_fname_dot);
- return NULL;
- }
-
- glfd = glfs_opendir(handle->data, full_fname->base_name);
+ glfd = glfs_opendir(handle->data, fsp->fsp_name->base_name);
if (glfd == NULL) {
- TALLOC_FREE(full_fname);
- TALLOC_FREE(smb_fname_dot);
return NULL;
}
- TALLOC_FREE(full_fname);
- TALLOC_FREE(smb_fname_dot);
-
return (DIR *)glfd;
}
static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
- DIR *dirp,
- SMB_STRUCT_STAT *sbuf)
+ DIR *dirp)
{
static char direntbuf[512];
int ret;
- struct stat stat;
struct dirent *dirent = 0;
START_PROFILE(syscall_readdir);
- if (sbuf != NULL) {
- ret = glfs_readdirplus_r((void *)dirp, &stat, (void *)direntbuf,
- &dirent);
- } else {
- ret = glfs_readdir_r((void *)dirp, (void *)direntbuf, &dirent);
- }
+
+ ret = glfs_readdir_r((void *)dirp, (void *)direntbuf, &dirent);
if ((ret < 0) || (dirent == NULL)) {
END_PROFILE(syscall_readdir);
return NULL;
}
- if (sbuf != NULL) {
- SET_STAT_INVALID(*sbuf);
- if (!S_ISLNK(stat.st_mode)) {
- smb_stat_ex_from_stat(sbuf, &stat);
- }
- }
-
END_PROFILE(syscall_readdir);
return dirent;
}
-static long vfs_gluster_telldir(struct vfs_handle_struct *handle, DIR *dirp)
-{
- long ret;
-
- START_PROFILE(syscall_telldir);
- ret = glfs_telldir((void *)dirp);
- END_PROFILE(syscall_telldir);
-
- return ret;
-}
-
-static void vfs_gluster_seekdir(struct vfs_handle_struct *handle, DIR *dirp,
- long offset)
-{
- START_PROFILE(syscall_seekdir);
- glfs_seekdir((void *)dirp, offset);
- END_PROFILE(syscall_seekdir);
-}
-
static void vfs_gluster_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
{
START_PROFILE(syscall_rewinddir);
struct smb_filename *full_fname = NULL;
bool have_opath = false;
bool became_root = false;
- glfs_fd_t *glfd;
+ glfs_fd_t *glfd = NULL;
glfs_fd_t *pglfd = NULL;
glfs_fd_t **p_tmp;
became_root = true;
}
- /*
- * O_CREAT flag in open is handled differently in a way which is *NOT*
- * safe against symlink race situations. We use glfs_creat() instead
- * for correctness as glfs_openat() is broken with O_CREAT present
- * in open flags.
- */
- if (flags & O_CREAT) {
- if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
- /*
- * Replace smb_fname with full_path constructed above.
- */
- smb_fname = full_fname;
+ if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+#ifdef HAVE_GFAPI_VER_7_11
+ /*
+ * Fetch Gluster fd for parent directory using dirfsp
+ * before calling glfs_openat();
+ */
+ pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+ if (pglfd == NULL) {
+ END_PROFILE(syscall_openat);
+ DBG_ERR("Failed to fetch gluster fd\n");
+ return -1;
}
+ glfd = glfs_openat(pglfd,
+ smb_fname->base_name,
+ flags,
+ how->mode);
+#else
+ /*
+ * Replace smb_fname with full_path constructed above.
+ */
+ smb_fname = full_fname;
+#endif
+ }
+
+ if (pglfd == NULL) {
/*
* smb_fname can either be a full_path or the same one
* as received from the caller. In the latter case we
* are operating at current working directory.
*/
- glfd = glfs_creat(handle->data,
- smb_fname->base_name,
- flags,
- how->mode);
- } else {
- if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
-#ifdef HAVE_GFAPI_VER_7_11
- /*
- * Fetch Gluster fd for parent directory using dirfsp
- * before calling glfs_openat();
- */
- pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
- if (pglfd == NULL) {
- END_PROFILE(syscall_openat);
- DBG_ERR("Failed to fetch gluster fd\n");
- return -1;
- }
-
- glfd = glfs_openat(pglfd,
- smb_fname->base_name,
- flags,
- how->mode);
-#else
- /*
- * Replace smb_fname with full_path constructed above.
- */
- smb_fname = full_fname;
-#endif
- }
-
- if (pglfd == NULL) {
- /*
- * smb_fname can either be a full_path or the same one
- * as received from the caller. In the latter case we
- * are operating at current working directory.
- */
+ if (flags & O_CREAT) {
+ glfd = glfs_creat(handle->data,
+ smb_fname->base_name,
+ flags,
+ how->mode);
+ } else {
glfd = glfs_open(handle->data,
smb_fname->base_name,
flags);
return -1;
}
- ret = glfs_futimens(glfd, times);
+ if (!fsp->fsp_flags.is_pathref) {
+ ret = glfs_futimens(glfd, times);
+ } else {
+ ret = glfs_utimens(handle->data,
+ fsp->fsp_name->base_name,
+ times);
+ }
END_PROFILE(syscall_fntimes);
return ret;
int ret;
char key_buf[GLUSTER_NAME_MAX + 64];
char val_buf[GLUSTER_NAME_MAX + 1];
-#ifdef HAVE_GFAPI_VER_7_11
- glfs_fd_t *pglfd = NULL;
-#else
- struct smb_filename *smb_fname_dot = NULL;
- struct smb_filename *full_fname = NULL;
-#endif
if (strlen(name) >= GLUSTER_NAME_MAX) {
return NT_STATUS_OBJECT_NAME_INVALID;
snprintf(key_buf, GLUSTER_NAME_MAX + 64,
"glusterfs.get_real_filename:%s", name);
-#ifdef HAVE_GFAPI_VER_7_11
- pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
- if (pglfd == NULL) {
- DBG_ERR("Failed to fetch gluster fd\n");
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- }
-
- ret = glfs_fgetxattr(pglfd, key_buf, val_buf, GLUSTER_NAME_MAX + 1);
-#else
- smb_fname_dot = synthetic_smb_fname(mem_ctx,
- ".",
- NULL,
- NULL,
- 0,
- 0);
- if (smb_fname_dot == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- full_fname = full_path_from_dirfsp_atname(talloc_tos(),
- dirfsp,
- smb_fname_dot);
- if (full_fname == NULL) {
- TALLOC_FREE(smb_fname_dot);
- return NT_STATUS_NO_MEMORY;
- }
-
- ret = glfs_getxattr(handle->data, full_fname->base_name,
- key_buf, val_buf, GLUSTER_NAME_MAX + 1);
-
- TALLOC_FREE(smb_fname_dot);
- TALLOC_FREE(full_fname);
-#endif
-
+ ret = glfs_getxattr(handle->data,
+ dirfsp->fsp_name->base_name,
+ key_buf,
+ val_buf,
+ GLUSTER_NAME_MAX + 1);
if (ret == -1) {
if (errno == ENOATTR) {
errno = ENOENT;
return NT_STATUS_OK;
}
-static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
- const struct smb_filename *smb_fname)
+static const char *vfs_gluster_connectpath(
+ struct vfs_handle_struct *handle,
+ const struct files_struct *dirfsp,
+ const struct smb_filename *smb_fname)
{
return handle->conn->connectpath;
}
return -1;
}
- return glfs_fgetxattr(glfd, name, value, size);
+ if (!fsp->fsp_flags.is_pathref) {
+ /*
+ * We can use an io_fd to retrieve xattr value.
+ */
+ return glfs_fgetxattr(glfd, name, value, size);
+ }
+
+ /*
+ * This is no longer a handle based call.
+ */
+ return glfs_getxattr(handle->data,
+ fsp->fsp_name->base_name,
+ name,
+ value,
+ size);
}
static ssize_t vfs_gluster_flistxattr(struct vfs_handle_struct *handle,
.fdopendir_fn = vfs_gluster_fdopendir,
.readdir_fn = vfs_gluster_readdir,
- .seekdir_fn = vfs_gluster_seekdir,
- .telldir_fn = vfs_gluster_telldir,
.rewind_dir_fn = vfs_gluster_rewinddir,
.mkdirat_fn = vfs_gluster_mkdirat,
.closedir_fn = vfs_gluster_closedir,