Skip to content

Commit

Permalink
bullshit
Browse files Browse the repository at this point in the history
  • Loading branch information
comex committed Jun 21, 2011
1 parent 1b42932 commit 755d4c9
Show file tree
Hide file tree
Showing 28 changed files with 201 additions and 601 deletions.
1 change: 1 addition & 0 deletions catalog/kcode.S
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ syscall_0:
bl _proc_ucred
mov r1, #0
str r1, [r0, #0xc]
str r1, [r0, #0x10]
ldr r0, [r0, #0x6c]
cmp r0, #0
strne r1, [r0, #8]
Expand Down
7 changes: 4 additions & 3 deletions fs/fs.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#define IS_64BIT_PROCESS(x) 0
#include <sys/buf_internal.h>
//extern void IOLog(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
//#define printf(args...) IOLog(args)
//#define printf(args...) (void) (args)
int x_namei(struct nameidata *ndp)
asm("$bl1__vnode_lookup");
void x_nameidone(struct nameidata *)
Expand Down Expand Up @@ -46,3 +43,7 @@ inline void buf_setvnode(buf_t bp, vnode_t vp) {

#define bcopy(a, b, c) memcpy(b, a, c)


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

2 changes: 1 addition & 1 deletion fs/union/union_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ struct vfs_fsentry fe = {
vfstable_t ft;
__attribute__((constructor))
static void init() {
vfs_fsadd(&fe, &ft);
printf("vfs_fsadd: %d\n", vfs_fsadd(&fe, &ft));
}

__attribute__((destructor))
Expand Down
111 changes: 80 additions & 31 deletions fs/union/union_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@
#include <sys/kdebug.h>
#include <sys/uio_internal.h>

static int stub(const char *name, vnode_t vp) {
char buf[512] = "[???]";
int len = 511;
vn_getpath(vp, buf, &len);
buf[len] = 0;
printf("Stub for %s: %s\n", name, buf);
return ENXIO;
}
#define STUB(func, typ, field) static int func(typ ap) { return stub(#func, ap->field); }

__attribute__((const))
static char is_union(vnode_t vp) {
return vp != NULLVP && vp->v_op == union_vnodeop_p;
}

__attribute__((const))
static vnode_t upper(vnode_t vp) {
if(!is_union(vp)) return vp;
return VTOUNION(vp)->un_uppervp;
}

__attribute__((const))
static vnode_t lower(vnode_t vp) {
if(!is_union(vp)) return vp;
return VTOUNION(vp)->un_lowervp;
}

/* called with no union lock held */
static int
union_lookup1(struct vnode *udvp, struct vnode **dvpp, struct vnode **vpp,
Expand Down Expand Up @@ -181,6 +208,8 @@ union_lookup(struct vnop_lookup_args *ap)
int retry_count = 0;

*ap->a_vpp = NULLVP;

printf("looking up %s\n", cnp->cn_nameptr);

retry:
union_lock();
Expand Down Expand Up @@ -228,6 +257,7 @@ union_lookup(struct vnop_lookup_args *ap)
goto out;
}
} else {
printf("lookup: dir = %d\n", vnode_isdir(uppervp));
if(!vnode_isdir(uppervp)) {
vnode_get(*ap->a_vpp = uppervp);
goto out;
Expand Down Expand Up @@ -292,6 +322,8 @@ union_lookup(struct vnop_lookup_args *ap)
* vnode referencing whatever the new top layer and
* whatever the bottom layer returned.
*/

printf("lookup: uerror=%d lerror=%d\n", uerror, lerror);

/* case 1. */
if ((uerror != 0) && (lerror != 0)) {
Expand All @@ -313,6 +345,10 @@ union_lookup(struct vnop_lookup_args *ap)
goto out;
}

printf("lookup: okay we are allocvp'ing\n");

// I don't get this weird reference counting it so I'll just do this
vnode_get(uppervp); vnode_get(lowervp);
union_lock();
error = union_allocvp(ap->a_vpp, dvp->v_mount, dvp, upperdvp, cnp,
uppervp, lowervp, 1);
Expand Down Expand Up @@ -378,9 +414,7 @@ union_create(struct vnop_create_args *ap)
return (EROFS);
}

static int
union_whiteout(struct vnop_whiteout_args *ap)
{ return ENXIO; }
STUB(union_whiteout, struct vnop_whiteout_args *, a_dvp)

/* mknod can do fifos, chr, blk or whiteout entries */
static int
Expand Down Expand Up @@ -427,7 +461,15 @@ union_mknod(struct vnop_mknod_args *ap)

static int
union_open(struct vnop_open_args *ap)
{ return ENXIO; }
{
stub("union_open", ap->a_vp);
struct union_node *un = VTOUNION(ap->a_vp);
printf("upper=%p lower=%p\n", un->un_uppervp, un->un_lowervp);
if(un->un_uppervp != NULLVP) return VNOP_OPEN(un->un_uppervp, ap->a_mode, ap->a_context);
un->un_openl++;
if(un->un_lowervp != NULLVP) return VNOP_OPEN(un->un_lowervp, ap->a_mode, ap->a_context);
return ENOMSG;
}

static int
union_close(struct vnop_close_args *ap)
Expand Down Expand Up @@ -838,19 +880,28 @@ union_remove(struct vnop_remove_args *ap)
*/
{
int error, flags;
struct union_node *dun = VTOUNION(ap->a_dvp);
struct union_node *un = VTOUNION(ap->a_vp);
vnode_t dvp = ap->a_dvp;
vnode_t vp = ap->a_vp;
//IOLog("%d %p %p %d %p %p\n", is_union(ap->a_dvp), dun->un_uppervp, dun->un_lowervp, is_union(ap->a_vp), un->un_uppervp, un->un_lowervp);
//return ENXIO;
struct componentname *cnp = ap->a_cnp;
int busydel = 0;

if(!vnode_isdir(ap->a_vp)) {
int error = ENXIO;
if(upper(dvp) != NULLVP && upper(vp) != NULLVP) if(error = VNOP_REMOVE(upper(dvp), upper(vp), ap->a_cnp, ap->a_flags, ap->a_context)) return error;
if(lower(dvp) != NULLVP && lower(vp) != NULLVP) if(error = VNOP_REMOVE(lower(dvp), lower(vp), ap->a_cnp, ap->a_flags, ap->a_context)) return error;
return error;
}

if(!is_union(dvp) || !is_union(dvp)) return ENXIO;

struct union_node *dun = VTOUNION(ap->a_dvp);
struct union_node *un = VTOUNION(ap->a_vp);

if (dun->un_uppervp == NULLVP)
panic("union remove: null upper vnode");

if (UNNODE_FAULTIN(dun) && ((ap->a_vp != NULLVP) &&
((vnode_isreg(ap->a_vp) != 0) || (vnode_islnk(ap->a_vp) != 0)))) {
return(VNOP_REMOVE(dun->un_uppervp, ap->a_vp, ap->a_cnp, ap->a_flags, ap->a_context));
}

if (un->un_uppervp != NULLVP) {
struct vnode *dvp = dun->un_uppervp;
struct vnode *vp = un->un_uppervp;
Expand Down Expand Up @@ -971,23 +1022,31 @@ union_rename(struct vnop_rename_args *ap)
struct union_node *dun = VTOUNION(fdvp);
struct union_node *un = VTOUNION(fvp);

IOLog("vps: %p, %p, %p, %p\n", fdvp, fvp, tdvp, tvp);
IOLog("upper:%p, %p, %p, %p\n", dun->un_uppervp, un->un_uppervp, upper(tdvp), upper(tvp));
IOLog("lower:%p, %p, %p, %p\n", dun->un_lowervp, un->un_lowervp, lower(tdvp), lower(tvp));
return ENXIO;


if(un->un_uppervp != NULLVP) {
if(dun->un_uppervp == NULLVP) panic("wat (upper)");
if(error = VNOP_RENAME(dun->un_uppervp, un->un_uppervp, ap->a_fcnp, tdvp, tvp, ap->a_tcnp, ap->a_context)) {
if(error = VNOP_RENAME(dun->un_uppervp, un->un_uppervp, ap->a_fcnp, upper(tdvp), upper(tvp), ap->a_tcnp, ap->a_context)) {
printf("got an error from upper: %d\n", error);
return error;
}
}


if(un->un_lowervp != NULLVP) {
if(dun->un_lowervp == NULLVP) panic("wat (lower)");
if(error = VNOP_RENAME(dun->un_lowervp, un->un_lowervp, ap->a_fcnp, tdvp, tvp, ap->a_tcnp, ap->a_context)) {
if(error = VNOP_RENAME(dun->un_lowervp, un->un_lowervp, ap->a_fcnp, lower(tdvp), lower(tvp), ap->a_tcnp, ap->a_context)) {
if(un->un_uppervp != NULLVP) {
printf("bad bad bad - the first rename succeeded but the second one failed; trying to rename it back\n");
printf("bad bad bad - the first rename succeeded but the second one failed (%d); trying to rename it back\n", error);
/*
int error2;
if(error2 = VNOP_RENAME(dun->un_uppervp, un->un_uppervp, ap->a_fcnp, tdvp, tvp, ap->a_fcnp, ap->a_context)) {
if(error2 = VNOP_RENAME(dun->un_uppervp, un->un_uppervp, ap->a_fcnp, upper(fdvp), NULLVP, ap->a_fcnp, ap->a_context)) {
printf("that failed too: %d\n", error2);
}
*/
}
return error;
}
Expand Down Expand Up @@ -1152,9 +1211,7 @@ union_readdir(struct vnop_readdir_args *ap)
return (VCALL(uvp, VOFFSET(vnop_readdir), ap));
}

static int
union_readlink(struct vnop_readlink_args *ap)
{ return ENXIO; }
STUB(union_readlink, struct vnop_readlink_args *, a_vp)

static int
union_inactive(struct vnop_inactive_args *ap)
Expand Down Expand Up @@ -1316,24 +1373,16 @@ union_strategy(struct vnop_strategy_args *ap)
}

/* Pagein */
static int
union_pagein(struct vnop_pagein_args *ap)
{ return ENXIO; }
STUB(union_pagein, struct vnop_pagein_args *, a_vp)

/* Pageout */
static int
union_pageout(struct vnop_pageout_args *ap)
{ return ENXIO; }
STUB(union_pageout, struct vnop_pageout_args *, a_vp)

/* Blktooff derives file offset for the given logical block number */
static int
union_blktooff(struct vnop_blktooff_args *ap)
{ return ENXIO; }
STUB(union_blktooff, struct vnop_blktooff_args *, a_vp)

/* offtoblk derives file offset for the given logical block number */
static int
union_offtoblk(struct vnop_offtoblk_args *ap)
{ return ENXIO; }
STUB(union_offtoblk, struct vnop_offtoblk_args *, a_vp)

#define VOPFUNC int (*)(void *)

Expand Down
Loading

0 comments on commit 755d4c9

Please sign in to comment.