From 275df9a5c3b1ade9f2467870c3628a2a896c004c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 2004 23:57:59 +0000 Subject: r4182: fixed trans2 mkdir, allowing mkdir with an initial EA list (This used to be commit 7d981c29c28391813c7f93245f64b3ee108378a4) --- source4/ntvfs/posix/pvfs_mkdir.c | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'source4/ntvfs') diff --git a/source4/ntvfs/posix/pvfs_mkdir.c b/source4/ntvfs/posix/pvfs_mkdir.c index 1bc0fa569e..b43e67faed 100644 --- a/source4/ntvfs/posix/pvfs_mkdir.c +++ b/source4/ntvfs/posix/pvfs_mkdir.c @@ -23,6 +23,54 @@ #include "includes.h" #include "vfs_posix.h" +/* + create a directory with EAs +*/ +static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs, + struct smbsrv_request *req, union smb_mkdir *md) +{ + NTSTATUS status; + struct pvfs_filename *name; + mode_t mode; + int i; + + /* resolve the cifs name to a posix name */ + status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (name->exists) { + return NT_STATUS_OBJECT_NAME_COLLISION; + } + + mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY); + + if (mkdir(name->full_name, mode) == -1) { + return pvfs_map_errno(pvfs, errno); + } + + status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + if (!name->exists || + !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) { + return NT_STATUS_INTERNAL_ERROR; + } + + /* setup any EAs that were asked for */ + for (i=0;it2mkdir.in.num_eas;i++) { + status = pvfs_setfileinfo_ea_set(pvfs, name, -1, &md->t2mkdir.in.eas[i]); + if (!NT_STATUS_IS_OK(status)) { + rmdir(name->full_name); + return status; + } + } + + return NT_STATUS_OK; +} + /* create a directory */ @@ -34,6 +82,10 @@ NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs, struct pvfs_filename *name; mode_t mode; + if (md->generic.level == RAW_MKDIR_T2MKDIR) { + return pvfs_t2mkdir(pvfs, req, md); + } + if (md->generic.level != RAW_MKDIR_MKDIR) { return NT_STATUS_INVALID_LEVEL; } -- cgit