{
struct gpfs_config_data *config;
int fd = fsp_get_pathref_fd(fsp);
- char buf[PATH_MAX];
+ struct sys_proc_fd_path_buf buf;
const char *p = NULL;
struct gpfs_iattr64 iattr = { };
unsigned int litemask = 0;
if (fsp->fsp_flags.is_pathref && !config->pathref_ok.gpfs_fstat_x) {
if (fsp->fsp_flags.have_proc_fds) {
- p = sys_proc_fd_path(fd, buf, sizeof(buf));
- if (p == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
+ p = sys_proc_fd_path(fd, &buf);
} else {
p = fsp->fsp_name->base_name;
}
if (fsp->fsp_flags.have_proc_fds) {
int fd = fsp_get_pathref_fd(fsp);
- const char *p = NULL;
- char buf[PATH_MAX];
-
- p = sys_proc_fd_path(fd, buf, sizeof(buf));
- if (p == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
+ struct sys_proc_fd_path_buf buf;
- ret = gpfswrap_set_winattrs_path(p,
+ ret = gpfswrap_set_winattrs_path(sys_proc_fd_path(fd, &buf),
GPFS_WINATTR_SET_ATTRS,
&attrs);
if (ret == -1) {
- DBG_WARNING("Setting winattrs failed for [%s][%s]: %s\n",
- p, fsp_str_dbg(fsp), strerror(errno));
+ DBG_WARNING("Setting winattrs failed for "
+ "[%s][%s]: %s\n",
+ buf.buf,
+ fsp_str_dbg(fsp),
+ strerror(errno));
return map_nt_error_from_unix(errno);
}
return NT_STATUS_OK;
return NT_STATUS_OK;
}
-static int stat_with_capability(struct vfs_handle_struct *handle,
- struct smb_filename *smb_fname, int flag)
-{
- bool fake_dctime = lp_fake_directory_create_times(SNUM(handle->conn));
- int fd = -1;
- NTSTATUS status;
- struct smb_filename *dir_name = NULL;
- struct smb_filename *rel_name = NULL;
- int ret = -1;
-
- status = SMB_VFS_PARENT_PATHNAME(handle->conn,
- talloc_tos(),
- smb_fname,
- &dir_name,
- &rel_name);
- if (!NT_STATUS_IS_OK(status)) {
- errno = map_errno_from_nt_status(status);
- return -1;
- }
-
- fd = open(dir_name->base_name, O_RDONLY, 0);
- if (fd == -1) {
- TALLOC_FREE(dir_name);
- return -1;
- }
-
- set_effective_capability(DAC_OVERRIDE_CAPABILITY);
- ret = sys_fstatat(fd,
- rel_name->base_name,
- &smb_fname->st,
- flag,
- fake_dctime);
-
- drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
-
- TALLOC_FREE(dir_name);
- close(fd);
-
- return ret;
-}
-
-static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
- struct smb_filename *smb_fname)
-{
- int ret;
-
- ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
- if (ret == -1 && errno == EACCES) {
- DEBUG(10, ("Trying stat with capability for %s\n",
- smb_fname->base_name));
- ret = stat_with_capability(handle, smb_fname, 0);
- }
- return ret;
-}
-
-static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
- struct smb_filename *smb_fname)
-{
- int ret;
-
- ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
- if (ret == -1 && errno == EACCES) {
- DEBUG(10, ("Trying lstat with capability for %s\n",
- smb_fname->base_name));
- ret = stat_with_capability(handle, smb_fname,
- AT_SYMLINK_NOFOLLOW);
- }
- return ret;
-}
-
static int timespec_to_gpfs_time(
struct timespec ts, gpfs_timestruc_t *gt, int idx, int *flags)
{
if (fsp->fsp_flags.have_proc_fds) {
int fd = fsp_get_pathref_fd(fsp);
- const char *p = NULL;
- char buf[PATH_MAX];
+ struct sys_proc_fd_path_buf buf;
- p = sys_proc_fd_path(fd, buf, sizeof(buf));
- if (p == NULL) {
- return -1;
- }
-
- rc = gpfswrap_set_times_path(buf, flags, gpfs_times);
+ rc = gpfswrap_set_times_path(sys_proc_fd_path(fd, &buf),
+ flags,
+ gpfs_times);
if (rc != 0) {
DBG_WARNING("gpfs_set_times_path(%s,%s) failed: %s\n",
- fsp_str_dbg(fsp), p, strerror(errno));
+ fsp_str_dbg(fsp),
+ buf.buf,
+ strerror(errno));
}
return rc;
}
if (ret == -1) {
/* don't complain if access was denied */
if (errno != EPERM && errno != EACCES) {
- DBG_WARNING("SMB_VFS_NEXT_FNTIMES failed: %s",
+ DBG_WARNING("SMB_VFS_NEXT_FNTIMES failed: %s\n",
strerror(errno));
}
return -1;
if (fsp->fsp_flags.have_proc_fds) {
int fd = fsp_get_pathref_fd(fsp);
- const char *p = NULL;
- char buf[PATH_MAX];
+ struct sys_proc_fd_path_buf buf;
- p = sys_proc_fd_path(fd, buf, sizeof(buf));
- if (p == NULL) {
- return -1;
- }
-
- ret = gpfswrap_set_winattrs_path(p,
- GPFS_WINATTR_SET_CREATION_TIME,
- &attrs);
+ ret = gpfswrap_set_winattrs_path(
+ sys_proc_fd_path(fd, &buf),
+ GPFS_WINATTR_SET_CREATION_TIME,
+ &attrs);
if (ret == -1 && errno != ENOSYS) {
DBG_WARNING("Set GPFS ntimes failed %d\n", ret);
return -1;
return 0;
}
- gpfswrap_lib_init(0);
+ ret = gpfswrap_init();
+ if (ret < 0) {
+ DBG_ERR("Could not load GPFS library.\n");
+ return ret;
+ }
+
+ ret = gpfswrap_lib_init(0);
+ if (ret < 0) {
+ DBG_ERR("Could not open GPFS device file: %s\n",
+ strerror(errno));
+ return ret;
+ }
ret = gpfswrap_register_cifs_export();
if (ret < 0) {
.sys_acl_delete_def_fd_fn = gpfsacl_sys_acl_delete_def_fd,
.fchmod_fn = vfs_gpfs_fchmod,
.close_fn = vfs_gpfs_close,
- .stat_fn = vfs_gpfs_stat,
- .lstat_fn = vfs_gpfs_lstat,
+ .stat_fn = nfs4_acl_stat,
+ .fstat_fn = nfs4_acl_fstat,
+ .lstat_fn = nfs4_acl_lstat,
+ .fstatat_fn = nfs4_acl_fstatat,
.fntimes_fn = vfs_gpfs_fntimes,
.aio_force_fn = vfs_gpfs_aio_force,
.sendfile_fn = vfs_gpfs_sendfile,
static_decl_vfs;
NTSTATUS vfs_gpfs_init(TALLOC_CTX *ctx)
{
- int ret;
-
- ret = gpfswrap_init();
- if (ret != 0) {
- DEBUG(1, ("Could not initialize GPFS library wrapper\n"));
- }
-
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs",
&vfs_gpfs_fns);
}