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;
37 /* resolve the cifs name to a posix name */
38 status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name);
39 if (!NT_STATUS_IS_OK(status)) {
44 return NT_STATUS_OBJECT_NAME_COLLISION;
47 mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
49 if (mkdir(name->full_name, mode) == -1) {
50 return pvfs_map_errno(pvfs, errno);
53 status = pvfs_resolve_name(pvfs, req, md->t2mkdir.in.path, 0, &name);
54 if (!NT_STATUS_IS_OK(status)) {
58 !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) {
59 return NT_STATUS_INTERNAL_ERROR;
62 /* setup any EAs that were asked for */
63 for (i=0;i<md->t2mkdir.in.num_eas;i++) {
64 status = pvfs_setfileinfo_ea_set(pvfs, name, -1, &md->t2mkdir.in.eas[i]);
65 if (!NT_STATUS_IS_OK(status)) {
66 rmdir(name->full_name);
77 NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs,
78 struct smbsrv_request *req, union smb_mkdir *md)
80 struct pvfs_state *pvfs = ntvfs->private_data;
82 struct pvfs_filename *name;
85 if (md->generic.level == RAW_MKDIR_T2MKDIR) {
86 return pvfs_t2mkdir(pvfs, req, md);
89 if (md->generic.level != RAW_MKDIR_MKDIR) {
90 return NT_STATUS_INVALID_LEVEL;
93 /* resolve the cifs name to a posix name */
94 status = pvfs_resolve_name(pvfs, req, md->mkdir.in.path, 0, &name);
95 if (!NT_STATUS_IS_OK(status)) {
100 return NT_STATUS_OBJECT_NAME_COLLISION;
103 mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
105 if (mkdir(name->full_name, mode) == -1) {
106 return pvfs_map_errno(pvfs, errno);
115 NTSTATUS pvfs_rmdir(struct ntvfs_module_context *ntvfs,
116 struct smbsrv_request *req, struct smb_rmdir *rd)
118 struct pvfs_state *pvfs = ntvfs->private_data;
120 struct pvfs_filename *name;
122 /* resolve the cifs name to a posix name */
123 status = pvfs_resolve_name(pvfs, req, rd->in.path, 0, &name);
124 if (!NT_STATUS_IS_OK(status)) {
129 return NT_STATUS_OBJECT_NAME_NOT_FOUND;
132 if (rmdir(name->full_name) == -1) {
133 return pvfs_map_errno(pvfs, errno);