smb: rename NTCREATEX_OPTIONS_PRIVATE_DENY_FCB to NTCREATEX_FLAG_DENY_FCB
[samba.git] / source4 / ntvfs / ntvfs_generic.c
index 3319539b63d5361844aacbf4faff120bcfe6be62..de0ae2ce8280363c4eaf7b4afe3d11b7e0078cfb 100644 (file)
@@ -35,6 +35,8 @@
 #include "libcli/smb2/smb2.h"
 #include "libcli/smb2/smb2_calls.h"
 
+#undef strcasecmp
+
 /* a second stage function converts from the out parameters of the generic
    call onto the out parameters of the specific call made */
 typedef NTSTATUS (*second_stage_t)(struct ntvfs_module_context *,
@@ -148,7 +150,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
        time_t write_time = 0;
        uint32_t set_size = 0;
        union smb_setfileinfo *sf;
-       uint_t state;
+       unsigned int state;
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -236,6 +238,8 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
                io->smb2.out.file_attr          = io2->generic.out.attrib;
                io->smb2.out.reserved2          = 0;
                io->smb2.out.maximal_access     = io2->generic.out.maximal_access;
+               memcpy(io->smb2.out.on_disk_id, io2->generic.out.on_disk_id,
+                      sizeof(io2->generic.out.on_disk_id));
                break;
 
        default:
@@ -255,7 +259,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
                sf->standard.in.create_time = 0;
                sf->standard.in.write_time  = write_time;
                sf->standard.in.access_time = 0;
-               status = ntvfs->ops->setfileinfo(ntvfs, req, sf);
+               status = ntvfs->ops->setfileinfo_fn(ntvfs, req, sf);
        }
 
        if (set_size != 0) {
@@ -264,7 +268,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
                sf->generic.level            = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
                sf->generic.in.file.ntvfs    = io2->generic.out.file.ntvfs;
                sf->end_of_file_info.in.size = set_size;
-               status = ntvfs->ops->setfileinfo(ntvfs, req, sf);
+               status = ntvfs->ops->setfileinfo_fn(ntvfs, req, sf);
                if (NT_STATUS_IS_OK(status)) {
                        io->openx.out.size = io->openx.in.size;
                }
@@ -284,6 +288,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode,
                               union smb_open *io2)
 {
        io2->generic.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
+       io2->generic.in.private_flags = 0;
 
        if (flags & OPENX_FLAGS_REQUEST_OPLOCK) {
                io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK;
@@ -327,8 +332,8 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode,
                break;
        case OPENX_MODE_DENY_DOS:
                /* DENY_DOS is quite strange - it depends on the filename! */
-               io2->generic.in.create_options |= 
-                       NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
+               io2->generic.in.private_flags |=
+                       NTCREATEX_FLAG_DENY_DOS;
                if (is_exe_filename(fname)) {
                        io2->generic.in.share_access = 
                                NTCREATEX_SHARE_ACCESS_READ | 
@@ -342,7 +347,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode,
                }
                break;
        case OPENX_MODE_DENY_FCB:
-               io2->generic.in.create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
+               io2->generic.in.private_flags |= NTCREATEX_FLAG_DENY_FCB;
                io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
                break;
        default:
@@ -415,7 +420,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.file_attr = io->openx.in.file_attrs;
                io2->generic.in.fname = io->openx.in.fname;
                
-               status = ntvfs->ops->open(ntvfs, req, io2);
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
                
                
@@ -432,7 +437,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.file_attr = io->openold.in.search_attrs;
                io2->generic.in.fname = io->openold.in.fname;
 
-               status = ntvfs->ops->open(ntvfs, req, io2);
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
 
        case RAW_OPEN_T2OPEN:
@@ -458,7 +463,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.ea_list->num_eas = io->t2open.in.num_eas;
                io2->generic.in.ea_list->eas     = io->t2open.in.eas;
 
-               status = ntvfs->ops->open(ntvfs, req, io2);
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
 
        case RAW_OPEN_MKNEW:
@@ -471,7 +476,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.share_access = 
                        NTCREATEX_SHARE_ACCESS_READ | 
                        NTCREATEX_SHARE_ACCESS_WRITE;
-               status = ntvfs->ops->open(ntvfs, req, io2);
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
 
        case RAW_OPEN_CREATE:
@@ -484,7 +489,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.share_access = 
                        NTCREATEX_SHARE_ACCESS_READ | 
                        NTCREATEX_SHARE_ACCESS_WRITE;
-               status = ntvfs->ops->open(ntvfs, req, io2);
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
 
        case RAW_OPEN_CTEMP:
@@ -500,7 +505,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.share_access = 
                        NTCREATEX_SHARE_ACCESS_READ | 
                        NTCREATEX_SHARE_ACCESS_WRITE;
-               status = ntvfs->ops->open(ntvfs, req, io2);
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
        case RAW_OPEN_SMB2:
                switch (io->smb2.in.oplock_level) {
@@ -528,6 +533,8 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.sec_desc        = io->smb2.in.sec_desc;
                io2->generic.in.ea_list         = &io->smb2.in.eas;
                io2->generic.in.query_maximal_access = io->smb2.in.query_maximal_access; 
+               io2->generic.in.query_on_disk_id = io->smb2.in.query_on_disk_id;
+               io2->generic.in.private_flags   = 0;
 
                /* we don't support timewarp yet */
                if (io->smb2.in.timewarp != 0) {
@@ -547,7 +554,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.create_options &= ~NTCREATEX_OPTIONS_SYNC_ALERT;
                io2->generic.in.create_options &= ~NTCREATEX_OPTIONS_ASYNC_ALERT;
 
-               status = ntvfs->ops->open(ntvfs, req, io2);             
+               status = ntvfs->ops->open_fn(ntvfs, req, io2);
                break;
 
        default:
@@ -574,12 +581,9 @@ static NTSTATUS ntvfs_map_fsinfo_finish(struct ntvfs_module_context *ntvfs,
 
        /* and convert it to the required level */
        switch (fs->generic.level) {
-       case RAW_QFS_GENERIC:
-               return NT_STATUS_INVALID_LEVEL;
-
        case RAW_QFS_DSKATTR: {
                /* map from generic to DSKATTR */
-               uint_t bpunit = 64;
+               unsigned int bpunit = 64;
 
                /* we need to scale the sizes to fit */
                for (bpunit=64; bpunit<0x10000; bpunit *= 2) {
@@ -664,8 +668,27 @@ static NTSTATUS ntvfs_map_fsinfo_finish(struct ntvfs_module_context *ntvfs,
                fs->objectid_information.out.guid = fs2->generic.out.guid;
                ZERO_STRUCT(fs->objectid_information.out.unknown);
                return NT_STATUS_OK;
-       }
 
+       case RAW_QFS_SECTOR_SIZE_INFORMATION:
+               fs->sector_size_info.out.logical_bytes_per_sector
+                                               = fs2->generic.out.block_size;
+               fs->sector_size_info.out.phys_bytes_per_sector_atomic
+                                               = fs2->generic.out.block_size;
+               fs->sector_size_info.out.phys_bytes_per_sector_perf
+                                               = fs2->generic.out.block_size;
+               fs->sector_size_info.out.fs_effective_phys_bytes_per_sector_atomic
+                                               = fs2->generic.out.block_size;
+               fs->sector_size_info.out.flags
+                                       = QFS_SSINFO_FLAGS_ALIGNED_DEVICE
+                               | QFS_SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE;
+               fs->sector_size_info.out.byte_off_sector_align = 0;
+               fs->sector_size_info.out.byte_off_partition_align = 0;
+               return NT_STATUS_OK;
+
+       case RAW_QFS_GENERIC:
+       case RAW_QFS_UNIX_INFO:
+               return NT_STATUS_INVALID_LEVEL;
+       }
 
        return NT_STATUS_INVALID_LEVEL;
 }
@@ -698,7 +721,7 @@ NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs,
        /* ask the backend for the generic info */
        fs2->generic.level = RAW_QFS_GENERIC;
 
-       status = ntvfs->ops->fsinfo(ntvfs, req, fs2);
+       status = ntvfs->ops->fsinfo_fn(ntvfs, req, fs2);
        return ntvfs_map_async_finish(req, status);
 }
 
@@ -713,8 +736,6 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
        int i;
        /* and convert it to the required level using results in info2 */
        switch (info->generic.level) {
-               case RAW_FILEINFO_GENERIC:
-               return NT_STATUS_INVALID_LEVEL;
        case RAW_FILEINFO_GETATTR:
                info->getattr.out.attrib = info2->generic.out.attrib & 0xff;
                info->getattr.out.size = info2->generic.out.size;
@@ -843,6 +864,7 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
                
        case RAW_FILEINFO_ALT_NAME_INFO:
        case RAW_FILEINFO_ALT_NAME_INFORMATION:
+       case RAW_FILEINFO_SMB2_ALT_NAME_INFORMATION:
                info->alt_name_info.out.fname.s = talloc_strdup(mem_ctx, info2->generic.out.alt_fname.s);
                NT_STATUS_HAVE_NO_MEMORY(info->alt_name_info.out.fname.s);
                info->alt_name_info.out.fname.private_length = info2->generic.out.alt_fname.private_length;
@@ -908,8 +930,10 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
                info->alignment_information.out.alignment_requirement =
                        info2->generic.out.alignment_requirement;
                return NT_STATUS_OK;
-#if 0  
        case RAW_FILEINFO_UNIX_BASIC:
+#if 1
+               return NT_STATUS_INVALID_LEVEL;
+#else
                info->unix_basic_info.out.end_of_file = info2->generic.out.end_of_file;
                info->unix_basic_info.out.num_bytes = info2->generic.out.size;
                info->unix_basic_info.out.status_change_time = info2->generic.out.change_time;
@@ -924,11 +948,23 @@ NTSTATUS ntvfs_map_fileinfo(TALLOC_CTX *mem_ctx,
                info->unix_basic_info.out.permissions = info2->generic.out.permissions;
                info->unix_basic_info.out.nlink = info2->generic.out.nlink;
                return NT_STATUS_OK;
-               
+#endif
        case RAW_FILEINFO_UNIX_LINK:
+#if 1
+               return NT_STATUS_INVALID_LEVEL;
+#else
                info->unix_link_info.out.link_dest = info2->generic.out.link_dest;
                return NT_STATUS_OK;
 #endif
+       case RAW_FILEINFO_GENERIC:
+       case RAW_FILEINFO_SEC_DESC:
+       case RAW_FILEINFO_EA_LIST:
+       case RAW_FILEINFO_UNIX_INFO2:
+       case RAW_FILEINFO_SMB2_ALL_EAS:
+       case RAW_FILEINFO_SMB2_ALL_INFORMATION:
+               return NT_STATUS_INVALID_LEVEL;
+       case RAW_FILEINFO_NORMALIZED_NAME_INFORMATION:
+               return NT_STATUS_NOT_SUPPORTED;
        }
 
        return NT_STATUS_INVALID_LEVEL;
@@ -979,7 +1015,7 @@ NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs,
        info2->generic.level = RAW_FILEINFO_GENERIC;
        info2->generic.in.file.ntvfs= info->generic.in.file.ntvfs;
 
-       status = ntvfs->ops->qfileinfo(ntvfs, req, info2);
+       status = ntvfs->ops->qfileinfo_fn(ntvfs, req, info2);
        return ntvfs_map_async_finish(req, status);
 }
 
@@ -1028,7 +1064,7 @@ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs,
        info2->generic.level            = RAW_FILEINFO_GENERIC;
        info2->generic.in.file.path     = info->generic.in.file.path;
 
-       status = ntvfs->ops->qpathinfo(ntvfs, req, info2);
+       status = ntvfs->ops->qpathinfo_fn(ntvfs, req, info2);
        return ntvfs_map_async_finish(req, status);
 }
 
@@ -1116,7 +1152,8 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
                        isunlock = false;
                }
                for (i=0;i<lck->smb2.in.lock_count;i++) {
-                       if (lck->smb2.in.locks[i].flags == SMB2_LOCK_FLAG_NONE) {
+                       if (!isunlock &&
+                           lck->smb2.in.locks[i].flags == SMB2_LOCK_FLAG_NONE) {
                                return NT_STATUS_INVALID_PARAMETER;
                        }
 
@@ -1171,7 +1208,7 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
         * as lock() doesn't have any output fields
         */
 
-       return ntvfs->ops->lock(ntvfs, req, lck2);
+       return ntvfs->ops->lock_fn(ntvfs, req, lck2);
 }
 
 
@@ -1186,7 +1223,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs,
 {
        union smb_lock *lck;
        union smb_close *cl;
-       uint_t state;
+       unsigned int state;
 
        if (NT_STATUS_IS_ERR(status)) {
                return status;
@@ -1214,7 +1251,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs,
                        /* do the lock sync for now */
                        state = req->async_states->state;
                        req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC;
-                       status = ntvfs->ops->lock(ntvfs, req, lck);
+                       status = ntvfs->ops->lock_fn(ntvfs, req, lck);
                        req->async_states->state = state;
                }
                break;
@@ -1235,7 +1272,7 @@ static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs,
                        /* do the close sync for now */
                        state = req->async_states->state;
                        req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC;
-                       status = ntvfs->ops->close(ntvfs, req, cl);
+                       status = ntvfs->ops->close_fn(ntvfs, req, cl);
                        req->async_states->state = state;
                }
                break;
@@ -1292,7 +1329,7 @@ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs,
                wr2->writex.in.remaining = wr->write.in.remaining;
                wr2->writex.in.count     = wr->write.in.count;
                wr2->writex.in.data      = wr->write.in.data;
-               status = ntvfs->ops->write(ntvfs, req, wr2);
+               status = ntvfs->ops->write_fn(ntvfs, req, wr2);
                break;
 
        case RAW_WRITE_WRITEUNLOCK:
@@ -1302,7 +1339,7 @@ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs,
                wr2->writex.in.remaining = wr->writeunlock.in.remaining;
                wr2->writex.in.count     = wr->writeunlock.in.count;
                wr2->writex.in.data      = wr->writeunlock.in.data;
-               status = ntvfs->ops->write(ntvfs, req, wr2);
+               status = ntvfs->ops->write_fn(ntvfs, req, wr2);
                break;
 
        case RAW_WRITE_WRITECLOSE:
@@ -1312,7 +1349,7 @@ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs,
                wr2->writex.in.remaining = 0;
                wr2->writex.in.count     = wr->writeclose.in.count;
                wr2->writex.in.data      = wr->writeclose.in.data;
-               status = ntvfs->ops->write(ntvfs, req, wr2);
+               status = ntvfs->ops->write_fn(ntvfs, req, wr2);
                break;
 
        case RAW_WRITE_SPLWRITE:
@@ -1322,7 +1359,7 @@ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs,
                wr2->writex.in.remaining = 0;
                wr2->writex.in.count     = wr->splwrite.in.count;
                wr2->writex.in.data      = wr->splwrite.in.data;
-               status = ntvfs->ops->write(ntvfs, req, wr2);
+               status = ntvfs->ops->write_fn(ntvfs, req, wr2);
                break;
 
        case RAW_WRITE_SMB2:
@@ -1332,7 +1369,7 @@ NTSTATUS ntvfs_map_write(struct ntvfs_module_context *ntvfs,
                wr2->writex.in.remaining = 0;
                wr2->writex.in.count     = wr->smb2.in.data.length;
                wr2->writex.in.data      = wr->smb2.in.data.data;
-               status = ntvfs->ops->write(ntvfs, req, wr2);
+               status = ntvfs->ops->write_fn(ntvfs, req, wr2);
        }
 
        return ntvfs_map_async_finish(req, status);
@@ -1380,7 +1417,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
        union smb_read *rd2;
        union smb_lock *lck;
        NTSTATUS status;
-       uint_t state;
+       unsigned int state;
 
        rd2 = talloc(req, union smb_read);
        if (rd2 == NULL) {
@@ -1408,7 +1445,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
                rd2->readx.in.maxcnt    = rd->read.in.count;
                rd2->readx.in.remaining = rd->read.in.remaining;
                rd2->readx.out.data     = rd->read.out.data;
-               status = ntvfs->ops->read(ntvfs, req, rd2);
+               status = ntvfs->ops->read_fn(ntvfs, req, rd2);
                break;
 
        case RAW_READ_READBRAW:
@@ -1418,7 +1455,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
                rd2->readx.in.maxcnt    = rd->readbraw.in.maxcnt;
                rd2->readx.in.remaining = 0;
                rd2->readx.out.data     = rd->readbraw.out.data;
-               status = ntvfs->ops->read(ntvfs, req, rd2);
+               status = ntvfs->ops->read_fn(ntvfs, req, rd2);
                break;
 
        case RAW_READ_LOCKREAD:
@@ -1435,7 +1472,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
                lck->lock.in.file.ntvfs = rd->lockread.in.file.ntvfs;
                lck->lock.in.count      = rd->lockread.in.count;
                lck->lock.in.offset     = rd->lockread.in.offset;
-               status = ntvfs->ops->lock(ntvfs, req, lck);
+               status = ntvfs->ops->lock_fn(ntvfs, req, lck);
                req->async_states->state = state;
 
                rd2->readx.in.file.ntvfs= rd->lockread.in.file.ntvfs;
@@ -1446,7 +1483,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
                rd2->readx.out.data     = rd->lockread.out.data;
 
                if (NT_STATUS_IS_OK(status)) {
-                       status = ntvfs->ops->read(ntvfs, req, rd2);
+                       status = ntvfs->ops->read_fn(ntvfs, req, rd2);
                }
                break;
 
@@ -1457,7 +1494,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
                rd2->readx.in.maxcnt    = rd->smb2.in.length;
                rd2->readx.in.remaining = 0;
                rd2->readx.out.data     = rd->smb2.out.data.data;
-               status = ntvfs->ops->read(ntvfs, req, rd2);
+               status = ntvfs->ops->read_fn(ntvfs, req, rd2);
                break;
        }
 
@@ -1541,7 +1578,7 @@ NTSTATUS ntvfs_map_close(struct ntvfs_module_context *ntvfs,
                                       (second_stage_t)ntvfs_map_close_finish);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       status = ntvfs->ops->close(ntvfs, req, cl2);
+       status = ntvfs->ops->close_fn(ntvfs, req, cl2);
 
        return ntvfs_map_async_finish(req, status);
 }
@@ -1560,7 +1597,7 @@ static NTSTATUS ntvfs_map_notify_finish(struct ntvfs_module_context *ntvfs,
        switch (nt->nttrans.level) {
        case RAW_NOTIFY_SMB2:
                if (nt2->nttrans.out.num_changes == 0) {
-                       return STATUS_NOTIFY_ENUM_DIR;
+                       return NT_STATUS_NOTIFY_ENUM_DIR;
                }
                nt->smb2.out.num_changes        = nt2->nttrans.out.num_changes;
                nt->smb2.out.changes            = talloc_steal(req, nt2->nttrans.out.changes);
@@ -1603,7 +1640,7 @@ NTSTATUS ntvfs_map_notify(struct ntvfs_module_context *ntvfs,
                nt2->nttrans.in.buffer_size             = nt->smb2.in.buffer_size;
                nt2->nttrans.in.completion_filter       = nt->smb2.in.completion_filter;
                nt2->nttrans.in.recursive               = nt->smb2.in.recursive;
-               status = ntvfs->ops->notify(ntvfs, req, nt2);
+               status = ntvfs->ops->notify_fn(ntvfs, req, nt2);
                break;
        }