r3351: handle far more operations on open directory handles. pvfs was failing
authorAndrew Tridgell <tridge@samba.org>
Fri, 29 Oct 2004 04:43:28 +0000 (04:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:04:58 +0000 (13:04 -0500)
with a wxp client because of qfileinfo operations on directories
failing with NT_STATUS_INVALID_HANDLE after the fstat() failed (as
pvfs sets f->fd to -1 for directories)
(This used to be commit 1993128cb1dbf49db6e3e0387996ecf2a14b8d76)

source4/ntvfs/posix/pvfs_flush.c
source4/ntvfs/posix/pvfs_resolve.c
source4/ntvfs/posix/pvfs_setfileinfo.c

index 49eaa74cfbba23dc94aa77fc4bded9063e463d33..43893af80da19c146aaecd6b2c79db12270ba6e8 100644 (file)
@@ -28,6 +28,9 @@
 */
 static void pvfs_flush_file(struct pvfs_state *pvfs, struct pvfs_file *f)
 {
+       if (f->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+               return;
+       }
        if (pvfs->flags & PVFS_FLAG_STRICT_SYNC) {
                fsync(f->fd);
        }
index 75fbeb39a5f2359417d9e174e42906c5cab5a7a6..be1662437e0c9acaae7645d3ff4cce5828ddfcaa 100644 (file)
@@ -510,8 +510,14 @@ NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd,
                inode = name->st.st_ino;
        }
 
-       if (fstat(fd, &name->st) == -1) {
-               return NT_STATUS_INVALID_HANDLE;
+       if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+               if (stat(name->full_name, &name->st) == -1) {
+                       return NT_STATUS_INVALID_HANDLE;
+               }
+       } else {
+               if (fstat(fd, &name->st) == -1) {
+                       return NT_STATUS_INVALID_HANDLE;
+               }
        }
 
        if (name->exists &&
index bba3ee3747a8e97787cf50fd85a5484b7191a97d..bc96f25fecdc37573b5f273dc2b51eea37ac2ac0 100644 (file)
@@ -128,6 +128,9 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
 
        /* possibly change the file size */
        if (newstats.st.st_size != f->name->st.st_size) {
+               if (f->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+                       return NT_STATUS_FILE_IS_A_DIRECTORY;
+               }
                if (ftruncate(f->fd, newstats.st.st_size) == -1) {
                        return pvfs_map_errno(pvfs, errno);
                }
@@ -150,6 +153,10 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
        /* possibly change the attribute */
        if (newstats.dos.attrib != f->name->dos.attrib) {
                mode_t mode = pvfs_fileperms(pvfs, newstats.dos.attrib);
+               if (f->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+                       /* ignore on directories for now */
+                       return NT_STATUS_OK;
+               }
                if (fchmod(f->fd, mode) == -1) {
                        return pvfs_map_errno(pvfs, errno);
                }