/* return info on a pathname */ NTSTATUS pvfs_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, struct pvfs_state); struct pvfs_filename *name; NTSTATUS status; /* resolve the cifs name to a posix name */ status = pvfs_resolve_name(pvfs, req, info->generic.in.file.path, PVFS_RESOLVE_STREAMS, &name); if (!NT_STATUS_IS_OK(status)) { return status; } if (!name->stream_exists) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } status = pvfs_can_stat(pvfs, req, name); if (!NT_STATUS_IS_OK(status)) { return status; } status = pvfs_access_check_simple(pvfs, req, name, pvfs_fileinfo_access(info)); if (!NT_STATUS_IS_OK(status)) { return status; } status = pvfs_map_fileinfo(pvfs, req, name, info, -1); return status; }
/* rename_information level for streams */ static NTSTATUS pvfs_setfileinfo_rename_stream(struct pvfs_state *pvfs, struct ntvfs_request *req, struct pvfs_filename *name, int fd, DATA_BLOB *odb_locking_key, union smb_setfileinfo *info) { NTSTATUS status; struct odb_lock *lck = NULL; /* strangely, this gives a sharing violation, not invalid parameter */ if (info->rename_information.in.new_name[0] != ':') { return NT_STATUS_SHARING_VIOLATION; } status = pvfs_access_check_simple(pvfs, req, name, SEC_FILE_WRITE_ATTRIBUTE); if (!NT_STATUS_IS_OK(status)) { return status; } lck = odb_lock(req, pvfs->odb_context, odb_locking_key); if (lck == NULL) { DEBUG(0,("Unable to lock opendb for can_stat\n")); return NT_STATUS_INTERNAL_DB_CORRUPTION; } status = pvfs_stream_rename(pvfs, name, fd, info->rename_information.in.new_name+1, info->rename_information.in.overwrite); return status; }
/* remove a directory */ NTSTATUS pvfs_rmdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_rmdir *rd) { struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, struct pvfs_state); NTSTATUS status; struct pvfs_filename *name; /* resolve the cifs name to a posix name */ status = pvfs_resolve_name(pvfs, req, rd->in.path, 0, &name); if (!NT_STATUS_IS_OK(status)) { return status; } if (!name->exists) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } status = pvfs_access_check_simple(pvfs, req, name, SEC_STD_DELETE); if (!NT_STATUS_IS_OK(status)) { return status; } status = pvfs_xattr_unlink_hook(pvfs, name->full_name); if (!NT_STATUS_IS_OK(status)) { return status; } if (pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override) == -1) { /* some olders systems don't return ENOTEMPTY to rmdir() */ if (errno == EEXIST) { return NT_STATUS_DIRECTORY_NOT_EMPTY; } return pvfs_map_errno(pvfs, errno); } notify_trigger(pvfs->notify_context, NOTIFY_ACTION_REMOVED, FILE_NOTIFY_CHANGE_DIR_NAME, name->full_name); return NT_STATUS_OK; }