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 "../afs/param.h" /* Should be always first */
17 #include "../afs/sysincludes.h" /* Standard vendor system headers */
18 #include "../afs/afsincludes.h" /* Afs-based standard headers */
19 #include "../afs/osi_inode.h"
20 #include "../afs/afs_stats.h" /* statistics stuff */
21 #include <sys/mount.h>
25 getinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror)
27 struct mount *mp = (vfsp ? VFSTOM(vfsp) : 0);
31 if (!mp && !(mp = getmp(dev))) {
33 return((struct inode *)0);
35 pip=iget(dev,mp,inode);
42 igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror)
44 struct inode *pip, *ip;
45 extern struct osi_dev cacheDev;
46 register int code = 0;
49 AFS_STATCNT(igetinode);
50 ip = getinode(vfsp, dev, inode,perror);
53 u.u_error = ENOENT; /* Well... */
56 if (ip->i_mode == 0) {
57 /* Not an allocated inode */
62 if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) {
76 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4)
77 long dev, near_inode, param1, param2, param3, param4;
80 struct inode *ip, *newip;
82 AFS_STATCNT(afs_syscall_icreate);
89 ip = getinode(0, (dev_t)dev, 2,&dummy);
91 u.u_error = ENOENT; /* Well... */
95 newip = (struct inode *)ialloc(ip, near_inode, 0);
100 newip->i_flag |= IACC|IUPD|ICHG;
102 newip->i_mode = IFREG;
103 newip->i_vnode.v_type = VREG;
104 newip->i_vicemagic = VICEMAGIC;
105 newip->i_vicep1 = param1;
106 newip->i_vicep2 = param2;
107 I_VICE3(newip) = param3;
108 newip->i_vicep4 = param4;
109 u.u_r.r_val1 = newip->i_number;
117 afs_syscall_iopen(dev, inode, usrmod)
118 int dev, inode, usrmod;
122 struct vnode *vp = (struct vnode *)0;
124 extern struct fileops vnodefops;
127 AFS_STATCNT(afs_syscall_iopen);
134 ip = igetinode(0, (dev_t)dev, (ino_t)inode,&dummy);
144 fp->f_ops = &vnodefops;
146 fp->f_data = (char *)vp;
147 fp->f_type = DTYPE_VNODE;
148 fp->f_flag = (usrmod+1) & (FMASK);
150 /* Obtained from hp kernel sys/vfs_scalls.c: copen().
151 * Otherwise we panic because the v_writecount
152 * goes less than 0 during close.
154 if ((vp->v_type == VREG) && (fp->f_flag & FWRITE)) {
155 VN_INC_WRITECOUNT(vp);
158 /* fp->f_count, f_msgcount are set by falloc */
159 /* fp->f_offset zeroed by falloc */
160 /* f_cred set by falloc */
163 * Obtained from hp kernel sys/vfs_scalls.c: copen() does
164 * a PUTF() (defined earlier in the file) before returning,
165 * so we parrot what it does. If this is not done, then
166 * threaded processes will get EBADF errors when they try
167 * to use the resulting file descriptor (e.g. with lseek()).
169 * Note: u.u_r.r_val1 is set by ufalloc(), which is
170 * called by falloc(), which is called above.
172 if (is_multithreaded(u.u_procp)) {
173 int fd = (int)u.u_r.r_val1;
181 afs_syscall_iincdec(dev, inode, inode_p1, amount)
182 int dev, inode, inode_p1, amount;
186 register afs_int32 code;
193 ip = igetinode(0, (dev_t)dev, (ino_t)inode,&dummy);
198 if (!IS_VICEMAGIC(ip))
200 else if (ip->i_vicep1 != inode_p1)
203 ip->i_nlink += amount;
204 if (ip->i_nlink == 0) {