root/morphix/trunk/mini_fo/fist_mini_fo.c

Revision 2, 2.3 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 /*
2  * mini_fo.c
3  * Do not edit by hand.
4  * Automatically generated by fistgen.
5  */
6
7 #ifdef HAVE_CONFIG_H
8 # include <config.h>
9 #endif /* HAVE_CONFIG_H */
10 #ifdef FISTGEN
11 # include "fist_mini_fo.h"
12 #endif /* FISTGEN */
13 #include "fist.h"
14 #include "mini_fo.h"
15 #include <linux/mount.h>
16
17 /* OPTIONAL CODE FOLLOWS */
18 #define IS_POSIX(fl)    (fl->fl_flags & FL_POSIX)
19 #define IS_FLOCK(fl)    (fl->fl_flags & FL_FLOCK)
20 #define IS_LEASE(fl)    (fl->fl_flags & FL_LEASE)
21 STATIC int
22 mini_fo_print_locks(dentry_t *entry, char* str){
23         struct file_lock *cfl;
24         if(!entry->d_inode || !entry->d_inode->i_flock){
25                 printk("%s: %s:entry->d_inode->i_flock IS NULL\n",__FUNCTION__,str);
26                 return 0;
27         }
28         for (cfl = entry->d_inode->i_flock; cfl; cfl = cfl->fl_next) {
29                 printk("%s: %s: IS_POSIX(%p)=%i, IS_FLOCK(cfl)=%i,IS_LEASE(cfl)=%i\n",__FUNCTION__,str,cfl,IS_POSIX(cfl),IS_FLOCK(cfl),IS_LEASE(cfl));
30         }
31         return 0;
32 }
33
34
35
36
37 STATIC int
38 mini_fo_copy_to_sto(dentry_t *dentry, int copy_data)
39 {
40         int err=0;
41         print_entry_location();
42         if(S_ISREG(dentry->d_inode->i_mode)) {
43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
44                 mini_fo_create(dentry->d_parent->d_inode,
45                                    dentry,
46                                    dentry->d_inode->i_mode,NULL);
47 #else
48                 mini_fo_create(dentry->d_parent->d_inode,
49                                    dentry,
50                                    dentry->d_inode->i_mode);
51 #endif         
52         } else if(S_ISDIR(dentry->d_inode->i_mode)) {
53                 mini_fo_mkdir(dentry->d_parent->d_inode,
54                                                                    dentry,
55                                                                    dentry->d_inode->i_mode);
56         } else if (!S_ISSOCK(dentry->d_inode->i_mode) ){
57                 err=mini_fo_mknod(dentry->d_parent->d_inode,dentry,dentry->d_inode->i_mode,dentry->d_inode->i_rdev);
58                 if (err)
59                         goto out;
60         } else{
61                 /* tbd: creating socket files */
62                 err=-EINVAL;
63                 goto out;
64         }
65
66
67
68         /* double check */
69         if(DENTRY_TO_PRIVATE(dentry)->state != 1) {
70                 printk("mini_fo:mini_fo_copy_to_sto: ERROR creating storage file.\n");
71                 err = -EINVAL;
72                 goto out;
73         }
74
75         if(S_ISREG(dentry->d_inode->i_mode) && copy_data) {
76                 err = mini_fo_cp_cont(DENTRY_TO_LOWER_STO(dentry),
77                                                                                   SUPERBLOCK_TO_PRIVATE(dentry->d_inode->i_sb)->lower_mnt2,
78                                                                                   DENTRY_TO_LOWER(dentry),
79                                                                                   SUPERBLOCK_TO_PRIVATE(dentry->d_inode->i_sb)->lower_mnt);
80                                         if(err < 0)
81                                                         printk(KERN_CRIT "mini_fo:mini_fo_copy_to_sto: ERROR copying contents.\n");
82         }       
83        
84 out:
85         print_exit_status(err);
86         return err;     
87 }
88
89
90
91
92
93 /* no extra routines are needed */
94
95
96 /*
97  * Local variables:
98  * c-basic-offset: 4
99  * End:
100  */
Note: See TracBrowser for help on using the browser.