~ubuntu-branches/ubuntu/warty/openafs/warty

« back to all changes in this revision

Viewing changes to src/afs/HPUX/osi_vfsops.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2004-01-10 16:37:33 UTC
  • Revision ID: james.westby@ubuntu.com-20040110163733-jvr0n1uahshlb1uu
Tags: upstream-1.2.11
ImportĀ upstreamĀ versionĀ 1.2.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2000, International Business Machines Corporation and others.
 
3
 * All Rights Reserved.
 
4
 * 
 
5
 * This software has been released under the terms of the IBM Public
 
6
 * License.  For details, see the LICENSE file in the top-level source
 
7
 * directory or online at http://www.openafs.org/dl/license10.html
 
8
 */
 
9
 
 
10
/*
 
11
 * osi_vfsops.c for HPUX
 
12
 */
 
13
#include <afsconfig.h>
 
14
#include "../afs/param.h"
 
15
 
 
16
RCSID("$Header: /afs/sipb.mit.edu/project/openafs/debian/cvs/openafs/src/afs/HPUX/osi_vfsops.c,v 1.1.1.6 2003/07/30 17:08:07 hartmans Exp $");
 
17
 
 
18
#include "../afs/sysincludes.h" /* Standard vendor system headers */
 
19
#include "../afs/afsincludes.h" /* Afs-based standard headers */
 
20
#include "../afs/afs_stats.h"   /* statistics stuff */
 
21
#include <sys/scall_kernprivate.h>
 
22
 
 
23
 
 
24
static char afs_mountpath[512];
 
25
struct vfs *afs_globalVFS = 0;
 
26
struct vcache *afs_globalVp = 0;
 
27
 
 
28
int afs_mount(struct vfs *afsp, char *path, smountargs_t *data)
 
29
{
 
30
    AFS_GLOCK();
 
31
    AFS_STATCNT(afs_mount);
 
32
 
 
33
    if (afs_globalVFS) { /* Don't allow remounts. */
 
34
        AFS_GUNLOCK();
 
35
        return (setuerror(EBUSY));
 
36
    }
 
37
 
 
38
    afs_globalVFS = afsp;
 
39
    afsp->vfs_bsize = 8192;
 
40
    afsp->vfs_fsid[0] = AFS_VFSMAGIC; /* magic */
 
41
    afsp->vfs_fsid[1] = AFS_VFSFSID; 
 
42
    strcpy(afsp->vfs_name, "AFS");
 
43
    afsp->vfs_name[3] = '\0';
 
44
 
 
45
    strncpy(afs_mountpath, path, sizeof(afs_mountpath));
 
46
    afs_mountpath[sizeof afs_mountpath - 1] = '\0';
 
47
 
 
48
#ifndef AFS_NONFSTRANS
 
49
    /* Set up the xlator in case it wasn't done elsewhere */
 
50
    afs_xlatorinit_v2(); 
 
51
#endif
 
52
 
 
53
    AFS_GUNLOCK();
 
54
    return 0;
 
55
}
 
56
 
 
57
 
 
58
int afs_unmount(struct vfs *afsp)
 
59
{
 
60
    AFS_GLOCK();
 
61
    AFS_STATCNT(afs_unmount);
 
62
 
 
63
    afs_globalVFS = 0;
 
64
    afs_shutdown();
 
65
 
 
66
    AFS_GUNLOCK();
 
67
    return 0;
 
68
}       
 
69
 
 
70
int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1)
 
71
{
 
72
    int code = 0;
 
73
    struct vrequest treq;
 
74
    register struct vcache *tvp=0;
 
75
    AFS_GLOCK();
 
76
    AFS_STATCNT(afs_root);
 
77
 
 
78
    if (afs_globalVp && (afs_globalVp->states & CStatd)) {
 
79
        tvp = afs_globalVp;
 
80
    } else {
 
81
        if (!(code = afs_InitReq(&treq,  p_cred(u.u_procp))) &&
 
82
            !(code = afs_CheckInit())) {
 
83
            tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
 
84
                                (struct vcache*)0, WRITE_LOCK);
 
85
            /* we really want this to stay around */
 
86
            if (tvp) {
 
87
                afs_globalVp = tvp;
 
88
            } else
 
89
                code = ENOENT;
 
90
        }
 
91
    }
 
92
    if (tvp) {
 
93
        VN_HOLD(AFSTOV(tvp));
 
94
        SET_V_FLAG(AFSTOV(tvp), VROOT);
 
95
 
 
96
        afs_globalVFS = afsp;
 
97
        *avpp = AFSTOV(tvp);
 
98
    }
 
99
 
 
100
    afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
 
101
               ICL_TYPE_INT32, code);
 
102
 
 
103
    AFS_GUNLOCK();
 
104
    return code;
 
105
}       
 
106
 
 
107
int afs_statfs(register struct vfs *afsp, struct k_statvfs *abp)
 
108
{
 
109
    AFS_GLOCK();
 
110
    AFS_STATCNT(afs_statfs);
 
111
 
 
112
    abp->f_type = 0;
 
113
    abp->f_frsize = 1024;
 
114
    abp->f_bsize = afsp->vfs_bsize;
 
115
    /* Fake a high number below to satisfy programs that use the statfs
 
116
     * call to make sure that there's enough space in the device partition
 
117
     * before storing something there.
 
118
     */
 
119
    abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
 
120
        abp->f_ffree = abp->f_favail = 9000000;
 
121
    abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
 
122
 
 
123
    AFS_GUNLOCK();
 
124
    return 0;
 
125
}       
 
126
 
 
127
int afs_sync(struct vfs *unused1, int unused2)
 
128
{
 
129
    AFS_STATCNT(afs_sync);
 
130
    return 0;
 
131
}
 
132
 
 
133
int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp)
 
134
{
 
135
    int code;
 
136
    struct vrequest treq;
 
137
    AFS_GLOCK();
 
138
    AFS_STATCNT(afs_vget);
 
139
 
 
140
    * avcp = NULL;
 
141
 
 
142
    if ((code = afs_InitReq(&treq, p_cred(u.u_procp)))==0) {
 
143
        code = afs_osi_vget((struct vcache**)avcp, fidp, &treq);
 
144
    }
 
145
 
 
146
    afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
 
147
               ICL_TYPE_INT32, treq.uid, ICL_TYPE_FID, fidp);
 
148
    code = afs_CheckCode(code, &treq, 42);
 
149
 
 
150
    AFS_GUNLOCK();
 
151
    return code;
 
152
}       
 
153
 
 
154
int afs_getmount(struct vfs *vfsp, char *fsmntdir, struct mount_data *mdp, char *unused1)
 
155
{
 
156
    int l;
 
157
 
 
158
    mdp->md_msite = 0;
 
159
    mdp->md_dev = 0;
 
160
    mdp->md_rdev = 0;
 
161
    return(copyoutstr(afs_mountpath, fsmntdir, strlen(afs_mountpath)+1, &l));
 
162
}
 
163
 
 
164
 
 
165
struct vfsops Afs_vfsops = {
 
166
    afs_mount,
 
167
    afs_unmount,
 
168
    afs_root,
 
169
    afs_statfs,
 
170
    afs_sync,
 
171
    afs_vget,
 
172
    afs_getmount,
 
173
    (vfs_freeze_t *)0,  /* vfs_freeze */
 
174
    (vfs_thaw_t *)0,    /* vfs_thaw */
 
175
    (vfs_quota_t *)0,   /* vfs_quota */
 
176
    (vfs_mountroot_t *)0,               /* vfs_mountroot. Note: afs_mountroot_nullop in this
 
177
                         *                position panicked HP 11.00+
 
178
                         */
 
179
    (vfs_size_t *)0     /* vfs_size */
 
180
};
 
181
 
 
182
static int afs_Starting = 0;
 
183
 
 
184
#pragma align 64
 
185
#if defined(AFS_HPUX110_ENV)
 
186
b_sema_t afs_global_sema = {0};
 
187
#else
 
188
sema_t afs_global_sema = {
 
189
   NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, /* sa_type */
 
190
   0, 0, 0, 0, 0, 0, 0, NULL, /* sa_link */
 
191
   NULL, NULL
 
192
#ifdef SEMA_COUNTING
 
193
   , 0, 0, 0, NULL
 
194
#endif
 
195
  };
 
196
#endif
 
197
 
 
198
void
 
199
osi_InitGlock()
 
200
{
 
201
    register ulong_t context;
 
202
 
 
203
    SPINLOCK_USAV(sched_lock, context);
 
204
    if ( !afs_Starting ) {
 
205
        afs_Starting = 1;
 
206
        SPINUNLOCK_USAV(sched_lock, context);
 
207
#if defined(AFS_HPUX110_ENV)
 
208
        b_initsema(&afs_global_sema, 1,  NFS_LOCK_ORDER2, "AFS GLOCK");
 
209
#else
 
210
        initsema(&afs_global_sema, 1, FILESYS_SEMA_PRI, FILESYS_SEMA_ORDER);
 
211
        afsHash(64);    /* 64 buckets */
 
212
#endif
 
213
    } else {
 
214
        SPINUNLOCK_USAV(sched_lock, context);
 
215
    }
 
216
    if (!afs_Starting) {
 
217
        osi_Panic("osi_Init lost initialization race");
 
218
    }
 
219
}
 
220
 
 
221
/*
 
222
 * afsc_link - Initialize VFS
 
223
 */
 
224
int afs_vfs_slot=-1; 
 
225
 
 
226
 
 
227
afsc_link()
 
228
{
 
229
    extern int Afs_syscall(), afs_xioctl(), Afs_xsetgroups();
 
230
 
 
231
    /* For now nothing special is required during AFS initialization. */
 
232
    AFS_STATCNT(afsc_link);
 
233
    osi_Init();         
 
234
    if ( (afs_vfs_slot=add_vfs_type("afs", &Afs_vfsops)) < 0 )
 
235
        return;
 
236
    sysent_assign_function(AFS_SYSCALL, 7, (void (*)())Afs_syscall, "Afs_syscall");
 
237
    sysent_define_arg(AFS_SYSCALL, 0, longArg);
 
238
    sysent_define_arg(AFS_SYSCALL, 1, longArg);
 
239
    sysent_define_arg(AFS_SYSCALL, 2, longArg);
 
240
    sysent_define_arg(AFS_SYSCALL, 3, longArg);
 
241
    sysent_define_arg(AFS_SYSCALL, 4, longArg);
 
242
    sysent_define_arg(AFS_SYSCALL, 5, longArg);
 
243
    sysent_define_arg(AFS_SYSCALL, 6, longArg);
 
244
    sysent_returns_long(AFS_SYSCALL);
 
245
 
 
246
    sysent_delete(80);
 
247
    sysent_assign_function(80, 2, (void (*)())Afs_xsetgroups, "setgroups");
 
248
    sysent_define_arg(80, 0, longArg);
 
249
    sysent_define_arg(80, 1, longArg);
 
250
    sysent_returns_long(80);
 
251
    return 0;
 
252
}
 
253