2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * HPUX inode operations
16 #include <afsconfig.h>
17 #include "afs/param.h"
20 #include "afs/sysincludes.h" /* Standard vendor system headers */
21 #include "afsincludes.h" /* Afs-based standard headers */
22 #include "afs/osi_inode.h"
23 #include "afs/afs_stats.h" /* statistics stuff */
24 #include <sys/mount.h>
28 getinode(struct vfs
*vfsp
, dev_t dev
, ino_t inode
, int *perror
)
30 struct mount
*mp
= (vfsp
? VFSTOM(vfsp
) : 0);
34 if (!mp
&& !(mp
= getmp(dev
))) {
38 pip
= iget(dev
, mp
, inode
);
45 igetinode(struct vfs
*vfsp
, dev_t dev
, ino_t inode
, int *perror
)
47 struct inode
*pip
, *ip
;
48 extern struct osi_dev cacheDev
;
52 AFS_STATCNT(igetinode
);
53 ip
= getinode(vfsp
, dev
, inode
, perror
);
56 u
.u_error
= ENOENT
; /* Well... */
59 if (ip
->i_mode
== 0) {
60 /* Not an allocated inode */
65 if (ip
->i_nlink
== 0 || (ip
->i_mode
& IFMT
) != IFREG
) {
79 afs_syscall_icreate(dev
, near_inode
, param1
, param2
, param3
, param4
)
80 long dev
, near_inode
, param1
, param2
, param3
, param4
;
83 struct inode
*ip
, *newip
;
85 AFS_STATCNT(afs_syscall_icreate
);
87 if (!afs_suser(NULL
)) {
92 ip
= getinode(0, (dev_t
) dev
, 2, &dummy
);
94 u
.u_error
= ENOENT
; /* Well... */
98 newip
= (struct inode
*)ialloc(ip
, near_inode
, 0);
103 newip
->i_flag
|= IACC
| IUPD
| ICHG
;
105 newip
->i_mode
= IFREG
;
106 newip
->i_vnode
.v_type
= VREG
;
107 newip
->i_vicemagic
= VICEMAGIC
;
108 newip
->i_vicep1
= param1
;
109 newip
->i_vicep2
= param2
;
110 I_VICE3(newip
) = param3
;
111 newip
->i_vicep4
= param4
;
112 u
.u_r
.r_val1
= newip
->i_number
;
120 afs_syscall_iopen(dev
, inode
, usrmod
)
121 int dev
, inode
, usrmod
;
125 struct vnode
*vp
= NULL
;
127 extern struct fileops vnodefops
;
131 AFS_STATCNT(afs_syscall_iopen
);
133 if (!afs_suser(NULL
)) {
138 ip
= igetinode(0, (dev_t
) dev
, (ino_t
) inode
, &dummy
);
149 fp
->f_ops
= &vnodefops
;
151 fp
->f_data
= (char *)vp
;
152 fp
->f_type
= DTYPE_VNODE
;
153 fp
->f_flag
= (usrmod
+ 1) & (FMASK
);
155 /* Obtained from hp kernel sys/vfs_scalls.c: copen().
156 * Otherwise we panic because the v_writecount
157 * goes less than 0 during close.
159 if ((vp
->v_type
== VREG
) && (fp
->f_flag
& FWRITE
)) {
160 VN_INC_WRITECOUNT(vp
);
163 /* fp->f_count, f_msgcount are set by falloc */
164 /* fp->f_offset zeroed by falloc */
165 /* f_cred set by falloc */
168 * Obtained from hp kernel sys/vfs_scalls.c: copen() does
169 * a PUTF() (defined earlier in the file) before returning,
170 * so we parrot what it does. If this is not done, then
171 * threaded processes will get EBADF errors when they try
172 * to use the resulting file descriptor (e.g. with lseek()).
174 * Note: u.u_r.r_val1 is set by ufalloc(), which is
175 * called by falloc(), which is called above.
177 if (is_multithreaded(u
.u_procp
)) {
185 afs_syscall_iincdec(dev
, inode
, inode_p1
, amount
)
186 int dev
, inode
, inode_p1
, amount
;
192 if (!afs_suser(NULL
)) {
197 ip
= igetinode(0, (dev_t
) dev
, (ino_t
) inode
, &dummy
);
202 if (!IS_VICEMAGIC(ip
))
204 else if (ip
->i_vicep1
!= inode_p1
)
207 ip
->i_nlink
+= amount
;
208 if (ip
->i_nlink
== 0) {