kernels/linux-2.4.0/fs/minix/namei.c
/*
 *	minix_find_entry()
 *
 * finds an entry in the specified directory with the wanted name. It
 * returns the cache buffer in which the entry was found, and the entry
 * itself (as a parameter - res_dir). It does NOT read the inode of the
 * entry - you'll have to do that yourself if you want to.
 */
minix_find_entry()
finds an entry in the specified directory with the wanted name. It
returns the cache buffer in which the entry was found, and the entry
itself (as a parameter - res_dir). It does NOT read the inode of the
entry - you'll have to do that yourself if you want to.
minix_find_entry () finds an entry in the specified directory with the wanted name . It returns the cache buffer in which the entry was found and the entry itself ( as a parameter - res_dir ) . It does NOT read the inode of the entry - you ' ll have to do that yourself if you want to .
static struct buffer_head * minix_find_entry(struct inode * dir,
	const char * name, int namelen, struct minix_dir_entry ** res_dir)
{
	unsigned long block, offset;
	struct buffer_head * bh;
	struct minix_sb_info * info;
	struct minix_dir_entry *de;
	*res_dir = NULL;
	info = &dir->i_sb->u.minix_sb;
	if (namelen > info->s_namelen) {
#ifdef NO_TRUNCATE
		return NULL;
#else
		namelen = info->s_namelen;
#endif
	}
	bh = NULL;
	block = offset = 0;
	while (block*BLOCK_SIZE+offset < dir->i_size) {
		if (!bh) {
			bh = minix_bread(dir,block,0);
			if (!bh) {
				block++;
				continue;
			}
		}
		de = (struct minix_dir_entry *) (bh->b_data + offset);
		offset += info->s_dirsize;
		if (de->inode && namecompare(namelen,info->s_namelen,name,de->name)) {
			*res_dir = de;
			return bh;
		}
		if (offset < bh->b_size)
			continue;
		brelse(bh);
		bh = NULL;
		offset = 0;
		block++;
	}
	brelse(bh);
	return NULL;
}
static struct buffer_head * minix_find_entry ( struct inode * dir , const char * name , int namelen , struct minix_dir_entry * * res_dir ) { unsigned long block , offset ; struct buffer_head * bh ; struct minix_sb_info * info ; struct minix_dir_entry * de ; * res_dir = NULL ; info = & dir -> i_sb -> u . minix_sb ; if ( namelen > info -> s_namelen ) { #ifdef NO_TRUNCATE return NULL ; #else namelen = info -> s_namelen ; #endif } bh = NULL ; block = offset = 0 ; while ( block * BLOCK_SIZE + offset < dir -> i_size ) { if ( ! bh ) { bh = minix_bread ( dir , block , 0 ) ; if ( ! bh ) { block ++ ; continue ; } } de = ( struct minix_dir_entry * ) ( bh -> b_data + offset ) ; offset += info -> s_dirsize ; if ( de -> inode && namecompare ( namelen , info -> s_namelen , name , de -> name ) ) { * res_dir = de ; return bh ; } if ( offset < bh -> b_size ) continue ; brelse ( bh ) ; bh = NULL ; offset = 0 ; block ++ ; } brelse ( bh ) ; return NULL ; }
minix_find_entry()
 finds an entry in the specified directory with the wanted name.
minix_find_entry () finds an entry in the specified directory with the wanted name .