summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/ntvfs')
-rw-r--r--source4/ntvfs/posix/pvfs_dirlist.c24
-rw-r--r--source4/ntvfs/posix/pvfs_open.c3
2 files changed, 27 insertions, 0 deletions
diff --git a/source4/ntvfs/posix/pvfs_dirlist.c b/source4/ntvfs/posix/pvfs_dirlist.c
index a5d394d2aa..a055773b51 100644
--- a/source4/ntvfs/posix/pvfs_dirlist.c
+++ b/source4/ntvfs/posix/pvfs_dirlist.c
@@ -310,3 +310,27 @@ NTSTATUS pvfs_list_seek(struct pvfs_dir *dir, const char *name, uint_t *ofs)
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
+
+
+/*
+ see if a directory is empty
+*/
+BOOL pvfs_directory_empty(struct pvfs_state *pvfs, struct pvfs_filename *name)
+{
+ struct dirent *de;
+ DIR *dir = opendir(name->full_name);
+ if (dir == NULL) {
+ return True;
+ }
+
+ while ((de = readdir(dir))) {
+ if (strcmp(de->d_name, ".") != 0 &&
+ strcmp(de->d_name, "..") != 0) {
+ closedir(dir);
+ return False;
+ }
+ }
+
+ closedir(dir);
+ return True;
+}
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index d0e7d82117..3ae8e2150f 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -1244,6 +1244,9 @@ NTSTATUS pvfs_change_create_options(struct pvfs_state *pvfs,
}
if (f->handle->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+ if (!pvfs_directory_empty(pvfs, f->handle->name)) {
+ return NT_STATUS_DIRECTORY_NOT_EMPTY;
+ }
f->handle->create_options = create_options;
return NT_STATUS_OK;
}