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
10 * MACOS inode operations
15 #include <afsconfig.h>
16 #include "afs/param.h"
19 #include "afs/sysincludes.h" /* Standard vendor system headers */
20 #include "afsincludes.h" /* Afs-based standard headers */
21 #include "afs/osi_inode.h"
22 #include "afs/afs_stats.h" /* statistics stuff */
23 #ifndef AFS_DARWIN80_ENV
24 #include <ufs/ufs/ufsmount.h>
26 extern struct ucred afs_osi_cred
;
27 extern int afs_CacheFSType
;
29 #ifdef AFS_DARWIN80_ENV
30 getinode(fs
, dev
, inode
, vpp
, perror
)
44 sprintf(volfspath
, "/.vol/%d/%d", dev
, inode
);
45 code
= vnode_open(volfspath
, O_RDWR
, 0, 0, &vp
, afs_osi_ctxtp
);
56 igetinode(vfsp
, dev
, inode
, vpp
, va
, perror
)
65 extern struct osi_dev cacheDev
;
70 AFS_STATCNT(igetinode
);
71 if ((code
= getinode(vfsp
, dev
, inode
, &vp
, perror
)) != 0) {
74 if (vnode_vtype(vp
) != VREG
&& vnode_vtype(vp
) != VDIR
&& vnode_vtype(vp
) != VLNK
) {
75 vnode_close(vp
, O_RDWR
, afs_osi_ctxtp
);
76 printf("igetinode: bad type %d\n", vnode_vtype(vp
));
80 VATTR_WANTED(va
, va_mode
);
81 VATTR_WANTED(va
, va_nlink
);
82 VATTR_WANTED(va
, va_size
);
83 code
= vnode_getattr(vp
, va
, afs_osi_ctxtp
);
85 vnode_close(vp
, O_RDWR
, afs_osi_ctxtp
);
88 if (!VATTR_ALL_SUPPORTED(va
)) {
89 vnode_close(vp
, O_RDWR
, afs_osi_ctxtp
);
92 if (va
->va_mode
== 0) {
93 vnode_close(vp
, O_RDWR
, afs_osi_ctxtp
);
94 /* Not an allocated inode */
97 if (va
->va_nlink
== 0) {
98 vnode_close(vp
, O_RDWR
, afs_osi_ctxtp
);
106 getinode(fs
, dev
, inode
, vpp
, perror
)
119 struct ufsmount
*ump
;
121 struct hfsmount
*hmp
;
125 extern struct mount
*rootfs
;
129 * XXX Also do the test for MFS
131 if (!strcmp(mp
->mnt_vfc
->vfc_name
, "ufs")) {
133 if (ump
->um_fs
== NULL
)
135 if (ump
->um_dev
== dev
) {
140 if (!strcmp(mp
->mnt_vfc
->vfc_name
, "hfs")) {
143 if (hmp
->hfs_mp
== NULL
)
146 if (hmp
->hfs_raw_dev
== dev
) {
152 mp
= CIRCLEQ_NEXT(mp
, mnt_list
);
153 } while (mp
!= rootfs
);
157 code
= VFS_VGET(fs
, (void *)inode
, &vp
);
167 igetinode(vfsp
, dev
, inode
, vpp
, va
, perror
)
175 struct vnode
*pvp
, *vp
;
176 extern struct osi_dev cacheDev
;
181 AFS_STATCNT(igetinode
);
182 if ((code
= getinode(vfsp
, dev
, inode
, &vp
, perror
)) != 0) {
185 if (vp
->v_type
!= VREG
&& vp
->v_type
!= VDIR
&& vp
->v_type
!= VLNK
) {
186 printf("igetinode: bad type %d\n", vp
->v_type
);
190 VOP_GETATTR(vp
, va
, &afs_osi_cred
, current_proc());
191 if (va
->va_mode
== 0) {
192 /* Not an allocated inode */
196 if (vfsp
&& afs_CacheFSType
== AFS_APPL_HFS_CACHE
&& va
->va_nlink
== 0) {
197 printf("igetinode: hfs nlink 0\n");
199 if (va
->va_nlink
== 0) {
204 VOP_UNLOCK(vp
, 0, current_proc());
213 AFS_STATCNT(iforget
);
214 /* XXX could sleep */
215 vn_lock(vp
, LK_EXCLUSIVE
| LK_RETRY
, current_proc());
216 /* this whole thing is too wierd. Why??? XXX */
217 if (vp
->v_usecount
== 1) {
219 VOP_UNLOCK(vp
, 0, current_proc());
221 simple_lock(&vnode_free_list_slock
);
222 TAILQ_INSERT_TAIL(&vnode_free_list
, vp
, v_freelist
);
224 simple_unlock(&vnode_free_list_slock
);
226 printf("iforget: leaking vnode\n");
235 afs_syscall_icreate(long dev
, long near_inode
, long param1
, long param2
,
236 long param3
, long param4
, long *retval
)
242 afs_syscall_iopen(int dev
, int inode
, int usrmod
, long *retval
)
248 afs_syscall_iincdec(int dev
, int inode
, int inode_p1
, int amount
)