/*
- * Copyright (c) 1995-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1995-2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
mp = (struct mount *)_MALLOC_ZONE((u_long)sizeof(struct mount),
M_MOUNT, M_WAITOK);
bzero((char *)mp, (u_long)sizeof(struct mount));
+
+ /* Initialize the default IO constraints */
+ mp->mnt_maxreadcnt = mp->mnt_maxwritecnt = MAXPHYS;
+ mp->mnt_segreadcnt = mp->mnt_segwritecnt = 32;
+
lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, 0);
(void)vfs_busy(mp, LK_NOWAIT, 0, p);
mp->mnt_op = vfsp->vfc_vfsops;
mp->mnt_flag |= MNT_RDONLY;
else if (mp->mnt_flag & MNT_RDONLY)
mp->mnt_kern_flag |= MNTK_WANTRDWR;
- mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
- MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_UNKNOWNPERMISSIONS);
- mp->mnt_flag |= uap->flags & (MNT_NOSUID | MNT_NOEXEC |
- MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_UNKNOWNPERMISSIONS);
+ mp->mnt_flag &= ~(MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
+ MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC |
+ MNT_UNKNOWNPERMISSIONS | MNT_DONTBROWSE | MNT_AUTOMOUNTED);
+ mp->mnt_flag |= uap->flags & (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
+ MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC |
+ MNT_UNKNOWNPERMISSIONS | MNT_DONTBROWSE | MNT_AUTOMOUNTED);
/*
* Mount the filesystem.
*/
extern unsigned int dp_pgins, dp_pgouts;
if(print_vmpage_stat) {
vm_countdirtypages();
- printf("VP: %d: %d: %d: %d: %d\n", vp_pgodirty, vp_pgoclean, vp_pagein, dp_pgins, dp_pgouts);
+ printf("VP: %d: %d: %d: %d: %d\n", vp_pgodirty, vp_pgoclean, vp_pagein,
+ dp_pgins, dp_pgouts);
}
}
#if DIAGNOSTIC
if (error = VFS_STATFS(mp, sp, p))
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
-/* return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp))); */
- return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)-sizeof(sp->f_reserved3)-sizeof(sp->f_reserved4)));
+ return (copyout((caddr_t)sp, (caddr_t)uap->buf,
+ sizeof(*sp)-sizeof(sp->f_reserved3)-sizeof(sp->f_reserved4)));
}
/*
if (error = VFS_STATFS(mp, sp, p))
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
-/* return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp))); */
- return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)-sizeof(sp->f_reserved3)-sizeof(sp->f_reserved4)));
+ return (copyout((caddr_t)sp, (caddr_t)uap->buf,
+ sizeof(*sp)-sizeof(sp->f_reserved3)-sizeof(sp->f_reserved4)));
}
/*
continue;
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (error = copyout((caddr_t)sp, sfsp, sizeof(*sp) - sizeof(sp->f_reserved3) - sizeof(sp->f_reserved4)))
+ error = copyout((caddr_t)sp, sfsp,
+ sizeof(*sp) - sizeof(sp->f_reserved3) - sizeof(sp->f_reserved4));
+ if (error)
return (error);
sfsp += sizeof(*sp) - sizeof(sp->f_reserved4);
}
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register struct vnode *vp;
- int flags, cmode;
+ int flags, cmode, oflags;
struct file *nfp;
int type, indx, error;
struct flock lf;
struct nameidata nd;
extern struct fileops vnops;
- /* CERT advisory patch applied from FreeBSD */
- /* Refer to Radar#2262895 A. Ramesh */
- flags = FFLAGS(uap->flags);
- if ((flags & (FREAD | FWRITE))==0)
+ oflags = uap->flags;
+ if ((oflags & O_ACCMODE) == O_ACCMODE)
return(EINVAL);
+ flags = FFLAGS(uap->flags);
if (error = falloc(p, &nfp, &indx))
return (error);
fp = nfp;
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- /* with hfs semantics, busy files cannot be deleted */
+ /* with Carbon semantics, busy files cannot be deleted */
if (nodelbusy)
nd.ni_cnd.cn_flags |= NODELETEBUSY;
if (error = namei(&nd))
}
/*
- * Delete a name from the filesystem using HFS semantics.
+ * Delete a name from the filesystem using Carbon semantics.
*/
int
delete(p, uap, retval)
vp = nd.ni_vp;
/*
- XXX A TEMPORARY HACK FOR NOW: Try to track console_user
- by looking for chown() calls on /dev/console from a console process:
+ * XXX A TEMPORARY HACK FOR NOW: Try to track console_user
+ * by looking for chown() calls on /dev/console from a console process.
*/
if ((vp) && (vp->v_specinfo) &&
(major(vp->v_specinfo->si_rdev) == CONSMAJOR) &&
int error;
struct nameidata nd;
- if (uap->length < 0)
- return(EINVAL);
+ if (uap->length < 0)
+ return(EINVAL);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
if (error = namei(&nd))
return (error);
struct file *fp;
int error;
- if (uap->length < 0)
- return(EINVAL);
+ if (uap->length < 0)
+ return(EINVAL);
if (error = fdgetf(p, uap->fd, &fp))
return (error);
if (fp->f_type != DTYPE_VNODE)
return (EINVAL);
-
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
vp = (struct vnode *)fp->f_data;
struct nameidata fromnd, tond;
int error;
int mntrename;
+ int casesense,casepres;
mntrename = FALSE;
error = EINVAL;
/*
* If source is the same as the destination (that is the
- * same inode number) then there is nothing to do.
+ * same inode number) then there is nothing to do...
+ * EXCEPT if the
+ * underlyning file system supports case insensitivity and is case preserving. Then
+ * a special case is made, i.e. foo -> Foo.
+ *
+ * Only file systems that support the pathconf selectors _PC_CASE_SENSITIVE and
+ * _PC_CASE_PRESERVING can have this exception, and then they would need to
+ * handle the special case of getting the same vnode as target and source.
+ * NOTE: Then the target is unlocked going into VOP_RENAME, so not to cause
+ * locking problems. There is a single reference on tvp.
*/
- if (fvp == tvp)
+ if (fvp == tvp) {
error = -1;
+ /*
+ * Check to see if just changing case, if:
+ * - file system is case insensitive
+ * - and also case preserving
+ * _ same parent directories (so changing case by different links is not supported)
+ * For instance: mv a/foo a/Foo
+ */
+ if ((tond.ni_dvp == fromnd.ni_dvp) &&
+ (VOP_PATHCONF(tdvp, _PC_CASE_SENSITIVE, &casesense) == 0) &&
+ (VOP_PATHCONF(tdvp, _PC_CASE_PRESERVING, &casepres) == 0) &&
+ (casesense == 0) &&
+ (casepres == 1)) {
+ /* Since the target is locked...unlock it and lose a ref */
+ vput(tvp);
+ error = 0;
+ }
+ }
/*
* Allow the renaming of mount points.
VOP_UNLOCK(lvp, 0, p);
fp->f_data = (caddr_t) lvp;
fp->f_offset = 0;
- error = vn_close(vp, FREAD, fp->f_cred, p);
+ error = VOP_CLOSE(vp, FREAD, fp->f_cred, p);
+ vrele(vp);
if (error)
return (error);
vp = lvp;
VOP_UNLOCK(lvp, 0, p);
fp->f_data = (caddr_t) lvp;
fp->f_offset = 0;
- error = vn_close(vp, FREAD, fp->f_cred, p);
+ error = VOP_CLOSE(vp, FREAD, fp->f_cred, p);
+ vrele(vp);
if (error)
return (error);
vp = lvp;
*fpp = fp;
return (0);
}
+
/*
* HFS/HFS PlUS SPECIFIC SYSTEM CALLS
* The following 10 system calls are designed to support features
return error;
}
/* end of fsctl system call */
+
+/*
+ * An in-kernel sync for power management to call.
+ */
+__private_extern__ int
+sync_internal(void)
+{
+ boolean_t funnel_state;
+ int error;
+
+ struct sync_args data;
+
+ int retval[2];
+
+ funnel_state = thread_funnel_set(kernel_flock, TRUE);
+
+ error = sync(current_proc(), &data, &retval);
+
+ thread_funnel_set(kernel_flock, funnel_state);
+
+ return (error);
+} /* end of sync_internal call */
+