*
* %sccs.include.redist.c%
*
- * @(#)ufs_vnops.c 7.99 (Berkeley) %G%
+ * @(#)ufs_vnops.c 7.101 (Berkeley) %G%
*/
#include <sys/param.h>
#include <sys/specdev.h>
#include <sys/fifo.h>
#include <sys/malloc.h>
+#include <sys/dirent.h>
#include <vm/vm.h>
struct proc *a_p;
} */ *ap;
{
- USES_VOP_ISLOCKED;
register struct vnode *vp = ap->a_vp;
register struct inode *ip = VTOI(vp);
register struct ucred *cred = ap->a_cred;
struct proc *a_p;
} */ *ap;
{
- USES_VOP_TRUNCATE;
- USES_VOP_UPDATE;
register struct vattr *vap = ap->a_vap;
register struct vnode *vp = ap->a_vp;
register struct inode *ip = VTOI(vp);
struct componentname *a_cnp;
} */ *ap;
{
- USES_VOP_UPDATE;
- USES_VOP_ABORTOP;
register struct vnode *vp = ap->a_vp;
register struct vnode *tdvp = ap->a_tdvp;
register struct componentname *cnp = ap->a_cnp;
struct vnode *dvp, **vpp;
struct componentname *cnp;
{
- USES_VOP_LOCK;
- USES_VOP_LOOKUP;
- USES_VOP_UNLOCK;
register struct vnode *dp = 0; /* the directory we are searching */
struct vnode *tdp; /* saved dp */
struct mount *mp; /* mount table entry */
struct componentname *a_tcnp;
} */ *ap;
{
- USES_VOP_ABORTOP;
- USES_VOP_ACCESS;
- USES_VOP_LOCK;
- USES_VOP_TRUNCATE;
- USES_VOP_UNLOCK;
- USES_VOP_UPDATE;
struct vnode *tvp = ap->a_tvp;
register struct vnode *tdvp = ap->a_tdvp;
struct vnode *fvp = ap->a_fvp;
int doingdirectory = 0, oldparent = 0, newparent = 0;
int error = 0;
int fdvpneedsrele = 1, tdvpneedsrele = 1;
+ u_char namlen;
/* Check for cross-device rename */
if ((fvp->v_mount != tdvp->v_mount) ||
UIO_SYSSPACE, IO_NODELOCKED,
tcnp->cn_cred, (int *)0, (struct proc *)0);
if (error == 0) {
- if (dirbuf.dotdot_namlen != 2 ||
+# if (BYTE_ORDER == LITTLE_ENDIAN)
+ if (fvp->v_mount->mnt_maxsymlinklen <= 0)
+ namlen = dirbuf.dotdot_type;
+ else
+ namlen = dirbuf.dotdot_namlen;
+# else
+ namlen = dirbuf.dotdot_namlen;
+# endif
+ if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') {
ufs_dirbad(xp, (doff_t)12,
* A virgin directory (no blushing please).
*/
static struct dirtemplate mastertemplate = {
+ 0, 12, DT_DIR, 1, ".",
+ 0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
+};
+static struct odirtemplate omastertemplate = {
0, 12, 1, ".",
0, DIRBLKSIZ - 12, 2, ".."
};
struct vattr *a_vap;
} */ *ap;
{
- USES_VOP_UPDATE;
- USES_VOP_VALLOC;
- USES_VOP_VFREE;
register struct vnode *dvp = ap->a_dvp;
register struct vattr *vap = ap->a_vap;
register struct componentname *cnp = ap->a_cnp;
register struct inode *ip, *dp;
struct vnode *tvp;
- struct dirtemplate dirtemplate;
+ struct dirtemplate dirtemplate, *dtp;
int error;
int dmode;
goto bad;
/* Initialize directory with "." and ".." from static template. */
- dirtemplate = mastertemplate;
+ if (dvp->v_mount->mnt_maxsymlinklen > 0)
+ dtp = &mastertemplate;
+ else
+ dtp = (struct dirtemplate *)&omastertemplate;
+ dirtemplate = *dtp;
dirtemplate.dot_ino = ip->i_number;
dirtemplate.dotdot_ino = dp->i_number;
error = vn_rdwr(UIO_WRITE, ITOV(ip), (caddr_t)&dirtemplate,
int
ufs_rmdir(ap)
struct vop_rmdir_args /* {
- struct vnodeop_desc *a_desc;
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
} */ *ap;
{
- USES_VOP_TRUNCATE;
register struct vnode *dvp = ap->a_dvp;
register struct componentname *cnp = ap->a_cnp;
register struct inode *ip, *dp;
struct ucred *a_cred;
} */ *ap;
{
- USES_VOP_READ;
register struct uio *uio = ap->a_uio;
int count, lost, error;
return (EINVAL);
uio->uio_resid = count;
uio->uio_iov->iov_len = count;
- error = VOP_READ(ap->a_vp, uio, 0, ap->a_cred);
+# if (BYTE_ORDER == LITTLE_ENDIAN)
+ if (ap->a_vp->v_mount->mnt_maxsymlinklen > 0) {
+ error = VOP_READ(ap->a_vp, uio, 0, ap->a_cred);
+ } else {
+ struct dirent *dp, *edp;
+ struct uio auio;
+ struct iovec aiov;
+ caddr_t dirbuf;
+ int readcnt;
+ u_char tmp;
+
+ auio = *uio;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_segflg = UIO_SYSSPACE;
+ aiov.iov_len = count;
+ MALLOC(dirbuf, caddr_t, count, M_TEMP, M_WAITOK);
+ aiov.iov_base = dirbuf;
+ error = VOP_READ(ap->a_vp, uio, 0, ap->a_cred);
+ if (error == 0) {
+ readcnt = count - auio.uio_resid;
+ edp = (struct dirent *)&dirbuf[readcnt];
+ for (dp = (struct dirent *)dirbuf; dp < edp; ) {
+ tmp = dp->d_namlen;
+ dp->d_namlen = dp->d_type;
+ dp->d_type = tmp;
+ if (dp->d_reclen > 0) {
+ dp = (struct dirent *)
+ ((char *)dp + dp->d_reclen);
+ } else {
+ error = EIO;
+ break;
+ }
+ }
+ if (dp >= edp)
+ error = uiomove(dirbuf, readcnt, uio);
+ }
+ FREE(dirbuf, M_TEMP);
+ }
+# else
+ error = VOP_READ(ap->a_vp, uio, 0, ap->a_cred);
+# endif
uio->uio_resid += lost;
return (error);
}
{
register struct vnode *vp = ap->a_vp;
register struct inode *ip = VTOI(vp);
- USES_VOP_READ;
if (ip->i_size < vp->v_mount->mnt_maxsymlinklen) {
uiomove((char *)ip->i_shortlink, (int)ip->i_size, ap->a_uio);
struct buf *a_bp;
} */ *ap;
{
- USES_VOP_BMAP;
register struct buf *bp = ap->a_bp;
register struct vnode *vp = bp->b_vp;
register struct inode *ip;
struct vnode **vpp;
struct componentname *cnp;
{
- USES_VOP_UPDATE;
- USES_VOP_VALLOC;
- USES_VOP_VFREE;
register struct inode *ip, *pdir;
struct vnode *tvp;
int error;