char *upper_sname;
DEBUG(10, ("stream_inode called for %lu/%lu [%s]\n",
- (unsigned long)sbuf->st_dev,
- (unsigned long)sbuf->st_ino, sname));
+ (unsigned long)sbuf->st_ex_dev,
+ (unsigned long)sbuf->st_ex_ino, sname));
upper_sname = talloc_strdup_upper(talloc_tos(), sname);
SMB_ASSERT(upper_sname != NULL);
MD5Init(&ctx);
- MD5Update(&ctx, (unsigned char *)&(sbuf->st_dev),
- sizeof(sbuf->st_dev));
- MD5Update(&ctx, (unsigned char *)&(sbuf->st_ino),
- sizeof(sbuf->st_ino));
+ MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_dev),
+ sizeof(sbuf->st_ex_dev));
+ MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_ino),
+ sizeof(sbuf->st_ex_ino));
MD5Update(&ctx, (unsigned char *)upper_sname,
talloc_get_size(upper_sname)-1);
MD5Final(hash, &ctx);
return result;
}
+/**
+ * Given a stream name, populate xattr_name with the xattr name to use for
+ * accessing the stream.
+ */
+static NTSTATUS streams_xattr_get_name(TALLOC_CTX *ctx,
+ const char *stream_name,
+ char **xattr_name)
+{
+ char *stype;
+
+ stype = strchr_m(stream_name + 1, ':');
+
+ *xattr_name = talloc_asprintf(ctx, "%s%s",
+ SAMBA_XATTR_DOSSTREAM_PREFIX,
+ stream_name + 1);
+ if (*xattr_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (stype == NULL) {
+ /* Append an explicit stream type if one wasn't specified. */
+ *xattr_name = talloc_asprintf(ctx, "%s:$DATA",
+ *xattr_name);
+ if (*xattr_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ /* Normalize the stream type to upercase. */
+ strupper_m(strrchr_m(*xattr_name, ':') + 1);
+ }
+
+ DEBUG(10, ("xattr_name: %s, stream_name: %s\n", *xattr_name,
+ stream_name));
+
+ return NT_STATUS_OK;
+}
+
static bool streams_xattr_recheck(struct stream_io *sio)
{
NTSTATUS status;
- char *base = NULL;
- char *sname = NULL;
+ struct smb_filename *smb_fname = NULL;
char *xattr_name = NULL;
if (sio->fsp->fsp_name == sio->fsp_name_ptr) {
return true;
}
- status = split_ntfs_stream_name(talloc_tos(), sio->fsp->fsp_name,
- &base, &sname);
+ status = create_synthetic_smb_fname_split(talloc_tos(),
+ sio->fsp->fsp_name, NULL,
+ &smb_fname);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
- if (sname == NULL) {
+ if (smb_fname->stream_name == NULL) {
/* how can this happen */
errno = EINVAL;
return false;
}
- xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
- if (xattr_name == NULL) {
+ status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
+ &xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
xattr_name);
sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
- base);
+ smb_fname->base_name);
sio->fsp_name_ptr = sio->fsp->fsp_name;
+ TALLOC_FREE(smb_fname);
+ TALLOC_FREE(xattr_name);
+
if ((sio->xattr_name == NULL) || (sio->base == NULL)) {
return false;
}
return true;
}
+/**
+ * Helper to stat/lstat the base file of an smb_fname.
+ */
+static int streams_xattr_stat_base(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname,
+ bool follow_links)
+{
+ char *tmp_stream_name;
+ int result;
+
+ tmp_stream_name = smb_fname->stream_name;
+ smb_fname->stream_name = NULL;
+ if (follow_links) {
+ result = SMB_VFS_NEXT_STAT(handle, smb_fname);
+ } else {
+ result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+ }
+ smb_fname->stream_name = tmp_stream_name;
+ return result;
+}
+
static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
SMB_STRUCT_STAT *sbuf)
{
+ struct smb_filename *smb_fname_base = NULL;
+ NTSTATUS status;
+ int ret = -1;
struct stream_io *io = (struct stream_io *)
VFS_FETCH_FSP_EXTENSION(handle, fsp);
return -1;
}
- if (SMB_VFS_STAT(handle->conn, io->base, sbuf) == -1) {
+ /* Create an smb_filename with stream_name == NULL. */
+ status = create_synthetic_smb_fname(talloc_tos(),
+ io->base,
+ NULL, NULL,
+ &smb_fname_base);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
+ }
+
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, smb_fname_base);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, smb_fname_base);
+ }
+ *sbuf = smb_fname_base->st;
+ TALLOC_FREE(smb_fname_base);
+
+ if (ret == -1) {
return -1;
}
- sbuf->st_size = get_xattr_size(handle->conn, fsp->base_fsp,
+ sbuf->st_ex_size = get_xattr_size(handle->conn, fsp->base_fsp,
io->base, io->xattr_name);
- if (sbuf->st_size == -1) {
+ if (sbuf->st_ex_size == -1) {
return -1;
}
- DEBUG(10, ("sbuf->st_size = %d\n", (int)sbuf->st_size));
+ DEBUG(10, ("sbuf->st_ex_size = %d\n", (int)sbuf->st_ex_size));
- sbuf->st_ino = stream_inode(sbuf, io->xattr_name);
- sbuf->st_mode &= ~S_IFMT;
- sbuf->st_mode |= S_IFREG;
- sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1;
+ sbuf->st_ex_ino = stream_inode(sbuf, io->xattr_name);
+ sbuf->st_ex_mode &= ~S_IFMT;
+ sbuf->st_ex_mode |= S_IFREG;
+ sbuf->st_ex_blocks = sbuf->st_ex_size % STAT_ST_BLOCKSIZE + 1;
return 0;
}
-static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname,
- SMB_STRUCT_STAT *sbuf)
+static int streams_xattr_stat(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname)
{
NTSTATUS status;
- char *base = NULL, *sname = NULL;
int result = -1;
- char *xattr_name;
-
- if (!is_ntfs_stream_name(fname)) {
- return SMB_VFS_NEXT_STAT(handle, fname, sbuf);
- }
+ char *xattr_name = NULL;
- status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname);
- if (!NT_STATUS_IS_OK(status)) {
- errno = EINVAL;
- return -1;
+ if (!is_ntfs_stream_smb_fname(smb_fname)) {
+ return SMB_VFS_NEXT_STAT(handle, smb_fname);
}
- if (sname == NULL){
- return SMB_VFS_NEXT_STAT(handle, base, sbuf);
+ /* If the default stream is requested, just stat the base file. */
+ if (is_ntfs_default_stream_smb_fname(smb_fname)) {
+ return streams_xattr_stat_base(handle, smb_fname, true);
}
- if (SMB_VFS_STAT(handle->conn, base, sbuf) == -1) {
- goto fail;
+ /* Populate the stat struct with info from the base file. */
+ if (streams_xattr_stat_base(handle, smb_fname, true) == -1) {
+ return -1;
}
- xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
- if (xattr_name == NULL) {
- errno = ENOMEM;
- goto fail;
+ /* Derive the xattr name to lookup. */
+ status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
+ &xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
}
- sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
- if (sbuf->st_size == -1) {
+ /* Augment the base file's stat information before returning. */
+ smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
+ smb_fname->base_name,
+ xattr_name);
+ if (smb_fname->st.st_ex_size == -1) {
errno = ENOENT;
+ result = -1;
goto fail;
}
- sbuf->st_ino = stream_inode(sbuf, xattr_name);
- sbuf->st_mode &= ~S_IFMT;
- sbuf->st_mode |= S_IFREG;
- sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1;
+ smb_fname->st.st_ex_ino = stream_inode(&smb_fname->st, xattr_name);
+ smb_fname->st.st_ex_mode &= ~S_IFMT;
+ smb_fname->st.st_ex_mode |= S_IFREG;
+ smb_fname->st.st_ex_blocks =
+ smb_fname->st.st_ex_size % STAT_ST_BLOCKSIZE + 1;
result = 0;
fail:
- TALLOC_FREE(base);
- TALLOC_FREE(sname);
+ TALLOC_FREE(xattr_name);
return result;
}
-static int streams_xattr_lstat(vfs_handle_struct *handle, const char *fname,
- SMB_STRUCT_STAT *sbuf)
+static int streams_xattr_lstat(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname)
{
NTSTATUS status;
- char *base, *sname;
int result = -1;
- char *xattr_name;
+ char *xattr_name = NULL;
- if (!is_ntfs_stream_name(fname)) {
- return SMB_VFS_NEXT_LSTAT(handle, fname, sbuf);
+ if (!is_ntfs_stream_smb_fname(smb_fname)) {
+ return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
}
- status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname);
- if (!NT_STATUS_IS_OK(status)) {
- errno = EINVAL;
- goto fail;
- }
-
- if (sname == NULL){
- return SMB_VFS_NEXT_LSTAT(handle, base, sbuf);
+ /* If the default stream is requested, just stat the base file. */
+ if (is_ntfs_default_stream_smb_fname(smb_fname)) {
+ return streams_xattr_stat_base(handle, smb_fname, false);
}
- if (SMB_VFS_LSTAT(handle->conn, base, sbuf) == -1) {
- goto fail;
+ /* Populate the stat struct with info from the base file. */
+ if (streams_xattr_stat_base(handle, smb_fname, false) == -1) {
+ return -1;
}
- xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
- if (xattr_name == NULL) {
- errno = ENOMEM;
- goto fail;
+ /* Derive the xattr name to lookup. */
+ status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
+ &xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
}
- sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
- if (sbuf->st_size == -1) {
+ /* Augment the base file's stat information before returning. */
+ smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
+ smb_fname->base_name,
+ xattr_name);
+ if (smb_fname->st.st_ex_size == -1) {
errno = ENOENT;
+ result = -1;
goto fail;
}
- sbuf->st_ino = stream_inode(sbuf, xattr_name);
- sbuf->st_mode &= ~S_IFMT;
- sbuf->st_mode |= S_IFREG;
- sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1;
+ smb_fname->st.st_ex_ino = stream_inode(&smb_fname->st, xattr_name);
+ smb_fname->st.st_ex_mode &= ~S_IFMT;
+ smb_fname->st.st_ex_mode |= S_IFREG;
+ smb_fname->st.st_ex_blocks =
+ smb_fname->st.st_ex_size % STAT_ST_BLOCKSIZE + 1;
result = 0;
+
fail:
- TALLOC_FREE(base);
- TALLOC_FREE(sname);
+ TALLOC_FREE(xattr_name);
return result;
}
-static int streams_xattr_open(vfs_handle_struct *handle, const char *fname,
+static int streams_xattr_open(vfs_handle_struct *handle,
+ struct smb_filename *smb_fname,
files_struct *fsp, int flags, mode_t mode)
{
- TALLOC_CTX *frame;
NTSTATUS status;
+ struct smb_filename *smb_fname_base = NULL;
struct stream_io *sio;
- char *base, *sname;
struct ea_struct ea;
- char *xattr_name;
+ char *xattr_name = NULL;
int baseflags;
int hostfd = -1;
- DEBUG(10, ("streams_xattr_open called for %s\n", fname));
+ DEBUG(10, ("streams_xattr_open called for %s\n",
+ smb_fname_str_dbg(smb_fname)));
- if (!is_ntfs_stream_name(fname)) {
- return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
+ if (!is_ntfs_stream_smb_fname(smb_fname)) {
+ return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
}
- frame = talloc_stackframe();
+ /* If the default stream is requested, just open the base file. */
+ if (is_ntfs_default_stream_smb_fname(smb_fname)) {
+ char *tmp_stream_name;
+ int ret;
- status = split_ntfs_stream_name(talloc_tos(), fname,
- &base, &sname);
- if (!NT_STATUS_IS_OK(status)) {
- errno = EINVAL;
- goto fail;
+ tmp_stream_name = smb_fname->stream_name;
+ smb_fname->stream_name = NULL;
+
+ ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+
+ smb_fname->stream_name = tmp_stream_name;
+
+ return ret;
}
- if (sname == NULL) {
- hostfd = SMB_VFS_NEXT_OPEN(handle, base, fsp, flags, mode);
- talloc_free(frame);
- return hostfd;
+ status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
+ &xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ goto fail;
}
- xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
- if (xattr_name == NULL) {
- errno = ENOMEM;
+ /* Create an smb_filename with stream_name == NULL. */
+ status = create_synthetic_smb_fname(talloc_tos(),
+ smb_fname->base_name,
+ NULL, NULL,
+ &smb_fname_base);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
goto fail;
}
baseflags &= ~O_EXCL;
baseflags &= ~O_CREAT;
- hostfd = SMB_VFS_OPEN(handle->conn, base, fsp, baseflags, mode);
+ hostfd = SMB_VFS_OPEN(handle->conn, smb_fname_base, fsp,
+ baseflags, mode);
+
+ TALLOC_FREE(smb_fname_base);
/* It is legit to open a stream on a directory, but the base
* fd has to be read-only.
if ((hostfd == -1) && (errno == EISDIR)) {
baseflags &= ~O_ACCMODE;
baseflags |= O_RDONLY;
- hostfd = SMB_VFS_OPEN(handle->conn, fname, fsp, baseflags,
+ hostfd = SMB_VFS_OPEN(handle->conn, smb_fname, fsp, baseflags,
mode);
}
goto fail;
}
- status = get_ea_value(talloc_tos(), handle->conn, NULL, base,
- xattr_name, &ea);
+ status = get_ea_value(talloc_tos(), handle->conn, NULL,
+ smb_fname->base_name, xattr_name, &ea);
DEBUG(10, ("get_ea_value returned %s\n", nt_errstr(status)));
* file for us.
*/
DEBUG(10, ("streams_xattr_open: base file %s not around, "
- "returning ENOENT\n", base));
+ "returning ENOENT\n", smb_fname->base_name));
errno = ENOENT;
goto fail;
}
char null = '\0';
DEBUG(10, ("creating attribute %s on file %s\n",
- xattr_name, base));
+ xattr_name, smb_fname->base_name));
if (fsp->base_fsp->fh->fd != -1) {
if (SMB_VFS_FSETXATTR(
}
} else {
if (SMB_VFS_SETXATTR(
- handle->conn, base, xattr_name,
- &null, sizeof(null),
+ handle->conn, smb_fname->base_name,
+ xattr_name, &null, sizeof(null),
flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
goto fail;
}
}
} else {
if (SMB_VFS_SETXATTR(
- handle->conn, base, xattr_name,
- &null, sizeof(null),
+ handle->conn, smb_fname->base_name,
+ xattr_name, &null, sizeof(null),
flags & O_EXCL ? XATTR_CREATE : 0) == -1) {
goto fail;
}
sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
xattr_name);
sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
- base);
+ smb_fname->base_name);
sio->fsp_name_ptr = fsp->fsp_name;
sio->handle = handle;
sio->fsp = fsp;
goto fail;
}
- TALLOC_FREE(frame);
return hostfd;
fail:
SMB_VFS_CLOSE(fsp);
}
- TALLOC_FREE(frame);
return -1;
}
-static int streams_xattr_unlink(vfs_handle_struct *handle, const char *fname)
+static int streams_xattr_unlink(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname)
{
NTSTATUS status;
- char *base = NULL;
- char *sname = NULL;
int ret = -1;
char *xattr_name;
- if (!is_ntfs_stream_name(fname)) {
- return SMB_VFS_NEXT_UNLINK(handle, fname);
+ if (!is_ntfs_stream_smb_fname(smb_fname)) {
+ return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
}
- status = split_ntfs_stream_name(talloc_tos(), fname, &base, &sname);
- if (!NT_STATUS_IS_OK(status)) {
- errno = EINVAL;
- goto fail;
- }
+ /* If the default stream is requested, just open the base file. */
+ if (is_ntfs_default_stream_smb_fname(smb_fname)) {
+ struct smb_filename *smb_fname_base = NULL;
+
+ status = copy_smb_filename(talloc_tos(), smb_fname,
+ &smb_fname_base);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
+ return -1;
+ }
- if (sname == NULL){
- return SMB_VFS_NEXT_UNLINK(handle, base);
+ ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_base);
+
+ TALLOC_FREE(smb_fname_base);
+ return ret;
}
- xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
- if (xattr_name == NULL) {
- errno = ENOMEM;
+ status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
+ &xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
goto fail;
}
- ret = SMB_VFS_REMOVEXATTR(handle->conn, base, xattr_name);
+ ret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname->base_name, xattr_name);
if ((ret == -1) && (errno == ENOATTR)) {
errno = ENOENT;
ret = 0;
fail:
- TALLOC_FREE(base);
- TALLOC_FREE(sname);
+ TALLOC_FREE(xattr_name);
return ret;
}
static int streams_xattr_rename(vfs_handle_struct *handle,
- const char *oldname,
- const char *newname)
+ const struct smb_filename *smb_fname_src,
+ const struct smb_filename *smb_fname_dst)
{
NTSTATUS status;
- TALLOC_CTX *frame = NULL;
- char *obase;
- char *ostream;
- char *nbase;
- char *nstream;
- const char *base;
int ret = -1;
- char *oxattr_name;
- char *nxattr_name;
- bool o_is_stream;
- bool n_is_stream;
+ char *src_xattr_name = NULL;
+ char *dst_xattr_name = NULL;
+ bool src_is_stream, dst_is_stream;
ssize_t oret;
ssize_t nret;
struct ea_struct ea;
- o_is_stream = is_ntfs_stream_name(oldname);
- n_is_stream = is_ntfs_stream_name(newname);
+ src_is_stream = is_ntfs_stream_smb_fname(smb_fname_src);
+ dst_is_stream = is_ntfs_stream_smb_fname(smb_fname_dst);
- if (!o_is_stream && !n_is_stream) {
- return SMB_VFS_NEXT_RENAME(handle, oldname, newname);
+ if (!src_is_stream && !dst_is_stream) {
+ return SMB_VFS_NEXT_RENAME(handle, smb_fname_src,
+ smb_fname_dst);
}
- frame = talloc_stackframe();
- if (!frame) {
- goto fail;
- }
-
- status = split_ntfs_stream_name(talloc_tos(), oldname, &obase, &ostream);
- if (!NT_STATUS_IS_OK(status)) {
- errno = EINVAL;
- goto fail;
- }
-
- status = split_ntfs_stream_name(talloc_tos(), newname, &nbase, &nstream);
- if (!NT_STATUS_IS_OK(status)) {
- errno = EINVAL;
- goto fail;
- }
-
- /*TODO: maybe call SMB_VFS_NEXT_RENAME() both streams are NULL (::$DATA) */
- if (ostream == NULL) {
- errno = ENOSYS;
- goto fail;
- }
-
- if (nstream == NULL) {
+ /* For now don't allow renames from or to the default stream. */
+ if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
+ is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
errno = ENOSYS;
- goto fail;
+ goto done;
}
- if (StrCaseCmp(ostream, nstream) == 0) {
+ /* Don't rename if the streams are identical. */
+ if (StrCaseCmp(smb_fname_src->stream_name,
+ smb_fname_dst->stream_name) == 0) {
goto done;
}
- base = obase;
-
- oxattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, ostream);
- if (oxattr_name == NULL) {
- errno = ENOMEM;
+ /* Get the xattr names. */
+ status = streams_xattr_get_name(talloc_tos(),
+ smb_fname_src->stream_name,
+ &src_xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
goto fail;
}
-
- nxattr_name = talloc_asprintf(talloc_tos(), "%s%s",
- SAMBA_XATTR_DOSSTREAM_PREFIX, nstream);
- if (nxattr_name == NULL) {
- errno = ENOMEM;
+ status = streams_xattr_get_name(talloc_tos(),
+ smb_fname_dst->stream_name,
+ &dst_xattr_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
goto fail;
}
/* read the old stream */
status = get_ea_value(talloc_tos(), handle->conn, NULL,
- base, oxattr_name, &ea);
+ smb_fname_src->base_name, src_xattr_name, &ea);
if (!NT_STATUS_IS_OK(status)) {
errno = ENOENT;
goto fail;
}
/* (over)write the new stream */
- nret = SMB_VFS_SETXATTR(handle->conn, base, nxattr_name,
- ea.value.data, ea.value.length, 0);
+ nret = SMB_VFS_SETXATTR(handle->conn, smb_fname_src->base_name,
+ dst_xattr_name, ea.value.data, ea.value.length,
+ 0);
if (nret < 0) {
if (errno == ENOATTR) {
errno = ENOENT;
}
/* remove the old stream */
- oret = SMB_VFS_REMOVEXATTR(handle->conn, base, oxattr_name);
+ oret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname_src->base_name,
+ src_xattr_name);
if (oret < 0) {
if (errno == ENOATTR) {
errno = ENOENT;
errno = 0;
ret = 0;
fail:
- TALLOC_FREE(frame);
+ TALLOC_FREE(src_xattr_name);
+ TALLOC_FREE(dst_xattr_name);
return ret;
}
struct streaminfo_state state;
if ((fsp != NULL) && (fsp->fh->fd != -1)) {
- if (is_ntfs_stream_name(fsp->fsp_name)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
ret = SMB_VFS_FSTAT(fsp, &sbuf);
}
else {
- if (is_ntfs_stream_name(fname)) {
- return NT_STATUS_INVALID_PARAMETER;
+ struct smb_filename *smb_fname = NULL;
+ status = create_synthetic_smb_fname(talloc_tos(), fname, NULL,
+ NULL, &smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, smb_fname);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, smb_fname);
}
- ret = SMB_VFS_STAT(handle->conn, fname, &sbuf);
+ sbuf = smb_fname->st;
+ TALLOC_FREE(smb_fname);
}
if (ret == -1) {
state.streams = NULL;
state.num_streams = 0;
- if (!S_ISDIR(sbuf.st_mode)) {
+ if (!S_ISDIR(sbuf.st_ex_mode)) {
if (!add_one_stream(mem_ctx,
&state.num_streams, &state.streams,
- "::$DATA", sbuf.st_size,
+ "::$DATA", sbuf.st_ex_size,
SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
&sbuf))) {
return NT_STATUS_NO_MEMORY;