My favorites
▼
|
Sign in
fscops
OHSM - Online Hierarchical Storage Manager
Project Home
Downloads
Wiki
Issues
Source
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
9
attachment: ohsm_meta_module.c
(7.4 KB)
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
This is the device driver code for "ohsm_meta" device
It accepts the mount point from the user and prints in the kernel meddages the incore superblock of
ext2 file system
It also prints the block group information in the kernel messages
Copyright (C) <2008> <rishi b-> agrawal>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version->
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE-> See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/fs.h>
#include<asm/uaccess.h>
#include <linux/namei.h>
#include <linux/mount.h>
#include <linux/ext2_fs.h>
#include <../fs/ext2/ext2.h>
#include "ohsm_meta_module.h"
#include <linux/buffer_head.h>
#include <linux/ext2_fs_sb.h>
#define MNTPNT_LEN 256
#define DEVICE_NAME "OHSM_TEST_MODULE"
#define BUFF_LEN 80
#define SUCCESS 0
#define PRINT_SUPER_PRINT_GROUP 1
/* Variables */
unsigned int Major;
int Device_open = 0;
char msg[BUFF_LEN] = "Character Device for OHSM META DATA PRINTING";
char *msg_ptr;
char *uptr;
/* Defining Operations */
int init_module (void);
void cleanup_module (void);
/* Operations of our device */
static int device_release (struct inode *, struct file *);
static int device_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
/* Registering our device's functions */
struct file_operations fops = {
.release = device_release,
.ioctl = device_ioctl,
};
MODULE_LICENSE ("GPL");
MODULE_AUTHOR ("Rishi Bhushan Agrawal");
/* Init Module */
int
init_module (void)
{
printk (KERN_ALERT "\nOSHM META: INITILAIZED\n");
Major = register_chrdev (0, DEVICE_NAME, &fops);
if (Major < 0)
{
printk (KERN_INFO "\nOHSM META: Unable to initialize driver\n");
return Major;
}
printk (KERN_INFO "\nOSHM_META_MODULE %d\n", Major);
printk (KERN_INFO "\nOSHM META: Dont forget to remove module when done\n");
return SUCCESS;
}
/* exit module */
void
cleanup_module (void)
{
unregister_chrdev (Major, DEVICE_NAME);
printk (KERN_ALERT "\nOSHM META: I AM OUT\n");
}
/* Releasing our device */
static int
device_release (struct inode *in, struct file *fp)
{
Device_open--;
module_put (THIS_MODULE);
return SUCCESS;
}
/*
struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned int block_group,
struct buffer_head ** bh);
void ohsm_print_block_groups(struct super_block *, unsigned long);
void ohsm_print_ext2_sb_info_fun(struct ext2_sb_info *);
*/
void
ohsm_print_in_dmesg (unsigned int arg)
{
struct nameidata nd;
struct ohsm_input_to_meta_device *ptr =
(struct ohsm_input_to_meta_device *) arg;
struct super_block *sb = NULL;
struct ext2_sb_info *sbi = NULL;
int retval = 0;
struct vfsmount *vfs = NULL;
retval = path_lookup (ptr->mountpoint, LOOKUP_OPEN, &nd);
vfs = nd.path.mnt;
sb = (struct super_block *) vfs->mnt_sb;
sbi = (struct ext2_sb_info *) sb->s_fs_info;
ohsm_print_ext2_sb_info_fun (sbi);
ohsm_print_block_groups (sb, sbi->s_groups_count);
}
void
print_gd (struct ext2_group_desc *gd)
{
printk (KERN_ALERT "\nBlocks bitmap block %-15u",
(unsigned int) gd->bg_block_bitmap);
printk (KERN_ALERT "\nInodes bitmap block %-15u",
(unsigned int) gd->bg_inode_bitmap);
printk (KERN_ALERT "\nInodes table block %-15u",
(unsigned int) gd->bg_inode_table);
printk (KERN_ALERT "\nFree blocks count %-15u",
(unsigned int) gd->bg_free_blocks_count);
printk (KERN_ALERT "\nFree inodes count %-15u",
(unsigned int) gd->bg_free_inodes_count);
printk (KERN_ALERT "\nDirectories count %-15u",
(unsigned int) gd->bg_used_dirs_count);
}
void
ohsm_print_block_groups (struct super_block *sb, unsigned long number)
{
struct ext2_group_desc *gd = NULL;
unsigned long i = 0;
printk (KERN_ALERT "\nBlock Group Number %lu", i);
for (i = 0; i < number; i++)
{
gd = ext2_get_group_desc (sb, i, NULL);
print_gd (gd);
}
}
static int
device_ioctl (struct inode *in, struct file *fp, unsigned int cmd,
unsigned long arg)
{
printk (KERN_ALERT "\n\nCHAR DEVICE OSHM META: ioctl called ");
switch (cmd)
{
case PRINT_SUPER_PRINT_GROUP:
ohsm_print_in_dmesg (arg);
break;
/*
other cases will be added soon
*/
}
return 0;
}
void
ohsm_print_ext2_sb_info_fun (struct ext2_sb_info *sb)
{
printk (KERN_ALERT "\nSize of fragments in Bytes %lu ", sb->s_frag_size); /* Size of a fragment in bytes */
printk (KERN_ALERT "\nNumber of fragments per block%lu", sb->s_frags_per_block); /* Number of fragments per block */
printk (KERN_ALERT "\nNumber of inodes per block %lu", sb->s_inodes_per_block); /* Number of inodes per block */
printk (KERN_ALERT "\nNumber of fragments in a group %lu", sb->s_frags_per_group); /* Number of fragments in a group */
printk (KERN_ALERT "\nNumber of blocks in a group %lu", sb->s_blocks_per_group); /* Number of blocks in a group */
printk (KERN_ALERT "\nNumber of inodes in a group %lu", sb->s_inodes_per_group); /* Number of inodes in a group */
printk (KERN_ALERT "\nNumber of inode table blocks per group%lu", sb->s_itb_per_group); /* Number of inode table blocks per group */
printk (KERN_ALERT "\nNumber of group descriptor blocks %lu", sb->s_gdb_count); /* Number of group descriptor blocks */
printk (KERN_ALERT "\nNumber of group descriptors per block %lu", sb->s_desc_per_block); /* Number of group descriptors per block */
printk (KERN_ALERT "\nNumber of groups in the fs %lu", sb->s_groups_count); /* Number of groups in the fs */
printk (KERN_ALERT "\nLast calculated overhead %lu", sb->s_overhead_last); /* Last calculated overhead */
printk (KERN_ALERT "\nLast seen block count%lu", sb->s_blocks_last); /* Last seen block count */
/*
struct buffer_head * s_sbh;
*//* Buffer containing the super block */
/*
struct ext2_super_block * s_es; //pointer to disk super block ext2 super block
*/
/* Pointer to the super block in the buffer */
/*
struct buffer_head ** s_group_desc;
unsigned long s_mount_opt;
unsigned long sb->s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
unsigned short s_pad;
*/
printk (KERN_ALERT "\nsb->s_addr_per_block_bits %d",
sb->s_addr_per_block_bits);
printk (KERN_ALERT "\nsb->s_desc_per_block_bits %d",
sb->s_desc_per_block_bits);
printk (KERN_ALERT "\nsb->s_desc_per_block_bits %d", sb->s_inode_size);
printk (KERN_ALERT "\nsb->s_desc_per_block_bits %d", sb->s_first_ino);
/*spinlock_t s_next_gen_lock;
u32 s_next_generation;
unsigned long s_dir_count;
u8 *s_debts;
struct percpu_counter s_freeblocks_counter;
struct percpu_counter s_freeinodes_counter;
struct percpu_counter s_dirs_counter;
struct blockgroup_lock s_blockgroup_lock;
*/
/* root of the per fs reservation window tree */
/*spinlock_t s_rsv_window_lock;
struct rb_root s_rsv_window_root;
struct ext2_reserve_window_node s_rsv_window_head;
*/
return;
}
Powered by
Google Project Hosting