summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-03 17:22:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:06 -0500
commit5ef83290bc4db2ac409b0de32f459aef3c52faeb (patch)
tree7a4808e4c9a9c2229415cdaf79e8a3f1df6ead28 /source4/ntvfs
parentd4c4f16f944f33188077200c69df0c876bdf8c7f (diff)
downloadsamba-5ef83290bc4db2ac409b0de32f459aef3c52faeb.tar.gz
samba-5ef83290bc4db2ac409b0de32f459aef3c52faeb.tar.bz2
samba-5ef83290bc4db2ac409b0de32f459aef3c52faeb.zip
r9007: fixed error code for setting delete on close on a non-empty directory
(This used to be commit 320ab3c93b05a79b77dbbb85e9b038bb07848ba5)
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;
}