source: trunk/kernel/vfs/devfs.h @ 378

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

Fixing bugs in vfs_lookup()

File size: 6.6 KB
RevLine 
[23]1/*
2 * devfs.h - DEVFS File System API definition                               
3 *
4 * Authors       Mohamed Lamine Karaoui (2014,2015)
5 *               Alain Greiner (2016,2017)
6 *
7 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef _DEVFS_H_
26#define _DEVFS_H_
27
[188]28//////////////////////////////////////////////////////////////////////////////////////////
29// The DEVFS File System contains inodes and dentries associated to all chdev descriptors
[238]30// availables in the architecture.
31//
32// It is structured as a three levels tree structure :
[188]33// - The "dev" directory inode is stored in cluster_IO. It is the root of the DEVFS
34//   file system. The parent inode is the "/" VFS root.
[23]35// - There is one "internal_cxy" directory inode per cluster, that is the parent of
[188]36//   the local children inodes associated to the local, internal chdev descriptors.
37//   The parent dentry is stored in cluster_IO.
[23]38// - The I/O cluster contains one "external" directory inode, that is the parent of
[188]39//   the remote children inodes associated to the remote external chdev descriptors.
40//   The parent dentry is stored in cluster_IO.
[23]41//
[238]42// The DEVFS extensions to the generic VFS are the following:
43// 1) The vfs_ctx_t "extend" field is a void* pointing on the devfs_ctx_t structure.
44//    This structure contains two extended pointers on the DEVFS "dev" directory inode,
45//    and on the "external" directory inode.
46// 2) The vfs_inode_t "extend" field is a void*, pointing on the associated
47//    chdev descriptor.
[188]48//////////////////////////////////////////////////////////////////////////////////////////
[23]49
[188]50/*****************************************************************************************
51 * This structure defines the DEVFS context extension.
52 ****************************************************************************************/
[23]53
[188]54typedef struct devfs_ctx_s
[23]55{
[204]56    xptr_t   dev_inode_xp;               /*! extended pointer on DEVFS root inode       */ 
[188]57    xptr_t   external_inode_xp;          /*! extended pointer on DEVFS external inode   */ 
[23]58}
[188]59devfs_ctx_t;
[23]60
61
62/*****************************************************************************************
[188]63 * This fuction allocates memory from local cluster for a DEVFS context descriptor.
[23]64 *****************************************************************************************
[188]65 * @ return a pointer on the created context / return NULL if failure.
[23]66 ****************************************************************************************/
[188]67devfs_ctx_t * devfs_ctx_alloc();
[23]68
69/*****************************************************************************************
[188]70 * This function initialises the DEVFS context from arguments values, and link it
71 * to the relevant VFS context in the local cluster.
72 *****************************************************************************************
73 * @ devfs_ctx               : local pointer on DEVFS context.
[204]74 * @ devfs_dev_inode_xp      : [out] extended pointer on  <dev> inode.
75 * @ devfs_external_inode_xp : [out] extended pointer on  <external> inode.
[23]76 ****************************************************************************************/
[188]77void devfs_ctx_init( devfs_ctx_t * devfs_ctx,
[204]78                     xptr_t        devfs_dev_inode_xp,
[188]79                     xptr_t        devfs_external_inode_xp );
[23]80
81/*****************************************************************************************
[188]82 * This function releases memory dynamically allocated for the DEVFS context.
[23]83 *****************************************************************************************
[188]84 * @ devfs_ctx   : local pointer on DEVFS context.
[23]85 ****************************************************************************************/
[188]86void devfs_ctx_destroy( devfs_ctx_t * devfs_ctx );
[23]87
88/*****************************************************************************************
[188]89 * This function start to create the DEVFS subtree.
90 * This function should be called once in the cluster containing the VFS parent inode.
91 * More precisely, it creates in cluster IO the "dev" and "external" DEVFS directories.
92 * For each one, it creates the inode and link the associated dentry to parent inode.
93 * The DEVFS root inode is linked to the VFS parent inode identified by <parent_inode_xp>.
[23]94 *****************************************************************************************
[188]95 * @ parent_inode_xp         : extended pointer on the parent VFS inode.
[204]96 * @ devfs_dev_inode_xp      : [out] extended pointer on created <dev> inode.
[188]97 * @ devfs_external_inode_xp : [out] extended pointer on created <external> inode.
[23]98 ****************************************************************************************/
[188]99void devfs_global_init( xptr_t   parent_inode_xp,
[204]100                        xptr_t * devfs_dev_inode_xp,
[188]101                        xptr_t * devfs_external_inode_xp );
[23]102
103/*****************************************************************************************
[188]104 * This function completes the initialisation of the DEVFS subtree.
105 * It should be called once in each cluster.
106 * 1. In each cluster (i), it creates the "internal" directory,
107 *    linked to the DEVFS "dev" parent directory.
108 * 2. In each cluster (i), it creates - for each external chdev in cluster (i) -
109 *    a pseudo-file, linked to the DEVFS "external" parent directory.
110 * 3. In each cluster (i), it creates - for each internal chdev in cluster (i) -
111 *    a pseudo-file, linked to the DEVFS "internal" parent directory.
112 *****************************************************************************************
[204]113 * @ devfs_dev_inode_xp      : extended pointer on DEVFS root inode.
[188]114 * @ devfs_external_inode_xp : extended pointer on DEVFS external inode.
[204]115 * @ devfs_internal_inode_xp : [out] extended pointer on created <internal> inode.
[23]116 ****************************************************************************************/
[204]117void devfs_local_init( xptr_t   devfs_dev_inode_xp,
118                       xptr_t   devfs_external_inode_xp,
119                       xptr_t * devfs_internal_inode_xp );
[188]120                       
[23]121#endif  /* _DEVFS_H_ */
Note: See TracBrowser for help on using the repository browser.