/** * vxfs_find_entry - find a mathing directory entry for a dentry * @ip: directory inode * @dp: dentry for which we want to find a direct * @ppp: gets filled with the page the return value sits in * * Description: * vxfs_find_entry finds a &struct vxfs_direct for the VFS directory * cache entry @dp. @ppp will be filled with the page the return * value resides in. * * Returns: * The wanted direct on success, else a NULL pointer.
*/ staticstruct vxfs_direct *
vxfs_find_entry(struct inode *ip, struct dentry *dp, struct page **ppp)
{
u_long bsize = ip->i_sb->s_blocksize; constchar *name = dp->d_name.name; int namelen = dp->d_name.len;
loff_t limit = VXFS_DIRROUND(ip->i_size); struct vxfs_direct *de_exit = NULL;
loff_t pos = 0; struct vxfs_sb_info *sbi = VXFS_SBI(ip->i_sb);
while (pos < limit) { struct page *pp; char *kaddr; int pg_ofs = pos & ~PAGE_MASK;
if (namelen != fs16_to_cpu(sbi, de->d_namelen)) continue; if (!memcmp(name, de->d_name, namelen)) {
*ppp = pp;
de_exit = de; break;
}
} if (!de_exit)
vxfs_put_page(pp); else break;
}
return de_exit;
}
/** * vxfs_inode_by_name - find inode number for dentry * @dip: directory to search in * @dp: dentry we search for * * Description: * vxfs_inode_by_name finds out the inode number of * the path component described by @dp in @dip. * * Returns: * The wanted inode number on success, else Zero.
*/ static ino_t
vxfs_inode_by_name(struct inode *dip, struct dentry *dp)
{ struct vxfs_direct *de; struct page *pp;
ino_t ino = 0;
de = vxfs_find_entry(dip, dp, &pp); if (de) {
ino = fs32_to_cpu(VXFS_SBI(dip->i_sb), de->d_ino);
kunmap(pp);
put_page(pp);
}
return (ino);
}
/** * vxfs_lookup - lookup pathname component * @dip: dir in which we lookup * @dp: dentry we lookup * @flags: lookup flags * * Description: * vxfs_lookup tries to lookup the pathname component described * by @dp in @dip. * * Returns: * A NULL-pointer on success, else a negative error code encoded * in the return pointer.
*/ staticstruct dentry *
vxfs_lookup(struct inode *dip, struct dentry *dp, unsignedint flags)
{ struct inode *ip = NULL;
ino_t ino;
if (dp->d_name.len > VXFS_NAMELEN) return ERR_PTR(-ENAMETOOLONG);
ino = vxfs_inode_by_name(dip, dp); if (ino)
ip = vxfs_iget(dip->i_sb, ino); return d_splice_alias(ip, dp);
}
/** * vxfs_readdir - read a directory * @fp: the directory to read * @ctx: dir_context for filldir/readdir * * Description: * vxfs_readdir fills @retp with directory entries from @fp * using the VFS supplied callback @filler. * * Returns: * Zero.
*/ staticint
vxfs_readdir(struct file *fp, struct dir_context *ctx)
{ struct inode *ip = file_inode(fp); struct super_block *sbp = ip->i_sb;
u_long bsize = sbp->s_blocksize;
loff_t pos, limit; struct vxfs_sb_info *sbi = VXFS_SBI(sbp);
if (ctx->pos == 0) { if (!dir_emit_dot(fp, ctx)) goto out;
ctx->pos++;
} if (ctx->pos == 1) { if (!dir_emit(ctx, "..", 2, VXFS_INO(ip)->vii_dotdot, DT_DIR)) goto out;
ctx->pos++;
}
limit = VXFS_DIRROUND(ip->i_size); if (ctx->pos > limit) goto out;
pos = ctx->pos & ~3L;
while (pos < limit) { struct page *pp; char *kaddr; int pg_ofs = pos & ~PAGE_MASK; int rc = 0;
pp = vxfs_get_page(ip->i_mapping, pos >> PAGE_SHIFT); if (IS_ERR(pp)) return -ENOMEM;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.