Date: Tue, 22 Oct 2002 08:16:11 -0700 (PDT) From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 19877 for review Message-ID: <200210221516.g9MFGBhg006073@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=19877 Change 19877 by rwatson@rwatson_tislabs on 2002/10/22 08:15:52 Integ trustedbsd base from freebsd main tree: loop back MAC user api and related cleanups; also, sysinstall and libdisk fixes. More kirk FFS/UFS snapshot deadlock fixes. Affected files ... .. //depot/projects/trustedbsd/base/Makefile.inc1#25 integrate .. //depot/projects/trustedbsd/base/crypto/heimdal/kadmin/version4.c#4 integrate .. //depot/projects/trustedbsd/base/gnu/usr.bin/binutils/gdb/kvm-fbsd.c#7 integrate .. //depot/projects/trustedbsd/base/lib/libc/posix1e/mac.3#2 integrate .. //depot/projects/trustedbsd/base/lib/libc/posix1e/posix1e.3#3 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/Makefile#3 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/blocks.c#3 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/change.c#4 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/chunk.c#5 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/create_chunk.c#8 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/disk.c#10 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/disklabel.c#3 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/libdisk.3#2 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/libdisk.h#5 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/rules.c#5 integrate .. //depot/projects/trustedbsd/base/lib/libdisk/write_disk.c#5 integrate .. //depot/projects/trustedbsd/base/release/doc/en_US.ISO8859-1/hardware/alpha/proc-alpha.sgml#11 integrate .. //depot/projects/trustedbsd/base/share/man/man4/ip.4#3 integrate .. //depot/projects/trustedbsd/base/share/man/man7/hier.7#8 integrate .. //depot/projects/trustedbsd/base/share/man/man9/Makefile#21 integrate .. //depot/projects/trustedbsd/base/share/man/man9/mac.9#1 branch .. //depot/projects/trustedbsd/base/sys/alpha/include/psl.h#2 delete .. //depot/projects/trustedbsd/base/sys/compat/linprocfs/linprocfs.c#11 integrate .. //depot/projects/trustedbsd/base/sys/ddb/db_ps.c#10 integrate .. //depot/projects/trustedbsd/base/sys/dev/md/md.c#16 integrate .. //depot/projects/trustedbsd/base/sys/dev/tx/if_tx.c#5 integrate .. //depot/projects/trustedbsd/base/sys/dev/tx/if_txreg.h#2 integrate .. //depot/projects/trustedbsd/base/sys/dev/tx/if_txvar.h#3 integrate .. //depot/projects/trustedbsd/base/sys/fs/msdosfs/msdosfs_vfsops.c#11 integrate .. //depot/projects/trustedbsd/base/sys/fs/specfs/spec_vnops.c#14 integrate .. //depot/projects/trustedbsd/base/sys/kern/init_sysent.c#21 integrate .. //depot/projects/trustedbsd/base/sys/kern/kern_mac.c#21 integrate .. //depot/projects/trustedbsd/base/sys/kern/kern_proc.c#24 integrate .. //depot/projects/trustedbsd/base/sys/kern/subr_disk.c#12 integrate .. //depot/projects/trustedbsd/base/sys/kern/syscalls.c#21 integrate .. //depot/projects/trustedbsd/base/sys/kern/syscalls.master#21 integrate .. //depot/projects/trustedbsd/base/sys/kern/vfs_mount.c#9 integrate .. //depot/projects/trustedbsd/base/sys/netinet/in.h#11 integrate .. //depot/projects/trustedbsd/base/sys/netinet/udp_usrreq.c#16 integrate .. //depot/projects/trustedbsd/base/sys/pci/if_xl.c#10 integrate .. //depot/projects/trustedbsd/base/sys/pci/if_xlreg.h#4 integrate .. //depot/projects/trustedbsd/base/sys/security/mac_biba/mac_biba.c#13 integrate .. //depot/projects/trustedbsd/base/sys/security/mac_biba/mac_biba.h#3 integrate .. //depot/projects/trustedbsd/base/sys/security/mac_mls/mac_mls.c#12 integrate .. //depot/projects/trustedbsd/base/sys/security/mac_mls/mac_mls.h#3 integrate .. //depot/projects/trustedbsd/base/sys/security/mac_none/mac_none.c#8 integrate .. //depot/projects/trustedbsd/base/sys/security/mac_test/mac_test.c#8 integrate .. //depot/projects/trustedbsd/base/sys/sparc64/sparc64/clock.c#4 integrate .. //depot/projects/trustedbsd/base/sys/sparc64/sparc64/tick.c#5 integrate .. //depot/projects/trustedbsd/base/sys/sys/_label.h#2 integrate .. //depot/projects/trustedbsd/base/sys/sys/_types.h#7 integrate .. //depot/projects/trustedbsd/base/sys/sys/cdefs.h#10 integrate .. //depot/projects/trustedbsd/base/sys/sys/mac.h#11 integrate .. //depot/projects/trustedbsd/base/sys/sys/mac_policy.h#12 integrate .. //depot/projects/trustedbsd/base/sys/sys/proc.h#26 integrate .. //depot/projects/trustedbsd/base/sys/sys/syscall.h#22 integrate .. //depot/projects/trustedbsd/base/sys/sys/syscall.mk#22 integrate .. //depot/projects/trustedbsd/base/sys/sys/sysproto.h#23 integrate .. //depot/projects/trustedbsd/base/sys/sys/types.h#15 integrate .. //depot/projects/trustedbsd/base/sys/ufs/ffs/ffs_balloc.c#7 integrate .. //depot/projects/trustedbsd/base/sys/ufs/ffs/ffs_snapshot.c#14 integrate .. //depot/projects/trustedbsd/base/sys/vm/uma.h#8 integrate .. //depot/projects/trustedbsd/base/sys/vm/vm_glue.c#20 integrate .. //depot/projects/trustedbsd/base/usr.sbin/sysinstall/disks.c#6 integrate .. //depot/projects/trustedbsd/base/usr.sbin/sysinstall/install.c#10 integrate .. //depot/projects/trustedbsd/base/usr.sbin/sysinstall/wizard.c#3 integrate Differences ... ==== //depot/projects/trustedbsd/base/Makefile.inc1#25 (text+ko) ==== @@ -1,5 +1,5 @@ # -# $FreeBSD: src/Makefile.inc1,v 1.305 2002/10/20 11:18:55 markm Exp $ +# $FreeBSD: src/Makefile.inc1,v 1.306 2002/10/22 08:30:31 ru Exp $ # # Make command line options: # -DMAKE_KERBEROS4 to build KerberosIV @@ -621,7 +621,7 @@ .endif build-tools: -.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \ +.for _tool in bin/csh bin/sh gnu/usr.bin/cc/cc_tools ${_fortran} \ ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \ usr.bin/awk usr.bin/file usr.sbin/sysinstall ${ECHODIR} "===> ${_tool}"; \ ==== //depot/projects/trustedbsd/base/crypto/heimdal/kadmin/version4.c#4 (text+ko) ==== @@ -41,7 +41,7 @@ #include <krb_err.h> #include <kadm_err.h> -RCSID("$Id: version4.c,v 1.26 2002/09/10 15:20:46 joda Exp $"); +RCSID("$Id: version4.c,v 1.27 2002/10/21 12:35:07 joda Exp $"); #define KADM_NO_OPCODE -1 #define KADM_NO_ENCRYPT -2 @@ -822,6 +822,13 @@ off += _krb5_get_int(msg + off, &rlen, 4); memset(&authent, 0, sizeof(authent)); authent.length = message.length - rlen - KADM_VERSIZE - 4; + + if(authent.length >= MAX_KTXT_LEN) { + krb5_warnx(context, "received bad rlen (%lu)", (unsigned long)rlen); + make_you_loose_packet (KADM_LENGTH_ERROR, reply); + return; + } + memcpy(authent.dat, (char*)msg + off, authent.length); off += authent.length; ==== //depot/projects/trustedbsd/base/gnu/usr.bin/binutils/gdb/kvm-fbsd.c#7 (text+ko) ==== @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $FreeBSD: src/gnu/usr.bin/binutils/gdb/kvm-fbsd.c,v 1.43 2002/10/12 18:08:44 mp Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/binutils/gdb/kvm-fbsd.c,v 1.44 2002/10/21 21:36:36 mp Exp $ */ /* * This works like "remote" but, you use it like this: @@ -500,19 +500,78 @@ #ifdef __sparc64__ -/* -#include "sparc/tm-sp64.h" -*/ +#define SPARC_INTREG_SIZE 8 +static void fetch_kcore_registers (struct pcb *pcbp) { + static struct frame top; + CORE_ADDR f_addr; + int i; + + /* Get the register values out of the sys pcb and store them where + `read_register' will find them. */ + /* + * XXX many registers aren't available. + * XXX for the non-core case, the registers are stale - they are for + * the last context switch to the debugger. + * XXX do something with the floating-point registers? + */ + supply_register (SP_REGNUM, (char *)&pcbp->pcb_fp); + supply_register (PC_REGNUM, (char *)&pcbp->pcb_pc); + f_addr = extract_address (&pcbp->pcb_fp, SPARC_INTREG_SIZE); + /* Load the previous frame by hand (XXX) and supply it. */ + read_memory (f_addr + SPOFF, (char *)&top, sizeof (top)); + for (i = 0; i < 8; i++) + supply_register (i + L0_REGNUM, (char *)&top.fr_local[i]); + for (i = 0; i < 8; i++) + supply_register (i + I0_REGNUM, (char *)&top.fr_in[i]); } - CORE_ADDR fbsd_kern_frame_saved_pc (struct frame_info *fi) { - return NULL; + struct minimal_symbol *sym; + CORE_ADDR frame, pc_addr, pc; + char *buf; + + buf = alloca (MAX_REGISTER_RAW_SIZE); + /* XXX: duplicates fi->extra_info->bottom. */ + frame = (fi->next != NULL) ? fi->next->frame : read_sp (); + pc_addr = frame + offsetof (struct frame, fr_in[7]); + +#define READ_PC(pc, a, b) do { \ + read_memory (a, b, SPARC_INTREG_SIZE); \ + pc = extract_address (b, SPARC_INTREG_SIZE); \ +} while (0) + + READ_PC (pc, pc_addr, buf); + + sym = lookup_minimal_symbol_by_pc (pc); + if (sym != NULL) + { + if (strncmp (SYMBOL_NAME (sym), "tl0_", 4) == 0 || + strcmp (SYMBOL_NAME (sym), "btext") == 0 || + strcmp (SYMBOL_NAME (sym), "mp_startup") == 0 || + strcmp (SYMBOL_NAME (sym), "fork_trampoline") == 0) + { + /* + * Ugly kluge: user space addresses aren't separated from kernel + * ones by range; if encountering a trap from user space, just + * return a 0 to stop the trace. + * Do the same for entry points of kernel processes to avoid + * printing garbage. + */ + pc = 0; + } + if (strncmp (SYMBOL_NAME (sym), "tl1_", 4) == 0) + { + pc_addr = fi->frame + sizeof (struct frame) + + offsetof (struct trapframe, tf_tpc); + READ_PC (pc, pc_addr, buf); + } + } + return (pc); } #endif /* __sparc64__ */ ==== //depot/projects/trustedbsd/base/lib/libc/posix1e/mac.3#2 (text+ko) ==== @@ -31,7 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/posix1e/mac.3,v 1.1 2002/08/02 21:14:42 rwatson Exp $ +.\" $FreeBSD: src/lib/libc/posix1e/mac.3,v 1.2 2002/10/22 01:52:53 rwatson Exp $ .Dd December 21, 2001 .Dt MAC 3 .Sh NAME @@ -129,7 +129,8 @@ .Xr mac_free 3 , .Xr mac_get 3 , .Xr mac_set 3 , -.Xr mac_text 3 +.Xr mac_text 3 , +.Xr mac 9 .Sh STANDARDS POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion of the draft ==== //depot/projects/trustedbsd/base/lib/libc/posix1e/posix1e.3#3 (text+ko) ==== @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/posix1e/posix1e.3,v 1.21 2002/08/09 03:03:08 rwatson Exp $ +.\" $FreeBSD: src/lib/libc/posix1e/posix1e.3,v 1.22 2002/10/22 01:52:53 rwatson Exp $ .\" .Dd January 17, 2000 .Dt POSIX1E 3 @@ -38,7 +38,7 @@ .In sys/acl.h .\" .In sys/audit.h .In sys/capability.h -.\" .In sys/mac.h +.In sys/mac.h .Sh DESCRIPTION The IEEE POSIX.1e specification never left draft form, but the interfaces it describes are now widely used despite inherent limitations. Currently, @@ -97,7 +97,8 @@ .Xr mac 3 , .Xr acl 9 , .Xr cap 9 , -.Xr extattr 9 +.Xr extattr 9 , +.Xr mac 9 .Sh STANDARDS POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion of the draft continues on the cross-platform POSIX.1e implementation ==== //depot/projects/trustedbsd/base/lib/libdisk/Makefile#3 (text+ko) ==== @@ -1,7 +1,7 @@ -# $FreeBSD: src/lib/libdisk/Makefile,v 1.31 2002/05/13 12:00:45 ru Exp $ +# $FreeBSD: src/lib/libdisk/Makefile,v 1.32 2002/10/22 09:13:02 phk Exp $ LIB= disk -SRCS= blocks.c disklabel.c chunk.c disk.c change.c \ +SRCS= blocks.c chunk.c disk.c change.c \ create_chunk.c rules.c write_disk.c INCS= libdisk.h @@ -14,33 +14,6 @@ NOPIC= yes MAN= libdisk.3 -MLINKS+= libdisk.3 Open_Disk.3 \ - libdisk.3 Clone_Disk.3 \ - libdisk.3 Free_Disk.3 \ - libdisk.3 Debug_Disk.3 \ - libdisk.3 Set_Bios_Geom.3 \ - libdisk.3 Delete_Chunk.3 \ - libdisk.3 Collapse_Disk.3 \ - libdisk.3 Collapse_Chunk.3 \ - libdisk.3 Create_Chunk.3 \ - libdisk.3 All_FreeBSD.3 \ - libdisk.3 CheckRules.3 \ - libdisk.3 Disk_Names.3 \ - libdisk.3 Set_Boot_Mgr.3 \ - libdisk.3 Set_Boot_Blocks.3 \ - libdisk.3 Write_Disk.3 \ - libdisk.3 Cyl_Aligned.3 \ - libdisk.3 Next_Cyl_Aligned.3 \ - libdisk.3 Prev_Cyl_Aligned.3 \ - libdisk.3 Track_Aligned.3 \ - libdisk.3 Next_Track_Aligned.3 \ - libdisk.3 Prev_Track_Aligned.3 \ - libdisk.3 Create_Chunk_DWIM.3 \ - libdisk.3 MakeDev.3 \ - libdisk.3 MakeDevDisk.3 \ - libdisk.3 ShowChunkFlags.3 \ - libdisk.3 ChunkCanBeRoot.3 \ - libdisk.3 slice_type_name.3 .include <bsd.lib.mk> ==== //depot/projects/trustedbsd/base/lib/libdisk/blocks.c#3 (text+ko) ==== @@ -8,7 +8,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libdisk/blocks.c,v 1.12 2002/03/25 13:49:15 phk Exp $"); +__FBSDID("$FreeBSD: src/lib/libdisk/blocks.c,v 1.13 2002/10/22 09:13:02 phk Exp $"); #include <stdio.h> #include <stdlib.h> @@ -35,8 +35,9 @@ } int -write_block(int fd, daddr_t block, void *foo, u_long sector_size) +write_block(int fd, daddr_t block, const void *foo, u_long sector_size) { + if (-1 == lseek(fd, (off_t)block * sector_size, SEEK_SET)) return -1; if (sector_size != write(fd, foo, sector_size)) ==== //depot/projects/trustedbsd/base/lib/libdisk/change.c#4 (text+ko) ==== @@ -8,7 +8,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libdisk/change.c,v 1.21 2002/10/14 13:15:14 nyan Exp $"); +__FBSDID("$FreeBSD: src/lib/libdisk/change.c,v 1.23 2002/10/22 11:55:27 phk Exp $"); #include <stdio.h> #include <stdlib.h> @@ -81,7 +81,14 @@ All_FreeBSD(struct disk *d, int force_all) { struct chunk *c; + int type; +#ifdef PC98 + type = 0x494; +#else + type = 0xa5; +#endif + again: for (c = d->chunks->part; c; c = c->next) if (c->type != unused) { @@ -91,19 +98,10 @@ c = d->chunks; if (force_all) { Sanitize_Bios_Geom(d); -#ifdef PC98 - Create_Chunk(d, c->offset, c->size, freebsd, 0x494, + Create_Chunk(d, c->offset, c->size, freebsd, type, CHUNK_FORCE_ALL, "FreeBSD"); -#else - Create_Chunk(d, c->offset, c->size, freebsd, 0xa5, - CHUNK_FORCE_ALL); -#endif } else { -#ifdef PC98 - Create_Chunk(d, c->offset, c->size, freebsd, 0x494, 0, + Create_Chunk(d, c->offset, c->size, freebsd, type, 0, "FreeBSD"); -#else - Create_Chunk(d, c->offset, c->size, freebsd, 0xa5, 0); -#endif } } ==== //depot/projects/trustedbsd/base/lib/libdisk/chunk.c#5 (text+ko) ==== @@ -8,7 +8,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libdisk/chunk.c,v 1.31 2002/03/25 13:49:15 phk Exp $"); +__FBSDID("$FreeBSD: src/lib/libdisk/chunk.c,v 1.33 2002/10/22 10:51:58 phk Exp $"); #include <stdio.h> #include <stdlib.h> @@ -18,12 +18,22 @@ #include <err.h> #include "libdisk.h" -#define new_chunk() memset(malloc(sizeof(struct chunk)), 0, sizeof(struct chunk)) +static struct chunk * +new_chunk(void) +{ + struct chunk *c; + + c = malloc(sizeof *c); + if (c == NULL) + err(1, "malloc"); + memset(c, 0, sizeof *c); + return (c); +} /* Is c2 completely inside c1 ? */ static int -Chunk_Inside(struct chunk *c1, struct chunk *c2) +Chunk_Inside(const struct chunk *c1, const struct chunk *c2) { /* if c1 ends before c2 do */ if (c1->end < c2->end) @@ -34,7 +44,7 @@ return 1; } -struct chunk * +static struct chunk * Find_Mother_Chunk(struct chunk *chunks, u_long offset, u_long end, chunk_e type) { struct chunk *c1,*c2,ct; @@ -92,7 +102,7 @@ } struct chunk * -Clone_Chunk(struct chunk *c1) +Clone_Chunk(const struct chunk *c1) { struct chunk *c2; @@ -112,14 +122,9 @@ return c2; } -int -#ifdef PC98 +static int Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name, chunk_e type, int subtype, u_long flags, const char *sname) -#else -Insert_Chunk(struct chunk *c2, u_long offset, u_long size, const char *name, - chunk_e type, int subtype, u_long flags) -#endif { struct chunk *ct,*cs; @@ -208,13 +213,8 @@ } int -#ifdef PC98 Add_Chunk(struct disk *d, long offset, u_long size, const char *name, chunk_e type, int subtype, u_long flags, const char *sname) -#else -Add_Chunk(struct disk *d, long offset, u_long size, const char *name, - chunk_e type, int subtype, u_long flags) -#endif { struct chunk *c1,*c2,ct; u_long end = offset + size - 1; @@ -233,10 +233,8 @@ c2->offset = c1->offset = offset; c2->size = c1->size = size; c2->end = c1->end = end; -#ifdef PC98 c1->sname = strdup(sname); c2->sname = strdup("-"); -#endif c1->name = strdup(name); c2->name = strdup("-"); c1->type = type; @@ -303,13 +301,8 @@ size -= offset; doit: -#ifdef PC98 return Insert_Chunk(c2, offset, size, name, type, subtype, flags, sname); -#else - return Insert_Chunk(c2, offset, size, name, - type, subtype, flags); -#endif } } return __LINE__; ==== //depot/projects/trustedbsd/base/lib/libdisk/create_chunk.c#8 (text+ko) ==== @@ -8,7 +8,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libdisk/create_chunk.c,v 1.69 2002/10/08 12:12:03 nyan Exp $"); +__FBSDID("$FreeBSD: src/lib/libdisk/create_chunk.c,v 1.72 2002/10/22 10:51:58 phk Exp $"); #include <stdio.h> #include <stdlib.h> @@ -33,38 +33,7 @@ #include <pwd.h> #include "libdisk.h" -static void msgDebug(char *, ...) __printflike(1, 2); - -/* Clone these two from sysinstall because we need our own copies - * due to link order problems with `crunch'. Feh! - */ static int -isDebug() -{ - static int debug = 0; /* Allow debugger to tweak it */ - - return debug; -} - -/* Write something to the debugging port */ -static void -msgDebug(char *fmt, ...) -{ - va_list args; - char *dbg; - static int DebugFD = -1; - - if (DebugFD == -1) - DebugFD = open(_PATH_DEV"ttyv1", O_RDWR); - dbg = (char *)alloca(FILENAME_MAX); - strcpy(dbg, "DEBUG: "); - va_start(args, fmt); - vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); - va_end(args); - write(DebugFD, dbg, strlen(dbg)); -} - -int Fixup_FreeBSD_Names(struct disk *d, struct chunk *c) { struct chunk *c1, *c3; @@ -132,7 +101,7 @@ return 0; } -int +static int Fixup_Extended_Names(struct disk *d, struct chunk *c) { struct chunk *c1; @@ -155,14 +124,13 @@ Fixup_Names(struct disk *d) { struct chunk *c1, *c2; - int i; #ifdef __i386__ struct chunk *c3; int j; #endif c1 = d->chunks; - for(i=1,c2 = c1->part; c2 ; c2 = c2->next) { + for(c2 = c1->part; c2 ; c2 = c2->next) { c2->flags &= ~CHUNK_BSD_COMPAT; if (c2->type == unused) continue; @@ -208,11 +176,7 @@ } int -#ifdef PC98 Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags, const char *sname) -#else -Create_Chunk(struct disk *d, u_long offset, u_long size, chunk_e type, int subtype, u_long flags) -#endif { int i; u_long l; @@ -237,17 +201,13 @@ size -= l; } -#ifdef PC98 i = Add_Chunk(d, offset, size, "X", type, subtype, flags, sname); -#else - i = Add_Chunk(d, offset, size, "X", type, subtype, flags); -#endif Fixup_Names(d); return i; } struct chunk * -Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags) +Create_Chunk_DWIM(struct disk *d, const struct chunk *parent , u_long size, chunk_e type, int subtype, u_long flags) { int i; struct chunk *c1; @@ -263,11 +223,7 @@ } return 0; found: -#ifdef PC98 i = Add_Chunk(d, offset, size, "X", type, subtype, flags, "-"); -#else - i = Add_Chunk(d, offset, size, "X", type, subtype, flags); -#endif if (i) return 0; Fixup_Names(d); @@ -279,180 +235,14 @@ } int -MakeDev(struct chunk *c1, const char *path) -{ - char *p = c1->name; - u_long cmaj, min, unit, part, slice; - char buf[BUFSIZ], buf2[BUFSIZ]; - struct group *grp; - struct passwd *pwd; - struct statfs fs; - uid_t owner; - gid_t group; - - *buf2 = '\0'; - if (isDebug()) - msgDebug("MakeDev: Called with %s on path %s\n", p, path); - if (!strcmp(p, "X")) - return 0; - if (statfs(path, &fs) != 0) { -#ifdef DEBUG - warn("statfs(%s) failed\n", path); -#endif - return 0; - } - if (strcmp(fs.f_fstypename, "devfs") == 0) { - if (isDebug()) - msgDebug("MakeDev: No need to mknod(2) with DEVFS.\n"); - return 1; - } - - if (!strncmp(p, "ad", 2)) - cmaj = 116, p += 2; -#ifdef PC98 - else if (!strncmp(p, "wd", 2)) - cmaj = 3, p += 2; -#endif - else if (!strncmp(p, "wfd", 3)) - cmaj = 87, p += 3; - else if (!strncmp(p, "afd", 3)) - cmaj = 118, p += 3; - else if (!strncmp(p, "fla", 3)) - cmaj = 102, p += 3; - else if (!strncmp(p, "idad", 4)) - cmaj = 109, p += 4; - else if (!strncmp(p, "mlxd", 4)) - cmaj = 131, p += 4; - else if (!strncmp(p, "amrd", 4)) - cmaj = 133, p += 4; - else if (!strncmp(p, "twed", 4)) - cmaj = 147, p += 4; - else if (!strncmp(p, "aacd", 4)) - cmaj = 151, p += 4; - else if (!strncmp(p, "ar", 2)) /* ATA RAID */ - cmaj = 157, p += 2; - else if (!strncmp(p, "da", 2)) /* CAM support */ - cmaj = 13, p += 2; - else { - msgDebug("MakeDev: Unknown major/minor for devtype %s\n", p); - return 0; - } - if (!isdigit(*p)) { - msgDebug("MakeDev: Invalid disk unit passed: %s\n", p); - return 0; - } - unit = *p - '0'; - p++; - if (!*p) { - slice = 1; - part = 2; - goto done; - } - else if (isdigit(*p)) { - unit *= 10; - unit += (*p - '0'); - p++; - } -#ifndef __alpha__ - if (*p != 's') { - msgDebug("MakeDev: `%s' is not a valid slice delimiter\n", p); - return 0; - } - p++; - if (!isdigit(*p)) { - msgDebug("MakeDev: `%s' is an invalid slice number\n", p); - return 0; - } - slice = *p - '0'; - p++; - if (isdigit(*p)) { - slice *= 10; - slice += (*p - '0'); - p++; - } - slice = slice + 1; -#else - slice = 0; -#endif - if (!*p) { - part = 2; - if(c1->type == freebsd) - sprintf(buf2, "%sc", c1->name); - goto done; - } - if (*p < 'a' || *p > 'h') { - msgDebug("MakeDev: `%s' is not a valid partition name.\n", p); - return 0; - } - part = *p - 'a'; - done: - if (isDebug()) - msgDebug("MakeDev: Unit %lu, Slice %lu, Part %lu\n", unit, slice, part); - if (unit > 32) - return 0; - if (slice > 32) - return 0; - if ((pwd = getpwnam("root")) == NULL) { - if (isDebug()) - msgDebug("MakeDev: Unable to lookup user \"root\", using 0.\n"); - owner = 0; - } else { - owner = pwd->pw_uid; - } - if ((grp = getgrnam("operator")) == NULL) { - if (isDebug()) - msgDebug("MakeDev: Unable to lookup group \"operator\", using 5.\n"); - group = 5; - } else { - group = grp->gr_gid; - } - min = unit * 8 + 65536 * slice + part; - sprintf(buf, "%s/r%s", path, c1->name); - unlink(buf); - if (mknod(buf, S_IFCHR|0640, makedev(cmaj,min)) == -1) { - msgDebug("mknod of %s returned failure status!\n", buf); - return 0; - } - if (chown(buf, owner, group) == -1) { - msgDebug("chown of %s returned failure status!\n", buf); - return 0; - } - if (*buf2) { - sprintf(buf, "%s/r%s", path, buf2); - unlink(buf); - if (mknod(buf, S_IFCHR|0640, makedev(cmaj,min)) == -1) { - msgDebug("mknod of %s returned failure status!\n", buf); - return 0; - } - if (chown(buf, owner, group) == -1) { - msgDebug("chown of %s returned failure status!\n", buf); - return 0; - } - } - sprintf(buf, "%s/%s", path, c1->name); - unlink(buf); - if (mknod(buf, S_IFCHR|0640, makedev(cmaj,min)) == -1) { - msgDebug("mknod of %s returned failure status!\n", buf); - return 0; - } - if (chown(buf, owner, group) == -1) { - msgDebug("chown of %s returned failure status!\n", buf); - return 0; - } - return 1; -} - -int -MakeDevChunk(struct chunk *c1, const char *path) +MakeDevChunk(const struct chunk *c1, const char *path) { - int i; - i = MakeDev(c1, path); if (c1->next) MakeDevChunk(c1->next, path); if (c1->part) MakeDevChunk(c1->part, path); - return i; + return 1; } int ==== //depot/projects/trustedbsd/base/lib/libdisk/disk.c#10 (text+ko) ==== @@ -8,7 +8,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libdisk/disk.c,v 1.83 2002/10/20 22:19:37 sam Exp $"); +__FBSDID("$FreeBSD: src/lib/libdisk/disk.c,v 1.87 2002/10/22 10:51:58 phk Exp $"); #include <stdio.h> #include <stdlib.h> @@ -400,15 +400,15 @@ * Callback to collect disk-related data. */ static int -assignToDisk(void *arg, XMLToken t, u_int *slice, u_int64_t v) +assignToDisk(void *arg, XMLToken t, const u_int *slice, u_int64_t v) { struct disklabel *dl = (struct disklabel *) arg; switch ((int) t) { case XML_FWHEADS: + dl->d_ntracks = (u_int32_t) v; + case XML_FWSECTORS: dl->d_nsectors = (u_int32_t) v; - case XML_FWSECTORS: - dl->d_ntracks = (u_int32_t) v; break; case XML_MEDIASIZE: /* store this temporarily; it gets moved later */ @@ -471,7 +471,6 @@ struct dos_partition *dp; void *p; #endif - u_long offset = 0; #ifdef HAVE_GEOM char *confxml = NULL; size_t xmlsize; @@ -612,12 +611,6 @@ continue; if (!Read_Int32(&dp->dp_size)) continue; - - if (dp->dp_typ == DOSPTYP_ONTRACK) { - d->flags |= DISK_ON_TRACK; - offset = 63; - } - } free(p); #endif @@ -631,11 +624,7 @@ if (dl.d_ntracks && dl.d_nsectors) d->bios_cyl = size / (dl.d_ntracks * dl.d_nsectors); -#ifdef PC98 - if (Add_Chunk(d, -offset, size, name, whole, 0, 0, "-")) -#else - if (Add_Chunk(d, -offset, size, name, whole, 0, 0)) -#endif + if (Add_Chunk(d, 0, size, name, whole, 0, 0, "-")) DPRINT(("Failed to add 'whole' chunk")); #ifdef __i386__ @@ -662,7 +651,6 @@ if (! ds.dss_slices[i].ds_size) continue; - ds.dss_slices[i].ds_offset -= offset; snprintf(sname, sizeof(sname), "%ss%d", name, i - 1); #ifdef PC98 subtype = ds.dss_slices[i].ds_type | @@ -707,7 +695,7 @@ ds.dss_slices[i].ds_name)) #else if (Add_Chunk(d, ds.dss_slices[i].ds_offset, - ds.dss_slices[i].ds_size, sname, ce, subtype, flags)) + ds.dss_slices[i].ds_size, sname, ce, subtype, flags, "")) #endif DPRINT(("failed to add chunk for slice %d", i - 1)); @@ -770,7 +758,7 @@ 0, ds.dss_slices[i].ds_name) && j != 3) #else - 0) && j != 3) + 0, "") && j != 3) #endif DPRINT(( "Failed to add chunk for partition %c [%lu,%lu]", @@ -849,7 +837,6 @@ Debug_Disk(struct disk *d) { printf("Debug_Disk(%s)", d->name); - printf(" flags=%lx", d->flags); #if 0 printf(" real_geom=%lu/%lu/%lu", d->real_cyl, d->real_hd, d->real_sect); #endif @@ -887,49 +874,6 @@ free(d); } -struct disk * -Clone_Disk(struct disk *d) -{ - struct disk *d2; - - d2 = (struct disk*) malloc(sizeof *d2); - if(!d2) return NULL; - *d2 = *d; - d2->name = strdup(d2->name); - d2->chunks = Clone_Chunk(d2->chunks); -#ifdef PC98 - if(d2->bootipl) { - d2->bootipl = malloc(d2->bootipl_size); - memcpy(d2->bootipl, d->bootipl, d2->bootipl_size); - } - if(d2->bootmenu) { - d2->bootmenu = malloc(d2->bootmenu_size); - memcpy(d2->bootmenu, d->bootmenu, d2->bootmenu_size); - } -#else - if(d2->bootmgr) { - d2->bootmgr = malloc(d2->bootmgr_size); - memcpy(d2->bootmgr, d->bootmgr, d2->bootmgr_size); - } -#endif -#if defined(__i386__) - if(d2->boot1) { - d2->boot1 = malloc(512); - memcpy(d2->boot1, d->boot1, 512); - } - if(d2->boot2) { - d2->boot2 = malloc(512 * 15); - memcpy(d2->boot2, d->boot2, 512 * 15); - } -#elif defined(__alpha__) - if(d2->boot1) { - d2->boot1 = malloc(512 * 15); - memcpy(d2->boot1, d->boot1, 512 * 15); - } -#endif - return d2; -} - #if 0 void Collapse_Disk(struct disk *d) ==== //depot/projects/trustedbsd/base/lib/libdisk/disklabel.c#3 (text+ko) ==== @@ -8,7 +8,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libdisk/disklabel.c,v 1.10 2002/03/25 13:49:15 phk Exp $"); +__FBSDID("$FreeBSD: src/lib/libdisk/disklabel.c,v 1.11 2002/10/22 09:13:02 phk Exp $"); #include <stdio.h> #include <stdlib.h> @@ -16,17 +16,3 @@ #include <sys/disklabel.h> #include "libdisk.h" -struct disklabel * -read_disklabel(int fd, daddr_t block, u_long sector_size) -{ - struct disklabel *dp; - - dp = (struct disklabel *) read_block(fd, block, sector_size); - if (dp->d_magic != DISKMAGIC) - return 0; - if (dp->d_magic2 != DISKMAGIC) - return 0; - if (dkcksum(dp) != 0) - return 0; - return dp; -} ==== //depot/projects/trustedbsd/base/lib/libdisk/libdisk.3#2 (text+ko) ==== @@ -25,14 +25,13 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libdisk/libdisk.3,v 1.26 2001/10/03 03:49:48 bde Exp $ +.\" $FreeBSD: src/lib/libdisk/libdisk.3,v 1.27 2002/10/22 09:13:02 phk Exp $ .\" " .Dd March 15, 1996 .Dt LIBDISK 3 .Os .Sh NAME .Nm Open_Disk , -.Nm Clone_Disk , .Nm Free_Disk , .Nm Debug_Disk , .Nm Set_Bios_Geom , @@ -56,7 +55,6 @@ >>> TRUNCATED FOR MAIL (1000 lines) <<< To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210221516.g9MFGBhg006073>