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 * FreeBSD 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/queue.h>
28 #include <ufs/ufsmount.h>
29 #include <ufs/ufs/dinode.h>
31 getinode(fs, dev, inode, ipp, perror)
38 register struct vnode *vp;
39 char fake_vnode[FAKE_INODE_SIZE];
46 register struct ufsmount *ump;
47 register struct vnode *vp;
48 register struct mount *mp;
51 if (mp = TAILQ_FIRST(&mountlist))
54 * XXX Also do the test for MFS
58 if (mp->mnt_stat.f_type == MOUNT_UFS) {
61 if (ump->um_fs == NULL)
63 if (ump->um_dev == dev) {
68 mp = TAILQ_NEXT(mp, mnt_list);
69 } while (mp != TAILQ_FIRST(&mountlist));
74 vp = (struct vnode *)fake_vnode;
75 fake_inode_init(vp, fs);
76 code = iget(VTOI(vp), inode, &ip, 0);
86 igetinode(vfsp, dev, inode, ipp, perror)
93 struct inode *pip, *ip;
94 extern struct osi_dev cacheDev;
95 register int code = 0;
99 AFS_STATCNT(igetinode);
101 if ((code = getinode(vfsp, dev, inode, &ip, perror)) != 0) {
105 if (ip->i_mode == 0) {
106 /* Not an allocated inode */
111 if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) {
123 struct vnode *vp = ITOV(ip);
125 AFS_STATCNT(iforget);
128 /* this whole thing is too wierd. Why??? XXX */
129 if (vp->v_usecount == 1) {
138 * icreate system call -- create an inode
140 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
142 long dev, near_inode, param1, param2, param3, param4;
145 struct inode *ip, *newip;
149 AFS_STATCNT(afs_syscall_icreate);
154 code = getinode(0, (dev_t) dev, 2, &ip, &dummy);
158 code = ialloc(ip, (ino_t) near_inode, 0, &newip);
164 newip->i_flag |= IACC | IUPD | ICHG;
168 newip->i_mode = IFREG;
177 * if ( !vp->v_object)
179 * extern struct vfs_ubcops ufs_ubcops;
180 * extern struct vm_ubc_object* ubc_object_allocate();
181 * struct vm_ubc_object* vop;
182 * vop = ubc_object_allocate(&vp, &ufs_ubcops,
183 * vp->v_mount->m_funnel);
185 * vp->v_object = vop;
191 /* newip->i_flags |= IC_XUID|IC_XGID; */
192 /* newip->i_flags &= ~IC_PROPLIST; */
193 newip->i_vicep1 = param1;
194 if (param2 == 0x1fffffff /*INODESPECIAL*/) {
195 newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3));
196 newip->i_vicep3a = (u_short) (param3 >> 16);
197 newip->i_vicep3b = (u_short) param3;
200 (((param2 >> 16) & 0x1f) << 27) +
201 (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff);
202 newip->i_vicep3a = (u_short) param4;
203 newip->i_vicep3b = (u_short) param2;
205 newip->i_vicemagic = VICEMAGIC;
207 *retval = newip->i_number;
214 afs_syscall_iopen(dev, inode, usrmod, retval)
216 int dev, inode, usrmod;
220 struct vnode *vp = NULL;
223 extern struct fileops vnops;
226 AFS_STATCNT(afs_syscall_iopen);
231 code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
235 if ((code = falloc(curproc, &fp, &fd)) != 0) {
241 /* FreeBSD doesn't do much mp stuff yet :( */
243 fp->f_flag = (usrmod) & FMASK;
244 fp->f_type = DTYPE_VNODE;
246 fp->f_data = (caddr_t) ITOV(ip);
254 * Support for iinc() and idec() system calls--increment or decrement
256 * Restricted to super user.
257 * Only VICEMAGIC type inodes.
259 afs_syscall_iincdec(dev, inode, inode_p1, amount)
260 int dev, inode, inode_p1, amount;
269 code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
273 if (!IS_VICEMAGIC(ip)) {
275 } else if (ip->i_vicep1 != inode_p1) {
278 ip->i_nlink += amount;
279 if (ip->i_nlink == 0) {