OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [fs/] [minix/] [dir.c] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1628 jcastillo
/*
2
 *  linux/fs/minix/dir.c
3
 *
4
 *  Copyright (C) 1991, 1992 Linus Torvalds
5
 *
6
 *  minix directory handling functions
7
 */
8
 
9
#include <linux/string.h>
10
#include <linux/errno.h>
11
#include <linux/fs.h>
12
#include <linux/minix_fs.h>
13
#include <linux/stat.h>
14
 
15
#include <asm/segment.h>
16
 
17
static int minix_dir_read(struct inode * inode, struct file * filp, char * buf, int count)
18
{
19
        return -EISDIR;
20
}
21
 
22
static int minix_readdir(struct inode *, struct file *, void *, filldir_t);
23
 
24
static struct file_operations minix_dir_operations = {
25
        NULL,                   /* lseek - default */
26
        minix_dir_read,         /* read */
27
        NULL,                   /* write - bad */
28
        minix_readdir,          /* readdir */
29
        NULL,                   /* select - default */
30
        NULL,                   /* ioctl - default */
31
        NULL,                   /* mmap */
32
        NULL,                   /* no special open code */
33
        NULL,                   /* no special release code */
34
        file_fsync              /* default fsync */
35
};
36
 
37
/*
38
 * directories can handle most operations...
39
 */
40
struct inode_operations minix_dir_inode_operations = {
41
        &minix_dir_operations,  /* default directory file-ops */
42
        minix_create,           /* create */
43
        minix_lookup,           /* lookup */
44
        minix_link,             /* link */
45
        minix_unlink,           /* unlink */
46
        minix_symlink,          /* symlink */
47
        minix_mkdir,            /* mkdir */
48
        minix_rmdir,            /* rmdir */
49
        minix_mknod,            /* mknod */
50
        minix_rename,           /* rename */
51
        NULL,                   /* readlink */
52
        NULL,                   /* follow_link */
53
        NULL,                   /* readpage */
54
        NULL,                   /* writepage */
55
        NULL,                   /* bmap */
56
        minix_truncate,         /* truncate */
57
        NULL                    /* permission */
58
};
59
 
60
static int minix_readdir(struct inode * inode, struct file * filp,
61
        void * dirent, filldir_t filldir)
62
{
63
        unsigned int offset;
64
        struct buffer_head * bh;
65
        struct minix_dir_entry * de;
66
        struct minix_sb_info * info;
67
 
68
        if (!inode || !inode->i_sb || !S_ISDIR(inode->i_mode))
69
                return -EBADF;
70
        info = &inode->i_sb->u.minix_sb;
71
        if (filp->f_pos & (info->s_dirsize - 1))
72
                return -EBADF;
73
        while (filp->f_pos < inode->i_size) {
74
                offset = filp->f_pos & 1023;
75
                bh = minix_bread(inode,(filp->f_pos)>>BLOCK_SIZE_BITS,0);
76
                if (!bh) {
77
                        filp->f_pos += 1024-offset;
78
                        continue;
79
                }
80
                do {
81
                        de = (struct minix_dir_entry *) (offset + bh->b_data);
82
                        if (de->inode) {
83
                                int size = strnlen(de->name, info->s_namelen);
84
                                if (filldir(dirent, de->name, size, filp->f_pos, de->inode) < 0) {
85
                                        brelse(bh);
86
                                        return 0;
87
                                }
88
                        }
89
                        offset += info->s_dirsize;
90
                        filp->f_pos += info->s_dirsize;
91
                } while (offset < 1024 && filp->f_pos < inode->i_size);
92
                brelse(bh);
93
        }
94
        return 0;
95
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.