Example #1
0
/**
 *  read all dir entries in specified directory
 * @param filp         file pointer of specified directory to read     
 * @param dirent       buffer pointer
 * @param filldir      function pointer which fills dir info
 * @return             return 0 on success, errno on failure
 */
static int rfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
       struct dentry *dentry = filp->f_dentry;
       struct inode *inode = dentry->d_inode;
       struct buffer_head *bh = NULL;
       struct rfs_dir_info dir_info;
       unsigned int type;
       loff_t pos;
       int ret;

       CHECK_RFS_INODE(inode, -ENOENT);

       while (1) {
               pos = filp->f_pos;
       
               ret = internal_readdir(inode, &bh, (loff_t *) &filp->f_pos, &dir_info);
               if (ret < 0) 
                       break;

               if (dir_info.type == TYPE_DIR)
                       type = DT_DIR;
               else
                       type = DT_REG;

               ret = filldir(dirent, dir_info.name, strlen(dir_info.name), 
                               pos, dir_info.ino, type);       
               if (ret < 0) {
                       filp->f_pos = pos; /* rollback */
                       break;
               }
       }
       
       brelse(bh);
       return 0;
}
Example #2
0
struct direct *
readdir(DIR *dirp)
{
	if (internal_readdir(dirp) == NULL)
		return (NULL);

	/* Check for overflows */
	if (dc64.d_ino > SIZE_MAX) {
		errno = EOVERFLOW;
		return (NULL);
	}

	/* Copy dirent into direct */
	dc.d_ino = dc64.d_ino;
	dc.d_reclen = dc64.d_reclen - 4;
	dc.d_namlen = dc64.d_namlen;
	(void) strcpy(dc.d_name, dc64.d_name);

	return (&dc);
}
Example #3
0
struct direct64 *
readdir64(DIR *dirp)
{
	return (internal_readdir(dirp));
}