kernels/linux-2.4.0/fs/cramfs/inode.c
/*
 * Lookup and fill in the inode data..
 */
Lookup and fill in the inode data
Lookup and fill in the inode data
static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry)
{
	unsigned int offset = 0;
	while (offset < dir->i_size) {
		struct cramfs_inode *de;
		char *name;
		int namelen;
		de = cramfs_read(dir->i_sb, OFFSET(dir) + offset, sizeof(*de)+256);
		name = (char *)(de+1);
		namelen = de->namelen << 2;
		offset += sizeof(*de) + namelen;
		if (((dentry->d_name.len + 3) & ~3) != namelen)
			continue;
		for (;;) {
			if (!namelen)
				return ERR_PTR(-EIO);
			if (name[namelen-1])
				break;
			namelen--;
		}
		if (namelen != dentry->d_name.len)
			continue;
		if (memcmp(dentry->d_name.name, name, namelen))
			continue;
		d_add(dentry, get_cramfs_inode(dir->i_sb, de));
		return NULL;
	}
	d_add(dentry, NULL);
	return NULL;
}
static struct dentry * cramfs_lookup ( struct inode * dir , struct dentry * dentry ) { unsigned int offset = 0 ; while ( offset < dir -> i_size ) { struct cramfs_inode * de ; char * name ; int namelen ; de = cramfs_read ( dir -> i_sb , OFFSET ( dir ) + offset , sizeof ( * de ) + 256 ) ; name = ( char * ) ( de + 1 ) ; namelen = de -> namelen << 2 ; offset += sizeof ( * de ) + namelen ; if ( ( ( dentry -> d_name . len + 3 ) & ~ 3 ) != namelen ) continue ; for ( ; ; ) { if ( ! namelen ) return ERR_PTR ( - EIO ) ; if ( name [ namelen - 1 ] ) break ; namelen -- ; } if ( namelen != dentry -> d_name . len ) continue ; if ( memcmp ( dentry -> d_name . name , name , namelen ) ) continue ; d_add ( dentry , get_cramfs_inode ( dir -> i_sb , de ) ) ; return NULL ; } d_add ( dentry , NULL ) ; return NULL ; }
Lookup and fill in the inode data..
Lookup and fill in the inode data ..
/* Quick check that the name is roughly the right length */