.\" This manpage has been automatically generated by docbook2man .\" from a DocBook document. This tool can be found at: .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . .TH "NTFS_INDEX_LOOKUP" "9" "09 October 2005" "" "" .SH NAME ntfs_index_lookup \- find a key in an index and return its index entry .SH SYNOPSIS "SYNOPSIS" .sp \fB .sp int ntfs_index_lookup (const void * \fIkey\fB, const int \fIkey_len\fB, ntfs_index_context * \fIictx\fB); \fR .SH "ARGUMENTS" .TP \fB\fIkey\fB\fR [IN] key for which to search in the index .TP \fB\fIkey_len\fB\fR [IN] length of \fIkey\fR in bytes .TP \fB\fIictx\fB\fR [IN/OUT] context describing the index and the returned entry .SH "DESCRIPTION" .PP Before calling \fBntfs_index_lookup\fR, \fIictx\fR must have been obtained from a call to \fBntfs_index_ctx_get\fR\&. .PP Look for the \fIkey\fR in the index specified by the index lookup context \fIictx\fR\&. \fBntfs_index_lookup\fR walks the contents of the index looking for the \fIkey\fR\&. .PP If the \fIkey\fR is found in the index, 0 is returned and \fIictx\fR is setup to describe the index entry containing the matching \fIkey\fR\&. \fIictx\fR->entry is the index entry and \fIictx\fR->data and \fIictx\fR->data_len are the index entry data and its length in bytes, respectively. .PP If the \fIkey\fR is not found in the index, -ENOENT is returned and \fIictx\fR is setup to describe the index entry whose key collates immediately after the search \fIkey\fR, i.e. this is the position in the index at which an index entry with a key of \fIkey\fR would need to be inserted. .PP If an error occurs return the negative error code and \fIictx\fR is left untouched. .PP When finished with the entry and its data, call \fBntfs_index_ctx_put\fR to free the context and other associated resources. .PP If the index entry was modified, call \fBflush_dcache_index_entry_page\fR immediately after the modification and either \fBntfs_index_entry_mark_dirty\fR or \fBntfs_index_entry_write\fR before the call to \fBntfs_index_ctx_put\fR to ensure that the changes are written to disk. .SH "LOCKING" .PP - Caller must hold i_sem on the index inode. - Each page cache page in the index allocation mapping must be locked whilst being accessed otherwise we may find a corrupt page due to it being under ->writepage at the moment which applies the mst protection fixups before writing out and then removes them again after the write is complete after which it unlocks the page.