Skip to content

Commit

Permalink
xnu-517.3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent 5245d98 commit 8cbfc45
Show file tree
Hide file tree
Showing 70 changed files with 4,816 additions and 755 deletions.
4 changes: 2 additions & 2 deletions bsd/conf/MASTER.i386
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
# Standard Apple Research Configurations:
# -------- ----- -------- ---------------
#
# RELEASE = [intel pc mach medium event vol pst gdb kernobjc libdriver fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 volfs devfs synthfs revfs hfs mrouting ipdivert ipfirewall inet6 ipsec gif tcpdrop_synfin ktrace stf]
# RELEASE = [intel pc mach medium event vol pst gdb kernobjc libdriver fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 volfs devfs synthfs revfs hfs mrouting ipdivert ipfirewall inet6 ipsec gif tcpdrop_synfin ktrace stf vlan]
# PROFILE = [RELEASE profile]
# DEBUG = [intel pc mach medium event vol pst gdb kernobjc libdriver_g fixpri debug simple_clock mdebug kernserv driverkit xpr_debug uxpr kernstack ipc_compat ipc_debug nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs hfs volfs devfs synthfs mach_assert mrouting ipdivert ipfirewall inet6 ipsec gif tcpdrop_synfin ktrace stf]
# DEBUG = [intel pc mach medium event vol pst gdb kernobjc libdriver_g fixpri debug simple_clock mdebug kernserv driverkit xpr_debug uxpr kernstack ipc_compat ipc_debug nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs hfs volfs devfs synthfs mach_assert mrouting ipdivert ipfirewall inet6 ipsec gif tcpdrop_synfin ktrace stf vlan]
#
######################################################################
#
Expand Down
6 changes: 3 additions & 3 deletions bsd/conf/MASTER.ppc
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
# Standard Apple Research Configurations:
# -------- ----- -------- ---------------
#
# RELEASE = [ppc mach medium vol pst gdb simple_clock kernstack nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs noprofiling hfs volfs devfs synthfs netat mrouting ipdivert ipfirewall ktrace inet6 ipsec tcpdrop_synfin gif stf]
# RELEASE = [ppc mach medium vol pst gdb simple_clock kernstack nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs noprofiling hfs volfs devfs synthfs netat mrouting ipdivert ipfirewall ktrace inet6 ipsec tcpdrop_synfin gif stf vlan]
# RELEASE_TRACE = [RELEASE kdebug]
# PROFILE = [ppc mach medium vol pst gdb simple_clock kernstack nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs profile hfs volfs devfs synthfs netat mrouting ipdivert ipfirewall ktrace inet6 ipsec tcpdrop_synfin gif stf]
# DEBUG = [ppc mach medium vol pst gdb debug simple_clock kernstack nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs profiling hfs volfs devfs synthfs netat mrouting mach_assert ipdivert ipfirewall ktrace inet6 ipsec tcpdrop_synfin gif stf]
# PROFILE = [ppc mach medium vol pst gdb simple_clock kernstack nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs profile hfs volfs devfs synthfs netat mrouting ipdivert ipfirewall ktrace inet6 ipsec tcpdrop_synfin gif stf vlan]
# DEBUG = [ppc mach medium vol pst gdb debug simple_clock kernstack nfsclient nfsserver quota fifo fdesc union ffs cd9660 compat_43 revfs profiling hfs volfs devfs synthfs netat mrouting mach_assert ipdivert ipfirewall ktrace inet6 ipsec tcpdrop_synfin gif stf vlan]
# DEBUG_TRACE = [DEBUG kdebug]
#
######################################################################
Expand Down
2 changes: 1 addition & 1 deletion bsd/conf/version.minor
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2
3
12 changes: 8 additions & 4 deletions bsd/hfs/hfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3717,10 +3717,14 @@ hfs_makenode(mode, dvp, vpp, cnp)
* have the ASCII name of the userid.
*/
if (VFS_VGET(HFSTOVFS(hfsmp), &parid, &ddvp) == 0) {
if (VTOC(ddvp)->c_desc.cd_nameptr &&
(cp->c_uid == strtoul(VTOC(ddvp)->c_desc.cd_nameptr, 0, 0))) {
cp->c_flags |= UF_NODUMP;
cp->c_flag |= C_CHANGE;
if (VTOC(ddvp)->c_desc.cd_nameptr) {
uid_t uid;

uid = strtoul(VTOC(ddvp)->c_desc.cd_nameptr, 0, 0);
if (uid == cp->c_uid || uid == cnp->cn_cred->cr_uid) {
cp->c_flags |= UF_NODUMP;
cp->c_flag |= C_CHANGE;
}
}
vput(ddvp);
}
Expand Down
18 changes: 14 additions & 4 deletions bsd/hfs/hfscommon/Misc/VolumeAllocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,15 @@ static OSErr BlockFindContiguous(
UInt32 blockRef;
UInt32 wordsPerBlock;

if (!useMetaZone) {
struct hfsmount *hfsmp = VCBTOHFS(vcb);


if ((hfsmp->hfs_flags & HFS_METADATA_ZONE) &&
(startingBlock <= hfsmp->hfs_metazone_end))
startingBlock = hfsmp->hfs_metazone_end + 1;
}

if ((endingBlock - startingBlock) < minBlocks)
{
// The set of blocks we're checking is smaller than the minimum number
Expand Down Expand Up @@ -1428,8 +1437,9 @@ static OSErr BlockFindContiguous(
*/
if (!useMetaZone) {
currentBlock = NextBitmapBlock(vcb, currentBlock);
if (currentBlock >= stopBlock)
break;
if (currentBlock >= stopBlock) {
goto LoopExit;
}
}

err = ReadBitmapBlock(vcb, currentBlock, &buffer, &blockRef);
Expand Down Expand Up @@ -1516,7 +1526,7 @@ static OSErr BlockFindContiguous(

nextBlock = NextBitmapBlock(vcb, currentBlock);
if (nextBlock != currentBlock) {
break; /* allocation gap, so stop */
goto LoopExit; /* allocation gap, so stop */
}
}

Expand Down Expand Up @@ -1585,7 +1595,7 @@ static OSErr BlockFindContiguous(
++vcb->vcbFreeExtCnt;
}
} while (currentBlock < stopBlock);

LoopExit:

// Return the outputs.
if (foundBlocks < minBlocks)
Expand Down
54 changes: 32 additions & 22 deletions bsd/kern/kern_aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ aio_suspend( struct proc *p, struct aio_suspend_args *uap, int *retval )
goto ExitThisRoutine;
}

if ( uap->nent < 1 || uap->nent > AIO_LISTIO_MAX ) {
if ( uap->nent < 1 || uap->nent > aio_max_requests_per_process ) {
error = EINVAL;
goto ExitThisRoutine;
}
Expand Down Expand Up @@ -950,24 +950,29 @@ aio_suspend( struct proc *p, struct aio_suspend_args *uap, int *retval )
goto ExitThisRoutine;
}

/* check list of aio requests to see if any have completed */
/* copyin our aiocb pointers from list */
for ( i = 0; i < uap->nent; i++ ) {
struct aiocb *aiocbp;

/* copyin in aiocb pointer from list */
error = copyin( (void *)(uap->aiocblist + i), (aiocbpp + i), sizeof(aiocbp) );
error = copyin( (void *)(uap->aiocblist + i), (aiocbpp + i), sizeof(*aiocbpp) );
if ( error != 0 ) {
error = EAGAIN;
goto ExitThisRoutine;
}

} /* for ( ; i < uap->nent; ) */

/* check list of aio requests to see if any have completed */
AIO_LOCK;
for ( i = 0; i < uap->nent; i++ ) {
struct aiocb *aiocbp;

/* NULL elements are legal so check for 'em */
aiocbp = *(aiocbpp + i);
if ( aiocbp == NULL )
continue;

/* return immediately if any aio request in the list is done */
AIO_LOCK;
TAILQ_FOREACH( entryp, &p->aio_doneq, aio_workq_link ) {
if ( entryp->uaiocbp == aiocbp ) {
*retval = 0;
Expand All @@ -976,7 +981,6 @@ aio_suspend( struct proc *p, struct aio_suspend_args *uap, int *retval )
goto ExitThisRoutine;
}
}
AIO_UNLOCK;
} /* for ( ; i < uap->nent; ) */

KERNEL_DEBUG( (BSDDBG_CODE(DBG_BSD_AIO, AIO_suspend_sleep)) | DBG_FUNC_NONE,
Expand All @@ -990,10 +994,13 @@ aio_suspend( struct proc *p, struct aio_suspend_args *uap, int *retval )
* use tsleep() here in order to avoid getting kernel funnel lock.
*/
assert_wait( (event_t) &p->AIO_SUSPEND_SLEEP_CHAN, THREAD_ABORTSAFE );
AIO_UNLOCK;

if ( abstime > 0 ) {
thread_set_timer_deadline( abstime );
}
error = thread_block( THREAD_CONTINUE_NULL );

if ( error == THREAD_AWAKENED ) {
/* got our wakeup call from aio_work_thread() */
if ( abstime > 0 ) {
Expand Down Expand Up @@ -1173,19 +1180,18 @@ lio_listio( struct proc *p, struct lio_listio_args *uap, int *retval )
aio_anchor.lio_sync_workq_count++;
}
}
AIO_UNLOCK;

if ( uap->mode == LIO_NOWAIT )
if ( uap->mode == LIO_NOWAIT ) {
/* caller does not want to wait so we'll fire off a worker thread and return */
wakeup_one( &aio_anchor.aio_async_workq );
}
else {
aio_workq_entry *entryp;
int error;

/*
* mode is LIO_WAIT - handle the IO requests now.
*/
AIO_LOCK;
entryp = TAILQ_FIRST( &aio_anchor.lio_sync_workq );
while ( entryp != NULL ) {
if ( p == entryp->procp && group_tag == entryp->group_tag ) {
Expand Down Expand Up @@ -1230,8 +1236,8 @@ lio_listio( struct proc *p, struct lio_listio_args *uap, int *retval )

entryp = TAILQ_NEXT( entryp, aio_workq_link );
} /* while ( entryp != NULL ) */
AIO_UNLOCK;
} /* uap->mode == LIO_WAIT */
AIO_UNLOCK;

/* call_result == -1 means we had no trouble queueing up requests */
if ( call_result == -1 ) {
Expand Down Expand Up @@ -1264,6 +1270,7 @@ aio_work_thread( void )
struct uthread *uthread = (struct uthread *)get_bsdthread_info(current_act());

for( ;; ) {
AIO_LOCK;
entryp = aio_get_some_work();
if ( entryp == NULL ) {
/*
Expand All @@ -1274,6 +1281,7 @@ aio_work_thread( void )
* tsleep() here in order to avoid getting kernel funnel lock.
*/
assert_wait( (event_t) &aio_anchor.aio_async_workq, THREAD_UNINT );
AIO_UNLOCK;
thread_block( THREAD_CONTINUE_NULL );

KERNEL_DEBUG( (BSDDBG_CODE(DBG_BSD_AIO, AIO_worker_wake)) | DBG_FUNC_NONE,
Expand All @@ -1286,6 +1294,8 @@ aio_work_thread( void )
vm_map_t oldmap = VM_MAP_NULL;
task_t oldaiotask = TASK_NULL;

AIO_UNLOCK;

KERNEL_DEBUG( (BSDDBG_CODE(DBG_BSD_AIO, AIO_worker_thread)) | DBG_FUNC_START,
(int)entryp->procp, (int)entryp->uaiocbp, entryp->flags, 0, 0 );

Expand Down Expand Up @@ -1377,6 +1387,7 @@ aio_work_thread( void )
* aio_get_some_work - get the next async IO request that is ready to be executed.
* aio_fsync complicates matters a bit since we cannot do the fsync until all async
* IO requests at the time the aio_fsync call came in have completed.
* NOTE - AIO_LOCK must be held by caller
*/

static aio_workq_entry *
Expand All @@ -1386,7 +1397,6 @@ aio_get_some_work( void )
int skip_count = 0;

/* pop some work off the work queue and add to our active queue */
AIO_LOCK;
for ( entryp = TAILQ_FIRST( &aio_anchor.aio_async_workq );
entryp != NULL;
entryp = TAILQ_NEXT( entryp, aio_workq_link ) ) {
Expand All @@ -1411,7 +1421,6 @@ aio_get_some_work( void )
aio_anchor.aio_active_count++;
entryp->procp->aio_active_count++;
}
AIO_UNLOCK;

return( entryp );

Expand Down Expand Up @@ -1513,13 +1522,12 @@ aio_queue_async_request( struct proc *procp, struct aiocb *aiocbp, int kindOfIO
TAILQ_INSERT_TAIL( &aio_anchor.aio_async_workq, entryp, aio_workq_link );
aio_anchor.aio_async_workq_count++;

AIO_UNLOCK;
wakeup_one( &aio_anchor.aio_async_workq );
AIO_UNLOCK;

KERNEL_DEBUG( (BSDDBG_CODE(DBG_BSD_AIO, AIO_work_queued)) | DBG_FUNC_NONE,
(int)procp, (int)aiocbp, 0, 0, 0 );

wakeup_one( &aio_anchor.aio_async_workq );


return( 0 );

error_exit:
Expand Down Expand Up @@ -1901,15 +1909,15 @@ do_aio_completion( aio_workq_entry *entryp )

AIO_LOCK;
active_requests = aio_active_requests_for_process( entryp->procp );
AIO_UNLOCK;
//AIO_UNLOCK;
if ( active_requests < 1 ) {
/* no active aio requests for this process, continue exiting */
wakeup_one( &entryp->procp->AIO_CLEANUP_SLEEP_CHAN );

KERNEL_DEBUG( (BSDDBG_CODE(DBG_BSD_AIO, AIO_completion_cleanup_wake)) | DBG_FUNC_NONE,
(int)entryp->procp, (int)entryp->uaiocbp, 0, 0, 0 );

wakeup_one( &entryp->procp->AIO_CLEANUP_SLEEP_CHAN );
}
AIO_UNLOCK;
return;
}

Expand All @@ -1923,10 +1931,12 @@ do_aio_completion( aio_workq_entry *entryp )
* call wakeup for them. If we do mark them we should unmark them after
* the aio_suspend wakes up.
*/
AIO_LOCK;
wakeup_one( &entryp->procp->AIO_SUSPEND_SLEEP_CHAN );
AIO_UNLOCK;

KERNEL_DEBUG( (BSDDBG_CODE(DBG_BSD_AIO, AIO_completion_suspend_wake)) | DBG_FUNC_NONE,
(int)entryp->procp, (int)entryp->uaiocbp, 0, 0, 0 );

wakeup_one( &entryp->procp->AIO_SUSPEND_SLEEP_CHAN );

return;

Expand Down
21 changes: 20 additions & 1 deletion bsd/kern/kern_descrip.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,16 @@ fcntl(p, uap, retval)

len = MAXPATHLEN;
MALLOC(pathbuf, char *, len, M_TEMP, M_WAITOK);

error = vn_lock(vp, LK_EXCLUSIVE|LK_RETRY, p);
if (error) {
FREE(pathbuf, M_TEMP);
return (error);
}
error = vn_getpath(vp, pathbuf, &len);
if (error == 0)
error = copyout((caddr_t)pathbuf, (caddr_t)uap->arg, len);
VOP_UNLOCK(vp, 0, p);
FREE(pathbuf, M_TEMP);
return error;
}
Expand All @@ -612,7 +619,13 @@ fcntl(p, uap, retval)
return (EBADF);
vp = (struct vnode *)fp->f_data;

return (VOP_IOCTL(vp, 6, (caddr_t)NULL, 0, fp->f_cred, p));
error = vn_lock(vp, LK_EXCLUSIVE|LK_RETRY, p);
if (error) {
return (error);
}
error = VOP_IOCTL(vp, 6, (caddr_t)NULL, 0, fp->f_cred, p);
VOP_UNLOCK(vp, 0, p);
return error;
}

default:
Expand Down Expand Up @@ -1216,6 +1229,12 @@ fdfree(p)
FREE(fdp->fd_knhash, M_KQUEUE);

FREE_ZONE(fdp, sizeof *fdp, M_FILEDESC);

// XXXdbg
{
void clean_up_fmod_watch(struct proc *p);
clean_up_fmod_watch(p);
}
}

static int
Expand Down
1 change: 1 addition & 0 deletions bsd/kern/kern_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ forkproc(p1, lock)
p2->p_stat = SIDL;
p2->p_pid = nextpid;

p2->p_shutdownstate = 0;
/*
* Make a proc table entry for the new process.
* Start by zeroing the section of proc that is zero-initialized,
Expand Down
2 changes: 1 addition & 1 deletion bsd/kern/kern_newsysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ sysctl_sysctl_name2oid SYSCTL_HANDLER_ARGS
return (error);
}

SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY, 0, 0,
SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_KERN, 0, 0,
sysctl_sysctl_name2oid, "I", "");

static int
Expand Down
Loading

0 comments on commit 8cbfc45

Please sign in to comment.