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"
22 #include "afs/sysincludes.h" /* Standard vendor system headers */
23 #include "afsincludes.h" /* Afs-based standard headers */
24 #include "afs/osi_inode.h"
25 #include "afs/afs_stats.h" /* statistics stuff */
26 #include <sys/mount.h>
30 getinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror)
32 struct mount *mp = (vfsp ? VFSTOM(vfsp) : 0);
36 if (!mp && !(mp = getmp(dev))) {
40 pip = iget(dev, mp, inode);
47 igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror)
49 struct inode *pip, *ip;
50 extern struct osi_dev cacheDev;
51 register int code = 0;
54 AFS_STATCNT(igetinode);
55 ip = getinode(vfsp, dev, inode, perror);
58 u.u_error = ENOENT; /* Well... */
61 if (ip->i_mode == 0) {
62 /* Not an allocated inode */
67 if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) {
81 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4)
82 long dev, near_inode, param1, param2, param3, param4;
85 struct inode *ip, *newip;
87 AFS_STATCNT(afs_syscall_icreate);
89 if (!afs_suser(NULL)) {
94 ip = getinode(0, (dev_t) dev, 2, &dummy);
96 u.u_error = ENOENT; /* Well... */
100 newip = (struct inode *)ialloc(ip, near_inode, 0);
105 newip->i_flag |= IACC | IUPD | ICHG;
107 newip->i_mode = IFREG;
108 newip->i_vnode.v_type = VREG;
109 newip->i_vicemagic = VICEMAGIC;
110 newip->i_vicep1 = param1;
111 newip->i_vicep2 = param2;
112 I_VICE3(newip) = param3;
113 newip->i_vicep4 = param4;
114 u.u_r.r_val1 = newip->i_number;
122 afs_syscall_iopen(dev, inode, usrmod)
123 int dev, inode, usrmod;
127 struct vnode *vp = NULL;
129 extern struct fileops vnodefops;
132 AFS_STATCNT(afs_syscall_iopen);
134 if (!afs_suser(NULL)) {
139 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)) {
178 int fd = (int)u.u_r.r_val1;
186 afs_syscall_iincdec(dev, inode, inode_p1, amount)
187 int dev, inode, inode_p1, amount;
191 register afs_int32 code;
193 if (!afs_suser(NULL)) {
198 ip = igetinode(0, (dev_t) dev, (ino_t) inode, &dummy);
203 if (!IS_VICEMAGIC(ip))
205 else if (ip->i_vicep1 != inode_p1)
208 ip->i_nlink += amount;
209 if (ip->i_nlink == 0) {