source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/gpl-linux/dmapi.c @ 223

Last change on this file since 223 was 16, checked in by rock, 17 years ago
File size: 4.1 KB
Line 
1/***************************************************************************
2 *
3 * Copyright (C) 2001 International Business Machines
4 * All rights reserved.
5 *
6 * This file is part of the GPFS mmfslinux kernel module.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 *  1. Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *  2. Redistributions in binary form must reproduce the above copyright
15 *     notice, this list of conditions and the following disclaimer in the
16 *     documentation and/or other materials provided with the distribution.
17 *  3. The name of the author may not be used to endorse or promote products
18 *     derived from this software without specific prior written
19 *     permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *************************************************************************** */
33/* @(#)11       1.7  src/avs/fs/mmfs/ts/kernext/gpl-linux/dmapi.c, mmfs, avs_rgpfs24, rgpfs240610b 5/3/04 15:03:02 */
34
35#include <Shark-gpl.h>
36#include <linux/fs.h>
37#include <linux/string.h>
38#include <linux/file.h>
39#if LINUX_KERNEL_VERSION >= 2050000
40#include <linux/namei.h>
41#endif
42#include <cxiSystem.h>
43#include <cxiCred.h>
44
45/*
46#ifndef _KERNEL
47#define _KERNEL
48#include <cxi2gpfs.h>
49#undef _KERNEL
50#else
51#include <cxi2gpfs.h>
52#endif
53*/
54#include <linux2gpfs.h>
55#include <Trace.h>
56
57Boolean
58cxiIsReadOnlyMnt( void *vfsP)
59{
60  struct super_block *sbP = (struct super_block *)vfsP;
61  Boolean rc = (sbP->s_flags & MS_RDONLY);
62  return rc; 
63}
64
65int
66cxiGetFileAndVp(int fd, void **fileP, void **iPP)
67{
68  struct file *fP = NULL;
69  struct inode *iP = NULL;
70  *fileP = NULL;
71  *iPP = NULL;
72  fP = fget(fd);
73  if (fP == NULL)
74    return EBADF;
75
76  *fileP = (void *)fP;
77  iP = fP->f_dentry->d_inode;
78  *iPP = (void *)iP;
79  return 0;
80}
81
82void
83cxiReleaseFile(int fd, void *fP)
84{
85  struct file *fileP = (struct file *)fP;
86  fput(fileP);
87}
88
89Boolean
90cxiMountedOverVfsType(void *vfsP)
91{
92   struct super_block *sbP = (struct super_block *)vfsP;
93   if (strcmp(sbP->s_type->name, "gpfs") == 0)
94     return true;
95   else
96     return false;
97} 
98 
99void
100cxiGetMountedOverOSNode(void *vfsP, void **mntdovervfsP, 
101                        cxiNode_t **cnP)
102{ 
103   struct super_block *sbP = (struct super_block *)vfsP;
104   struct list_head *p;
105   struct vfsmount *tmp, *parent;
106   struct inode *mntdvverrootIP = NULL;
107   struct super_block *parentsbP; 
108   *mntdovervfsP = NULL;
109   *cnP = NULL;
110#if 0
111   spin_lock(&dcache_lock);
112   list_for_each(p, &sbP->s_mounts)
113   {
114     tmp = list_entry(p, struct vfsmount, mnt_instances);
115     parent = tmp->mnt_parent;
116     parentsbP = parent->mnt_sb;
117     if (parentsbP == sbP && cxiMountedOverVfsType((void *)parentsbP))
118     {
119       *mntdovervfsP = (void *)parentsbP->u.generic_sbp;
120       LOGASSERT(*mntdovervfsP != NULL);
121       mntdvverrootIP = (struct inode *)parentsbP->s_root->d_inode;
122       LOGASSERT(mntdvverrootIP != NULL);
123       *cnP = VP_TO_CNP(mntdvverrootIP);
124       break;
125     }
126   }
127   spin_unlock(&dcache_lock);
128#endif
129} 
130   
131void
132cxiGetRootInode(void *vfsP, cxiNode_t **cnP)
133{
134  struct super_block *sbP = (struct super_block *)vfsP;
135  struct inode *rootIP; 
136  if ( sbP->s_root )
137  {
138    rootIP = (struct inode *)sbP->s_root->d_inode;
139    LOGASSERT(rootIP != NULL);
140    *cnP = VP_TO_CNP(rootIP);
141  }
142}
143   
Note: See TracBrowser for help on using the repository browser.