- const_text = NULL;
- se = (struct section *) &orig_ts[1];
- for (i = 0; i < orig_ts->nsects; i++, se++) {
- if (!strcmp("__const", se->sectname)) {
- const_text = se;
- break;
- }
- }
- if (!const_text)
- goto out;
-
- header_size = sizeof(struct mach_header)
- + orig_ts->cmdsize
- + orig_ds->cmdsize
- + sizeof(struct symtab_command);
-
- (void) kmem_alloc_wired(kernel_map,
- (vm_offset_t *) &header,
- (vm_size_t) header_size);
- if (header)
- bzero((void *) header, header_size);
- else
- goto out;
-
- /*
- * Set up Mach-O header.
- */
- mh = (struct mach_header *) header;
- mh->magic = orig_mh->magic;
- mh->cputype = orig_mh->cputype;
- mh->cpusubtype = orig_mh->cpusubtype;
- mh->filetype = orig_mh->filetype;
- mh->ncmds = 3;
- mh->sizeofcmds = header_size - sizeof(struct mach_header);
- mh->flags = orig_mh->flags;
-
- // Initialise the current file offset and addr
- offset = round_page(header_size);
- addr = (caddr_t) const_text->addr; // Load address of __TEXT,__const
-
- /*
- * Construct a TEXT segment load command
- * the only part of the TEXT segment we keep is the __TEXT,__const
- * which contains the kernel vtables.
- */
- sg = (struct segment_command *) &mh[1];
- bcopy(orig_ts, sg, orig_ts->cmdsize);
- sg->vmaddr = (unsigned long) addr;
- sg->vmsize = const_text->size;
- sg->fileoff = 0;
- sg->filesize = const_text->size + round_page(header_size);
- sg->maxprot = 0;
- sg->initprot = 0;
- sg->flags = 0;
- se = (struct section *)(sg+1);
- for ( j = 0; j < sg->nsects; j++, se++ ) {
- se->addr = (unsigned long) addr;
- se->size = 0;
- se->offset = offset;
- se->nreloc = 0;
- if (!strcmp("__const", se->sectname)) {
- se->size = const_text->size;
- addr += const_text->size;
- offset += const_text->size;
- const_text = se;
- }
+ if ((error = vnode_open(name, (O_CREAT | FWRITE), (0), 0, &ref->vp, ref->ctx)))
+ goto out;
+
+ VATTR_INIT(&va);
+ VATTR_WANTED(&va, va_rdev);
+ VATTR_WANTED(&va, va_fsid);
+ VATTR_WANTED(&va, va_data_size);
+ VATTR_WANTED(&va, va_nlink);
+ error = EFAULT;
+ if (vnode_getattr(ref->vp, &va, ref->ctx))
+ goto out;
+
+ kprintf("vp va_rdev major %d minor %d\n", major(va.va_rdev), minor(va.va_rdev));
+ kprintf("vp va_fsid major %d minor %d\n", major(va.va_fsid), minor(va.va_fsid));
+ kprintf("vp size %qd\n", va.va_data_size);
+
+ if (ref->vp->v_type == VREG)
+ {
+ /* Don't dump files with links. */
+ if (va.va_nlink != 1)
+ goto out;
+
+ device = va.va_fsid;
+ p1 = (void *) device;
+ p2 = p;
+ do_ioctl = &file_ioctl;