.\" 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_LOOKUP" "9" "09 October 2005" "" "" .SH NAME ntfs_lookup \- find the inode represented by a dentry in a directory inode .SH SYNOPSIS "SYNOPSIS" .sp \fB .sp struct dentry * ntfs_lookup (struct inode * \fIdir_ino\fB, struct dentry * \fIdent\fB, struct nameidata * \fInd\fB); \fR .SH "ARGUMENTS" .TP \fB\fIdir_ino\fB\fR directory inode in which to look for the inode .TP \fB\fIdent\fB\fR dentry representing the inode to look for .TP \fB\fInd\fB\fR lookup nameidata .SH "DESCRIPTION" .PP In short, \fBntfs_lookup\fR looks for the inode represented by the dentry \fIdent\fR in the directory inode \fIdir_ino\fR and if found attaches the inode to the dentry \fIdent\fR\&. .PP In more detail, the dentry \fIdent\fR specifies which inode to look for by supplying the name of the inode in \fIdent\fR->d_name.name. \fBntfs_lookup\fR converts the name to Unicode and walks the contents of the directory inode \fIdir_ino\fR looking for the converted Unicode name. If the name is found in the directory, the corresponding inode is loaded by calling \fBntfs_iget\fR on its inode number and the inode is associated with the dentry \fIdent\fR via a call to \fBd_splice_alias\fR\&. .PP If the name is not found in the directory, a NULL inode is inserted into the dentry \fIdent\fR via a call to \fBd_add\fR\&. The dentry is then termed a negative dentry. .PP Only if an actual error occurs, do we return an error via \fBERR_PTR\fR\&. .PP In order to handle the case insensitivity issues of NTFS with regards to the dcache and the dcache requiring only one dentry per directory, we deal with dentry aliases that only differ in case in ->\fBntfs_lookup\fR while maintaining a case sensitive dcache. This means that we get the full benefit of dcache speed when the file/directory is looked up with the same case as returned by ->\fBntfs_readdir\fR but that a lookup for any other case (or for the short file name) will not find anything in dcache and will enter ->\fBntfs_lookup\fR instead, where we search the directory for a fully matching file name (including case) and if that is not found, we search for a file name that matches with different case and if that has non-POSIX semantics we return that. We actually do only one search (case sensitive) and keep tabs on whether we have found a case insensitive match in the process. .PP To simplify matters for us, we do not treat the short vs long filenames as two hard links but instead if the lookup matches a short filename, we return the dentry for the corresponding long filename instead. .SH "THERE ARE THREE CASES WE NEED TO DISTINGUISH HERE" .PP .PP 1) \fIdent\fR perfectly matches (i.e. including case) a directory entry with a file name in the WIN32 or POSIX namespaces. In this case \fBntfs_lookup_inode_by_name\fR will return with name set to NULL and we just \fBd_splice_alias\fR \fIdent\fR\&. 2) \fIdent\fR matches (not including case) a directory entry with a file name in the WIN32 namespace. In this case \fBntfs_lookup_inode_by_name\fR will return with name set to point to a \fBkmalloc\fRed ntfs_name structure containing the properly cased little endian Unicode name. We convert the name to the current NLS code page, search if a dentry with this name already exists and if so return that instead of \fIdent\fR\&. At this point things are complicated by the possibility of 'disconnected' dentries due to NFS which we deal with appropriately (see the code comments). The VFS will then destroy the old \fIdent\fR and use the one we returned. If a dentry is not found, we allocate a new one, \fBd_splice_alias\fR it, and return it as above. 3) \fIdent\fR matches either perfectly or not (i.e. we don't care about case) a directory entry with a file name in the DOS namespace. In this case \fBntfs_lookup_inode_by_name\fR will return with name set to point to a \fBkmalloc\fRed ntfs_name structure containing the mft reference (cpu endian) of the inode. We use the mft reference to read the inode and to find the file name in the WIN32 namespace corresponding to the matched short file name. We then convert the name to the current NLS code page, and proceed searching for a dentry with this name, etc, as in case 2), above. .SH "LOCKING" .PP Caller must hold i_sem on the directory.