⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readdir.cpp

📁 JFFS的源代码
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -