⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opendb_ctdb.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 2 页
字号:
{	struct odb_context *odb = lck->odb;	struct opendb_file file;	NTSTATUS status;			status = odb_pull_record(lck, &file);	NT_STATUS_NOT_OK_RETURN(status);	file.pending = talloc_realloc(lck, file.pending, struct opendb_pending, 				      file.num_pending+1);	NT_STATUS_HAVE_NO_MEMORY(file.pending);	file.pending[file.num_pending].server = odb->ntvfs_ctx->server_id;	file.pending[file.num_pending].notify_ptr = private;	file.num_pending++;	return odb_push_record(lck, &file);}/*  remove a opendb entry*/static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle,				    const char **_delete_path){	struct odb_context *odb = lck->odb;	struct opendb_file file;	const char *delete_path = NULL;	int i;	NTSTATUS status;	status = odb_pull_record(lck, &file);	NT_STATUS_NOT_OK_RETURN(status);	/* find the entry, and delete it */	for (i=0;i<file.num_entries;i++) {		if (file_handle == file.entries[i].file_handle &&		    cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.entries[i].server)) {			if (file.entries[i].delete_on_close) {				file.delete_on_close = true;			}			if (i < file.num_entries-1) {				memmove(file.entries+i, file.entries+i+1, 					(file.num_entries - (i+1)) * 					sizeof(struct opendb_entry));			}			break;		}	}	if (i == file.num_entries) {		return NT_STATUS_UNSUCCESSFUL;	}	/* send any pending notifications, removing them once sent */	for (i=0;i<file.num_pending;i++) {		messaging_send_ptr(odb->ntvfs_ctx->msg_ctx, file.pending[i].server, 				   MSG_PVFS_RETRY_OPEN, 				   file.pending[i].notify_ptr);	}	file.num_pending = 0;	file.num_entries--;	if (file.num_entries == 0 && file.delete_on_close) {		delete_path = talloc_strdup(lck, file.path);		NT_STATUS_HAVE_NO_MEMORY(delete_path);	}	if (_delete_path) {		*_delete_path = delete_path;	}		return odb_push_record(lck, &file);}/*  update the oplock level of the client*/static NTSTATUS odb_ctdb_update_oplock(struct odb_lock *lck, void *file_handle,				       uint32_t oplock_level){	/*	 * as this file will went away and isn't used yet,	 * copy the implementation from the tdb backend	 * --metze	 */	return NT_STATUS_FOOBAR;}static NTSTATUS odb_ctdb_break_oplocks(struct odb_lock *lck){	/*	 * as this file will went away and isn't used yet,	 * copy the implementation from the tdb backend	 * --metze	 */	return NT_STATUS_FOOBAR;}/*  remove a pending opendb entry*/static NTSTATUS odb_ctdb_remove_pending(struct odb_lock *lck, void *private){	struct odb_context *odb = lck->odb;	int i;	NTSTATUS status;	struct opendb_file file;	status = odb_pull_record(lck, &file);	NT_STATUS_NOT_OK_RETURN(status);	/* find the entry, and delete it */	for (i=0;i<file.num_pending;i++) {		if (private == file.pending[i].notify_ptr &&		    cluster_id_equal(&odb->ntvfs_ctx->server_id, &file.pending[i].server)) {			if (i < file.num_pending-1) {				memmove(file.pending+i, file.pending+i+1, 					(file.num_pending - (i+1)) * 					sizeof(struct opendb_pending));			}			break;		}	}	if (i == file.num_pending) {		return NT_STATUS_UNSUCCESSFUL;	}	file.num_pending--;		return odb_push_record(lck, &file);}/*  rename the path in a open file*/static NTSTATUS odb_ctdb_rename(struct odb_lock *lck, const char *path){	struct opendb_file file;	NTSTATUS status;	status = odb_pull_record(lck, &file);	if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {		/* not having the record at all is OK */		return NT_STATUS_OK;	}	NT_STATUS_NOT_OK_RETURN(status);	file.path = path;	return odb_push_record(lck, &file);}/*  get the path of an open file*/static NTSTATUS odb_ctdb_get_path(struct odb_lock *lck, const char **path){	struct opendb_file file;	NTSTATUS status;	*path = NULL;	status = odb_pull_record(lck, &file);	/* we don't ignore NT_STATUS_OBJECT_NAME_NOT_FOUND here */	NT_STATUS_NOT_OK_RETURN(status);	*path = file.path;	return NT_STATUS_OK;}/*  update delete on close flag on an open file*/static NTSTATUS odb_ctdb_set_delete_on_close(struct odb_lock *lck, bool del_on_close){	NTSTATUS status;	struct opendb_file file;	status = odb_pull_record(lck, &file);	NT_STATUS_NOT_OK_RETURN(status);	file.delete_on_close = del_on_close;	return odb_push_record(lck, &file);}/*  return the current value of the delete_on_close bit, and how many  people still have the file open*/static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb, 					    DATA_BLOB *key, bool *del_on_close){	NTSTATUS status;	struct opendb_file file;	struct odb_lock *lck;	(*del_on_close) = false;	lck = odb_lock(odb, odb, key);	NT_STATUS_HAVE_NO_MEMORY(lck);	status = odb_pull_record(lck, &file);	if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {		talloc_free(lck);		return NT_STATUS_OK;	}	if (!NT_STATUS_IS_OK(status)) {		talloc_free(lck);		return status;	}	(*del_on_close) = file.delete_on_close;	talloc_free(lck);	return NT_STATUS_OK;}/*  determine if a file can be opened with the given share_access,  create_options and access_mask*/static NTSTATUS odb_ctdb_can_open(struct odb_lock *lck,				  uint32_t stream_id, uint32_t share_access,				  uint32_t access_mask, bool delete_on_close,				  uint32_t open_disposition, bool break_to_none){	struct odb_context *odb = lck->odb;	NTSTATUS status;	struct opendb_file file;	struct opendb_entry e;	int i;	status = odb_pull_record(lck, &file);	if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {		return NT_STATUS_OK;	}	NT_STATUS_NOT_OK_RETURN(status);	if (delete_on_close &&	    file.num_entries != 0) {		return NT_STATUS_SHARING_VIOLATION;	}	if (file.delete_on_close) {		return NT_STATUS_DELETE_PENDING;	}	e.server       = odb->ntvfs_ctx->server_id;	e.file_handle  = NULL;	e.stream_id    = 0;	e.share_access = share_access;	e.access_mask  = access_mask;			for (i=0;i<file.num_entries;i++) {		status = share_conflict(&file.entries[i], &e);		if (!NT_STATUS_IS_OK(status)) {			/* note that we discard the error code			   here. We do this as unless we are actually			   doing an open (which comes via a different			   function), we need to return a sharing			   violation */			return NT_STATUS_SHARING_VIOLATION;		}	}	return NT_STATUS_OK;}static const struct opendb_ops opendb_ctdb_ops = {	.odb_init                = odb_ctdb_init,	.odb_lock                = odb_ctdb_lock,	.odb_get_key             = odb_ctdb_get_key,	.odb_open_file           = odb_ctdb_open_file,	.odb_open_file_pending   = odb_ctdb_open_file_pending,	.odb_close_file          = odb_ctdb_close_file,	.odb_remove_pending      = odb_ctdb_remove_pending,	.odb_rename              = odb_ctdb_rename,	.odb_get_path            = odb_ctdb_get_path,	.odb_set_delete_on_close = odb_ctdb_set_delete_on_close,	.odb_get_delete_on_close = odb_ctdb_get_delete_on_close,	.odb_can_open            = odb_ctdb_can_open,	.odb_update_oplock       = odb_ctdb_update_oplock,	.odb_break_oplocks       = odb_ctdb_break_oplocks};void odb_ctdb_init_ops(void){	odb_set_ops(&opendb_ctdb_ops);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -