[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Wed Aug 9 20:34:02 UTC 2017
The branch, master has been updated
via d55c27a vfs_fruit: factor out common code from ad_get() and ad_fget()
via 7583ee6 vfs_fruit: return fake pipe fd in fruit_open_meta_netatalk()
via e92a392 vfs_fruit: don't open basefile in ad_open() and simplify API
via aff6fc4 vfs_fruit: use path based setxattr call in ad_fset()
via bbc225d s4/torture: additional tests for kernel-oplocks
via a334fff s4/torture: reproducer for kernel oplocks issue with streams
via 0a8559d vfs_streams_xattr: return a fake fd in streams_xattr_open()
via 9647af6 vfs_streams_xattr: implement all missing handle based VFS functions
via 0ed3075 vfs_streams_xattr: always pass NULL as fsp arg to get_ea_value()
via 4cc59e6 vfs_streams_xattr: remove fsp argument from get_xattr_size()
via ea906bb vfs_streams_xattr: remove all uses of fd, use name based functions
via ec32f33 vfs_streams_xattr: invalidate stat info if xattr was not found
from b86f44c s3:utils: Fix buffer size for snprintf and format string
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit d55c27abc5a7357f740c7065bbe12e7f36b57125
Author: Ralph Boehme <slow at samba.org>
Date: Wed May 24 09:17:19 2017 +0200
vfs_fruit: factor out common code from ad_get() and ad_fget()
As a result of the previous changes ad_get() and ad_fget() do completey
the same, so factor out the common code to a new helper function. No
change in behaviour.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Autobuild-User(master): Volker Lendecke <vl at samba.org>
Autobuild-Date(master): Wed Aug 9 22:33:36 CEST 2017 on sn-devel-144
commit 7583ee6e1c558067e4c7a7351085fcc0e4240366
Author: Ralph Boehme <slow at samba.org>
Date: Tue May 23 17:44:16 2017 +0200
vfs_fruit: return fake pipe fd in fruit_open_meta_netatalk()
Do not open the basefile, that conflict with "kernel oplocks = yes". We
just return a fake file fd based on dup'ing a pipe fd and ensure all VFS
functions that go through vfs_fruit and work on the metadata stream can
deal with it.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit e92a39255e66f655e2758f0a71a01eaf258cf711
Author: Ralph Boehme <slow at samba.org>
Date: Tue May 23 17:31:47 2017 +0200
vfs_fruit: don't open basefile in ad_open() and simplify API
We never need an fd on the basefile when operating on the metadata, as
we can always use path based syscalls. Opening the basefile conflicts
with "kernel oplocks" so just don't do it.
Additional changes:
- remove the adouble_type_t argument to ad_open(), the type is passed
and set when allocating a struct adouble with ad_alloc()
- additionally pass an optional fsp to ad_open() (so the caller can pass
NULL). With this change we can move the fd inheritance from fsp to ad
into ad_open() itself where it belongs and remove it from the caller
ad_fget()
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
commit aff6fc49f4ac244aef162200a37bd846719e1e4f
Author: Ralph Boehme <slow at samba.org>
Date: Tue May 23 17:39:46 2017 +0200
vfs_fruit: use path based setxattr call in ad_fset()
This allows later commits to remove opening of the basefile which
conflict with "kernel oplocks = yes".
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit bbc225de83e7b0e5eaeb1b843532d1f0fca91a3c
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 18 13:17:38 2017 +0200
s4/torture: additional tests for kernel-oplocks
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
commit a334fff8a8c779704ee04ae784024efb67a6e9c9
Author: Ralph Boehme <slow at samba.org>
Date: Wed May 10 11:38:06 2017 +0200
s4/torture: reproducer for kernel oplocks issue with streams
test_smb2_kernel_oplocks3() wouldn't have failed without the patches,
I'm just adding it to have at least one test that tests with 2
clients. All other tests use just one client.
test_smb2_kernel_oplocks4() is the reproducer.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
commit 0a8559d4c9e4fc73c30a06b5f45f3b870afe4439
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 11 18:08:56 2017 +0200
vfs_streams_xattr: return a fake fd in streams_xattr_open()
The final step in changing vfs_streams_xattr to not call open() on the
basefile anymore. Instead, we just return a fake file fd based on
dup'ing a pipe fd. Previous commits ensured all calls to VFS API
functions use pathname based versions to do their work.
This ensures we don't trigger kernel oplock breaks for client "open
stream" requests when needlessly opening the basefile.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 9647af6bec62c9f61d541aad4a9b8f25fd5bc627
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 11 18:05:18 2017 +0200
vfs_streams_xattr: implement all missing handle based VFS functions
Implement all missing handle based VFS function. If the call is on a
named stream, implement the appropriate action for the VFS function, in
most cases a no-op.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 0ed3075ee7edfecde7455a2c64e9df882828343b
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 11 17:38:00 2017 +0200
vfs_streams_xattr: always pass NULL as fsp arg to get_ea_value()
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 4cc59e6d011cd3804499ba82bb4071973aa9d494
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 11 17:36:15 2017 +0200
vfs_streams_xattr: remove fsp argument from get_xattr_size()
Still in the process of changing all handle based operations to use path
based operations.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit ea906bb476516c05e7cbda478afd32acb443c03e
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 11 15:05:23 2017 +0200
vfs_streams_xattr: remove all uses of fd, use name based functions
We don't really need an fd in this module, all calls to the VFS xattr
API can just use the name based versions.
This paves the way for removing the open of the basefile in
streams_xattr_open() in a later commit.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit ec32f33ea6d50d9cb504400c3ef1e78643502e1a
Author: Ralph Boehme <slow at samba.org>
Date: Thu May 11 07:59:20 2017 +0200
vfs_streams_xattr: invalidate stat info if xattr was not found
We stat the basefile so we leave valid stat info from the base file
behind, even though the xattr for the stream was not there.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=12791
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/modules/vfs_fruit.c | 268 ++++++-----------
source3/modules/vfs_streams_xattr.c | 558 ++++++++++++++++++++++++++++++------
source4/torture/smb2/oplock.c | 346 ++++++++++++++++++++++
3 files changed, 897 insertions(+), 275 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 7c481cd..09e0fcd 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -863,13 +863,6 @@ exit:
return ealen;
}
-static int ad_open_meta(const struct smb_filename *smb_fname,
- int flags,
- mode_t mode)
-{
- return open(smb_fname->base_name, flags, mode);
-}
-
static int ad_open_rsrc_xattr(const struct smb_filename *smb_fname,
int flags,
mode_t mode)
@@ -923,34 +916,45 @@ static int ad_open_rsrc(vfs_handle_struct *handle,
return fd;
}
+/*
+ * Here's the deal: for ADOUBLE_META we can do without an fd as we can issue
+ * path based xattr calls. For ADOUBLE_RSRC however we need a full-fledged fd
+ * for file IO on the ._ file.
+ */
static int ad_open(vfs_handle_struct *handle,
struct adouble *ad,
+ files_struct *fsp,
const struct smb_filename *smb_fname,
- adouble_type_t t,
int flags,
mode_t mode)
{
int fd;
- DBG_DEBUG("Path [%s] type [%s]\n",
- smb_fname->base_name, t == ADOUBLE_META ? "meta" : "rsrc");
+ DBG_DEBUG("Path [%s] type [%s]\n", smb_fname->base_name,
+ ad->ad_type == ADOUBLE_META ? "meta" : "rsrc");
- if (t == ADOUBLE_META) {
- fd = ad_open_meta(smb_fname, flags, mode);
- } else {
- fd = ad_open_rsrc(handle, smb_fname, flags, mode);
+ if (ad->ad_type == ADOUBLE_META) {
+ return 0;
+ }
+
+ if ((fsp != NULL) && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
+ ad->ad_fd = fsp->fh->fd;
+ ad->ad_opened = false;
+ return 0;
}
- if (fd != -1) {
- ad->ad_opened = true;
- ad->ad_fd = fd;
+ fd = ad_open_rsrc(handle, smb_fname, flags, mode);
+ if (fd == -1) {
+ return -1;
}
+ ad->ad_opened = true;
+ ad->ad_fd = fd;
DBG_DEBUG("Path [%s] type [%s] fd [%d]\n",
smb_fname->base_name,
- t == ADOUBLE_META ? "meta" : "rsrc", fd);
+ ad->ad_type == ADOUBLE_META ? "meta" : "rsrc", fd);
- return fd;
+ return 0;
}
static ssize_t ad_read_rsrc_xattr(struct adouble *ad)
@@ -1237,26 +1241,21 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
return ad;
}
-/**
- * Return AppleDouble data for a file
- *
- * @param[in] ctx talloc context
- * @param[in] handle vfs handle
- * @param[in] smb_fname pathname to file or directory
- * @param[in] type type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
- *
- * @return talloced struct adouble or NULL on error
- **/
-static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
- const struct smb_filename *smb_fname,
- adouble_type_t type)
+static struct adouble *ad_get_internal(TALLOC_CTX *ctx,
+ vfs_handle_struct *handle,
+ files_struct *fsp,
+ const struct smb_filename *smb_fname,
+ adouble_type_t type)
{
int rc = 0;
ssize_t len;
struct adouble *ad = NULL;
- int fd;
int mode;
+ if (fsp != NULL) {
+ smb_fname = fsp->base_fsp->fsp_name;
+ }
+
DEBUG(10, ("ad_get(%s) called for %s\n",
type == ADOUBLE_META ? "meta" : "rsrc",
smb_fname->base_name));
@@ -1267,29 +1266,19 @@ static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
goto exit;
}
- /*
- * Here's the deal: for ADOUBLE_META we can do without an fd
- * as we can issue path based xattr calls. For ADOUBLE_RSRC
- * however we need a full-fledged fd for file IO on the ._
- * file.
- */
- if (type == ADOUBLE_RSRC) {
- /* Try rw first so we can use the fd in ad_convert() */
- mode = O_RDWR;
-
- fd = ad_open(handle, ad, smb_fname, ADOUBLE_RSRC, mode, 0);
- if (fd == -1 && ((errno == EROFS) || (errno == EACCES))) {
- mode = O_RDONLY;
- fd = ad_open(handle, ad, smb_fname,
- ADOUBLE_RSRC, mode, 0);
- }
+ /* Try rw first so we can use the fd in ad_convert() */
+ mode = O_RDWR;
+
+ rc = ad_open(handle, ad, fsp, smb_fname, mode, 0);
+ if (rc == -1 && ((errno == EROFS) || (errno == EACCES))) {
+ mode = O_RDONLY;
+ rc = ad_open(handle, ad, fsp, smb_fname, mode, 0);
+ }
+ if (rc == -1) {
+ DBG_DEBUG("ad_open [%s] error [%s]\n",
+ smb_fname->base_name, strerror(errno));
+ goto exit;
- if (fd == -1) {
- DBG_DEBUG("ad_open [%s] error [%s]\n",
- smb_fname->base_name, strerror(errno));
- rc = -1;
- goto exit;
- }
}
len = ad_read(ad, smb_fname);
@@ -1316,6 +1305,24 @@ exit:
*
* @param[in] ctx talloc context
* @param[in] handle vfs handle
+ * @param[in] smb_fname pathname to file or directory
+ * @param[in] type type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
+ *
+ * @return talloced struct adouble or NULL on error
+ **/
+static struct adouble *ad_get(TALLOC_CTX *ctx,
+ vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ adouble_type_t type)
+{
+ return ad_get_internal(ctx, handle, NULL, smb_fname, type);
+}
+
+/**
+ * Return AppleDouble data for a file
+ *
+ * @param[in] ctx talloc context
+ * @param[in] handle vfs handle
* @param[in] fsp fsp to use for IO
* @param[in] type type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
*
@@ -1324,73 +1331,7 @@ exit:
static struct adouble *ad_fget(TALLOC_CTX *ctx, vfs_handle_struct *handle,
files_struct *fsp, adouble_type_t type)
{
- int rc = 0;
- ssize_t len;
- struct adouble *ad = NULL;
-
- DBG_DEBUG("ad_get(%s) path [%s]\n",
- type == ADOUBLE_META ? "meta" : "rsrc",
- fsp_str_dbg(fsp));
-
- ad = ad_alloc(ctx, handle, type);
- if (ad == NULL) {
- rc = -1;
- goto exit;
- }
-
- if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) {
- ad->ad_fd = fsp->fh->fd;
- } else {
- /*
- * Here's the deal: for ADOUBLE_META we can do without an fd
- * as we can issue path based xattr calls. For ADOUBLE_RSRC
- * however we need a full-fledged fd for file IO on the ._
- * file.
- */
- int fd;
- int mode;
-
- if (type == ADOUBLE_RSRC) {
- /* Try rw first so we can use the fd in ad_convert() */
- mode = O_RDWR;
-
- fd = ad_open(handle, ad, fsp->base_fsp->fsp_name,
- ADOUBLE_RSRC, mode, 0);
- if (fd == -1 &&
- ((errno == EROFS) || (errno == EACCES)))
- {
- mode = O_RDONLY;
- fd = ad_open(handle, ad,
- fsp->base_fsp->fsp_name, ADOUBLE_RSRC,
- mode, 0);
- }
-
- if (fd == -1) {
- DBG_DEBUG("error opening AppleDouble for %s\n",
- fsp_str_dbg(fsp));
- rc = -1;
- goto exit;
- }
- }
- }
-
- len = ad_read(ad, fsp->base_fsp->fsp_name);
- if (len == -1) {
- DBG_DEBUG("error reading AppleDouble for %s\n",
- fsp_str_dbg(fsp));
- rc = -1;
- goto exit;
- }
-
-exit:
- DBG_DEBUG("ad_get(%s) path [%s] rc [%d]\n",
- type == ADOUBLE_META ? "meta" : "rsrc",
- fsp_str_dbg(fsp), rc);
-
- if (rc != 0) {
- TALLOC_FREE(ad);
- }
- return ad;
+ return ad_get_internal(ctx, handle, fsp, NULL, type);
}
/**
@@ -1461,11 +1402,11 @@ static int ad_fset(struct adouble *ad, files_struct *fsp)
switch (ad->ad_type) {
case ADOUBLE_META:
- rc = SMB_VFS_NEXT_FSETXATTR(ad->ad_handle,
- fsp,
- AFPINFO_EA_NETATALK,
- ad->ad_data,
- AD_DATASZ_XATTR, 0);
+ rc = SMB_VFS_NEXT_SETXATTR(ad->ad_handle,
+ fsp->fsp_name,
+ AFPINFO_EA_NETATALK,
+ ad->ad_data,
+ AD_DATASZ_XATTR, 0);
break;
case ADOUBLE_RSRC:
@@ -2767,56 +2708,24 @@ static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
int flags,
mode_t mode)
{
- int rc = 0;
- struct smb_filename *smb_fname_base = NULL;
- int baseflags;
- int hostfd = -1;
+ int rc;
+ int fakefd = -1;
struct adouble *ad = NULL;
+ int fds[2];
DBG_DEBUG("Path [%s]\n", smb_fname_str_dbg(smb_fname));
- /* Create an smb_filename with stream_name == NULL. */
- smb_fname_base = synthetic_smb_fname(talloc_tos(),
- smb_fname->base_name,
- NULL,
- NULL,
- smb_fname->flags);
-
- if (smb_fname_base == NULL) {
- errno = ENOMEM;
- rc = -1;
- goto exit;
- }
-
/*
- * We use baseflags to turn off nasty side-effects when opening the
- * underlying file.
+ * Return a valid fd, but ensure any attempt to use it returns an error
+ * (EPIPE). All operations on the smb_fname or the fsp will use path
+ * based syscalls.
*/
- baseflags = flags;
- baseflags &= ~O_TRUNC;
- baseflags &= ~O_EXCL;
- baseflags &= ~O_CREAT;
-
- hostfd = SMB_VFS_NEXT_OPEN(handle, smb_fname_base, fsp,
- baseflags, mode);
-
- /*
- * 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_NEXT_OPEN(handle, smb_fname_base, fsp,
- baseflags, mode);
- }
-
- TALLOC_FREE(smb_fname_base);
-
- if (hostfd == -1) {
- rc = -1;
+ rc = pipe(fds);
+ if (rc != 0) {
goto exit;
}
+ fakefd = fds[0];
+ close(fds[1]);
if (flags & (O_CREAT | O_TRUNC)) {
/*
@@ -2829,10 +2738,7 @@ static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
goto exit;
}
- fsp->fh->fd = hostfd;
-
- rc = ad_fset(ad, fsp);
- fsp->fh->fd = -1;
+ rc = ad_set(ad, fsp->fsp_name);
if (rc != 0) {
rc = -1;
goto exit;
@@ -2842,22 +2748,16 @@ static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
}
exit:
- DEBUG(10, ("fruit_open meta rc=%d, fd=%d\n", rc, hostfd));
+ DEBUG(10, ("fruit_open meta rc=%d, fd=%d\n", rc, fakefd));
if (rc != 0) {
int saved_errno = errno;
- if (hostfd >= 0) {
- /*
- * BUGBUGBUG -- we would need to call
- * fd_close_posix here, but we don't have a
- * full fsp yet
- */
- fsp->fh->fd = hostfd;
- SMB_VFS_NEXT_CLOSE(handle, fsp);
+ if (fakefd >= 0) {
+ close(fakefd);
}
- hostfd = -1;
+ fakefd = -1;
errno = saved_errno;
}
- return hostfd;
+ return fakefd;
}
static int fruit_open_meta(vfs_handle_struct *handle,
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 5114c09..bd3965c 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -26,6 +26,7 @@
#include "system/filesys.h"
#include "../lib/crypto/md5.h"
#include "lib/util/tevent_unix.h"
+#include "librpc/gen_ndr/ioctl.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
@@ -78,7 +79,6 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
}
static ssize_t get_xattr_size(connection_struct *conn,
- files_struct *fsp,
const struct smb_filename *smb_fname,
const char *xattr_name)
{
@@ -86,7 +86,7 @@ static ssize_t get_xattr_size(connection_struct *conn,
struct ea_struct ea;
ssize_t result;
- status = get_ea_value(talloc_tos(), conn, fsp, smb_fname,
+ status = get_ea_value(talloc_tos(), conn, NULL, smb_fname,
xattr_name, &ea);
if (!NT_STATUS_IS_OK(status)) {
@@ -232,7 +232,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
struct stream_io *io = (struct stream_io *)
VFS_FETCH_FSP_EXTENSION(handle, fsp);
- DEBUG(10, ("streams_xattr_fstat called for %d\n", fsp->fh->fd));
+ DBG_DEBUG("streams_xattr_fstat called for %s\n", fsp_str_dbg(io->fsp));
if (io == NULL || fsp->base_fsp == NULL) {
return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
@@ -265,10 +265,11 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
return -1;
}
- sbuf->st_ex_size = get_xattr_size(handle->conn, fsp,
+ sbuf->st_ex_size = get_xattr_size(handle->conn,
smb_fname_base, io->xattr_name);
if (sbuf->st_ex_size == -1) {
TALLOC_FREE(smb_fname_base);
+ SET_STAT_INVALID(*sbuf);
return -1;
}
@@ -318,10 +319,11 @@ static int streams_xattr_stat(vfs_handle_struct *handle,
}
/* Augment the base file's stat information before returning. */
- smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
+ smb_fname->st.st_ex_size = get_xattr_size(handle->conn,
smb_fname,
xattr_name);
if (smb_fname->st.st_ex_size == -1) {
+ SET_STAT_INVALID(smb_fname->st);
errno = ENOENT;
result = -1;
goto fail;
@@ -369,10 +371,11 @@ static int streams_xattr_lstat(vfs_handle_struct *handle,
}
/* Augment the base file's stat information before returning. */
- smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
+ smb_fname->st.st_ex_size = get_xattr_size(handle->conn,
smb_fname,
xattr_name);
if (smb_fname->st.st_ex_size == -1) {
+ SET_STAT_INVALID(smb_fname->st);
errno = ENOENT;
result = -1;
goto fail;
@@ -396,14 +399,17 @@ static int streams_xattr_open(vfs_handle_struct *handle,
files_struct *fsp, int flags, mode_t mode)
{
NTSTATUS status;
- struct smb_filename *smb_fname_base = NULL;
- struct stream_io *sio;
+ struct streams_xattr_config *config = NULL;
+ struct stream_io *sio = NULL;
struct ea_struct ea;
char *xattr_name = NULL;
- int baseflags;
- int hostfd = -1;
+ int pipe_fds[2];
+ int fakefd = -1;
int ret;
+ SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
+ return -1);
+
DEBUG(10, ("streams_xattr_open called for %s with flags 0x%x\n",
smb_fname_str_dbg(smb_fname), flags));
@@ -432,44 +438,18 @@ static int streams_xattr_open(vfs_handle_struct *handle,
goto fail;
}
- /* Create an smb_filename with stream_name == NULL. */
- smb_fname_base = synthetic_smb_fname(talloc_tos(),
- smb_fname->base_name,
- NULL,
- NULL,
- smb_fname->flags);
- if (smb_fname_base == NULL) {
- errno = ENOMEM;
+ /*
+ * Return a valid fd, but ensure any attempt to use it returns an error
+ * (EPIPE).
+ */
+ ret = pipe(pipe_fds);
+ if (ret != 0) {
goto fail;
}
- /*
- * We use baseflags to turn off nasty side-effects when opening the
--
Samba Shared Repository
More information about the samba-cvs
mailing list