• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ dir_emit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dir_emit函数的典型用法代码示例。如果您正苦于以下问题:C++ dir_emit函数的具体用法?C++ dir_emit怎么用?C++ dir_emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dir_emit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: befs_readdir

static int
befs_readdir(struct file *file, struct dir_context *ctx)
{
	struct inode *inode = file_inode(file);
	struct super_block *sb = inode->i_sb;
	befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
	befs_off_t value;
	int result;
	size_t keysize;
	unsigned char d_type;
	char keybuf[BEFS_NAME_LEN + 1];

	befs_debug(sb, "---> %s name %pD, inode %ld, ctx->pos %lld",
		  __func__, file, inode->i_ino, ctx->pos);

more:
	result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
				 keybuf, &keysize, &value);

	if (result == BEFS_ERR) {
		befs_debug(sb, "<--- %s ERROR", __func__);
		befs_error(sb, "IO error reading %pD (inode %lu)",
			   file, inode->i_ino);
		return -EIO;

	} else if (result == BEFS_BT_END) {
		befs_debug(sb, "<--- %s END", __func__);
		return 0;

	} else if (result == BEFS_BT_EMPTY) {
		befs_debug(sb, "<--- %s Empty directory", __func__);
		return 0;
	}

	d_type = DT_UNKNOWN;

	/* Convert to NLS */
	if (BEFS_SB(sb)->nls) {
		char *nlsname;
		int nlsnamelen;
		result =
		    befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen);
		if (result < 0) {
			befs_debug(sb, "<--- %s ERROR", __func__);
			return result;
		}
		if (!dir_emit(ctx, nlsname, nlsnamelen,
				 (ino_t) value, d_type)) {
			kfree(nlsname);
			return 0;
		}
		kfree(nlsname);
	} else {
		if (!dir_emit(ctx, keybuf, keysize,
				 (ino_t) value, d_type))
			return 0;
	}
	ctx->pos++;
	goto more;
}
开发者ID:Abioy,项目名称:kasan,代码行数:60,代码来源:linuxvfs.c


示例2: zpl_root_iterate

/*
 * Get root directory contents.
 */
static int
zpl_root_iterate(struct file *filp, struct dir_context *ctx)
{
	zfs_sb_t *zsb = ITOZSB(filp->f_path.dentry->d_inode);
	int error = 0;

	ZFS_ENTER(zsb);

	if (!dir_emit_dots(filp, ctx))
		goto out;

	if (ctx->pos == 2) {
		if (!dir_emit(ctx, ZFS_SNAPDIR_NAME, strlen(ZFS_SNAPDIR_NAME),
		    ZFSCTL_INO_SNAPDIR, DT_DIR))
			goto out;

		ctx->pos++;
	}

	if (ctx->pos == 3) {
		if (!dir_emit(ctx, ZFS_SHAREDIR_NAME, strlen(ZFS_SHAREDIR_NAME),
		    ZFSCTL_INO_SHARES, DT_DIR))
			goto out;

		ctx->pos++;
	}
out:
	ZFS_EXIT(zsb);

	return (error);
}
开发者ID:awein,项目名称:zfs,代码行数:34,代码来源:zpl_ctldir.c


示例3: f2fs_fill_dentries

bool f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        unsigned int start_pos)
{
    unsigned char d_type = DT_UNKNOWN;
    unsigned int bit_pos;
    struct f2fs_dir_entry *de = NULL;

    bit_pos = ((unsigned long)ctx->pos % d->max);

    while (bit_pos < d->max) {
        bit_pos = find_next_bit_le(d->bitmap, d->max, bit_pos);
        if (bit_pos >= d->max)
            break;

        de = &d->dentry[bit_pos];
        if (de->file_type < F2FS_FT_MAX)
            d_type = f2fs_filetype_table[de->file_type];
        else
            d_type = DT_UNKNOWN;
        if (!dir_emit(ctx, d->filename[bit_pos],
                      le16_to_cpu(de->name_len),
                      le32_to_cpu(de->ino), d_type))
            return true;

        bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
        ctx->pos = start_pos + bit_pos;
    }
    return false;
}
开发者ID:iamroot12a,项目名称:kernel,代码行数:29,代码来源:dir.c


示例4: HgfsReaddirFillEntry

static Bool
HgfsReaddirFillEntry(filldir_t filldirCb,            // IN: System filler callback
                     void *filldirCtx,               // IN/OUT: System filler context
                     char *entryName,                // IN: entry name
                     uint32 entryNameLength,         // IN: max name length
                     loff_t entryPos,                // IN: position = (ctx-pos)
                     ino_t entryIno,                 // IN: inode entry number
                     uint32 entryType)               // IN: entry type
{
   struct dir_context *ctx = filldirCtx;
   Bool result;

   ASSERT(filldirCb == NULL);   /* Contained within the context structure. */
   ASSERT(ctx != NULL);
   ASSERT(ctx->pos == entryPos);
   ASSERT(entryName != NULL);
   ASSERT(entryNameLength != 0);

   LOG(6, (KERN_DEBUG "VMware hgfs: %s: dir_emit(%s, %u, %Lu)\n",
            __func__, entryName, entryNameLength, ctx->pos));

   result = dir_emit(ctx,              /* filldir callback struct */
                     entryName,        /* name of dirent */
                     entryNameLength,  /* length of name */
                     entryIno,         /* inode number (0 makes it not show) */
                     entryType);       /* type of dirent */
   return result;
}
开发者ID:CryptoManiac,项目名称:vmhgfs,代码行数:28,代码来源:dir.c


示例5: f2fs_readdir

static int f2fs_readdir(struct file *file, struct dir_context *ctx)
{
	struct inode *inode = file_inode(file);
	unsigned long npages = dir_blocks(inode);
	unsigned int bit_pos = 0;
	struct f2fs_dentry_block *dentry_blk = NULL;
	struct f2fs_dir_entry *de = NULL;
	struct page *dentry_page = NULL;
	struct file_ra_state *ra = &file->f_ra;
	unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
	unsigned char d_type = DT_UNKNOWN;

	bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);

	/* readahead for multi pages of dir */
	if (npages - n > 1 && !ra_has_index(ra, n))
		page_cache_sync_readahead(inode->i_mapping, ra, file, n,
				min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));

	for (; n < npages; n++) {
		dentry_page = get_lock_data_page(inode, n);
		if (IS_ERR(dentry_page))
			continue;

		dentry_blk = kmap(dentry_page);
		while (bit_pos < NR_DENTRY_IN_BLOCK) {
			bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap,
							NR_DENTRY_IN_BLOCK,
							bit_pos);
			if (bit_pos >= NR_DENTRY_IN_BLOCK)
				break;

			de = &dentry_blk->dentry[bit_pos];
			if (de->file_type < F2FS_FT_MAX)
				d_type = f2fs_filetype_table[de->file_type];
			else
				d_type = DT_UNKNOWN;
			if (!dir_emit(ctx,
					dentry_blk->filename[bit_pos],
					le16_to_cpu(de->name_len),
					le32_to_cpu(de->ino), d_type))
				goto stop;

			bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
			ctx->pos = n * NR_DENTRY_IN_BLOCK + bit_pos;
		}
		bit_pos = 0;
		ctx->pos = (n + 1) * NR_DENTRY_IN_BLOCK;
		kunmap(dentry_page);
		f2fs_put_page(dentry_page, 1);
		dentry_page = NULL;
	}
stop:
	if (dentry_page && !IS_ERR(dentry_page)) {
		kunmap(dentry_page);
		f2fs_put_page(dentry_page, 1);
	}

	return 0;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:60,代码来源:dir.c


示例6: ecryptfs_filldir

/* Inspired by generic filldir in fs/readdir.c */
static int
ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen,
		 loff_t offset, u64 ino, unsigned int d_type)
{
	struct ecryptfs_getdents_callback *buf =
	    (struct ecryptfs_getdents_callback *)dirent;
	size_t name_size;
	char *name;
	int rc;

	buf->filldir_called++;
	rc = ecryptfs_decode_and_decrypt_filename(&name, &name_size,
						  buf->sb, lower_name,
						  lower_namelen);
	if (rc) {
		printk(KERN_ERR "%s: Error attempting to decode and decrypt "
		       "filename [%s]; rc = [%d]\n", __func__, lower_name,
		       rc);
		goto out;
	}
	buf->caller->pos = buf->ctx.pos;
	rc = !dir_emit(buf->caller, name, name_size, ino, d_type);
	kfree(name);
	if (!rc)
		buf->entries_written++;
out:
	return rc;
}
开发者ID:daltenty,项目名称:kernel-ubuntu.trusty-vgt,代码行数:29,代码来源:file.c


示例7: sysfs_readdir

static int sysfs_readdir(struct file *file, struct dir_context *ctx)
{
	struct dentry *dentry = file->f_path.dentry;
	struct sysfs_dirent *parent_sd = dentry->d_fsdata;
	struct sysfs_dirent *pos = file->private_data;
	enum kobj_ns_type type;
	const void *ns;

	type = sysfs_ns_type(parent_sd);
	ns = sysfs_info(dentry->d_sb)->ns[type];

	if (!dir_emit_dots(file, ctx))
		return 0;
	mutex_lock(&sysfs_mutex);
	for (pos = sysfs_dir_pos(ns, parent_sd, ctx->pos, pos);
	     pos;
	     pos = sysfs_dir_next_pos(ns, parent_sd, ctx->pos, pos)) {
		const char *name = pos->s_name;
		unsigned int type = dt_type(pos);
		int len = strlen(name);
		ino_t ino = pos->s_ino;
		ctx->pos = pos->s_hash;
		file->private_data = sysfs_get(pos);

		mutex_unlock(&sysfs_mutex);
		if (!dir_emit(ctx, name, len, ino, type))
			return 0;
		mutex_lock(&sysfs_mutex);
	}
	mutex_unlock(&sysfs_mutex);
	file->private_data = NULL;
	ctx->pos = INT_MAX;
	return 0;
}
开发者ID:AnadoluPanteri,项目名称:kernel-plus-harmattan,代码行数:34,代码来源:dir.c


示例8: romfs_readdir

/*
 * read the entries from a directory
 */
static int romfs_readdir(struct file *file, struct dir_context *ctx)
{
	struct inode *i = file_inode(file);
	struct romfs_inode ri;
	unsigned long offset, maxoff;
	int j, ino, nextfh;
	char fsname[ROMFS_MAXFN];	/* XXX dynamic? */
	int ret;

	maxoff = romfs_maxsize(i->i_sb);

	offset = ctx->pos;
	if (!offset) {
		offset = i->i_ino & ROMFH_MASK;
		ret = romfs_dev_read(i->i_sb, offset, &ri, ROMFH_SIZE);
		if (ret < 0)
			goto out;
		offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
	}

	/* Not really failsafe, but we are read-only... */
	for (;;) {
		if (!offset || offset >= maxoff) {
			offset = maxoff;
			ctx->pos = offset;
			goto out;
		}
		ctx->pos = offset;

		/* Fetch inode info */
		ret = romfs_dev_read(i->i_sb, offset, &ri, ROMFH_SIZE);
		if (ret < 0)
			goto out;

		j = romfs_dev_strnlen(i->i_sb, offset + ROMFH_SIZE,
				      sizeof(fsname) - 1);
		if (j < 0)
			goto out;

		ret = romfs_dev_read(i->i_sb, offset + ROMFH_SIZE, fsname, j);
		if (ret < 0)
			goto out;
		fsname[j] = '\0';

		ino = offset;
		nextfh = be32_to_cpu(ri.next);
		if ((nextfh & ROMFH_TYPE) == ROMFH_HRD)
			ino = be32_to_cpu(ri.spec);
		if (!dir_emit(ctx, fsname, j, ino,
			    romfs_dtype_table[nextfh & ROMFH_TYPE]))
			goto out;

		offset = nextfh & ROMFH_MASK;
	}
out:
	return 0;
}
开发者ID:19Dan01,项目名称:linux,代码行数:60,代码来源:super.c


示例9: simplefs_readdir

static int simplefs_readdir(struct file *filp, void *dirent, filldir_t filldir)
#endif
{
    loff_t pos;
    struct inode *inode;
    struct super_block *sb;
    struct buffer_head *bh;
    struct simplefs_inode *sfs_inode;
    struct simplefs_dir_record *record;
    int i;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
    pos = ctx->pos;
#else
    pos = filp->f_pos;
#endif
    inode = filp->f_dentry->d_inode;
    sb = inode->i_sb;

    if (pos) {
        /* FIXME: We use a hack of reading pos to figure if we have filled in all data.
         * We should probably fix this to work in a cursor based model and
         * use the tokens correctly to not fill too many data in each cursor based call */
        return 0;
    }

    sfs_inode = SIMPLEFS_INODE(inode);

    if (unlikely(!S_ISDIR(sfs_inode->mode))) {
        printk(KERN_ERR
               "inode [%llu][%lu] for fs object [%s] not a directory\n",
               sfs_inode->inode_no, inode->i_ino,
               filp->f_dentry->d_name.name);
        return -ENOTDIR;
    }

    bh = sb_bread(sb, sfs_inode->data_block_number);
    BUG_ON(!bh);

    record = (struct simplefs_dir_record *)bh->b_data;
    for (i = 0; i < sfs_inode->dir_children_count; i++) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
        dir_emit(ctx, record->filename, SIMPLEFS_FILENAME_MAXLEN,
                 record->inode_no, DT_UNKNOWN);
        ctx->pos += sizeof(struct simplefs_dir_record);
#else
        filldir(dirent, record->filename, SIMPLEFS_FILENAME_MAXLEN, pos,
                record->inode_no, DT_UNKNOWN);
        filp->f_pos += sizeof(struct simplefs_dir_record);
#endif
        pos += sizeof(struct simplefs_dir_record);
        record++;
    }
    brelse(bh);

    return 0;
}
开发者ID:duomo,项目名称:simplefs,代码行数:57,代码来源:simple.c


示例10: v9fs_dir_readdir

static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)
{
	bool over;
	struct p9_wstat st;
	int err = 0;
	struct p9_fid *fid;
	int buflen;
	int reclen = 0;
	struct p9_rdir *rdir;
	struct kvec kvec;

	p9_debug(P9_DEBUG_VFS, "name %pD\n", file);
	fid = file->private_data;

	buflen = fid->clnt->msize - P9_IOHDRSZ;

	rdir = v9fs_alloc_rdir_buf(file, buflen);
	if (!rdir)
		return -ENOMEM;
	kvec.iov_base = rdir->buf;
	kvec.iov_len = buflen;

	while (1) {
		if (rdir->tail == rdir->head) {
			struct iov_iter to;
			int n;
			iov_iter_kvec(&to, READ | ITER_KVEC, &kvec, 1, buflen);
			n = p9_client_read(file->private_data, ctx->pos, &to,
					   &err);
			if (err)
				return err;

			rdir->head = 0;
			rdir->tail = n;
		}
		while (rdir->head < rdir->tail) {
			p9stat_init(&st);
			err = p9stat_read(fid->clnt, rdir->buf + rdir->head,
					  rdir->tail - rdir->head, &st);
			if (err) {
				p9_debug(P9_DEBUG_VFS, "returned %d\n", err);
				p9stat_free(&st);
				return -EIO;
			}
			reclen = st.size+2;

			over = !dir_emit(ctx, st.name, strlen(st.name),
					 v9fs_qid2ino(&st.qid), dt_type(&st));
			p9stat_free(&st);
			if (over)
				return 0;

			rdir->head += reclen;
			ctx->pos += reclen;
		}
	}
}
开发者ID:LBSHackathon,项目名称:linux,代码行数:57,代码来源:vfs_dir.c


示例11: dedupfs_iterate

static int dedupfs_iterate(struct file *filp,
						   struct dir_context *ctx)
{
	loff_t pos;
	struct inode *inode;
	struct super_block *sb;
	struct buffer_head *bh;
	struct dedupfs_inode *dfs_inode;
	struct dedupfs_file_record *record;

	pos = ctx->pos;

	inode = file_inode(filp);
	sb = inode->i_sb;

	printk(KERN_INFO
		"We are inside iterate. The pos[%lu], inode_number[%lu]\n",
		(long unsigned int)pos, inode->i_ino);

	if (pos) {
		printk(KERN_INFO "pos seem to be non-zero which means "
					"we have already filled in all the details\n");
		return 0;
	}

	dfs_inode = DEDUPFS_INODE(inode);

	if(!S_ISDIR(dfs_inode->mode)) {
		printk(KERN_ERR
			   "inode [%d] is not a directory\n",
			   dfs_inode->inode_no);
		return -ENOTDIR;
	}

	bh = (struct buffer_head *)sb_bread(sb, dfs_inode->data_block_number);

	record = (struct dedupfs_file_record *)bh->b_data;
	for(int i = 0; i < dfs_inode->dir_children_count; i++) {
		printk(KERN_INFO "Got filename: %s\n", record->filename);
		dir_emit(ctx, record->filename, DEDUPFS_FILENAME_MAXLEN,
				record->inode_no, DT_UNKNOWN);
		ctx->pos += sizeof(struct dedupfs_file_record);
		record++;
	}
	brelse(bh);

	return 0;

}
开发者ID:Flynston,项目名称:ProgMonk,代码行数:49,代码来源:super.c


示例12: v9fs_dir_readdir_dotl

/**
 * v9fs_dir_readdir_dotl - iterate through a directory
 * @file: opened file structure
 * @ctx: actor we feed the entries to
 *
 */
static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx)
{
	int err = 0;
	struct p9_fid *fid;
	int buflen;
	struct p9_rdir *rdir;
	struct p9_dirent curdirent;

	p9_debug(P9_DEBUG_VFS, "name %pD\n", file);
	fid = file->private_data;

	buflen = fid->clnt->msize - P9_READDIRHDRSZ;

	rdir = v9fs_alloc_rdir_buf(file, buflen);
	if (!rdir)
		return -ENOMEM;

	while (1) {
		if (rdir->tail == rdir->head) {
			err = p9_client_readdir(fid, rdir->buf, buflen,
						ctx->pos);
			if (err <= 0)
				return err;

			rdir->head = 0;
			rdir->tail = err;
		}

		while (rdir->head < rdir->tail) {

			err = p9dirent_read(fid->clnt, rdir->buf + rdir->head,
					    rdir->tail - rdir->head,
					    &curdirent);
			if (err < 0) {
				p9_debug(P9_DEBUG_VFS, "returned %d\n", err);
				return -EIO;
			}

			if (!dir_emit(ctx, curdirent.d_name,
				      strlen(curdirent.d_name),
				      v9fs_qid2ino(&curdirent.qid),
				      curdirent.d_type))
				return 0;

			ctx->pos = curdirent.d_off;
			rdir->head += err;
		}
	}
}
开发者ID:LBSHackathon,项目名称:linux,代码行数:55,代码来源:vfs_dir.c


示例13: tierfs_filldir

/* Inspired by generic filldir in fs/readdir.c */
static int
tierfs_filldir(void *dirent, const char *lower_name, int lower_namelen,
		 loff_t offset, u64 ino, unsigned int d_type)
{
	struct tierfs_getdents_callback *buf =
	    (struct tierfs_getdents_callback *)dirent;
	int rc;

	TRACE_ENTRY();
	buf->filldir_called++;
	buf->caller->pos = buf->ctx.pos;
	rc = !dir_emit(buf->caller, lower_name, lower_namelen, ino, d_type);
	if (!rc)
		buf->entries_written++;
	TRACE_EXIT();
	return rc;
}
开发者ID:XavatarX,项目名称:code,代码行数:18,代码来源:file.c


示例14: nvmm_readdir

static int
nvmm_readdir(struct file *file, struct dir_context *ctx)
{
	loff_t pos = ctx->pos;
	int err = 0;
	struct inode *inode = file_inode(file);
	struct super_block *sb = inode->i_sb;
	unsigned long offset = pos && ~PAGE_CACHE_MASK;
	unsigned char *types = NULL;
	char *start_addr, *end_addr;
	struct nvmm_dir_entry *nde;

	types = nvmm_filetype_table;
	
	/*establish mapping*/
	err = nvmm_establish_mapping(inode);


	if(pos >= inode->i_size)
		goto final;

	if(file->f_version != inode->i_version){
		if(offset){
			offset = 0;
			ctx->pos = (loff_t)(NVMM_I(inode)->i_virt_addr);
		}
		file->f_version = inode->i_version;
	}
	start_addr = NVMM_I(inode)->i_virt_addr;
	end_addr = start_addr + inode->i_size;
	if(start_addr >= end_addr)
		goto final;
	nde = (struct nvmm_dir_entry *)start_addr;
	for(;(char *)nde < end_addr;nde =  nvmm_next_entry(nde)){
		if(nde->rec_len == 0){
			nvmm_error(sb, __FUNCTION__, "zero-length directory entry\n");
			err = -EIO;
			goto final;
		}
		if(nde->inode){
			unsigned char d_type = DT_UNKNOWN;
			if(types && nde->file_type < NVMM_FT_MAX)
				d_type = types[nde->file_type];
			if(!dir_emit(ctx, nde->name, nde->name_len, le64_to_cpu(nde->inode),d_type))
				goto final;
		}
开发者ID:szllong123,项目名称:nvmmfs,代码行数:46,代码来源:dir.c


示例15: parse_dirplusfile

static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
			     struct dir_context *ctx, u64 attr_version)
{
	struct fuse_direntplus *direntplus;
	struct fuse_dirent *dirent;
	size_t reclen;
	int over = 0;
	int ret;

	while (nbytes >= FUSE_NAME_OFFSET_DIRENTPLUS) {
		direntplus = (struct fuse_direntplus *) buf;
		dirent = &direntplus->dirent;
		reclen = FUSE_DIRENTPLUS_SIZE(direntplus);

		if (!dirent->namelen || dirent->namelen > FUSE_NAME_MAX)
			return -EIO;
		if (reclen > nbytes)
			break;
		if (memchr(dirent->name, '/', dirent->namelen) != NULL)
			return -EIO;

		if (!over) {
			/* We fill entries into dstbuf only as much as
			   it can hold. But we still continue iterating
			   over remaining entries to link them. If not,
			   we need to send a FORGET for each of those
			   which we did not link.
			*/
			over = !dir_emit(ctx, dirent->name, dirent->namelen,
				       dirent->ino, dirent->type);
			ctx->pos = dirent->off;
		}

		buf += reclen;
		nbytes -= reclen;

		ret = fuse_direntplus_link(file, direntplus, attr_version);
		if (ret)
			fuse_force_forget(file, direntplus->entry_out.nodeid);
	}

	return 0;
}
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:43,代码来源:dir.c


示例16: sysv_readdir

static int sysv_readdir(struct file *file, struct dir_context *ctx)
{
	unsigned long pos = ctx->pos;
	struct inode *inode = file_inode(file);
	struct super_block *sb = inode->i_sb;
	unsigned long npages = dir_pages(inode);
	unsigned offset;
	unsigned long n;

	ctx->pos = pos = (pos + SYSV_DIRSIZE-1) & ~(SYSV_DIRSIZE-1);
	if (pos >= inode->i_size)
		return 0;

	offset = pos & ~PAGE_MASK;
	n = pos >> PAGE_SHIFT;

	for ( ; n < npages; n++, offset = 0) {
		char *kaddr, *limit;
		struct sysv_dir_entry *de;
		struct page *page = dir_get_page(inode, n);

		if (IS_ERR(page))
			continue;
		kaddr = (char *)page_address(page);
		de = (struct sysv_dir_entry *)(kaddr+offset);
		limit = kaddr + PAGE_SIZE - SYSV_DIRSIZE;
		for ( ;(char*)de <= limit; de++, ctx->pos += sizeof(*de)) {
			char *name = de->name;

			if (!de->inode)
				continue;

			if (!dir_emit(ctx, name, strnlen(name,SYSV_NAMELEN),
					fs16_to_cpu(SYSV_SB(sb), de->inode),
					DT_UNKNOWN)) {
				dir_put_page(page);
				return 0;
			}
		}
		dir_put_page(page);
	}
	return 0;
}
开发者ID:020gzh,项目名称:linux,代码行数:43,代码来源:dir.c


示例17: logfs_readdir

/* FIXME: readdir currently has it's own dir_walk code.  I don't see a good
 * way to combine the two copies */
static int logfs_readdir(struct file *file, struct dir_context *ctx)
{
	struct inode *dir = file_inode(file);
	loff_t pos;
	struct page *page;
	struct logfs_disk_dentry *dd;

	if (ctx->pos < 0)
		return -EINVAL;

	if (!dir_emit_dots(file, ctx))
		return 0;

	pos = ctx->pos - 2;
	BUG_ON(pos < 0);
	for (;; pos++, ctx->pos++) {
		bool full;
		if (beyond_eof(dir, pos))
			break;
		if (!logfs_exist_block(dir, pos)) {
			/* deleted dentry */
			pos = dir_seek_data(dir, pos);
			continue;
		}
		page = read_cache_page(dir->i_mapping, pos,
				(filler_t *)logfs_readpage, NULL);
		if (IS_ERR(page))
			return PTR_ERR(page);
		dd = kmap(page);
		BUG_ON(dd->namelen == 0);

		full = !dir_emit(ctx, (char *)dd->name,
				be16_to_cpu(dd->namelen),
				be64_to_cpu(dd->ino), dd->type);
		kunmap(page);
		page_cache_release(page);
		if (full)
			break;
	}
	return 0;
}
开发者ID:19Dan01,项目名称:linux,代码行数:43,代码来源:dir.c


示例18: zpl_snapdir_iterate

static int
zpl_snapdir_iterate(struct file *filp, struct dir_context *ctx)
{
	zfs_sb_t *zsb = ITOZSB(filp->f_path.dentry->d_inode);
	fstrans_cookie_t cookie;
	char snapname[MAXNAMELEN];
	boolean_t case_conflict;
	uint64_t id, pos;
	int error = 0;

	ZFS_ENTER(zsb);
	cookie = spl_fstrans_mark();

	if (!dir_emit_dots(filp, ctx))
		goto out;

	pos = ctx->pos;
	while (error == 0) {
		dsl_pool_config_enter(dmu_objset_pool(zsb->z_os), FTAG);
		error = -dmu_snapshot_list_next(zsb->z_os, MAXNAMELEN,
		    snapname, &id, &pos, &case_conflict);
		dsl_pool_config_exit(dmu_objset_pool(zsb->z_os), FTAG);
		if (error)
			goto out;

		if (!dir_emit(ctx, snapname, strlen(snapname),
		    ZFSCTL_INO_SHARES - id, DT_DIR))
			goto out;

		ctx->pos = pos;
	}
out:
	spl_fstrans_unmark(cookie);
	ZFS_EXIT(zsb);

	if (error == -ENOENT)
		return (0);

	return (error);
}
开发者ID:awein,项目名称:zfs,代码行数:40,代码来源:zpl_ctldir.c


示例19: jffs2_readdir

static int jffs2_readdir(struct file *file, struct dir_context *ctx)
{
    struct inode *inode = file_inode(file);
    struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
    struct jffs2_full_dirent *fd;
    unsigned long curofs = 1;

    jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n", inode->i_ino);

    if (!dir_emit_dots(file, ctx))
        return 0;

    mutex_lock(&f->sem);
    for (fd = f->dents; fd; fd = fd->next) {
        curofs++;
        /* First loop: curofs = 2; pos = 2 */
        if (curofs < ctx->pos) {
            jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n",
                      fd->name, fd->ino, fd->type, curofs, (unsigned long)ctx->pos);
            continue;
        }
        if (!fd->ino) {
            jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n",
                      fd->name);
            ctx->pos++;
            continue;
        }
        jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n",
                  (unsigned long)ctx->pos, fd->name, fd->ino, fd->type);
        if (!dir_emit(ctx, fd->name, strlen(fd->name), fd->ino, fd->type))
            break;
        ctx->pos++;
    }
    mutex_unlock(&f->sem);
    return 0;
}
开发者ID:robeat101,项目名称:linux,代码行数:36,代码来源:dir.c


示例20: cifs_filldir

static int cifs_filldir(char *find_entry, struct file *file,
		struct dir_context *ctx,
		char *scratch_buf, unsigned int max_len)
{
	struct cifsFileInfo *file_info = file->private_data;
	struct super_block *sb = file_inode(file)->i_sb;
	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
	struct cifs_dirent de = { NULL, };
	struct cifs_fattr fattr;
	struct qstr name;
	int rc = 0;
	ino_t ino;

	rc = cifs_fill_dirent(&de, find_entry, file_info->srch_inf.info_level,
			      file_info->srch_inf.unicode);
	if (rc)
		return rc;

	if (de.namelen > max_len) {
		cifs_dbg(VFS, "bad search response length %zd past smb end\n",
			 de.namelen);
		return -EINVAL;
	}

	/* skip . and .. since we added them first */
	if (cifs_entry_is_dot(&de, file_info->srch_inf.unicode))
		return 0;

	if (file_info->srch_inf.unicode) {
		struct nls_table *nlt = cifs_sb->local_nls;
		int map_type;

		map_type = cifs_remap(cifs_sb);
		name.name = scratch_buf;
		name.len =
			cifs_from_utf16((char *)name.name, (__le16 *)de.name,
					UNICODE_NAME_MAX,
					min_t(size_t, de.namelen,
					      (size_t)max_len), nlt, map_type);
		name.len -= nls_nullsize(nlt);
	} else {
		name.name = de.name;
		name.len = de.namelen;
	}

	switch (file_info->srch_inf.info_level) {
	case SMB_FIND_FILE_UNIX:
		cifs_unix_basic_to_fattr(&fattr,
					 &((FILE_UNIX_INFO *)find_entry)->basic,
					 cifs_sb);
		break;
	case SMB_FIND_FILE_INFO_STANDARD:
		cifs_std_info_to_fattr(&fattr,
				       (FIND_FILE_STANDARD_INFO *)find_entry,
				       cifs_sb);
		break;
	default:
		cifs_dir_info_to_fattr(&fattr,
				       (FILE_DIRECTORY_INFO *)find_entry,
				       cifs_sb);
		break;
	}

	if (de.ino && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
		fattr.cf_uniqueid = de.ino;
	} else {
		fattr.cf_uniqueid = iunique(sb, ROOT_I);
		cifs_autodisable_serverino(cifs_sb);
	}

	if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) &&
	    couldbe_mf_symlink(&fattr))
		/*
		 * trying to get the type and mode can be slow,
		 * so just call those regular files for now, and mark
		 * for reval
		 */
		fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;

	cifs_prime_dcache(file->f_path.dentry, &name, &fattr);

	ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
	return !dir_emit(ctx, name.name, name.len, ino, fattr.cf_dtype);
}
开发者ID:piastry,项目名称:etercifs,代码行数:84,代码来源:readdir.c



注:本文中的dir_emit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dir_exists函数代码示例发布时间:2022-05-30
下一篇:
C++ dir_close函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap