summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-02-28 05:48:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:52:09 -0500
commit4d3cc7384338fe2182a2029c2e6d2fcca2ec8813 (patch)
treeb8497d434585cba3f33900c1a411a3ed1087ddbf /source4/ntvfs/posix
parente1380d63a0d85120ebf25d228b1bf6f8c6604d99 (diff)
downloadsamba-4d3cc7384338fe2182a2029c2e6d2fcca2ec8813.tar.gz
samba-4d3cc7384338fe2182a2029c2e6d2fcca2ec8813.tar.bz2
samba-4d3cc7384338fe2182a2029c2e6d2fcca2ec8813.zip
r13745: remove some code I was experimenting with and forgot was there when I
committed that will teach me to run svn diff before committing .... (This used to be commit ef6e30c72cf610728584dfab1755b47bfc53f01c)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c349
1 files changed, 0 insertions, 349 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index a8c0bba97f..e24887ca96 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -183,354 +183,6 @@ static NTSTATUS pvfs_locking_key(struct pvfs_filename *name,
/*
- create a new directory
-*/
-static NTSTATUS pvfs_create_directory(struct pvfs_state *pvfs,
- struct smbsrv_request *req,
- struct pvfs_filename *name,
- union smb_open *io)
-{
- struct pvfs_file *f;
- NTSTATUS status;
- int fnum, ret;
- struct odb_lock *lck;
- uint32_t create_options = io->generic.in.create_options;
- uint32_t share_access = io->generic.in.share_access;
- uint32_t access_mask = io->generic.in.access_mask;
- mode_t mode;
- uint32_t attrib;
- BOOL del_on_close;
-
- if ((io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) &&
- (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
- return NT_STATUS_CANNOT_DELETE;
- }
-
- status = pvfs_access_check_create(pvfs, req, name, &access_mask);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- f = talloc(req, struct pvfs_file);
- if (f == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- f->handle = talloc(f, struct pvfs_file_handle);
- if (f->handle == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- fnum = idr_get_new_above(pvfs->idtree_fnum, f, PVFS_MIN_NEW_FNUM, UINT16_MAX);
- if (fnum == -1) {
- return NT_STATUS_TOO_MANY_OPENED_FILES;
- }
-
- attrib = io->ntcreatex.in.file_attr | FILE_ATTRIBUTE_DIRECTORY;
- mode = pvfs_fileperms(pvfs, attrib);
-
- /* create the directory */
- ret = mkdir(name->full_name, mode);
- if (ret == -1) {
- idr_remove(pvfs->idtree_fnum, fnum);
- return pvfs_map_errno(pvfs, errno);
- }
-
- pvfs_xattr_unlink_hook(pvfs, name->full_name);
-
- /* re-resolve the new directory */
- status = pvfs_resolve_name_fd(pvfs, -1, name);
- if (!NT_STATUS_IS_OK(status)) {
- idr_remove(pvfs->idtree_fnum, fnum);
- rmdir(name->full_name);
- return status;
- }
-
- name->dos.attrib = attrib;
-
- status = pvfs_open_setup_eas_acl(pvfs, req, name, -1, fnum, io);
- if (!NT_STATUS_IS_OK(status)) {
- goto cleanup_delete;
- }
-
- /* form the lock context used for opendb locking */
- status = pvfs_locking_key(name, f->handle, &f->handle->odb_locking_key);
- if (!NT_STATUS_IS_OK(status)) {
- goto cleanup_delete;
- }
-
- /* grab a lock on the open file record */
- lck = odb_lock(req, pvfs->odb_context, &f->handle->odb_locking_key);
- if (lck == NULL) {
- DEBUG(0,("pvfs_open: failed to lock file '%s' in opendb\n",
- name->full_name));
- /* we were supposed to do a blocking lock, so something
- is badly wrong! */
- status = NT_STATUS_INTERNAL_DB_CORRUPTION;
- goto cleanup_delete;
- }
-
- if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) {
- del_on_close = True;
- } else {
- del_on_close = False;
- }
-
- status = odb_open_file(lck, f->handle, name->stream_id,
- share_access, access_mask, del_on_close, name->full_name);
- talloc_free(lck);
- if (!NT_STATUS_IS_OK(status)) {
- /* bad news, we must have hit a race */
- idr_remove(pvfs->idtree_fnum, fnum);
- return status;
- }
-
- f->fnum = fnum;
- f->session = req->session;
- f->smbpid = req->smbpid;
- f->pvfs = pvfs;
- f->pending_list = NULL;
- f->lock_count = 0;
- f->share_access = io->generic.in.share_access;
- f->access_mask = access_mask;
- f->impersonation = io->generic.in.impersonation;
-
- f->handle->pvfs = pvfs;
- f->handle->name = talloc_steal(f->handle, name);
- f->handle->fd = -1;
- f->handle->create_options = io->generic.in.create_options;
- f->handle->seek_offset = 0;
- f->handle->position = 0;
- f->handle->mode = 0;
- f->handle->have_opendb_entry = True;
- f->handle->sticky_write_time = False;
-
- DLIST_ADD(pvfs->open_files, f);
-
- /* setup a destructor to avoid file descriptor leaks on
- abnormal termination */
- talloc_set_destructor(f, pvfs_dir_fnum_destructor);
- talloc_set_destructor(f->handle, pvfs_dir_handle_destructor);
-
- io->generic.out.oplock_level = OPLOCK_NONE;
- io->generic.out.fnum = f->fnum;
- io->generic.out.create_action = NTCREATEX_ACTION_CREATED;
- io->generic.out.create_time = name->dos.create_time;
- io->generic.out.access_time = name->dos.access_time;
- io->generic.out.write_time = name->dos.write_time;
- io->generic.out.change_time = name->dos.change_time;
- io->generic.out.attrib = name->dos.attrib;
- io->generic.out.alloc_size = name->dos.alloc_size;
- io->generic.out.size = name->st.st_size;
- io->generic.out.file_type = FILE_TYPE_DISK;
- io->generic.out.ipc_state = 0;
- io->generic.out.is_directory = 0;
-
- /* success - keep the file handle */
- talloc_steal(pvfs, f);
-
- return NT_STATUS_OK;
-
-cleanup_delete:
- idr_remove(pvfs->idtree_fnum, fnum);
- rmdir(name->full_name);
- return status;
-}
-
-#if 0
-/*
- open a directory
-*/
-static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
- struct smbsrv_request *req,
- struct pvfs_filename *name,
- union smb_open *io)
-{
- struct pvfs_file *f;
- NTSTATUS status;
- int fnum;
- struct odb_lock *lck;
- uint32_t create_options;
- uint32_t share_access;
- uint32_t access_mask;
- BOOL del_on_close;
-
- create_options = io->generic.in.create_options;
- share_access = io->generic.in.share_access;
- access_mask = io->generic.in.access_mask;
-
- /* certain create options are not allowed */
- if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
- !(access_mask & SEC_STD_DELETE)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- switch (io->generic.in.open_disposition) {
- case NTCREATEX_DISP_SUPERSEDE:
- case NTCREATEX_DISP_OVERWRITE_IF:
- case NTCREATEX_DISP_OPEN_IF:
- break;
-
- case NTCREATEX_DISP_OPEN:
- case NTCREATEX_DISP_OVERWRITE:
- if (!name->exists) {
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- }
- break;
-
- case NTCREATEX_DISP_CREATE:
- if (name->exists) {
- return NT_STATUS_OBJECT_NAME_COLLISION;
- }
- break;
-
- default:
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- /* handle creating a new directory separately */
- if (!name->exists) {
- status = pvfs_create_directory(pvfs, req, name, io);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
- return status;
- }
-
- /* we've hit a race - the directory was created during this call */
- if (io->generic.in.open_disposition == NTCREATEX_DISP_CREATE) {
- return status;
- }
-
- /* try re-resolving the name */
- status = pvfs_resolve_name(pvfs, req, io->ntcreatex.in.fname, 0, &name);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
- /* fall through to a normal open */
- }
-
- if ((name->dos.attrib & FILE_ATTRIBUTE_READONLY) &&
- (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
- return NT_STATUS_CANNOT_DELETE;
- }
-
- /* check the security descriptor */
- status = pvfs_access_check(pvfs, req, name, &access_mask);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- f = talloc(req, struct pvfs_file);
- if (f == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- f->handle = talloc(f, struct pvfs_file_handle);
- if (f->handle == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- /* allocate a fnum */
- fnum = idr_get_new_above(pvfs->idtree_fnum, f, PVFS_MIN_DIR_FNUM, UINT16_MAX);
- if (fnum == -1) {
- return NT_STATUS_TOO_MANY_OPENED_FILES;
- }
-
- f->fnum = fnum;
- f->session = req->session;
- f->smbpid = req->smbpid;
- f->pvfs = pvfs;
- f->pending_list = NULL;
- f->lock_count = 0;
- f->share_access = io->generic.in.share_access;
- f->access_mask = access_mask;
- f->impersonation = io->generic.in.impersonation;
-
- f->handle->pvfs = pvfs;
- f->handle->fd = -1;
- f->handle->name = talloc_steal(f->handle, name);
- f->handle->create_options = io->generic.in.create_options;
- f->handle->seek_offset = 0;
- f->handle->position = 0;
- f->handle->mode = 0;
- f->handle->have_opendb_entry = False;
- f->handle->sticky_write_time = False;
-
- /* form the lock context used for opendb locking */
- status = pvfs_locking_key(name, f->handle, &f->handle->odb_locking_key);
- if (!NT_STATUS_IS_OK(status)) {
- idr_remove(pvfs->idtree_fnum, f->fnum);
- return status;
- }
-
- /* get a lock on this file before the actual open */
- lck = odb_lock(req, pvfs->odb_context, &f->handle->odb_locking_key);
- if (lck == NULL) {
- DEBUG(0,("pvfs_open: failed to lock file '%s' in opendb\n",
- name->full_name));
- /* we were supposed to do a blocking lock, so something
- is badly wrong! */
- idr_remove(pvfs->idtree_fnum, fnum);
- return NT_STATUS_INTERNAL_DB_CORRUPTION;
- }
-
- DLIST_ADD(pvfs->open_files, f);
-
- /* setup a destructor to avoid file descriptor leaks on
- abnormal termination */
- talloc_set_destructor(f, pvfs_dir_fnum_destructor);
- talloc_set_destructor(f->handle, pvfs_dir_handle_destructor);
-
- if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
- pvfs_directory_empty(pvfs, f->handle->name)) {
- del_on_close = True;
- } else {
- del_on_close = False;
- }
-
- /* see if we are allowed to open at the same time as existing opens */
- status = odb_open_file(lck, f->handle, f->handle->name->stream_id,
- share_access, access_mask, del_on_close, name->full_name);
-
-#if 0
- /* we don't do async open retries on directories yet */
- if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) &&
- (req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
- return pvfs_open_setup_retry(ntvfs, req, io, f, lck);
- }
-#endif
-
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(lck);
- return status;
- }
-
- f->handle->have_opendb_entry = True;
-
- talloc_free(lck);
-
- io->generic.out.oplock_level = OPLOCK_NONE;
- io->generic.out.fnum = f->fnum;
- io->generic.out.create_action = NTCREATEX_ACTION_EXISTED;
- io->generic.out.create_time = name->dos.create_time;
- io->generic.out.access_time = name->dos.access_time;
- io->generic.out.write_time = name->dos.write_time;
- io->generic.out.change_time = name->dos.change_time;
- io->generic.out.attrib = name->dos.attrib;
- io->generic.out.alloc_size = name->dos.alloc_size;
- io->generic.out.size = name->st.st_size;
- io->generic.out.file_type = FILE_TYPE_DISK;
- io->generic.out.ipc_state = 0;
- io->generic.out.is_directory = 0;
-
- /* success - keep the file handle */
- talloc_steal(f->pvfs, f);
-
- return NT_STATUS_OK;
-}
-#endif
-
-#if 1
-/*
open a directory
*/
static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
@@ -758,7 +410,6 @@ cleanup_delete:
rmdir(name->full_name);
return status;
}
-#endif
/*
destroy a struct pvfs_file_handle