readdir.cpp

来自「JFFS的源代码」· C++ 代码 · 共 42 行

CPP
42
字号
#include <stdio.h>
#include <string.h>

#include "../jffs/fileext.h"
#include "../jffs/jffstypes.h"
#include "../jffs/fs.h"
#include "../jffs/errno.h"

static int fillonedir(void * __buf, const char * name, int namlen, off_t offset, ino_t ino)
{
	char * buf = (char *)__buf;
	memset(buf, 0, sizeof(struct dirent));
	strncpy( buf, name, namlen);

	return 0;
}

int mf_readdir(unsigned int fd, void * dirent, unsigned int count)
{
	int error;
	struct file * file;
	/*struct readdir_callback buf;

	if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
		return -EBADF;*/
	if (fd >= NR_OPEN)
		return -EBADF;
	/*error = verify_area(VERIFY_WRITE, dirent, sizeof(struct old_linux_dirent));
	if (error)
		return error;
	buf.count = 0;
	buf.dirent = dirent;*/
	file = fget(fd);
	if (!file->f_op || !file->f_op->readdir)
		return -ENOTDIR;

	error = file->f_op->readdir(file->f_inode, file, dirent, (filldir_t)fillonedir);
	/*if (error < 0)*/
		return error;
	/*return buf.count;*/
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?