File: inode.c

package info (click to toggle)
kernel-image-2.4.18-hppa 62.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 156,012 kB
  • ctags: 448,723
  • sloc: ansic: 2,586,445; asm: 145,047; makefile: 8,574; sh: 3,097; perl: 2,578; yacc: 1,177; tcl: 577; lex: 352; awk: 251; lisp: 218; sed: 72
file content (168 lines) | stat: -rw-r--r-- 5,065 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * Super block/filesystem wide operations
 *
 * Copryright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk> and
 * Michael Callahan <callahan@maths.ox.ac.uk>
 *
 * Rewritten for Linux 2.1.  Peter Braam <braam@cs.cmu.edu>
 * Copyright (C) Carnegie Mellon University
 */

#define __NO_VERSION__
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/locks.h>
#include <linux/unistd.h>

#include <asm/system.h>
#include <asm/uaccess.h>

#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/locks.h>
#include <linux/string.h>
#include <asm/uaccess.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <asm/segment.h>

#include <linux/intermezzo_fs.h>
#include <linux/intermezzo_upcall.h>
#include <linux/intermezzo_psdev.h>

extern int presto_remount(struct super_block *, int *, char *);

int presto_excluded_gid = PRESTO_EXCL_GID;

extern int presto_prep(struct dentry *, struct presto_cache **,
                              struct presto_file_set **);
extern void presto_free_cache(struct presto_cache *);


void presto_set_ops(struct inode *inode, struct  filter_fs *filter)
{
	ENTRY; 
        if (!inode || is_bad_inode(inode))
                return;
	if (inode->i_gid == presto_excluded_gid ) { 
		EXIT;
                CDEBUG(D_INODE, "excluded methods for %ld at %p, %p\n",
                       inode->i_ino, inode->i_op, inode->i_fop);
		return; 
	}
        if (S_ISREG(inode->i_mode)) {
                if ( !filter_c2cfiops(filter) ) {
                       filter_setup_file_ops(filter, 
					     inode, &presto_file_iops,
					     &presto_file_fops);
                }
		inode->i_op = filter_c2ufiops(filter);
		inode->i_fop = filter_c2uffops(filter);
                CDEBUG(D_INODE, "set file methods for %ld to %p\n",
                       inode->i_ino, inode->i_op);
        } else if (S_ISDIR(inode->i_mode)) {
		inode->i_op = filter_c2udiops(filter);
		inode->i_fop = filter_c2udfops(filter);
                CDEBUG(D_INODE, "set dir methods for %ld to %p lookup %p\n",
                       inode->i_ino, inode->i_op, inode->i_op->lookup);
        } else if (S_ISLNK(inode->i_mode)) {
                if ( !filter_c2csiops(filter)) {
                        filter_setup_symlink_ops(filter, 
                                                 inode,
                                                 &presto_sym_iops, 
						 &presto_sym_fops);
                }
		inode->i_op = filter_c2usiops(filter);
		inode->i_fop = filter_c2usfops(filter);
                CDEBUG(D_INODE, "set link methods for %ld to %p\n",
                       inode->i_ino, inode->i_op);
        }
	EXIT;
}

void presto_read_inode(struct inode *inode)
{
        struct presto_cache *cache;

        cache = presto_get_cache(inode);
        if ( !cache ) {
                printk("PRESTO: BAD, BAD: cannot find cache\n");
                make_bad_inode(inode);
                return ;
        }

        filter_c2csops(cache->cache_filter)->read_inode(inode);

        CDEBUG(D_INODE, "presto_read_inode: ino %ld, gid %d\n", 
	       inode->i_ino, inode->i_gid);

	//        if (inode->i_gid == presto_excluded_gid)
        //       return;

	presto_set_ops(inode, cache->cache_filter); 
        /* XXX handle special inodes here or not - probably not? */
}

void presto_put_super(struct super_block *sb)
{
        struct presto_cache *cache;
        struct upc_comm *psdev;
        struct super_operations *sops;
        struct list_head *lh;

	ENTRY;
        cache = presto_find_cache(sb->s_dev);
        if (!cache) {
		EXIT;
                goto exit;
	}
        psdev = &upc_comms[presto_c2m(cache)];

        sops = filter_c2csops(cache->cache_filter);
        if (sops->put_super)
                sops->put_super(sb);

        /* free any remaining async upcalls when the filesystem is unmounted */
        lh = psdev->uc_pending.next;
        while ( lh != &psdev->uc_pending) {
                struct upc_req *req;
                req = list_entry(lh, struct upc_req, rq_chain);

                /* assignment must be here: we are about to free &lh */
                lh = lh->next;
                if ( ! (req->rq_flags & REQ_ASYNC) ) 
                        continue;
                list_del(&(req->rq_chain));
                PRESTO_FREE(req->rq_data, req->rq_bufsize);
                PRESTO_FREE(req, sizeof(struct upc_req));
        }

        presto_free_cache(cache);

exit:
        CDEBUG(D_MALLOC, "after umount: kmem %ld, vmem %ld\n",
               presto_kmemory, presto_vmemory);
        MOD_DEC_USE_COUNT;
        return ;
}


/* symlinks can be chowned */
struct inode_operations presto_sym_iops = {
	setattr:	presto_setattr
};

/* NULL for now */
struct file_operations presto_sym_fops; 

struct super_operations presto_super_ops = {
        read_inode:     presto_read_inode,
        put_super:      presto_put_super,
        remount_fs:     presto_remount
};
MODULE_LICENSE("GPL");