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 * DUX 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 <ufs/ufsmount.h>
23 getinode(fs, dev, inode, ipp, perror)
30 register struct vnode *vp;
31 char fake_vnode[FAKE_INODE_SIZE];
38 register struct ufsmount *ump;
39 register struct vnode *vp;
40 register struct mount *mp;
45 * XXX Also do the test for MFS
49 if (mp->m_stat.f_type == MOUNT_UFS) {
52 if (ump->um_fs == NULL)
54 if (ump->um_dev == dev) {
63 } while (mp != rootfs);
68 vp = (struct vnode *) fake_vnode;
69 fake_inode_init(vp, fs);
70 code = iget(VTOI(vp), inode, &ip, 0);
80 igetinode(vfsp, dev, inode, ipp, perror)
87 struct inode *pip, *ip;
88 extern struct osi_dev cacheDev;
89 register int code = 0;
93 AFS_STATCNT(igetinode);
95 if ((code = getinode(vfsp, dev, inode, &ip, perror)) != 0) {
99 if (ip->i_mode == 0) {
100 /* Not an allocated inode */
105 if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) {
117 struct vnode *vp = ITOV(ip);
119 AFS_STATCNT(iforget);
122 /* this whole thing is too wierd. Why??? XXX */
123 if (vp->v_usecount == 1) {
132 * icreate system call -- create an inode
134 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
136 long dev, near_inode, param1, param2, param3, param4;
139 struct inode *ip, *newip;
143 AFS_STATCNT(afs_syscall_icreate);
148 code = getinode(0, (dev_t)dev, 2, &ip, &dummy);
152 code = ialloc(ip, (ino_t)near_inode, 0, &newip);
158 newip->i_flag |= IACC|IUPD|ICHG;
162 newip->i_mode = IFREG;
172 extern struct vfs_ubcops ufs_ubcops;
173 extern struct vm_ubc_object* ubc_object_allocate();
174 struct vm_ubc_object* vop;
175 vop = ubc_object_allocate(&vp, &ufs_ubcops,
176 vp->v_mount->m_funnel);
184 newip->i_flags |= IC_XUID|IC_XGID;
185 newip->i_flags &= ~IC_PROPLIST;
186 newip->i_vicep1 = param1;
187 if (param2 == 0x1fffffff/*INODESPECIAL*/) {
188 newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3));
189 newip->i_vicep3a = (u_short)(param3 >> 16);
190 newip->i_vicep3b = (u_short)param3;
192 newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) +
193 (((param4 >> 16) & 0x1f) << 22) +
195 newip->i_vicep3a = (u_short)param4;
196 newip->i_vicep3b = (u_short)param2;
198 newip->i_vicemagic = VICEMAGIC;
200 *retval = newip->i_number;
207 afs_syscall_iopen(dev, inode, usrmod, retval)
209 int dev, inode, usrmod;
213 struct vnode *vp = (struct vnode *)0;
216 extern struct fileops vnops;
219 struct ufile_entry *fe;
222 AFS_STATCNT(afs_syscall_iopen);
227 code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy);
232 if ((code = falloc(&fp, &fd, &fe)) != 0) {
237 if ((code = falloc(&fp, &fd)) != 0) {
245 fp->f_flag = (usrmod-FOPEN) & FMASK;
246 fp->f_type = DTYPE_VNODE;
248 fp->f_data = (caddr_t)ITOV(ip);
252 u_set_fe(fd, fe, fp, &u.u_file_state);
254 U_FD_SET(fd, fp, &u.u_file_state);
262 * Support for iinc() and idec() system calls--increment or decrement
264 * Restricted to super user.
265 * Only VICEMAGIC type inodes.
267 afs_syscall_iincdec(dev, inode, inode_p1, amount)
268 int dev, inode, inode_p1, amount;
277 code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy);
281 if (!IS_VICEMAGIC(ip)) {
283 } else if (ip->i_vicep1 != inode_p1) {
286 ip->i_nlink += amount;
287 if (ip->i_nlink == 0) {