2 Unix SMB/CIFS implementation.
4 POSIX NTVFS backend - mkdir and rmdir
6 Copyright (C) Andrew Tridgell 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "vfs_posix.h"
27 create a directory with EAs
29 static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs,
30 struct smbsrv_request *req, union smb_mkdir *md)
33 struct pvfs_filename *name;
36 /* resolve the cifs name to a posix name */
37 status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name);
38 if (!NT_STATUS_IS_OK(status)) {
43 return NT_STATUS_OBJECT_NAME_COLLISION;
46 mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
48 if (mkdir(name->full_name, mode) == -1) {
49 return pvfs_map_errno(pvfs, errno);
52 status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name);
53 if (!NT_STATUS_IS_OK(status)) {
57 !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) {
58 return NT_STATUS_INTERNAL_ERROR;
61 /* setup any EAs that were asked for */
62 status = pvfs_setfileinfo_ea_set(pvfs, name, -1,
63 md->t2mkdir.in.num_eas,
65 if (!NT_STATUS_IS_OK(status)) {
66 rmdir(name->full_name);
76 NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs,
77 struct smbsrv_request *req, union smb_mkdir *md)
79 struct pvfs_state *pvfs = ntvfs->private_data;
81 struct pvfs_filename *name;
84 if (md->generic.level == RAW_MKDIR_T2MKDIR) {
85 return pvfs_t2mkdir(pvfs, req, md);
88 if (md->generic.level != RAW_MKDIR_MKDIR) {
89 return NT_STATUS_INVALID_LEVEL;
92 /* resolve the cifs name to a posix name */
93 status = pvfs_resolve_name(pvfs, req, md->mkdir.in.path, 0, &name);
94 if (!NT_STATUS_IS_OK(status)) {
99 return NT_STATUS_OBJECT_NAME_COLLISION;
102 mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
104 if (mkdir(name->full_name, mode) == -1) {
105 return pvfs_map_errno(pvfs, errno);
114 NTSTATUS pvfs_rmdir(struct ntvfs_module_context *ntvfs,
115 struct smbsrv_request *req, struct smb_rmdir *rd)
117 struct pvfs_state *pvfs = ntvfs->private_data;
119 struct pvfs_filename *name;
121 /* resolve the cifs name to a posix name */
122 status = pvfs_resolve_name(pvfs, req, rd->in.path, 0, &name);
123 if (!NT_STATUS_IS_OK(status)) {
128 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
131 status = pvfs_xattr_unlink_hook(pvfs, name->full_name);
132 if (!NT_STATUS_IS_OK(status)) {
136 if (rmdir(name->full_name) == -1) {
137 return pvfs_map_errno(pvfs, errno);