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 * IRIX inode operations
24 * afs_syscall_icreatename64
38 * afs_syscall_ilistinode64
42 #include "../afs/param.h" /* Should be always first */
43 #include "../afs/sysincludes.h" /* Standard vendor system headers */
44 #include "../afs/afsincludes.h" /* Afs-based standard headers */
45 #include "../afs/osi_inode.h"
46 #include "../afs/afs_stats.h" /* statistics stuff */
48 #define BAD_IGET -1000
51 * SGI dependent system calls
55 * `INODESPECIAL' type inodes are ones that describe volumes.
57 #define INODESPECIAL 0xffffffff /* ... from ../vol/viceinode.h */
60 * copy disk inode to incore inode and vice-versa
63 afsdptoip(struct efs_dinode *dp, struct inode *ip)
67 ip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP);
68 osi_Assert(ip->i_version == EFS_IVER_AFSSPEC
69 || ip->i_version == EFS_IVER_AFSINO);
70 ap = (struct afsparms *)ip->i_afs;
72 ap->vicep1 = dmag(dp, 0) << 24 | dmag(dp, 1) << 16 |
73 dmag(dp, 2) << 8 | dmag(dp, 3) << 0;
75 if (ip->i_version == EFS_IVER_AFSSPEC) {
76 ap->vicep3 = dmag(dp, 8); /* Type */
77 ap->vicep4 = dmag(dp, 4) << 24 | dmag(dp, 5) << 16 |
78 dmag(dp, 6) << 8 | dmag(dp, 7) << 0;
82 ap->vicep2 = dmag(dp, 4) << 16 |
83 dmag(dp, 5) << 8 | dmag(dp, 6) << 0;
85 ap->vicep3 = dmag(dp, 7) << 16 |
86 dmag(dp, 8) << 8 | dmag(dp, 9) << 0;
88 ap->vicep4 = dmag(dp, 10) << 16 |
89 dmag(dp, 11) << 8 | (dp)->di_spare;
94 afsiptodp(struct inode *ip, struct efs_dinode *dp)
98 if (ip->i_afs == NULL)
101 osi_Assert(ip->i_version == EFS_IVER_AFSSPEC
102 || ip->i_version == EFS_IVER_AFSINO);
103 ap = (struct afsparms *)ip->i_afs;
104 /* vicep1 is VOLid */
105 dmag(dp, 0) = ap->vicep1 >> 24;
106 dmag(dp, 1) = ap->vicep1 >> 16;
107 dmag(dp, 2) = ap->vicep1 >> 8;
108 dmag(dp, 3) = ap->vicep1 >> 0;
110 if (ip->i_version == EFS_IVER_AFSSPEC) {
112 dmag(dp, 8) = ap->vicep3;
114 dmag(dp, 4) = ap->vicep4 >> 24;
115 dmag(dp, 5) = ap->vicep4 >> 16;
116 dmag(dp, 6) = ap->vicep4 >> 8;
117 dmag(dp, 7) = ap->vicep4 >> 0;
120 dmag(dp, 4) = ap->vicep2 >> 16;
121 dmag(dp, 5) = ap->vicep2 >> 8;
122 dmag(dp, 6) = ap->vicep2 >> 0;
124 dmag(dp, 7) = ap->vicep3 >> 16;
125 dmag(dp, 8) = ap->vicep3 >> 8;
126 dmag(dp, 9) = ap->vicep3 >> 0;
128 dmag(dp, 10) = ap->vicep4 >> 16;
129 dmag(dp, 11) = ap->vicep4 >> 8;
130 dp->di_spare = ap->vicep4 >> 0;
135 afsidestroy(struct inode *ip)
138 kmem_free(ip->i_afs, sizeof(struct afsparms));
143 extern int efs_fstype;
144 #ifdef AFS_SGI_XFS_IOPS_ENV
145 extern int xfs_fstype;
149 getinode(struct vfs *vfsp, dev_t dev, ino_t inode, struct inode **ipp)
156 vfsp = vfs_devsearch(dev, efs_fstype);
158 vfsp = vfs_devsearch(dev);
164 #ifndef AFS_SGI65_ENV
165 if (vfsp->vfs_fstype != efs_fstype)
169 if (error = iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)),
170 (unsigned int)(inode&0xffffffff), &ip)) {
178 igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, struct inode **ipp)
183 AFS_STATCNT(igetinode);
184 if (error = getinode(vfsp, dev, inode, &ip))
193 #define SET_XFS_ERROR(POS, DEV, INO) \
194 XFS_IGET_EPOS = (POS), XFS_IGET_DEV = (DEV), XFS_IGET_INO = (INO)
196 int xfs_getinode(struct vfs *vfsp, dev_t dev, ino_t inode,
197 struct xfs_inode **ipp)
199 struct xfs_inode *ip;
204 vfsp = vfs_devsearch(dev, xfs_fstype);
206 vfsp = vfs_devsearch(dev);
209 SET_XFS_ERROR(1, dev, inode);
213 #ifndef AFS_SGI65_ENV
214 if (vfsp->vfs_fstype != xfs_fstype) {
215 SET_XFS_ERROR(2, vfsp->vfs_dev, inode);
220 if (error = xfs_iget((((struct mount *)
221 ((vfsp)->vfs_bh.bh_first)->bd_pdata)),
222 (void*)0, (xfs_ino_t)inode,
223 XFS_ILOCK_SHARED, &ip, (daddr_t)0)) {
224 SET_XFS_ERROR(3, vfsp->vfs_dev, inode);
232 /* xfs_igetinode now returns an unlocked inode. This is fine, since we
233 * have a refcount on the holding vnode.
235 int xfs_igetinode(struct vfs *vfsp, dev_t dev, ino_t inode,
236 struct xfs_inode **ipp)
238 struct xfs_inode *ip;
243 AFS_STATCNT(igetinode);
246 if (error = xfs_getinode(vfsp, dev, inode, &ip)) {
250 xfs_iunlock(ip, XFS_ILOCK_SHARED);
252 vattr.va_mask = AT_STAT;
253 AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), error);
255 SET_XFS_ERROR(4, vp->v_vfsp->vfs_dev, inode);
259 if (vattr.va_nlink == 0 || vattr.va_type != VREG) {
260 SET_XFS_ERROR(5, vp->v_vfsp->vfs_dev, inode);
269 /**************************************************************************
270 * inode creation routines.
272 ***************************************************************************/
282 /* EFS only fs suite uses this entry point - icreate in afssyscalls.c. */
283 #ifdef AFS_SGI_EFS_IOPS_ENV
285 icreate(struct icreateargs *uap, rval_t *rvp)
287 AFS_STATCNT(icreate);
288 return(afs_syscall_icreate(uap->dev, uap->near_inode, uap->param1,
289 uap->param2, uap->param3, uap->param4, rvp));
293 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp)
294 afs_uint32 dev, near_inode, param1, param2, param3, param4;
297 struct inode *ip, *newip;
302 AFS_STATCNT(afs_syscall_icreate);
306 if (error = getinode(0, (dev_t)dev, 2, &ip))
311 if (error = efs_ialloc(ip, IFREG, 1, NODEV, &newip, &cr)) {
317 newip->i_flags |= IACC|IUPD|ICHG;
319 osi_Assert(newip->i_afs == NULL);
320 newip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP);
321 if (param2 == INODESPECIAL)
322 newip->i_version = EFS_IVER_AFSSPEC;
324 newip->i_version = EFS_IVER_AFSINO;
325 ap = (struct afsparms *)newip->i_afs;
326 ap->vicep1 = param1; /* VOLid */
327 ap->vicep2 = param2; /* Vnode # */
328 ap->vicep3 = param3; /* SPEC:type INO:vnode uniq */
329 ap->vicep4 = param4; /* SPEC:parentId INO:data version */
330 rvp->r_val1 = newip->i_number;
334 #else /* !AFS_SGI_EFS_IOPS_ENV */
336 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp)
337 afs_uint32 dev, near_inode, param1, param2, param3, param4;
342 #endif /* AFS_SGI_EFS_IOPS_ENV */
344 #ifdef AFS_SGI_XFS_IOPS_ENV
345 /* inode creation routines for icreatename64 entry point. Use for EFS/XFS
346 * fileserver suite. For XFS, create a name in the namespace as well as the
347 * inode. For EFS, just call the original routine.
350 #include <afs/xfsattrs.h>
351 #include <sys/attributes.h>
353 extern char *int_to_base64(char *, int);
355 /* Lock against races creating/removing directory - vos zap RO, vos create RW*/
356 kmutex_t afs_vol_create_lock;
357 int afs_vol_create_lock_inited = 0;
358 #define AFS_LOCK_VOL_CREATE() { \
359 if (!afs_vol_create_lock_inited) { \
360 mutex_init(&afs_vol_create_lock, MUTEX_DEFAULT, \
361 "afs_vol_create_lock"); \
362 afs_vol_create_lock_inited = 1; \
364 mutex_enter(&afs_vol_create_lock); \
366 #define AFS_UNLOCK_VOL_CREATE() mutex_exit(&afs_vol_create_lock)
370 * Create an AFS inode in the XFS name space. If required create the proper
371 * containing directory. See sys/xfsattrs.h for the details on the naming
372 * conventions and the usage of file and directory attributes.
374 * The inode parameters are stored in an XFS attribute called "AFS". In
375 * addition gid is set to XFS_VICEMAGIC and uid is set to the low 31 bits
376 * of the RW volume id. This is so inode verification in iinc and idec
377 * don't need to get the attribute. Note that only the low 31 bits are set.
378 * This is because chmod only accepts up to MAX_UID and chmod is used
379 * to correct these values in xfs_ListViceInodes.
382 xfs_icreatename64(struct vfs *vfsp, int datap, int datalen,
383 afs_inode_params_t params, ino_t *inop)
385 #define AFS_PNAME_SIZE 16
388 b64_string_t stmp1, stmp2;
389 afs_xfs_attr_t attrs;
391 int name_version = AFS_XFS_NAME_VERS;
392 int code = 0, unused;
395 int rw_vno; /* volume ID of parent volume */
402 /* Get vnode for directory which will contain new inode. */
403 if (datalen >= AFS_PNAME_SIZE)
406 AFS_COPYINSTR((char*)datap, path, AFS_PNAME_SIZE-1, &junk, unused);
411 rw_vno = (params[1] == INODESPECIAL) ? params[3] : params[0];
415 strcat(path, AFS_INODE_DIR_NAME);
416 strcat(path, int_to_base64(stmp1, rw_vno));
418 if (params[1] == INODESPECIAL)
419 AFS_LOCK_VOL_CREATE();
421 code = gop_lookupname(path, AFS_UIOSYS, FOLLOW, (struct vnode **) 0, &dvp);
422 if (code == ENOENT) {
423 /* Maybe it's an old directory name format. */
424 AFS_COPYINSTR((char*)datap, name, AFS_PNAME_SIZE-1, &junk, unused);
426 strcat(name, int_to_base64(stmp1, rw_vno));
427 code = gop_lookupname(name, AFS_UIOSYS, FOLLOW, (struct vnode **) 0,
430 /* Use old name format. */
432 name_version = AFS_XFS_NAME_VERS1;
436 if (code == ENOENT) {
437 afs_xfs_dattr_t dattr;
438 /* make directory. */
440 code = AFS_VN_OPEN(path, UIO_SYSSPACE, FCREAT|FEXCL, 0700, &dvp,
443 if (code == EEXIST) {
444 /* someone beat us to it? */
445 code = gop_lookupname(path, AFS_UIOSYS, 0, (struct vnode **) 0,
449 AFS_UNLOCK_VOL_CREATE();
455 bzero((char*)&dattr, sizeof(dattr));
456 dattr.atd_version = AFS_XFS_ATD_VERS;
457 dattr.atd_volume = rw_vno;
458 AFS_VOP_ATTR_SET(dvp, AFS_XFS_DATTR, (char*)&dattr,
460 ATTR_ROOT|ATTR_CREATE, OSI_GET_CURRENT_CRED(), code);
464 (void) vn_remove(path, UIO_SYSSPACE, RMDIRECTORY);
465 AFS_UNLOCK_VOL_CREATE();
470 vattr.va_mask = AT_FSID|AT_NODEID; /* gets a guick return using FSID*/
471 AFS_VOP_GETATTR(dvp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
477 bzero((char*)&attrs, sizeof(attrs));
478 attrs.at_pino = vattr.va_nodeid;
481 /* Create the desired file. Use up to ten tries to create a unique name. */
482 (void) strcpy(name, path);
483 (void) strcat(name, "/.");
484 (void) strcat(name, int_to_base64(stmp2, params[2]));
485 s = &name[strlen(name)];
487 attrs.at_tag = 0; /* Initial guess at a unique tag. */
488 for (i=0; i<10; i++) {
491 strcat(s, int_to_base64(stmp1, attrs.at_tag));
492 code = AFS_VN_OPEN(name, UIO_SYSSPACE, FCREAT|FEXCL, 0600, &vp,
494 if (!code || code != EEXIST)
499 /* Unlock the creation process since the directory now has a file in it.*/
500 if (params[1] == INODESPECIAL)
501 AFS_UNLOCK_VOL_CREATE();
504 /* Set attributes. */
505 bcopy((char*)params, (char*)attrs.at_param,
506 sizeof(afs_inode_params_t));
507 attrs.at_attr_version = AFS_XFS_ATTR_VERS;
508 attrs.at_name_version = name_version;
509 AFS_VOP_ATTR_SET(vp, AFS_XFS_ATTR, (char*)&attrs,
511 ATTR_ROOT|ATTR_CREATE, OSI_GET_CURRENT_CRED(),
515 vattr.va_uid = AFS_XFS_VNO_CLIP(params[0]);
516 vattr.va_gid = XFS_VICEMAGIC;
517 vattr.va_mask = AT_MODE | AT_UID | AT_GID;
518 AFS_VOP_SETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
521 vattr.va_mask = AT_NODEID;
522 AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
525 *inop = vattr.va_nodeid;
530 /* remove partially created file. */
531 (void) vn_remove(name, UIO_SYSSPACE, RMFILE);
533 /* and directory if volume special file. */
535 AFS_LOCK_VOL_CREATE();
536 (void) vn_remove(path, UIO_SYSSPACE, RMDIRECTORY);
537 AFS_UNLOCK_VOL_CREATE();
543 /* afs_syscall_icreatename64
544 * This is the icreatename64 entry point used by the combined EFS/XFS
545 * fileserver suite. The datap and datalen do not need to be set for EFS.
548 afs_syscall_icreatename64(int dev, int datap, int datalen, int paramp,
552 afs_inode_params_t param;
562 vfsp = vfs_devsearch(dev, VFS_FSTYPE_ANY);
564 vfsp = vfs_devsearch(dev);
570 AFS_COPYIN((char*)paramp, (char*)param, sizeof(afs_inode_params_t), code);
571 if (vfsp->vfs_fstype == xfs_fstype) {
572 code = xfs_icreatename64(vfsp, datap, datalen, param, &ino);
576 AFS_COPYOUT((char*)&ino, (char*)inop, sizeof(ino_t), code);
580 else if (vfsp->vfs_fstype == efs_fstype) {
581 code = afs_syscall_icreate(dev, 0, param[0], param[1], param[2],
586 ino = (ino_t)rval.r_val1;
587 AFS_COPYOUT((char*)&ino, (char*)inop, sizeof(ino_t), code);
593 #endif /* AFS_SGI_XFS_IOPS_ENV */
596 * iopen system calls -- open an inode for reading/writing
597 * Restricted to super user.
599 * The original EFS only system calls are still present in the kernel for
600 * in case a kernel upgrade is done for a fix, but the EFS fileserver is
609 #ifdef AFS_SGI_XFS_IOPS_ENV
619 afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t *rvp)
627 AFS_STATCNT(afs_syscall_iopen);
630 vfsp = vfs_devsearch(dev, xfs_fstype);
632 vfsp = vfs_devsearch(dev, efs_fstype);
636 #ifdef AFS_SGI_EFS_IOPS_ENV
637 if (vfsp->vfs_fstype == efs_fstype) {
639 if (error = igetinode(vfsp, (dev_t)dev, inode, &ip))
642 if (error = vfile_alloc((usrmod+1) & (FMASK), &fp, &fd)) {
649 #endif /* AFS_SGI_EFS_IOPS_ENV */
650 if (vfsp->vfs_fstype == xfs_fstype) {
651 struct xfs_inode *xip;
652 if (error = xfs_igetinode(vfsp, (dev_t)dev, inode, &xip))
655 if (error = vfile_alloc((usrmod+1) & (FMASK), &fp, &fd)) {
661 osi_Panic("afs_syscall_iopen: bad fstype = %d\n",
670 * EFS/XFS version vectors to correct code based vfs_fstype. Expects a
671 * 64 bit inode number.
674 afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t *rvp)
681 AFS_STATCNT(afs_syscall_iopen);
684 vfsp = vfs_devsearch(dev);
689 if (vfsp->vfs_fstype == xfs_fstype) {
690 struct xfs_inode *xip;
692 if (error = xfs_igetinode(vfsp, (dev_t)dev, inode, &xip))
695 if (error = falloc(vp, (usrmod+1) & (FMASK), &fp, &fd)) {
700 else if (vfsp->vfs_fstype == efs_fstype) {
702 if (error = igetinode(vfsp, (dev_t)dev, inode, &ip))
704 if (error = falloc(EFS_ITOV(ip), (usrmod+1) & (FMASK), &fp, &fd)) {
711 osi_Panic("afs_syscall_iopen: bad fstype = %d\n",
718 #endif /* AFS_SGI65_ENV */
721 iopen(struct iopenargs *uap, rval_t *rvp)
724 return (afs_syscall_iopen(uap->dev, (ino_t)uap->inode, uap->usrmod,
729 iopen64(struct iopenargs64 *uap, rval_t *rvp)
732 return (afs_syscall_iopen(uap->dev,
733 (ino_t)((uap->inode_hi<<32) | uap->inode_lo),
737 #else /* AFS_SGI_XFS_IOPS_ENV */
738 /* iopen/afs_syscall_iopen
740 * Original EFS only 32 bit iopen call.
743 iopen(struct iopenargs *uap, rval_t *rvp)
746 return (afs_syscall_iopen(uap->dev, uap->inode, uap->usrmod, rvp));
750 afs_syscall_iopen(dev, inode, usrmod, rvp)
751 int dev, inode, usrmod;
759 AFS_STATCNT(afs_syscall_iopen);
762 if (error = igetinode(0, (dev_t)dev, inode, &ip))
764 if (error = falloc(EFS_ITOV(ip), (usrmod+1) & (FMASK), &fp, &fd)) {
775 #endif /* AFS_SGI_XFS_IOPS_ENV */
778 * Support for iinc() and idec() system calls--increment or decrement
780 * Restricted to super user.
781 * Only VICEMAGIC type inodes.
783 #ifdef AFS_SGI_XFS_IOPS_ENV
784 #ifdef AFS_SGI_EFS_IOPS_ENV
787 * XFS/EFS iinc/idec code for EFS. Uses 32 bit inode numbers.
789 static int efs_iincdec(vfsp, inode, inode_p1, amount)
791 int inode, inode_p1, amount;
796 if (error = igetinode(vfsp, NULL, inode, &ip))
799 if (!IS_VICEMAGIC(ip))
801 else if (((struct afsparms *)ip->i_afs)->vicep1 != inode_p1)
804 ip->i_nlink += amount;
805 osi_Assert(ip->i_nlink >= 0);
806 if (ip->i_nlink == 0) {
812 /* XXX sync write?? */
816 #endif /* AFS_SGI_EFS_IOPS_ENV */
820 * XFS/EFS iinc/idec code for EFS. Uses 64 bit inode numbers.
822 static int xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1,
828 afs_xfs_attr_t attrs;
829 int length = SIZEOF_XFS_ATTR_T;
830 afs_xfs_dattr_t dattr;
835 code = xfs_iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)),
836 (void*)0, (xfs_ino_t)inode, XFS_ILOCK_SHARED, &ip,
842 xfs_iunlock(ip, XFS_ILOCK_SHARED);
844 vattr.va_mask = AT_GID | AT_UID | AT_MODE;
845 AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
849 if (!code && (vattr.va_gid != XFS_VICEMAGIC))
852 if (!code && (AFS_XFS_VNO_CLIP(inode_p1) != vattr.va_uid))
860 nlink = vattr.va_mode & AFS_XFS_MODE_LINK_MASK;
866 vattr.va_mode &= ~AFS_XFS_MODE_LINK_MASK;
867 vattr.va_mode |= nlink;
868 vattr.va_mask = AT_MODE;
869 AFS_VOP_SETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
875 b64_string_t stmp1, stmp2;
879 length = SIZEOF_XFS_ATTR_T;
880 AFS_VOP_ATTR_GET(vp, AFS_XFS_ATTR, (char*)&attrs, &length,
881 ATTR_ROOT, OSI_GET_CURRENT_CRED(), code);
884 if (length != SIZEOF_XFS_ATTR_T
885 || attrs.at_attr_version != AFS_XFS_ATTR_VERS)
888 /* Get the vnode for the directory this file is in. */
892 code = xfs_getinode(vp->v_vfsp, NULL, attrs.at_pino, &ip);
897 xfs_iunlock(ip, XFS_ILOCK_SHARED);
899 /* Verify directory attributes. */
900 length = SIZEOF_XFS_DATTR_T;
901 AFS_VOP_ATTR_GET(dvp, AFS_XFS_DATTR , (char*)&dattr, &length,
902 ATTR_ROOT, OSI_GET_CURRENT_CRED(), code);
904 if (length != SIZEOF_XFS_DATTR_T
905 || dattr.atd_version != AFS_XFS_ATD_VERS)
914 strcat(path, int_to_base64(stmp1, attrs.at_param[2]));
916 strcat(path, int_to_base64(stmp1, attrs.at_tag));
918 AFS_VOP_REMOVE(dvp, path, OSI_GET_CURRENT_CRED(), code);
922 vattr.va_mask = AT_NLINK;
923 AFS_VOP_GETATTR(dvp, &vattr, 0, OSI_GET_CURRENT_CRED(),
926 if (vattr.va_nlink == 2) {
927 vnode_t *ddvp; /* parent of volume directory. */
928 /* Try to remove the directory if this is a volume
929 * special file. It's ok to fail.
931 AFS_VOP_LOOKUP(dvp, "..", &ddvp,
932 (struct pathname *)NULL,
933 0, OSI_GET_CURRENT_RDIR(),
934 OSI_GET_CURRENT_CRED(), code2);
939 if (attrs.at_name_version == AFS_XFS_NAME_VERS2)
940 strcpy(path, AFS_INODE_DIR_NAME);
944 (attrs.at_param[1] == INODESPECIAL) ?
945 attrs.at_param[3] : attrs.at_param[0]);
947 AFS_LOCK_VOL_CREATE();
948 AFS_VOP_RMDIR(ddvp, path, OSI_GET_CURRENT_CDIR(),
949 OSI_GET_CURRENT_CRED(), code2);
950 AFS_UNLOCK_VOL_CREATE();
963 iincdec64(int dev, int inode_hi, int inode_lo, int inode_p1, int amount)
970 vfsp = vfs_devsearch(dev, VFS_FSTYPE_ANY);
972 vfsp = vfs_devsearch(dev);
978 if (vfsp->vfs_fstype == xfs_fstype) {
983 return xfs_iincdec64(vfsp, inode, inode_p1, amount);
985 #ifdef AFS_SGI_EFS_IOPS_ENV
986 else if (vfsp->vfs_fstype == efs_fstype) {
987 return efs_iincdec(vfsp, inode_lo, inode_p1, amount);
989 #endif /* AFS_SGI_EFS_IOPS_ENV */
994 afs_syscall_idec64(int dev, int inode_hi, int inode_lo, int inode_p1)
996 return iincdec64(dev, inode_hi, inode_lo, inode_p1, -1);
1000 afs_syscall_iinc64(int dev, int inode_hi, int inode_lo, int inode_p1)
1002 return iincdec64(dev, inode_hi, inode_lo, inode_p1, 1);
1014 #ifdef AFS_SGI65_ENV
1015 int iinc(struct iincargs *uap, rval_t *rvp) {
1019 int idec(struct iincargs *uap, rval_t *rvp) {
1026 * XFS/EFS iinc/idec entry points for EFS only fileservers.
1030 iincdec(dev, inode, inode_p1, amount)
1031 int dev, inode, inode_p1, amount;
1037 vfsp = vfs_devsearch(dev);
1041 if (vfsp->vfs_fstype != efs_fstype)
1044 return efs_iincdec(vfsp, inode, inode_p1, amount);
1047 iinc(struct iincargs *uap, rval_t *rvp) {
1049 return (iincdec(uap->dev, uap->inode, uap->inode_p1, 1));
1053 idec(struct iincargs *uap, rval_t *rvp) {
1055 return (iincdec(uap->dev, uap->inode, uap->inode_p1, -1));
1057 #endif /* AFS_SGI65_ENV */
1059 #else /* AFS_SGI_XFS_IOPS_ENV */
1060 /* afs_syscall_iincdec iinc idec
1062 * These are the original EFS only entry points.
1065 afs_syscall_iincdec(dev, inode, inode_p1, amount)
1066 int dev, inode, inode_p1, amount;
1073 if (error = igetinode(0, (dev_t)dev, inode, &ip))
1076 if (!IS_VICEMAGIC(ip))
1078 else if (((struct afsparms *)ip->i_afs)->vicep1 != inode_p1)
1081 ip->i_nlink += amount;
1082 osi_Assert(ip->i_nlink >= 0);
1083 if (ip->i_nlink == 0) {
1084 CLEAR_VICEMAGIC(ip);
1087 ip->i_flags |= ICHG;
1089 /* XXX sync write?? */
1101 iinc(struct iincargs *uap, rval_t *rvp) {
1103 return (afs_syscall_iincdec(uap->dev, uap->inode, uap->inode_p1, 1));
1107 idec(struct iincargs *uap, rval_t *rvp) {
1109 return (afs_syscall_iincdec(uap->dev, uap->inode, uap->inode_p1, -1));
1111 #endif /* AFS_SGI_XFS_IOPS_ENV */
1113 #ifdef AFS_SGI_XFS_IOPS_ENV
1114 /* afs_syscall_ilistinode64
1115 * Gathers up all required info for ListViceInodes in one system call.
1118 afs_syscall_ilistinode64(int dev, int inode_hi, int inode_lo,
1119 int datap, int datalenp)
1127 afs_xfs_attr_t attrs;
1129 i_list_inode_t data;
1134 #ifdef AFS_SGI65_ENV
1135 vfsp = vfs_devsearch(dev, xfs_fstype);
1137 vfsp = vfs_devsearch(dev);
1142 #ifndef AFS_SGI65_ENV
1143 if (vfsp->vfs_fstype != xfs_fstype)
1147 AFS_COPYIN((char*)datalenp, &idatalen, sizeof(int), code);
1148 if (idatalen < sizeof(i_list_inode_t)) {
1149 idatalen = sizeof(i_list_inode_t);
1150 AFS_COPYOUT((char*)datalenp, (char*)&idatalen, sizeof(int), code);
1153 idatalen = sizeof(i_list_inode_t);
1154 AFS_COPYOUT((char*)datalenp, (char*)&idatalen, sizeof(int), code);
1156 AFS_COPYIN((char*)datap, (char*)&data, sizeof(i_list_inode_t), code);
1157 if (data.ili_version != AFS_XFS_ILI_VERSION) {
1158 data.ili_version = AFS_XFS_ILI_VERSION;
1159 AFS_COPYOUT((char*)&data, (char*)datap, sizeof(i_list_inode_t), code);
1167 code = xfs_iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)),
1168 (void*)0, (xfs_ino_t)inode,
1169 XFS_ILOCK_SHARED, &ip, (daddr_t)0);
1174 xfs_iunlock(ip, XFS_ILOCK_SHARED);
1176 length = SIZEOF_XFS_ATTR_T;
1178 AFS_VOP_ATTR_GET(vp, AFS_XFS_ATTR, (char*)&attrs, &length,
1179 ATTR_ROOT, OSI_GET_CURRENT_CRED(), code);
1185 if (attrs.at_attr_version != AFS_XFS_ATTR_VERS)
1190 vattr.va_mask = AT_STAT;
1191 AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
1195 bzero((char*)&data, sizeof(data));
1196 data.ili_info.inodeNumber = inode;
1197 data.ili_info.byteCount = vattr.va_size;
1198 data.ili_info.linkCount = (vattr.va_mode & AFS_XFS_MODE_LINK_MASK);
1199 bcopy((char*)attrs.at_param, (char*)data.ili_info.param,
1200 sizeof(data.ili_info.param));
1201 data.ili_attr_version = attrs.at_attr_version;
1202 data.ili_name_version = attrs.at_name_version;
1203 data.ili_tag = attrs.at_tag;
1204 data.ili_pino = attrs.at_pino;
1205 data.ili_vno = vattr.va_uid;
1206 data.ili_magic = vattr.va_gid;
1207 AFS_COPYOUT((char*)&data, (char*)datap, sizeof(data), code);
1212 #endif /* AFS_SGI_XFS_IOPS_ENV */