source: trunk/kernel/fs/sysfs/sysfs_context.c @ 9

Last change on this file since 9 was 9, checked in by alain, 7 years ago

Bloup

File size: 2.2 KB
Line 
1 /*
2 * sysfs/sysfs_context.c - sysfs context related operations
3 *
4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
6 *
7 * This file is part of ALMOS-kernel.
8 *
9 * ALMOS-kernel is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-kernel is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <chdev.h>
24#include <driver.h>
25#include <kmem.h>
26#include <string.h>
27#include <vfs.h>
28#include <errno.h>
29#include <metafs.h>
30
31#include <sysfs.h>
32#include <sysfs-private.h>
33
34sysfs_entry_t sysfs_root_entry;
35
36VFS_CREATE_CONTEXT(sysfs_create_context)
37{ 
38        context->ctx_type    = FS_TYPE_SYSFS;
39        VFS_SET(context->ctx_flags, VFS_FS_LOCAL);
40        context->ctx_op      = (struct vfs_context_op_s *) &sysfs_ctx_op;
41        context->ctx_inode_op = (struct vfs_inode_op_s *) &sysfs_i_op;
42        context->ctx_file_op = (struct vfs_file_op_s *) &sysfs_f_op;
43        return 0;
44}
45
46VFS_DESTROY_CONTEXT(sysfs_destroy_context)
47{
48        return 0;
49}
50
51VFS_READ_ROOT(sysfs_read_root)
52{ 
53        struct sysfs_node_s *info;
54 
55        root->i_links = 1;
56        root->i_size  = 0;
57        root->i_attr  = VFS_DIR;
58        root->i_number = vfs_inum_new(context);
59
60        //info has been allocated by sysfs_init
61        info         = root->i_pv;
62        info->node   = &sysfs_root_entry.node;
63 
64        return 0;
65}
66
67VFS_REPLI_ROOT(sysfs_repli_root)
68{ 
69        struct sysfs_node_s *info;
70
71        info         = root->i_pv;
72        info->node   = &sysfs_root_entry.node;
73 
74        return 0;
75}
76
77VFS_WRITE_ROOT(sysfs_write_root)
78{
79        return 0;
80}
81
82const struct vfs_context_op_s sysfs_ctx_op = 
83{
84        .create     = sysfs_create_context,
85        .destroy    = sysfs_destroy_context,
86        .read_root  = sysfs_read_root,
87        .repli_root = sysfs_repli_root,
88        .write_root = sysfs_write_root
89};
Note: See TracBrowser for help on using the repository browser.