📄 ntvfs_generic.c
字号:
info->internal_information.out.file_id = info2->generic.out.file_id; return NT_STATUS_OK; case RAW_FILEINFO_EA_INFO: case RAW_FILEINFO_EA_INFORMATION: info->ea_info.out.ea_size = info2->generic.out.ea_size; return NT_STATUS_OK; case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION: info->attribute_tag_information.out.attrib = info2->generic.out.attrib; info->attribute_tag_information.out.reparse_tag = info2->generic.out.reparse_tag; return NT_STATUS_OK; case RAW_FILEINFO_STREAM_INFO: case RAW_FILEINFO_STREAM_INFORMATION: info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { info->stream_info.out.streams = talloc_array(mem_ctx, struct stream_struct, info->stream_info.out.num_streams); if (!info->stream_info.out.streams) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n", info->stream_info.out.num_streams)); return NT_STATUS_NO_MEMORY; } for (i=0; i < info->stream_info.out.num_streams; i++) { info->stream_info.out.streams[i] = info2->generic.out.streams[i]; info->stream_info.out.streams[i].stream_name.s = talloc_strdup(info->stream_info.out.streams, info2->generic.out.streams[i].stream_name.s); if (!info->stream_info.out.streams[i].stream_name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; } } } return NT_STATUS_OK; case RAW_FILEINFO_NAME_INFO: case RAW_FILEINFO_NAME_INFORMATION: info->name_info.out.fname.s = talloc_strdup(mem_ctx, info2->generic.out.fname.s); NT_STATUS_HAVE_NO_MEMORY(info->name_info.out.fname.s); info->name_info.out.fname.private_length = info2->generic.out.fname.private_length; return NT_STATUS_OK; case RAW_FILEINFO_ALT_NAME_INFO: case RAW_FILEINFO_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; return NT_STATUS_OK; case RAW_FILEINFO_POSITION_INFORMATION: info->position_information.out.position = info2->generic.out.position; return NT_STATUS_OK; case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { info->all_eas.out.eas = talloc_array(mem_ctx, struct ea_struct, info->all_eas.out.num_eas); if (!info->all_eas.out.eas) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n", info->all_eas.out.num_eas)); return NT_STATUS_NO_MEMORY; } for (i = 0; i < info->all_eas.out.num_eas; i++) { info->all_eas.out.eas[i] = info2->generic.out.eas[i]; info->all_eas.out.eas[i].name.s = talloc_strdup(info->all_eas.out.eas, info2->generic.out.eas[i].name.s); if (!info->all_eas.out.eas[i].name.s) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; } info->all_eas.out.eas[i].value.data = talloc_memdup(info->all_eas.out.eas, info2->generic.out.eas[i].value.data, info2->generic.out.eas[i].value.length); if (!info->all_eas.out.eas[i].value.data) { DEBUG(2,("ntvfs_map_fileinfo: no memory for stream_name\n")); return NT_STATUS_NO_MEMORY; } } } return NT_STATUS_OK; case RAW_FILEINFO_IS_NAME_VALID: return NT_STATUS_OK; case RAW_FILEINFO_COMPRESSION_INFO: case RAW_FILEINFO_COMPRESSION_INFORMATION: info->compression_info.out.compressed_size = info2->generic.out.compressed_size; info->compression_info.out.format = info2->generic.out.format; info->compression_info.out.unit_shift = info2->generic.out.unit_shift; info->compression_info.out.chunk_shift = info2->generic.out.chunk_shift; info->compression_info.out.cluster_shift = info2->generic.out.cluster_shift; return NT_STATUS_OK; case RAW_FILEINFO_ACCESS_INFORMATION: info->access_information.out.access_flags = info2->generic.out.access_flags; return NT_STATUS_OK; case RAW_FILEINFO_MODE_INFORMATION: info->mode_information.out.mode = info2->generic.out.mode; return NT_STATUS_OK; case RAW_FILEINFO_ALIGNMENT_INFORMATION: info->alignment_information.out.alignment_requirement = info2->generic.out.alignment_requirement; return NT_STATUS_OK;#if 0 case RAW_FILEINFO_UNIX_BASIC: 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; info->unix_basic_info.out.access_time = info2->generic.out.access_time; info->unix_basic_info.out.change_time = info2->generic.out.change_time; info->unix_basic_info.out.uid = info2->generic.out.uid; info->unix_basic_info.out.gid = info2->generic.out.gid; info->unix_basic_info.out.file_type = info2->generic.out.file_type; info->unix_basic_info.out.dev_major = info2->generic.out.device; info->unix_basic_info.out.dev_minor = info2->generic.out.device; info->unix_basic_info.out.unique_id = info2->generic.out.inode; info->unix_basic_info.out.permissions = info2->generic.out.permissions; info->unix_basic_info.out.nlink = info2->generic.out.nlink; return NT_STATUS_OK; case RAW_FILEINFO_UNIX_LINK: info->unix_link_info.out.link_dest = info2->generic.out.link_dest; return NT_STATUS_OK;#endif } return NT_STATUS_INVALID_LEVEL;}/* NTVFS fileinfo generic to any mapper*/NTSTATUS ntvfs_map_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info){ NTSTATUS status; union smb_fileinfo *info2; info2 = talloc(req, union smb_fileinfo); if (info2 == NULL) { return NT_STATUS_NO_MEMORY; } if (info->generic.level == RAW_FILEINFO_GENERIC) { return NT_STATUS_INVALID_LEVEL; } /* ask the backend for the generic info */ info2->generic.level = RAW_FILEINFO_GENERIC; info2->generic.in.file.ntvfs= info->generic.in.file.ntvfs; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->qfileinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { return status; } return ntvfs_map_fileinfo(req, info, info2);}/* NTVFS pathinfo generic to any mapper*/NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info){ NTSTATUS status; union smb_fileinfo *info2; info2 = talloc(req, union smb_fileinfo); if (info2 == NULL) { return NT_STATUS_NO_MEMORY; } if (info->generic.level == RAW_FILEINFO_GENERIC) { return NT_STATUS_INVALID_LEVEL; } /* ask the backend for the generic info */ info2->generic.level = RAW_FILEINFO_GENERIC; info2->generic.in.file.path = info->generic.in.file.path; /* only used by the simple backend, which doesn't do async */ req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC; status = ntvfs->ops->qpathinfo(ntvfs, req, info2); if (!NT_STATUS_IS_OK(status)) { return status; } return ntvfs_map_fileinfo(req, info, info2);}/* NTVFS lock generic to any mapper*/NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_lock *lck){ union smb_lock *lck2; struct smb_lock_entry *locks; lck2 = talloc(req, union smb_lock); if (lck2 == NULL) { return NT_STATUS_NO_MEMORY; } locks = talloc_array(lck2, struct smb_lock_entry, 1); if (locks == NULL) { return NT_STATUS_NO_MEMORY; } switch (lck->generic.level) { case RAW_LOCK_LOCKX: return NT_STATUS_INVALID_LEVEL; case RAW_LOCK_LOCK: lck2->generic.level = RAW_LOCK_GENERIC; lck2->generic.in.file.ntvfs= lck->lock.in.file.ntvfs; lck2->generic.in.mode = 0; lck2->generic.in.timeout = 0; lck2->generic.in.ulock_cnt = 0; lck2->generic.in.lock_cnt = 1; lck2->generic.in.locks = locks; locks->pid = req->smbpid; locks->offset = lck->lock.in.offset; locks->count = lck->lock.in.count; break; case RAW_LOCK_UNLOCK: lck2->generic.level = RAW_LOCK_GENERIC; lck2->generic.in.file.ntvfs= lck->unlock.in.file.ntvfs; lck2->generic.in.mode = 0; lck2->generic.in.timeout = 0; lck2->generic.in.ulock_cnt = 1; lck2->generic.in.lock_cnt = 0; lck2->generic.in.locks = locks; locks->pid = req->smbpid; locks->offset = lck->unlock.in.offset; locks->count = lck->unlock.in.count; break; case RAW_LOCK_SMB2: { /* this is only approximate! We need to change the generic structure to fix this properly */ int i, j; if (lck->smb2.in.lock_count < 1) { return NT_STATUS_INVALID_PARAMETER; } lck2->generic.level = RAW_LOCK_GENERIC; lck2->generic.in.file.ntvfs= lck->smb2.in.file.ntvfs; lck2->generic.in.timeout = UINT32_MAX; lck2->generic.in.mode = 0; lck2->generic.in.lock_cnt = 0; lck2->generic.in.ulock_cnt = 0; lck2->generic.in.locks = talloc_zero_array(lck2, struct smb_lock_entry, lck->smb2.in.lock_count); if (lck2->generic.in.locks == NULL) { return NT_STATUS_NO_MEMORY; } for (i=0;i<lck->smb2.in.lock_count;i++) { if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) { break; } j = lck2->generic.in.ulock_cnt; if (lck->smb2.in.locks[i].flags & (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) { return NT_STATUS_INVALID_PARAMETER; } lck2->generic.in.ulock_cnt++; lck2->generic.in.locks[j].pid = 0; lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; lck2->generic.in.locks[j].pid = 0; } for (;i<lck->smb2.in.lock_count;i++) { if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) { /* w2008 requires unlocks to come first */ return NT_STATUS_INVALID_PARAMETER; } j = lck2->generic.in.ulock_cnt + lck2->generic.in.lock_cnt; lck2->generic.in.lock_cnt++; lck2->generic.in.locks[j].pid = 0; lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset; lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length; lck2->generic.in.locks[j].pid = 0; if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) { lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK; } if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) { lck2->generic.in.timeout = 0; } } /* initialize output value */ lck->smb2.out.reserved = 0; break; } case RAW_LOCK_SMB2_BREAK: lck2->generic.level = RAW_LOCK_GENERIC; lck2->generic.in.file.ntvfs = lck->smb2_break.in.file.ntvfs; lck2->generic.in.mode = LOCKING_ANDX_OPLOCK_RELEASE | ((lck->smb2_break.in.oplock_level << 8) & 0xFF00); lck2->generic.in.timeout = 0; lck2->generic.in.ulock_cnt = 0; lck2->generic.in.lock_cnt = 0; lck2->generic.in.locks = NULL; /* initialize output value */ lck->smb2_break.out.oplock_level= lck->smb2_break.in.oplock_level; lck->smb2_break.out.reserved = lck->smb2_break.in.reserved; lck->smb2_break.out.reserved2 = lck->smb2_break.in.reserved2; lck->smb2_break.out.file = lck->smb2_break.in.file; break; } /* * we don't need to call ntvfs_map_async_setup() here, * as lock() doesn't have any output fields */ return ntvfs->ops->lock(ntvfs, req, lck2);}/* NTVFS write generic to any mapper*/static NTSTATUS ntvfs_map_write_finish(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr, union smb_write *wr2, NTSTATUS status){ union smb_lock *lck; union smb_close *cl; uint_t state; if (NT_STATUS_IS_ERR(status)) { return status; } switch (wr->generic.level) { case RAW_WRITE_WRITE: wr->write.out.nwritten = wr2->generic.out.nwritten; break; case RAW_WRITE_WRITEUNLOCK: wr->writeunlock.out.nwritten = wr2->generic.out.nwritten; lck = talloc(wr2, union smb_lock); if (lck == NULL) { return NT_STATUS_NO_MEMORY; } lck->unlock.level = RAW_LOCK_UNLOCK; lck->unlock.in.file.ntvfs = wr->writeunlock.in.file.ntvfs; lck->unlock.in.count = wr->writeunlock.in.count; lck->unlock.in.offset = wr->writeunlock.in.offset; if (lck->unlock.in.count != 0) { /* 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); req->async_states->state = state; } break; case RAW_WRITE_WRITECLOSE: wr->writeclose.out.nwritten = wr2->generic.out.nwritten; cl = talloc(wr2, union smb_close); if (cl == NULL) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -