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"
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/queue.h>
26 #include <ufs/ufsmount.h>
27 #include <ufs/ufs/dinode.h>
29 getinode(fs, dev, inode, ipp, perror)
36 register struct vnode *vp;
37 char fake_vnode[FAKE_INODE_SIZE];
44 register struct ufsmount *ump;
45 register struct vnode *vp;
46 register struct mount *mp;
49 if (mp = TAILQ_FIRST(&mountlist))
52 * XXX Also do the test for MFS
56 if (mp->mnt_stat.f_type == MOUNT_UFS) {
59 if (ump->um_fs == NULL)
61 if (ump->um_dev == dev) {
66 mp = TAILQ_NEXT(mp, mnt_list);
67 } while (mp != TAILQ_FIRST(&mountlist));
72 vp = (struct vnode *)fake_vnode;
73 fake_inode_init(vp, fs);
74 code = iget(VTOI(vp), inode, &ip, 0);
84 igetinode(vfsp, dev, inode, ipp, perror)
91 struct inode *pip, *ip;
92 extern struct osi_dev cacheDev;
93 register int code = 0;
97 AFS_STATCNT(igetinode);
99 if ((code = getinode(vfsp, dev, inode, &ip, perror)) != 0) {
103 if (ip->i_mode == 0) {
104 /* Not an allocated inode */
109 if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) {
121 struct vnode *vp = ITOV(ip);
123 AFS_STATCNT(iforget);
126 /* this whole thing is too wierd. Why??? XXX */
127 if (vp->v_usecount == 1) {
136 * icreate system call -- create an inode
138 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
140 long dev, near_inode, param1, param2, param3, param4;
143 struct inode *ip, *newip;
147 AFS_STATCNT(afs_syscall_icreate);
149 if (!afs_suser(NULL))
152 code = getinode(0, (dev_t) dev, 2, &ip, &dummy);
156 code = ialloc(ip, (ino_t) near_inode, 0, &newip);
162 newip->i_flag |= IACC | IUPD | ICHG;
166 newip->i_mode = IFREG;
175 * if ( !vp->v_object)
177 * extern struct vfs_ubcops ufs_ubcops;
178 * extern struct vm_ubc_object* ubc_object_allocate();
179 * struct vm_ubc_object* vop;
180 * vop = ubc_object_allocate(&vp, &ufs_ubcops,
181 * vp->v_mount->m_funnel);
183 * vp->v_object = vop;
189 /* newip->i_flags |= IC_XUID|IC_XGID; */
190 /* newip->i_flags &= ~IC_PROPLIST; */
191 newip->i_vicep1 = param1;
192 if (param2 == 0x1fffffff /*INODESPECIAL*/) {
193 newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3));
194 newip->i_vicep3a = (u_short) (param3 >> 16);
195 newip->i_vicep3b = (u_short) param3;
198 (((param2 >> 16) & 0x1f) << 27) +
199 (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff);
200 newip->i_vicep3a = (u_short) param4;
201 newip->i_vicep3b = (u_short) param2;
203 newip->i_vicemagic = VICEMAGIC;
205 *retval = newip->i_number;
212 afs_syscall_iopen(dev, inode, usrmod, retval)
214 int dev, inode, usrmod;
218 struct vnode *vp = NULL;
221 extern struct fileops vnops;
224 AFS_STATCNT(afs_syscall_iopen);
226 if (!afs_suser(NULL))
229 code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
233 if ((code = falloc(curproc, &fp, &fd)) != 0) {
239 /* FreeBSD doesn't do much mp stuff yet :( */
241 fp->f_flag = (usrmod) & FMASK;
242 fp->f_type = DTYPE_VNODE;
244 fp->f_data = (caddr_t) ITOV(ip);
252 * Support for iinc() and idec() system calls--increment or decrement
254 * Restricted to super user.
255 * Only VICEMAGIC type inodes.
257 afs_syscall_iincdec(dev, inode, inode_p1, amount)
258 int dev, inode, inode_p1, amount;
264 if (!afs_suser(NULL))
267 code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
271 if (!IS_VICEMAGIC(ip)) {
273 } else if (ip->i_vicep1 != inode_p1) {
276 ip->i_nlink += amount;
277 if (ip->i_nlink == 0) {