Sun Dec 25 06:09:10 2011 UTC ()
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

 - add 'ls' op to struct fs_ops to support ls command on each fs,
   enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
   in libsa
 - split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
   that opens the target fs and calls fs-depedent XXX_ls() functions
 - add a ls op for ext2fs
   (all other fs than ufs and ext2fs don't have actual ls ops yet)
 - replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
      replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c


(tsutsui)
diff -r1.14 -r1.15 src/sys/arch/ews4800mips/stand/boot/Makefile
diff -r1.4 -r1.5 src/sys/arch/ews4800mips/stand/common/devopen.c
diff -r1.4 -r1.5 src/sys/arch/ews4800mips/stand/common/diskutil.c
diff -r1.55 -r1.56 src/sys/arch/i386/stand/boot/Makefile.boot
diff -r1.56 -r1.57 src/sys/arch/i386/stand/boot/boot2.c
diff -r1.26 -r1.27 src/sys/arch/i386/stand/dosboot/Makefile
diff -r1.30 -r1.31 src/sys/arch/i386/stand/dosboot/main.c
diff -r1.18 -r1.19 src/sys/arch/i386/stand/libsa/nfs.c
diff -r1.4 -r1.5 src/sys/arch/landisk/stand/boot/Makefile.boot
diff -r1.2 -r1.3 src/sys/arch/landisk/stand/boot/boot2.c
diff -r1.20 -r1.21 src/sys/arch/x68k/stand/boot/Makefile
diff -r1.16 -r1.17 src/sys/arch/x68k/stand/boot/boot.c
diff -r1.27 -r1.28 src/sys/arch/x68k/stand/libsa/Makefile
diff -r1.6 -r1.7 src/sys/arch/zaurus/stand/zboot/Makefile
diff -r1.3 -r1.4 src/sys/arch/zaurus/stand/zboot/boot.c
diff -r1.75 -r1.76 src/sys/lib/libsa/Makefile
diff -r1.27 -r1.28 src/sys/lib/libsa/cd9660.c
diff -r1.17 -r1.18 src/sys/lib/libsa/dosfs.c
diff -r1.10 -r1.11 src/sys/lib/libsa/ext2fs.c
diff -r1.10 -r1.11 src/sys/lib/libsa/nullfs.c
diff -r1.4 -r1.5 src/sys/lib/libsa/ffsv1.c
diff -r1.4 -r1.5 src/sys/lib/libsa/ffsv2.c
diff -r1.3 -r1.4 src/sys/lib/libsa/lfsv1.c
diff -r1.3 -r1.4 src/sys/lib/libsa/lfsv2.c
diff -r0 -r1.3 src/sys/lib/libsa/ls.c
diff -r1.46 -r1.47 src/sys/lib/libsa/nfs.c
diff -r1.73 -r1.74 src/sys/lib/libsa/stand.h
diff -r1.33 -r1.34 src/sys/lib/libsa/tftp.c
diff -r1.33 -r1.34 src/sys/lib/libsa/ustarfs.c
diff -r1.55 -r1.56 src/sys/lib/libsa/ufs.c
diff -r1.9 -r1.10 src/sys/lib/libsa/ufs.h
diff -r1.14 -r0 src/sys/lib/libsa/ufs_ls.c

cvs diff -r1.14 -r1.15 src/sys/arch/ews4800mips/stand/boot/Makefile (expand / switch to unified diff)

--- src/sys/arch/ews4800mips/stand/boot/Makefile 2011/07/10 23:35:12 1.14
+++ src/sys/arch/ews4800mips/stand/boot/Makefile 2011/12/25 06:09:08 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.14 2011/07/10 23:35:12 matt Exp $ 1# $NetBSD: Makefile,v 1.15 2011/12/25 06:09:08 tsutsui Exp $
2 2
3WARNS ?= 1 3WARNS ?= 1
4NOMAN = 4NOMAN =
5 5
6BINMODE = 444 6BINMODE = 444
7 7
8S = ${.CURDIR}/../../../.. 8S = ${.CURDIR}/../../../..
9COMMON = ${.CURDIR}/../common 9COMMON = ${.CURDIR}/../common
10 10
11LIBSADIR = ${S}/lib/libsa 11LIBSADIR = ${S}/lib/libsa
12SYSVBFSDIR = ${S}/fs/sysvbfs 12SYSVBFSDIR = ${S}/fs/sysvbfs
13EWS4800MIPSDIR = ${.CURDIR}/../../ews4800mips 13EWS4800MIPSDIR = ${.CURDIR}/../../ews4800mips
14DEVDIR = ${.CURDIR}/../../dev 14DEVDIR = ${.CURDIR}/../../dev
@@ -79,27 +79,28 @@ CPPFLAGS += -D__daddr_t=int32_t @@ -79,27 +79,28 @@ CPPFLAGS += -D__daddr_t=int32_t
79 79
80CLEANFILES += ${BINKERNEL_DUMMY_O} ${BINKERNEL_O} 80CLEANFILES += ${BINKERNEL_DUMMY_O} ${BINKERNEL_O}
81CLEANFILES += ${PROG} ${PROG}.elf ${PROG}.coff ${PROG}.tmp ${PROG}.dis 81CLEANFILES += ${PROG} ${PROG}.elf ${PROG}.coff ${PROG}.tmp ${PROG}.dis
82CLEANFILES += ${COFFHDRFIX} 82CLEANFILES += ${COFFHDRFIX}
83CLEANFILES += ${BOOT_KERNEL} ${BOOT_KERNEL}.elf ${BOOT_KERNEL}.tmp 83CLEANFILES += ${BOOT_KERNEL} ${BOOT_KERNEL}.elf ${BOOT_KERNEL}.tmp
84CLEANFILES += ${BOOT_KERNEL}.gz ${BOOT_KERNEL}.gz.tmp 84CLEANFILES += ${BOOT_KERNEL}.gz ${BOOT_KERNEL}.gz.tmp
85 85
86.include "${S}/lib/libkern/Makefile.inc" 86.include "${S}/lib/libkern/Makefile.inc"
87LIBKERN= ${KERNLIB} 87LIBKERN= ${KERNLIB}
88 88
89.include "${S}/lib/libz/Makefile.inc" 89.include "${S}/lib/libz/Makefile.inc"
90LIBZ= ${ZLIB} 90LIBZ= ${ZLIB}
91 91
92SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes 92CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 93SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes SA_ENABLE_LS_OP=yes
93.include "${S}/lib/libsa/Makefile.inc" 94.include "${S}/lib/libsa/Makefile.inc"
94LIBSA= ${SALIB} 95LIBSA= ${SALIB}
95 96
96LIBS = ${LIBSA} ${LIBZ} ${LIBKERN} 97LIBS = ${LIBSA} ${LIBZ} ${LIBKERN}
97 98
98# fixup GNU binutils file offset error. 99# fixup GNU binutils file offset error.
99coffhdrfix: ${COMMON}/coffhdrfix.c 100coffhdrfix: ${COMMON}/coffhdrfix.c
100 ${HOST_CC} -o ${COFFHDRFIX} ${COMMON}/coffhdrfix.c 101 ${HOST_CC} -o ${COFFHDRFIX} ${COMMON}/coffhdrfix.c
101 102
102clean cleandir distclean: .WAIT cleanlibdir 103clean cleandir distclean: .WAIT cleanlibdir
103 104
104cleanlibdir: 105cleanlibdir:
105 -rm -rf lib 106 -rm -rf lib

cvs diff -r1.4 -r1.5 src/sys/arch/ews4800mips/stand/common/devopen.c (expand / switch to unified diff)

--- src/sys/arch/ews4800mips/stand/common/devopen.c 2008/04/28 20:23:18 1.4
+++ src/sys/arch/ews4800mips/stand/common/devopen.c 2011/12/25 06:09:09 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: devopen.c,v 1.4 2008/04/28 20:23:18 martin Exp $ */ 1/* $NetBSD: devopen.c,v 1.5 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi. 8 * by UCHIYAMA Yasushi.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -36,32 +36,28 @@ @@ -36,32 +36,28 @@
36#include <lib/libsa/dev_net.h> 36#include <lib/libsa/dev_net.h>
37#include <lib/libsa/ufs.h> 37#include <lib/libsa/ufs.h>
38#include <lib/libsa/nfs.h> 38#include <lib/libsa/nfs.h>
39#include <lib/libsa/dev_net.h> 39#include <lib/libsa/dev_net.h>
40#include <machine/sbd.h> 40#include <machine/sbd.h>
41 41
42#include "local.h" 42#include "local.h"
43 43
44extern uint8_t kernel_binary[]; 44extern uint8_t kernel_binary[];
45extern int kernel_binary_size; 45extern int kernel_binary_size;
46 46
47extern struct fs_ops datafs_ops; 47extern struct fs_ops datafs_ops;
48extern struct fs_ops bfs_ops; 48extern struct fs_ops bfs_ops;
49struct fs_ops ufs_ops = { 49struct fs_ops ufs_ops = FS_OPS(ufs);
50 ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat 50struct fs_ops nfs_ops = FS_OPS(nfs);
51}; 
52struct fs_ops nfs_ops = { 
53 nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat 
54}; 
55 51
56extern struct devsw netdevsw; 52extern struct devsw netdevsw;
57extern struct devsw dkdevsw; 53extern struct devsw dkdevsw;
58char fname[16]; 54char fname[16];
59 55
60/* Referenced by libsa/open.c */ 56/* Referenced by libsa/open.c */
61struct fs_ops file_system[1]; 57struct fs_ops file_system[1];
62int nfsys = 1; 58int nfsys = 1;
63struct devsw devsw[1]; 59struct devsw devsw[1];
64int ndevs = 1; 60int ndevs = 1;
65 61
66int 62int
67devopen(struct open_file *f, const char *request, char **file) 63devopen(struct open_file *f, const char *request, char **file)

cvs diff -r1.4 -r1.5 src/sys/arch/ews4800mips/stand/common/diskutil.c (expand / switch to unified diff)

--- src/sys/arch/ews4800mips/stand/common/diskutil.c 2008/04/28 20:23:18 1.4
+++ src/sys/arch/ews4800mips/stand/common/diskutil.c 2011/12/25 06:09:09 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: diskutil.c,v 1.4 2008/04/28 20:23:18 martin Exp $ */ 1/* $NetBSD: diskutil.c,v 1.5 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi. 8 * by UCHIYAMA Yasushi.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -75,34 +75,32 @@ cmd_ls(int argc, char *argp[], int inter @@ -75,34 +75,32 @@ cmd_ls(int argc, char *argp[], int inter
75 return 1; 75 return 1;
76 } 76 }
77 77
78 if (!read_vtoc()) 78 if (!read_vtoc())
79 return 1; 79 return 1;
80 80
81 i = strtoul(argp[1], 0, 0); 81 i = strtoul(argp[1], 0, 0);
82 if (i < 0 || i >= VTOC_MAXPARTITIONS) 82 if (i < 0 || i >= VTOC_MAXPARTITIONS)
83 return 1; 83 return 1;
84 84
85 if (!device_attach(-1, -1, i)) 85 if (!device_attach(-1, -1, i))
86 return 1; 86 return 1;
87 switch (fstype(i)) { 87 switch (fstype(i)) {
88 case FSTYPE_UFS: 
89 ufs_ls("/"); 
90 break; 
91 case FSTYPE_BFS: 88 case FSTYPE_BFS:
92 bfs_ls(); 89 bfs_ls();
93 break; 90 break;
94 default: 91 default:
95 return 1; 92 ls("/");
 93 break;
96 } 94 }
97 95
98 return 0; 96 return 0;
99} 97}
100 98
101void 99void
102bfs_ls(void) 100bfs_ls(void)
103{ 101{
104 struct bfs *bfs; 102 struct bfs *bfs;
105 struct bfs_dirent *file; 103 struct bfs_dirent *file;
106 struct bfs_inode *inode; 104 struct bfs_inode *inode;
107 int i; 105 int i;
108 106

cvs diff -r1.55 -r1.56 src/sys/arch/i386/stand/boot/Makefile.boot (expand / switch to unified diff)

--- src/sys/arch/i386/stand/boot/Makefile.boot 2011/08/22 09:43:08 1.55
+++ src/sys/arch/i386/stand/boot/Makefile.boot 2011/12/25 06:09:09 1.56
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.boot,v 1.55 2011/08/22 09:43:08 mrg Exp $ 1# $NetBSD: Makefile.boot,v 1.56 2011/12/25 06:09:09 tsutsui Exp $
2 2
3S= ${.CURDIR}/../../../../.. 3S= ${.CURDIR}/../../../../..
4 4
5NOMAN= 5NOMAN=
6PROG?= boot 6PROG?= boot
7NEWVERSWHAT?= "BIOS Boot" 7NEWVERSWHAT?= "BIOS Boot"
8VERSIONFILE?= ${.CURDIR}/../version 8VERSIONFILE?= ${.CURDIR}/../version
9 9
10AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} 10AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
11 11
12SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c 12SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c
13SRCS= ${SOURCES} 13SRCS= ${SOURCES}
14.if !make(depend) 14.if !make(depend)
@@ -66,26 +66,27 @@ CPPFLAGS+= -DCONSPEED=boot_params.bp_con @@ -66,26 +66,27 @@ CPPFLAGS+= -DCONSPEED=boot_params.bp_con
66CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr 66CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr
67CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap 67CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap
68 68
69CPPFLAGS+= -DSUPPORT_CD9660 69CPPFLAGS+= -DSUPPORT_CD9660
70CPPFLAGS+= -DSUPPORT_USTARFS 70CPPFLAGS+= -DSUPPORT_USTARFS
71CPPFLAGS+= -DSUPPORT_DOSFS 71CPPFLAGS+= -DSUPPORT_DOSFS
72CPPFLAGS+= -DSUPPORT_EXT2FS 72CPPFLAGS+= -DSUPPORT_EXT2FS
73CPPFLAGS+= -DPASS_BIOSGEOM 73CPPFLAGS+= -DPASS_BIOSGEOM
74CPPFLAGS+= -DPASS_MEMMAP 74CPPFLAGS+= -DPASS_MEMMAP
75#CPPFLAGS+= -DBOOTPASSWD 75#CPPFLAGS+= -DBOOTPASSWD
76CPPFLAGS+= -DEPIA_HACK 76CPPFLAGS+= -DEPIA_HACK
77#CPPFLAGS+= -DDEBUG_MEMSIZE 77#CPPFLAGS+= -DDEBUG_MEMSIZE
78#CPPFLAGS+= -DBOOT_MSG_COM0 78#CPPFLAGS+= -DBOOT_MSG_COM0
 79CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
79 80
80# The biosboot code is linked to 'virtual' address of zero and is 81# The biosboot code is linked to 'virtual' address of zero and is
81# loaded at physical address 0x10000. 82# loaded at physical address 0x10000.
82# XXX The heap values should be determined from _end. 83# XXX The heap values should be determined from _end.
83SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000 84SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000
84SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT 85SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
85SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels 86SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels
86SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS 87SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
87 88
88.if defined(HAVE_GCC) || defined(HAVE_PCC) 89.if defined(HAVE_GCC) || defined(HAVE_PCC)
89CPPFLAGS+= -Wno-pointer-sign 90CPPFLAGS+= -Wno-pointer-sign
90.endif 91.endif
91 92
@@ -103,26 +104,27 @@ CLEANFILES+= machine x86 @@ -103,26 +104,27 @@ CLEANFILES+= machine x86
103 -rm -f lib && ln -s ${LIBOBJ}/lib lib 104 -rm -f lib && ln -s ${LIBOBJ}/lib lib
104 mkdir -p ${LIBOBJ}/lib 105 mkdir -p ${LIBOBJ}/lib
105.endif 106.endif
106.endif 107.endif
107 108
108### find out what to use for libi386 109### find out what to use for libi386
109I386DIR= ${I386_STAND_DIR}/lib 110I386DIR= ${I386_STAND_DIR}/lib
110.include "${I386DIR}/Makefile.inc" 111.include "${I386DIR}/Makefile.inc"
111LIBI386= ${I386LIB} 112LIBI386= ${I386LIB}
112 113
113### find out what to use for libsa 114### find out what to use for libsa
114SA_AS= library 115SA_AS= library
115SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 116SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
 117SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
116.include "${S}/lib/libsa/Makefile.inc" 118.include "${S}/lib/libsa/Makefile.inc"
117LIBSA= ${SALIB} 119LIBSA= ${SALIB}
118 120
119### find out what to use for libkern 121### find out what to use for libkern
120KERN_AS= library 122KERN_AS= library
121.include "${S}/lib/libkern/Makefile.inc" 123.include "${S}/lib/libkern/Makefile.inc"
122LIBKERN= ${KERNLIB} 124LIBKERN= ${KERNLIB}
123 125
124### find out what to use for libz 126### find out what to use for libz
125Z_AS= library 127Z_AS= library
126.include "${S}/lib/libz/Makefile.inc" 128.include "${S}/lib/libz/Makefile.inc"
127LIBZ= ${ZLIB} 129LIBZ= ${ZLIB}
128 130

cvs diff -r1.56 -r1.57 src/sys/arch/i386/stand/boot/boot2.c (expand / switch to unified diff)

--- src/sys/arch/i386/stand/boot/boot2.c 2011/11/28 07:56:54 1.56
+++ src/sys/arch/i386/stand/boot/boot2.c 2011/12/25 06:09:09 1.57
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: boot2.c,v 1.56 2011/11/28 07:56:54 tls Exp $ */ 1/* $NetBSD: boot2.c,v 1.57 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -399,27 +399,27 @@ command_help(char *arg) @@ -399,27 +399,27 @@ command_help(char *arg)
399 "multiboot [xdNx:][filename] [<args>]\n" 399 "multiboot [xdNx:][filename] [<args>]\n"
400 "userconf {command}\n" 400 "userconf {command}\n"
401 "rndseed {path_to_rndseed_file}\n" 401 "rndseed {path_to_rndseed_file}\n"
402 "help|?\n" 402 "help|?\n"
403 "quit\n"); 403 "quit\n");
404} 404}
405 405
406void 406void
407command_ls(char *arg) 407command_ls(char *arg)
408{ 408{
409 const char *save = default_filename; 409 const char *save = default_filename;
410 410
411 default_filename = "/"; 411 default_filename = "/";
412 ufs_ls(arg); 412 ls(arg);
413 default_filename = save; 413 default_filename = save;
414} 414}
415 415
416/* ARGSUSED */ 416/* ARGSUSED */
417void 417void
418command_quit(char *arg) 418command_quit(char *arg)
419{ 419{
420 420
421 printf("Exiting...\n"); 421 printf("Exiting...\n");
422 delay(1000000); 422 delay(1000000);
423 reboot(); 423 reboot();
424 /* Note: we shouldn't get to this point! */ 424 /* Note: we shouldn't get to this point! */
425 panic("Could not reboot!"); 425 panic("Could not reboot!");

cvs diff -r1.26 -r1.27 src/sys/arch/i386/stand/dosboot/Makefile (expand / switch to unified diff)

--- src/sys/arch/i386/stand/dosboot/Makefile 2011/05/20 22:29:55 1.26
+++ src/sys/arch/i386/stand/dosboot/Makefile 2011/12/25 06:09:09 1.27
@@ -1,46 +1,47 @@ @@ -1,46 +1,47 @@
1# $NetBSD: Makefile,v 1.26 2011/05/20 22:29:55 joerg Exp $ 1# $NetBSD: Makefile,v 1.27 2011/12/25 06:09:09 tsutsui Exp $
2 2
3S= ${.CURDIR}/../../../.. 3S= ${.CURDIR}/../../../..
4 4
5BASE= dosboot 5BASE= dosboot
6PROG= ${BASE}.com 6PROG= ${BASE}.com
7NOMAN= # defined 7NOMAN= # defined
8NEWVERSWHAT= "DOS Boot" 8NEWVERSWHAT= "DOS Boot"
9STARTFILE= ${DOSSTART} 9STARTFILE= ${DOSSTART}
10RELOC= 0x100 10RELOC= 0x100
11 11
12AFLAGS.dosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} 12AFLAGS.dosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
13AFLAGS.start_dos.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} 13AFLAGS.start_dos.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
14 14
15SRCS= main.c devopen.c exec.c 15SRCS= main.c devopen.c exec.c
16 16
17CPPFLAGS+= -DSLOW # for libz 17CPPFLAGS+= -DSLOW # for libz
18CPPFLAGS+= -DCOMPAT_386BSD_MBRPART 18CPPFLAGS+= -DCOMPAT_386BSD_MBRPART
19CPPFLAGS+= -DXMS 19CPPFLAGS+= -DXMS
 20CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
20#uncomment if there are problems with memory detection 21#uncomment if there are problems with memory detection
21#CPPFLAGS+= -DCONSERVATIVE_MEMDETECT 22#CPPFLAGS+= -DCONSERVATIVE_MEMDETECT
22 23
23#CFLAGS= -O2 -fomit-frame-pointer -fno-defer-pop 24#CFLAGS= -O2 -fomit-frame-pointer -fno-defer-pop
24CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main 25CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main
25 26
26# XXX should go into library 27# XXX should go into library
27SRCS+= getopt.c 28SRCS+= getopt.c
28.PATH: ${.CURDIR}/../libsa 29.PATH: ${.CURDIR}/../libsa
29 30
30# XXX these should depend on the size of the image 31# XXX these should depend on the size of the image
31CPPFLAGS+= -DSTACK_START=0x10000 32CPPFLAGS+= -DSTACK_START=0x10000
32SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000 33SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000
33SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no 34SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no SA_ENABLE_LS_OP=yes
34I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes 35I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes
35 36
36VERSIONFILE= ${.CURDIR}/version 37VERSIONFILE= ${.CURDIR}/version
37 38
38PIE_CFLAGS= 39PIE_CFLAGS=
39PIE_LDFLAGS= 40PIE_LDFLAGS=
40PIE_AFLAGS= 41PIE_AFLAGS=
41 42
42.include <bsd.own.mk> 43.include <bsd.own.mk>
43 44
44release: check_RELEASEDIR 45release: check_RELEASEDIR
45 ${HOST_INSTALL_FILE} -m ${BINMODE} dosboot.com \ 46 ${HOST_INSTALL_FILE} -m ${BINMODE} dosboot.com \
46 ${RELEASEDIR}/${MACHINE}/installation/misc 47 ${RELEASEDIR}/${MACHINE}/installation/misc

cvs diff -r1.30 -r1.31 src/sys/arch/i386/stand/dosboot/main.c (expand / switch to unified diff)

--- src/sys/arch/i386/stand/dosboot/main.c 2010/12/20 01:12:44 1.30
+++ src/sys/arch/i386/stand/dosboot/main.c 2011/12/25 06:09:09 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.30 2010/12/20 01:12:44 jakllsch Exp $ */ 1/* $NetBSD: main.c,v 1.31 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 1997 4 * Copyright (c) 1996, 1997
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * Copyright (c) 1996, 1997 6 * Copyright (c) 1996, 1997
7 * Perry E. Metzger. All rights reserved. 7 * Perry E. Metzger. All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -313,32 +313,28 @@ command_help(char *arg) @@ -313,32 +313,28 @@ command_help(char *arg)
313 "boot [xdNx:][filename] [-acdqsv]\n" 313 "boot [xdNx:][filename] [-acdqsv]\n"
314 " (ex. \"sd0a:netbsd.old -s\"\n" 314 " (ex. \"sd0a:netbsd.old -s\"\n"
315 "ls [path]\n" 315 "ls [path]\n"
316 "mode ufs|dos\n" 316 "mode ufs|dos\n"
317 "dev xd[N[x]]:\n" 317 "dev xd[N[x]]:\n"
318 "help|?\n" 318 "help|?\n"
319 "quit\n"); 319 "quit\n");
320} 320}
321 321
322void 322void
323command_ls(char *arg) 323command_ls(char *arg)
324{ 324{
325 char *help = default_filename; 325 char *help = default_filename;
326 if (strcmp(current_fsmode, "ufs")) { 
327 printf("UFS only\n"); 
328 return; 
329 } 
330 default_filename = "/"; 326 default_filename = "/";
331 ufs_ls(arg); 327 ls(arg);
332 default_filename = help; 328 default_filename = help;
333} 329}
334 330
335/* ARGSUSED */ 331/* ARGSUSED */
336void 332void
337command_quit(char *arg) 333command_quit(char *arg)
338{ 334{
339 printf("Exiting... goodbye...\n"); 335 printf("Exiting... goodbye...\n");
340 _rtt(); 336 _rtt();
341} 337}
342 338
343void 339void
344command_boot(char *arg) 340command_boot(char *arg)

cvs diff -r1.18 -r1.19 src/sys/arch/i386/stand/libsa/nfs.c (expand / switch to unified diff)

--- src/sys/arch/i386/stand/libsa/nfs.c 2011/06/16 13:27:59 1.18
+++ src/sys/arch/i386/stand/libsa/nfs.c 2011/12/25 06:09:09 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nfs.c,v 1.18 2011/06/16 13:27:59 joerg Exp $ */ 1/* $NetBSD: nfs.c,v 1.19 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 John Brezak 4 * Copyright (c) 1993 John Brezak
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -620,13 +620,22 @@ nfs_stat(struct open_file *f, struct sta @@ -620,13 +620,22 @@ nfs_stat(struct open_file *f, struct sta
620 620
621 ftype = ntohl(fp->fa.fa_type); 621 ftype = ntohl(fp->fa.fa_type);
622 mode = ntohl(fp->fa.fa_mode); 622 mode = ntohl(fp->fa.fa_mode);
623 mode |= nfs_stat_types[ftype & 7]; 623 mode |= nfs_stat_types[ftype & 7];
624 624
625 sb->st_mode = mode; 625 sb->st_mode = mode;
626 sb->st_nlink = ntohl(fp->fa.fa_nlink); 626 sb->st_nlink = ntohl(fp->fa.fa_nlink);
627 sb->st_uid = ntohl(fp->fa.fa_uid); 627 sb->st_uid = ntohl(fp->fa.fa_uid);
628 sb->st_gid = ntohl(fp->fa.fa_gid); 628 sb->st_gid = ntohl(fp->fa.fa_gid);
629 sb->st_size = ntohl(fp->fa.fa_size); 629 sb->st_size = ntohl(fp->fa.fa_size);
630 630
631 return (0); 631 return (0);
632} 632}
 633
 634#if defined(LIBSA_ENABLE_LS_OP)
 635__compactcall void
 636nfs_ls(struct open_file *f, const char *pattern)
 637{
 638 printf("Currently ls command is unsupported by nfs\n");
 639 return;
 640}
 641#endif

cvs diff -r1.4 -r1.5 src/sys/arch/landisk/stand/boot/Makefile.boot (expand / switch to unified diff)

--- src/sys/arch/landisk/stand/boot/Makefile.boot 2011/01/22 19:19:19 1.4
+++ src/sys/arch/landisk/stand/boot/Makefile.boot 2011/12/25 06:09:09 1.5
@@ -1,41 +1,43 @@ @@ -1,41 +1,43 @@
1# $NetBSD: Makefile.boot,v 1.4 2011/01/22 19:19:19 joerg Exp $ 1# $NetBSD: Makefile.boot,v 1.5 2011/12/25 06:09:09 tsutsui Exp $
2 2
3PROG?= boot 3PROG?= boot
4 4
5NEWVERSWHAT?= "Boot" 5NEWVERSWHAT?= "Boot"
6VERSIONFILE?= ${.CURDIR}/../version 6VERSIONFILE?= ${.CURDIR}/../version
7 7
8SRCS= boot.S boot2.c bootinfo.c conf.c devopen.c monitor.c 8SRCS= boot.S boot2.c bootinfo.c conf.c devopen.c monitor.c
9SRCS+= delay.c getsecs.c 9SRCS+= delay.c getsecs.c
10SRCS+= bios.S 10SRCS+= bios.S
11SRCS+= biosdisk.c biosdisk_ll.c 11SRCS+= biosdisk.c biosdisk_ll.c
12SRCS+= scifcons.c cons.c prf.c 12SRCS+= scifcons.c cons.c prf.c
13.if !make(depend) 13.if !make(depend)
14SRCS+= vers.c 14SRCS+= vers.c
15.endif 15.endif
16 16
17LDFLAGS+= -e boot_start 17LDFLAGS+= -e boot_start
18 18
19CFLAGS= 19CFLAGS=
20CPPFLAGS= -DSUPPORT_FFSv1 20CPPFLAGS= -DSUPPORT_FFSv1
21CPPFLAGS+= -DSUPPORT_FFSv2 21CPPFLAGS+= -DSUPPORT_FFSv2
22CPPFLAGS+= -DSUPPORT_DOSFS 22CPPFLAGS+= -DSUPPORT_DOSFS
23CPPFLAGS+= -DSUPPORT_USTARFS 23CPPFLAGS+= -DSUPPORT_USTARFS
24CPPFLAGS+= -DDBMONITOR 24CPPFLAGS+= -DDBMONITOR
 25CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
25#CPPFLAGS+= -DDEBUG 26#CPPFLAGS+= -DDEBUG
26 27
27SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" 28SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
28SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 29SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
 30SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
29 31
30.include "../Makefile.bootprogs" 32.include "../Makefile.bootprogs"
31 33
32LIBLIST= ${LIBSA} ${LIBZ} ${LIBKERN} 34LIBLIST= ${LIBSA} ${LIBZ} ${LIBKERN}
33 35
34CLEANFILES+= ${PROG}.sym ${PROG}.map vers.c 36CLEANFILES+= ${PROG}.sym ${PROG}.map vers.c
35 37
36vers.c: ${VERSIONFILE} ${SOURCES} ${.CURDIR}/../Makefile.boot 38vers.c: ${VERSIONFILE} ${SOURCES} ${.CURDIR}/../Makefile.boot
37 ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \ 39 ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
38 ${VERSIONFILE} ${MACHINE} ${NEWVERSWHAT} 40 ${VERSIONFILE} ${MACHINE} ${NEWVERSWHAT}
39 41
40${PROG}: ${OBJS} ${LIBLIST} 42${PROG}: ${OBJS} ${LIBLIST}
41 ${LD} -o ${PROG}.sym ${LDFLAGS} -Ttext ${SECONDARY_LOAD_ADDRESS} \ 43 ${LD} -o ${PROG}.sym ${LDFLAGS} -Ttext ${SECONDARY_LOAD_ADDRESS} \

cvs diff -r1.2 -r1.3 src/sys/arch/landisk/stand/boot/boot2.c (expand / switch to unified diff)

--- src/sys/arch/landisk/stand/boot/boot2.c 2011/01/22 19:19:19 1.2
+++ src/sys/arch/landisk/stand/boot/boot2.c 2011/12/25 06:09:09 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: boot2.c,v 1.2 2011/01/22 19:19:19 joerg Exp $ */ 1/* $NetBSD: boot2.c,v 1.3 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2003 4 * Copyright (c) 2003
5 * David Laight. All rights reserved 5 * David Laight. All rights reserved
6 * Copyright (c) 1996, 1997, 1999 6 * Copyright (c) 1996, 1997, 1999
7 * Matthias Drochner. All rights reserved. 7 * Matthias Drochner. All rights reserved.
8 * Copyright (c) 1996, 1997 8 * Copyright (c) 1996, 1997
9 * Perry E. Metzger. All rights reserved. 9 * Perry E. Metzger. All rights reserved.
10 * Copyright (c) 1997 10 * Copyright (c) 1997
11 * Jason R. Thorpe. All rights reserved 11 * Jason R. Thorpe. All rights reserved
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -319,27 +319,27 @@ bootcmd_help(char *arg) @@ -319,27 +319,27 @@ bootcmd_help(char *arg)
319 " (ex. \"hd0a:netbsd.old -s\"\n" 319 " (ex. \"hd0a:netbsd.old -s\"\n"
320 "ls [path]\n" 320 "ls [path]\n"
321 "help|?\n" 321 "help|?\n"
322 "halt\n" 322 "halt\n"
323 "quit\n"); 323 "quit\n");
324} 324}
325 325
326static void 326static void
327bootcmd_ls(char *arg) 327bootcmd_ls(char *arg)
328{ 328{
329 const char *save = default_filename; 329 const char *save = default_filename;
330 330
331 default_filename = "/"; 331 default_filename = "/";
332 ufs_ls(arg); 332 ls(arg);
333 default_filename = save; 333 default_filename = save;
334} 334}
335 335
336/* ARGSUSED */ 336/* ARGSUSED */
337static void 337static void
338bootcmd_quit(char *arg) 338bootcmd_quit(char *arg)
339{ 339{
340 340
341 printf("Exiting...\n"); 341 printf("Exiting...\n");
342 delay(1000); 342 delay(1000);
343 reboot(); 343 reboot();
344 /* Note: we shouldn't get to this point! */ 344 /* Note: we shouldn't get to this point! */
345 panic("Could not reboot!"); 345 panic("Could not reboot!");

cvs diff -r1.20 -r1.21 src/sys/arch/x68k/stand/boot/Makefile (expand / switch to unified diff)

--- src/sys/arch/x68k/stand/boot/Makefile 2011/04/12 14:07:35 1.20
+++ src/sys/arch/x68k/stand/boot/Makefile 2011/12/25 06:09:09 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.20 2011/04/12 14:07:35 tsutsui Exp $ 1# $NetBSD: Makefile,v 1.21 2011/12/25 06:09:09 tsutsui Exp $
2 2
3NOMAN= # defined 3NOMAN= # defined
4 4
5.include <bsd.own.mk> 5.include <bsd.own.mk>
6 6
7BOOT= Multi-boot 7BOOT= Multi-boot
8VERSIONFILE= ${.CURDIR}/version 8VERSIONFILE= ${.CURDIR}/version
9VERSION!= ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \ 9VERSION!= ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \
10 END { print it }' ${VERSIONFILE} 10 END { print it }' ${VERSIONFILE}
11NEWVERSWHAT= "${BOOT}" 11NEWVERSWHAT= "${BOOT}"
12 12
13# text address 13# text address
14TEXT= 006000 14TEXT= 006000
@@ -30,26 +30,27 @@ COMMONDIR= $M/stand/common @@ -30,26 +30,27 @@ COMMONDIR= $M/stand/common
30 30
31SRCS+= vers.c 31SRCS+= vers.c
32CLEANFILES+= vers.c 32CLEANFILES+= vers.c
33vers.c: ${VERSIONFILE} 33vers.c: ${VERSIONFILE}
34 ${_MKTARGET_CREATE} 34 ${_MKTARGET_CREATE}
35 ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \ 35 ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
36 ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT} 36 ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}
37 37
38CPPFLAGS+= -nostdinc -I$S -I${.OBJDIR} -I$M/stand/libsa 38CPPFLAGS+= -nostdinc -I$S -I${.OBJDIR} -I$M/stand/libsa
39CPPFLAGS+= -I$M/stand/libiocs -I${COMMONDIR} 39CPPFLAGS+= -I$M/stand/libiocs -I${COMMONDIR}
40CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE 40CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE
41CPPFLAGS+= -DTEXTADDR="0x${TEXT}"  41CPPFLAGS+= -DTEXTADDR="0x${TEXT}"
42CPPFLAGS+= -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\" 42CPPFLAGS+= -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\"
 43CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
43CFLAGS= -Wno-main -Os -m68020-60 44CFLAGS= -Wno-main -Os -m68020-60
44LINKFLAGS= -N -static -T ${.CURDIR}/boot.ldscript 45LINKFLAGS= -N -static -T ${.CURDIR}/boot.ldscript
45LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR} 46LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
46LIBSA!= cd $M/stand/libsa && ${PRINTOBJDIR} 47LIBSA!= cd $M/stand/libsa && ${PRINTOBJDIR}
47L= ${LIBSA}/lib 48L= ${LIBSA}/lib
48LDLIBS= ${L}/sa/libsa.a ${L}/kern/libkern.a ${L}/z/libz.a 49LDLIBS= ${L}/sa/libsa.a ${L}/kern/libkern.a ${L}/z/libz.a
49LDLIBS+= ${LIBIOCS}/libiocs.a 50LDLIBS+= ${LIBIOCS}/libiocs.a
50 51
51.include "../Makefile.booters" 52.include "../Makefile.booters"
52 53
53realall: ${PROG} 54realall: ${PROG}
54${PROG}: ${OBJS} ${LDLIBS} 55${PROG}: ${OBJS} ${LDLIBS}
55 ${_MKTARGET_LINK} 56 ${_MKTARGET_LINK}

cvs diff -r1.16 -r1.17 src/sys/arch/x68k/stand/boot/boot.c (expand / switch to unified diff)

--- src/sys/arch/x68k/stand/boot/boot.c 2011/01/22 19:19:24 1.16
+++ src/sys/arch/x68k/stand/boot/boot.c 2011/12/25 06:09:09 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: boot.c,v 1.16 2011/01/22 19:19:24 joerg Exp $ */ 1/* $NetBSD: boot.c,v 1.17 2011/12/25 06:09:09 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Minoura Makoto 4 * Copyright (c) 2001 Minoura Makoto
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -43,27 +43,27 @@ @@ -43,27 +43,27 @@
43#define HEAP_START ((void*) 0x00080000) 43#define HEAP_START ((void*) 0x00080000)
44#define HEAP_END ((void*) 0x000fffff) 44#define HEAP_END ((void*) 0x000fffff)
45#define EXSCSI_BDID ((void*) 0x00ea0001) 45#define EXSCSI_BDID ((void*) 0x00ea0001)
46#define SRAM_MEMSIZE (*((long*) 0x00ed0008)) 46#define SRAM_MEMSIZE (*((long*) 0x00ed0008))
47 47
48char default_kernel[20] = "sd0a:netbsd"; 48char default_kernel[20] = "sd0a:netbsd";
49int mpu, hostadaptor; 49int mpu, hostadaptor;
50int console_device = -1; 50int console_device = -1;
51 51
52static void help(void); 52static void help(void);
53static int get_scsi_host_adapter(void); 53static int get_scsi_host_adapter(void);
54static void doboot(const char *, int); 54static void doboot(const char *, int);
55static void boot(char *); 55static void boot(char *);
56static void ls(char *); 56static void cmd_ls(char *);
57int bootmenu(void); 57int bootmenu(void);
58void bootmain(int); 58void bootmain(int);
59extern int detectmpu(void); 59extern int detectmpu(void);
60extern int badbaddr(void *); 60extern int badbaddr(void *);
61 61
62/* from boot_ufs/bootmain.c */ 62/* from boot_ufs/bootmain.c */
63static int 63static int
64get_scsi_host_adapter(void) 64get_scsi_host_adapter(void)
65{ 65{
66 char *bootrom; 66 char *bootrom;
67 int ha; 67 int ha;
68 68
69 bootrom = (char *) (IOCS_BOOTINF() & 0x00ffffe0); 69 bootrom = (char *) (IOCS_BOOTINF() & 0x00ffffe0);
@@ -191,43 +191,43 @@ boot(char *arg) @@ -191,43 +191,43 @@ boot(char *arg)
191 if (parseopts(p, &flags) == 0) 191 if (parseopts(p, &flags) == 0)
192 return; 192 return;
193 } else if (*p != 0) { 193 } else if (*p != 0) {
194 help(); 194 help();
195 return; 195 return;
196 } 196 }
197 197
198 doboot(filename, flags); 198 doboot(filename, flags);
199 return; 199 return;
200 } 200 }
201} 201}
202 202
203static void 203static void
204ls(char *arg) 204cmd_ls(char *arg)
205{ 205{
206 char filename[80]; 206 char filename[80];
207 207
208 devopen_open_dir = 1; 208 devopen_open_dir = 1;
209 if (*arg == 0) { 209 if (*arg == 0) {
210 strcpy(filename, default_kernel); 210 strcpy(filename, default_kernel);
211 strcpy(strchr(filename, ':')+1, "/"); 211 strcpy(strchr(filename, ':')+1, "/");
212 } else if (strchr(arg, ':') == 0) { 212 } else if (strchr(arg, ':') == 0) {
213 strcpy(filename, default_kernel); 213 strcpy(filename, default_kernel);
214 strcpy(strchr(filename, ':')+1, arg); 214 strcpy(strchr(filename, ':')+1, arg);
215 } else { 215 } else {
216 strcpy(filename, arg); 216 strcpy(filename, arg);
217 if (*(strchr(arg, ':')+1) == 0) 217 if (*(strchr(arg, ':')+1) == 0)
218 strcat(filename, "/"); 218 strcat(filename, "/");
219 } 219 }
220 ufs_ls(filename); 220 ls(filename);
221 devopen_open_dir = 0; 221 devopen_open_dir = 0;
222} 222}
223 223
224int 224int
225bootmenu(void) 225bootmenu(void)
226{ 226{
227 char input[80]; 227 char input[80];
228 int n = 5, c; 228 int n = 5, c;
229 229
230 printf("Press return to boot now, any other key for boot menu\n"); 230 printf("Press return to boot now, any other key for boot menu\n");
231 printf("booting %s - starting in %d seconds. ", 231 printf("booting %s - starting in %d seconds. ",
232 default_kernel, n); 232 default_kernel, n);
233 while (n-- > 0 && (c = awaitkey_1sec()) == 0) { 233 while (n-- > 0 && (c = awaitkey_1sec()) == 0) {
@@ -256,27 +256,27 @@ bootmenu(void) @@ -256,27 +256,27 @@ bootmenu(void)
256 printf("> "); 256 printf("> ");
257 gets(input); 257 gets(input);
258 258
259 for (p = &input[0]; p - &input[0] < 80 && *p == ' '; p++); 259 for (p = &input[0]; p - &input[0] < 80 && *p == ' '; p++);
260 options = gettrailer(p); 260 options = gettrailer(p);
261 if (strcmp("boot", p) == 0) 261 if (strcmp("boot", p) == 0)
262 boot(options); 262 boot(options);
263 else if (strcmp("help", p) == 0 || 263 else if (strcmp("help", p) == 0 ||
264 strcmp("?", p) == 0) 264 strcmp("?", p) == 0)
265 help(); 265 help();
266 else if ((strcmp("halt", p) == 0) ||(strcmp("reboot", p) == 0)) 266 else if ((strcmp("halt", p) == 0) ||(strcmp("reboot", p) == 0))
267 exit(0); 267 exit(0);
268 else if (strcmp("ls", p) == 0) 268 else if (strcmp("ls", p) == 0)
269 ls(options); 269 cmd_ls(options);
270 else 270 else
271 printf("Unknown command %s\n", p); 271 printf("Unknown command %s\n", p);
272 } 272 }
273} 273}
274 274
275 275
276extern const char bootprog_rev[]; 276extern const char bootprog_rev[];
277extern const char bootprog_name[]; 277extern const char bootprog_name[];
278 278
279/* 279/*
280 * Arguments from the boot block: 280 * Arguments from the boot block:
281 * bootdev - specifies the device from which /boot was read, in  281 * bootdev - specifies the device from which /boot was read, in
282 * bootdev format. 282 * bootdev format.

cvs diff -r1.27 -r1.28 src/sys/arch/x68k/stand/libsa/Makefile (expand / switch to unified diff)

--- src/sys/arch/x68k/stand/libsa/Makefile 2011/10/11 13:07:06 1.27
+++ src/sys/arch/x68k/stand/libsa/Makefile 2011/12/25 06:09:09 1.28
@@ -1,47 +1,48 @@ @@ -1,47 +1,48 @@
1# $NetBSD: Makefile,v 1.27 2011/10/11 13:07:06 tsutsui Exp $ 1# $NetBSD: Makefile,v 1.28 2011/12/25 06:09:09 tsutsui Exp $
2 2
3S= ${.CURDIR}/../../../.. 3S= ${.CURDIR}/../../../..
4 4
5CFLAGS+= -m68020-60 5CFLAGS+= -m68020-60
6 6
7CPPFLAGS+= -nostdinc -I${.OBJDIR} -I. -I${S} 7CPPFLAGS+= -nostdinc -I${.OBJDIR} -I. -I${S}
8CPPFLAGS+= -I${.CURDIR}/../libiocs -I${.CURDIR}/../common 8CPPFLAGS+= -I${.CURDIR}/../libiocs -I${.CURDIR}/../common
9CPPFLAGS+= -D_STANDALONE 9CPPFLAGS+= -D_STANDALONE
10CPPFLAGS+= -DHEAP_VARIABLE 10CPPFLAGS+= -DHEAP_VARIABLE
11CPPFLAGS+= -DHAVE_CHANGEDISK_HOOK 11CPPFLAGS+= -DHAVE_CHANGEDISK_HOOK
12CPPFLAGS+= -DUSTAR_SECT_PER_CYL=16 12CPPFLAGS+= -DUSTAR_SECT_PER_CYL=16
 13CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
13#CPPFLAGS+= -DDEBUG 14#CPPFLAGS+= -DDEBUG
14 15
15.PATH: ${LIBSADIR} ${LIBKERNDIR} ${LIBZDIR} ${LIBZDIST} 16.PATH: ${LIBSADIR} ${LIBKERNDIR} ${LIBZDIR} ${LIBZDIST}
16 17
17.include "../Makefile.booters" 18.include "../Makefile.booters"
18 19
19# only needed during build 20# only needed during build
20libinstall:: 21libinstall::
21 22
22.include <bsd.prog.mk> 23.include <bsd.prog.mk>
23 24
24### find out what to use for libkern 25### find out what to use for libkern
25KERN_AS= library 26KERN_AS= library
26.include "${S}/lib/libkern/Makefile.inc" 27.include "${S}/lib/libkern/Makefile.inc"
27LIBKERN= ${KERNLIB} 28LIBKERN= ${KERNLIB}
28 29
29### find out what to use for libz 30### find out what to use for libz
30Z_AS= library 31Z_AS= library
31.include "${S}/lib/libz/Makefile.inc" 32.include "${S}/lib/libz/Makefile.inc"
32LIBZ= ${ZLIB} 33LIBZ= ${ZLIB}
33 34
34### find out what to use for libsa 35### find out what to use for libsa
35SA_AS= library 36SA_AS= library
36SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes SA_EXTRADIR=${.CURDIR} 37SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes SA_ENABLE_LS_OP=yes SA_EXTRADIR=${.CURDIR}
37.include "${S}/lib/libsa/Makefile.inc" 38.include "${S}/lib/libsa/Makefile.inc"
38LIBSA= ${SALIB} 39LIBSA= ${SALIB}
39 40
40LIBS= ${LIBKERN} ${LIBZ} ${LIBSA} 41LIBS= ${LIBKERN} ${LIBZ} ${LIBSA}
41 42
42all realall: ${LIBS} 43all realall: ${LIBS}
43 44
44cleandir distclean: .WAIT cleanlibdir 45cleandir distclean: .WAIT cleanlibdir
45 46
46cleanlibdir: 47cleanlibdir:
47 -rm -rf lib 48 -rm -rf lib

cvs diff -r1.6 -r1.7 src/sys/arch/zaurus/stand/zboot/Makefile (expand / switch to unified diff)

--- src/sys/arch/zaurus/stand/zboot/Makefile 2011/01/23 13:17:02 1.6
+++ src/sys/arch/zaurus/stand/zboot/Makefile 2011/12/25 06:09:10 1.7
@@ -1,59 +1,60 @@ @@ -1,59 +1,60 @@
1# $NetBSD: Makefile,v 1.6 2011/01/23 13:17:02 joerg Exp $ 1# $NetBSD: Makefile,v 1.7 2011/12/25 06:09:10 tsutsui Exp $
2 2
3PROG= zboot 3PROG= zboot
4 4
5S= ${.CURDIR}/../../../.. 5S= ${.CURDIR}/../../../..
6 6
7SRCS= crt0.c 7SRCS= crt0.c
8SRCS+= boot.c bootinfo.c bootmenu.c conf.c devopen.c diskprobe.c 8SRCS+= boot.c bootinfo.c bootmenu.c conf.c devopen.c diskprobe.c
9SRCS+= loadfile_zboot.c 9SRCS+= loadfile_zboot.c
10SRCS+= getsecs.c termios.c unixcons.c unixdev.c unixsys.S 10SRCS+= getsecs.c termios.c unixcons.c unixdev.c unixsys.S
11 11
12NOMAN= # defined 12NOMAN= # defined
13 13
14.include <bsd.own.mk> 14.include <bsd.own.mk>
15 15
16CFLAGS+= -Wall -Wno-main 16CFLAGS+= -Wall -Wno-main
17CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith 17CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
18CFLAGS+= -fno-stack-protector -fno-builtin -ffreestanding 18CFLAGS+= -fno-stack-protector -fno-builtin -ffreestanding
19CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -I${.OBJDIR} -I${S} 19CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -I${.OBJDIR} -I${S}
20CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE 20CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE
 21CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
21AFLAGS+= -D_LOCORE 22AFLAGS+= -D_LOCORE
22LDFLAGS+= -nostdlib -Bstatic 23LDFLAGS+= -nostdlib -Bstatic
23 24
24CLEANFILES+= vers.c vers.o 25CLEANFILES+= vers.c vers.o
25 26
26LIBCRT0= crt0.o 27LIBCRT0= crt0.o
27LIBC= # nothing 28LIBC= # nothing
28LIBCRTBEGIN= # nothing 29LIBCRTBEGIN= # nothing
29LIBCRTEND= # nothing 30LIBCRTEND= # nothing
30 31
31NEWVERSWHAT?= "Boot" 32NEWVERSWHAT?= "Boot"
32VERSIONFILE?= ${.CURDIR}/version 33VERSIONFILE?= ${.CURDIR}/version
33 34
34### find out what to use for libkern 35### find out what to use for libkern
35KERN_AS= library 36KERN_AS= library
36.include "${S}/lib/libkern/Makefile.inc" 37.include "${S}/lib/libkern/Makefile.inc"
37LIBKERN= ${KERNLIB} 38LIBKERN= ${KERNLIB}
38 39
39### find out what to use for libz 40### find out what to use for libz
40Z_AS= library 41Z_AS= library
41.include "${S}/lib/libz/Makefile.inc" 42.include "${S}/lib/libz/Makefile.inc"
42LIBZ= ${ZLIB} 43LIBZ= ${ZLIB}
43 44
44### find out what to use for libsa 45### find out what to use for libsa
45SA_AS= library 46SA_AS= library
46SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes 47SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes SA_ENABLE_LS_OP=yes
47.include "${S}/lib/libsa/Makefile.inc" 48.include "${S}/lib/libsa/Makefile.inc"
48LIBSA= ${SALIB} 49LIBSA= ${SALIB}
49 50
50${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} 51${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
51 ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \ 52 ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
52 ${VERSIONFILE} ${MACHINE} ${NEWVERSWHAT} 53 ${VERSIONFILE} ${MACHINE} ${NEWVERSWHAT}
53 ${CC} -c vers.c 54 ${CC} -c vers.c
54 ${LD} ${LDFLAGS} -o ${PROG} ${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBKERN} 55 ${LD} ${LDFLAGS} -o ${PROG} ${OBJS} vers.o ${LIBSA} ${LIBZ} ${LIBKERN}
55 56
56.include <bsd.klinks.mk> 57.include <bsd.klinks.mk>
57.include <bsd.prog.mk> 58.include <bsd.prog.mk>
58 59
59cleandir distclean: .WAIT cleanlibdir 60cleandir distclean: .WAIT cleanlibdir

cvs diff -r1.3 -r1.4 src/sys/arch/zaurus/stand/zboot/boot.c (expand / switch to unified diff)

--- src/sys/arch/zaurus/stand/zboot/boot.c 2011/06/20 12:39:21 1.3
+++ src/sys/arch/zaurus/stand/zboot/boot.c 2011/12/25 06:09:10 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: boot.c,v 1.3 2011/06/20 12:39:21 nonaka Exp $ */ 1/* $NetBSD: boot.c,v 1.4 2011/12/25 06:09:10 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009 NONAKA Kimihiro <nonaka@netbsd.org> 4 * Copyright (c) 2009 NONAKA Kimihiro <nonaka@netbsd.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -313,27 +313,27 @@ bootcmd_quit(char *arg) @@ -313,27 +313,27 @@ bootcmd_quit(char *arg)
313{ 313{
314 314
315 printf("Exiting...\n"); 315 printf("Exiting...\n");
316 exit(0); 316 exit(0);
317 /*NOTREACHED*/ 317 /*NOTREACHED*/
318} 318}
319 319
320static void 320static void
321bootcmd_ls(char *arg) 321bootcmd_ls(char *arg)
322{ 322{
323 const char *save = default_filename; 323 const char *save = default_filename;
324 324
325 default_filename = "/"; 325 default_filename = "/";
326 ufs_ls(arg); 326 ls(arg);
327 default_filename = save; 327 default_filename = save;
328} 328}
329 329
330static void 330static void
331bootcmd_boot(char *arg) 331bootcmd_boot(char *arg)
332{ 332{
333 char *filename; 333 char *filename;
334 int howto; 334 int howto;
335 335
336 if (parseboot(arg, &filename, &howto)) { 336 if (parseboot(arg, &filename, &howto)) {
337 bootit(filename, howto, 1); 337 bootit(filename, howto, 1);
338 } 338 }
339} 339}

cvs diff -r1.75 -r1.76 src/sys/lib/libsa/Makefile (expand / switch to unified diff)

--- src/sys/lib/libsa/Makefile 2011/07/03 15:29:35 1.75
+++ src/sys/lib/libsa/Makefile 2011/12/25 06:09:08 1.76
@@ -1,22 +1,23 @@ @@ -1,22 +1,23 @@
1# $NetBSD: Makefile,v 1.75 2011/07/03 15:29:35 mrg Exp $ 1# $NetBSD: Makefile,v 1.76 2011/12/25 06:09:08 tsutsui Exp $
2 2
3LIB= sa 3LIB= sa
4NOPIC= # defined 4NOPIC= # defined
5NOPROFILE=# defined 5NOPROFILE=# defined
6 6
7SA_USE_CREAD?= no # Read compressed kernels 7SA_USE_CREAD?= no # Read compressed kernels
8SA_INCLUDE_NET?= yes # Netboot via TFTP, NFS 8SA_INCLUDE_NET?= yes # Netboot via TFTP, NFS
9SA_USE_LOADFILE?= no # Generic executable loading support 9SA_USE_LOADFILE?= no # Generic executable loading support
 10SA_ENABLE_LS_OP?= no # Filesystems ls operation
10 11
11#DEBUGCPPFLAGS= -DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DRPC_DEBUG -DRARP_DEBUG -DARP_DEBUG -DNET_DEBUG -DDEBUG -DPARANOID 12#DEBUGCPPFLAGS= -DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DRPC_DEBUG -DRARP_DEBUG -DARP_DEBUG -DNET_DEBUG -DDEBUG -DPARANOID
12CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \ 13CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \
13 -DCOMPAT_UFS ${DEBUGCPPFLAGS} 14 -DCOMPAT_UFS ${DEBUGCPPFLAGS}
14 15
15#COPTS+= -ansi -pedantic -Wall 16#COPTS+= -ansi -pedantic -Wall
16 17
17.if defined(SA_EXTRADIR) 18.if defined(SA_EXTRADIR)
18.-include "${SA_EXTRADIR}/Makefile.inc" 19.-include "${SA_EXTRADIR}/Makefile.inc"
19.endif 20.endif
20 21
21.include <bsd.own.mk> 22.include <bsd.own.mk>
22 23
@@ -35,47 +36,50 @@ SRCS+= exec.c @@ -35,47 +36,50 @@ SRCS+= exec.c
35# string routines 36# string routines
36.if ${MACHINE_ARCH} != "i386" && ${MACHINE_ARCH} != "x86_64" 37.if ${MACHINE_ARCH} != "i386" && ${MACHINE_ARCH} != "x86_64"
37SRCS+= memcmp.c memcpy.c memmove.c memset.c strchr.c 38SRCS+= memcmp.c memcpy.c memmove.c memset.c strchr.c
38.endif 39.endif
39SRCS+= bcopy.c bzero.c # Remove me eventually. 40SRCS+= bcopy.c bzero.c # Remove me eventually.
40 41
41# io routines 42# io routines
42SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c 43SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c
43SRCS+= close.c lseek.c open.c read.c write.c 44SRCS+= close.c lseek.c open.c read.c write.c
44.if (${SA_USE_CREAD} == "yes") 45.if (${SA_USE_CREAD} == "yes")
45CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD 46CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD
46SRCS+= cread.c 47SRCS+= cread.c
47.endif 48.endif
 49.if (${SA_ENABLE_LS_OP} == "yes")
 50SRCS+= ls.c
 51.endif
48 52
49.if (${SA_USE_LOADFILE} == "yes") 53.if (${SA_USE_LOADFILE} == "yes")
50SRCS+= loadfile.c loadfile_ecoff.c loadfile_elf32.c lookup_elf32.c \ 54SRCS+= loadfile.c loadfile_ecoff.c loadfile_elf32.c lookup_elf32.c \
51 loadfile_elf64.c lookup_elf64.c 55 loadfile_elf64.c lookup_elf64.c
52.if (${MACHINE_CPU} != "mips") 56.if (${MACHINE_CPU} != "mips")
53SRCS+= loadfile_aout.c 57SRCS+= loadfile_aout.c
54.endif 58.endif
55.endif 59.endif
56 60
57.if (${SA_INCLUDE_NET} == "yes") 61.if (${SA_INCLUDE_NET} == "yes")
58# network routines 62# network routines
59SRCS+= arp.c ether.c ether_sprintf.c ip_cksum.c net.c netif.c rpc.c udp.c ip.c 63SRCS+= arp.c ether.c ether_sprintf.c ip_cksum.c net.c netif.c rpc.c udp.c ip.c
60 64
61# network info services: 65# network info services:
62SRCS+= bootp.c rarp.c bootparam.c 66SRCS+= bootp.c rarp.c bootparam.c
63 67
64# boot filesystems 68# boot filesystems
65SRCS+= nfs.c tftp.c 69SRCS+= nfs.c tftp.c
66.endif 70.endif
67 71
68SRCS+= ffsv1.c ffsv2.c ufs_ls.c 72SRCS+= ffsv1.c ffsv2.c
69SRCS+= lfsv1.c lfsv2.c 73SRCS+= lfsv1.c lfsv2.c
70SRCS+= cd9660.c 74SRCS+= cd9660.c
71SRCS+= ustarfs.c 75SRCS+= ustarfs.c
72SRCS+= dosfs.c 76SRCS+= dosfs.c
73SRCS+= ext2fs.c 77SRCS+= ext2fs.c
74# for historic compatibility ufs == ffsv1 78# for historic compatibility ufs == ffsv1
75SRCS+= ufs.c 79SRCS+= ufs.c
76 80
77# only needed during build 81# only needed during build
78libinstall:: 82libinstall::
79 83
80.undef DESTDIR 84.undef DESTDIR
81.include <bsd.lib.mk> 85.include <bsd.lib.mk>

cvs diff -r1.27 -r1.28 src/sys/lib/libsa/cd9660.c (expand / switch to unified diff)

--- src/sys/lib/libsa/cd9660.c 2011/06/16 13:27:58 1.27
+++ src/sys/lib/libsa/cd9660.c 2011/12/25 06:09:08 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cd9660.c,v 1.27 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: cd9660.c,v 1.28 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1996 Wolfgang Solfrank. 4 * Copyright (C) 1996 Wolfgang Solfrank.
5 * Copyright (C) 1996 TooLs GmbH. 5 * Copyright (C) 1996 TooLs GmbH.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -386,13 +386,22 @@ cd9660_seek(struct open_file *f, off_t o @@ -386,13 +386,22 @@ cd9660_seek(struct open_file *f, off_t o
386#endif /* !defined(LIBSA_NO_FS_SEEK) */ 386#endif /* !defined(LIBSA_NO_FS_SEEK) */
387 387
388__compactcall int 388__compactcall int
389cd9660_stat(struct open_file *f, struct stat *sb) 389cd9660_stat(struct open_file *f, struct stat *sb)
390{ 390{
391 struct file *fp = (struct file *)f->f_fsdata; 391 struct file *fp = (struct file *)f->f_fsdata;
392 392
393 /* only importatn stuff */ 393 /* only importatn stuff */
394 sb->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; 394 sb->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
395 sb->st_uid = sb->st_gid = 0; 395 sb->st_uid = sb->st_gid = 0;
396 sb->st_size = fp->size; 396 sb->st_size = fp->size;
397 return 0; 397 return 0;
398} 398}
 399
 400#if defined(LIBSA_ENABLE_LS_OP)
 401__compactcall void
 402cd9660_ls(struct open_file *f, const char *pattern)
 403{
 404 printf("Currently ls command is unsupported by cd9660\n");
 405 return;
 406}
 407#endif

cvs diff -r1.17 -r1.18 src/sys/lib/libsa/dosfs.c (expand / switch to unified diff)

--- src/sys/lib/libsa/dosfs.c 2011/06/16 13:27:58 1.17
+++ src/sys/lib/libsa/dosfs.c 2011/12/25 06:09:08 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dosfs.c,v 1.17 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: dosfs.c,v 1.18 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 1998 Robert Nordier 4 * Copyright (c) 1996, 1998 Robert Nordier
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in 13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the 14 * the documentation and/or other materials provided with the
@@ -395,26 +395,35 @@ dosfs_stat(struct open_file *fd, struct  @@ -395,26 +395,35 @@ dosfs_stat(struct open_file *fd, struct
395 DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; 395 DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
396 396
397 /* only important stuff */ 397 /* only important stuff */
398 sb->st_mode = (f->de.deAttributes & ATTR_DIRECTORY) ? 398 sb->st_mode = (f->de.deAttributes & ATTR_DIRECTORY) ?
399 (S_IFDIR | 0555) : (S_IFREG | 0444); 399 (S_IFDIR | 0555) : (S_IFREG | 0444);
400 sb->st_nlink = 1; 400 sb->st_nlink = 1;
401 sb->st_uid = 0; 401 sb->st_uid = 0;
402 sb->st_gid = 0; 402 sb->st_gid = 0;
403 if ((sb->st_size = fsize(f->fs, &f->de)) == -1) 403 if ((sb->st_size = fsize(f->fs, &f->de)) == -1)
404 return EINVAL; 404 return EINVAL;
405 return 0; 405 return 0;
406} 406}
407 407
 408#if defined(LIBSA_ENABLE_LS_OP)
 409__compactcall void
 410dosfs_ls(struct open_file *f, const char *pattern)
 411{
 412 printf("Currently ls command is unsupported by dosfs\n");
 413 return;
 414}
 415#endif
 416
408/* 417/*
409 * Parse DOS boot sector 418 * Parse DOS boot sector
410 */ 419 */
411static int 420static int
412parsebs(DOS_FS *fs, DOS_BS *bs) 421parsebs(DOS_FS *fs, DOS_BS *bs)
413{ 422{
414 u_int sc; 423 u_int sc;
415 424
416 if ((bs->jmp[0] != 0x69 && 425 if ((bs->jmp[0] != 0x69 &&
417 bs->jmp[0] != 0xe9 && 426 bs->jmp[0] != 0xe9 &&
418 (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) || 427 (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) ||
419 bs->bpb.bpbMedia < 0xf0) 428 bs->bpb.bpbMedia < 0xf0)
420 return EINVAL; 429 return EINVAL;

cvs diff -r1.10 -r1.11 src/sys/lib/libsa/ext2fs.c (expand / switch to unified diff)

--- src/sys/lib/libsa/ext2fs.c 2011/06/16 13:27:58 1.10
+++ src/sys/lib/libsa/ext2fs.c 2011/12/25 06:09:08 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ext2fs.c,v 1.10 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: ext2fs.c,v 1.11 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Manuel Bouyer. 4 * Copyright (c) 1997 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -136,26 +136,79 @@ typedef uint32_t ino32_t; @@ -136,26 +136,79 @@ typedef uint32_t ino32_t;
136struct file { 136struct file {
137 off_t f_seekp; /* seek pointer */ 137 off_t f_seekp; /* seek pointer */
138 struct m_ext2fs *f_fs; /* pointer to super-block */ 138 struct m_ext2fs *f_fs; /* pointer to super-block */
139 struct ext2fs_dinode f_di; /* copy of on-disk inode */ 139 struct ext2fs_dinode f_di; /* copy of on-disk inode */
140 uint f_nishift; /* for blocks in indirect block */ 140 uint f_nishift; /* for blocks in indirect block */
141 indp_t f_ind_cache_block; 141 indp_t f_ind_cache_block;
142 indp_t f_ind_cache[IND_CACHE_SZ]; 142 indp_t f_ind_cache[IND_CACHE_SZ];
143 143
144 char *f_buf; /* buffer for data block */ 144 char *f_buf; /* buffer for data block */
145 size_t f_buf_size; /* size of data block */ 145 size_t f_buf_size; /* size of data block */
146 daddr_t f_buf_blkno; /* block number of data block */ 146 daddr_t f_buf_blkno; /* block number of data block */
147}; 147};
148 148
 149#if defined(LIBSA_ENABLE_LS_OP)
 150
 151#define NELEM(x) (sizeof (x) / sizeof(*x))
 152
 153typedef struct entry_t entry_t;
 154struct entry_t {
 155 entry_t *e_next;
 156 ino32_t e_ino;
 157 uint8_t e_type;
 158 char e_name[1];
 159};
 160
 161static const char *const typestr[] = {
 162 "unknown",
 163 "REG",
 164 "DIR",
 165 "CHR",
 166 "BLK",
 167 "FIFO",
 168 "SOCK",
 169 "LNK"
 170};
 171
 172static int
 173fn_match(const char *fname, const char *pattern)
 174{
 175 char fc, pc;
 176
 177 do {
 178 fc = *fname++;
 179 pc = *pattern++;
 180 if (!fc && !pc)
 181 return 1;
 182 if (pc == '?' && fc)
 183 pc = fc;
 184 } while (fc == pc);
 185
 186 if (pc != '*')
 187 return 0;
 188 /*
 189 * Too hard (and unnecessary really) too check for "*?name" etc....
 190 * "**" will look for a '*' and "*?" a '?'
 191 */
 192 pc = *pattern++;
 193 if (!pc)
 194 return 1;
 195 while ((fname = strchr(fname, pc)))
 196 if (fn_match(++fname, pattern))
 197 return 1;
 198 return 0;
 199}
 200#endif /* LIBSA_ENABLE_LS_OP */
 201
149static int read_inode(ino32_t, struct open_file *); 202static int read_inode(ino32_t, struct open_file *);
150static int block_map(struct open_file *, indp_t, indp_t *); 203static int block_map(struct open_file *, indp_t, indp_t *);
151static int buf_read_file(struct open_file *, char **, size_t *); 204static int buf_read_file(struct open_file *, char **, size_t *);
152static int search_directory(const char *, int, struct open_file *, ino32_t *); 205static int search_directory(const char *, int, struct open_file *, ino32_t *);
153static int read_sblock(struct open_file *, struct m_ext2fs *); 206static int read_sblock(struct open_file *, struct m_ext2fs *);
154static int read_gdblock(struct open_file *, struct m_ext2fs *); 207static int read_gdblock(struct open_file *, struct m_ext2fs *);
155#ifdef EXT2FS_DEBUG 208#ifdef EXT2FS_DEBUG
156static void dump_sblock(struct m_ext2fs *); 209static void dump_sblock(struct m_ext2fs *);
157#endif 210#endif
158 211
159/* 212/*
160 * Read a new inode into a file structure. 213 * Read a new inode into a file structure.
161 */ 214 */
@@ -793,26 +846,117 @@ ext2fs_stat(struct open_file *f, struct  @@ -793,26 +846,117 @@ ext2fs_stat(struct open_file *f, struct
793{ 846{
794 struct file *fp = (struct file *)f->f_fsdata; 847 struct file *fp = (struct file *)f->f_fsdata;
795 848
796 /* only important stuff */ 849 /* only important stuff */
797 memset(sb, 0, sizeof *sb); 850 memset(sb, 0, sizeof *sb);
798 sb->st_mode = fp->f_di.e2di_mode; 851 sb->st_mode = fp->f_di.e2di_mode;
799 sb->st_uid = fp->f_di.e2di_uid; 852 sb->st_uid = fp->f_di.e2di_uid;
800 sb->st_gid = fp->f_di.e2di_gid; 853 sb->st_gid = fp->f_di.e2di_gid;
801 /* XXX should handle LARGEFILE */ 854 /* XXX should handle LARGEFILE */
802 sb->st_size = fp->f_di.e2di_size; 855 sb->st_size = fp->f_di.e2di_size;
803 return 0; 856 return 0;
804} 857}
805 858
 859#if defined(LIBSA_ENABLE_LS_OP)
 860__compactcall void
 861ext2fs_ls(struct open_file *f, const char *pattern)
 862{
 863 struct file *fp = (struct file *)f->f_fsdata;
 864 size_t block_size = fp->f_fs->e2fs_bsize;
 865 char *buf;
 866 size_t buf_size;
 867 entry_t *names = 0, *n, **np;
 868
 869 fp->f_seekp = 0;
 870 while (fp->f_seekp < (off_t)fp->f_di.e2di_size) {
 871 struct ext2fs_direct *dp, *edp;
 872 int rc = buf_read_file(f, &buf, &buf_size);
 873 if (rc)
 874 goto out;
 875 if (buf_size != block_size || buf_size == 0)
 876 goto out;
 877
 878 dp = (struct ext2fs_direct *)buf;
 879 edp = (struct ext2fs_direct *)(buf + buf_size);
 880
 881 for (; dp < edp;
 882 dp = (void *)((char *)dp + fs2h16(dp->e2d_reclen))) {
 883 const char *t;
 884
 885 if (fs2h16(dp->e2d_reclen) <= 0)
 886 goto out;
 887
 888 if (fs2h32(dp->e2d_ino) == 0)
 889 continue;
 890
 891 if (dp->e2d_type >= NELEM(typestr) ||
 892 !(t = typestr[dp->e2d_type])) {
 893 /*
 894 * This does not handle "old"
 895 * filesystems properly. On little
 896 * endian machines, we get a bogus
 897 * type name if the namlen matches a
 898 * valid type identifier. We could
 899 * check if we read namlen "0" and
 900 * handle this case specially, if
 901 * there were a pressing need...
 902 */
 903 printf("bad dir entry\n");
 904 goto out;
 905 }
 906 if (pattern && !fn_match(dp->e2d_name, pattern))
 907 continue;
 908 n = alloc(sizeof *n + strlen(dp->e2d_name));
 909 if (!n) {
 910 printf("%d: %s (%s)\n",
 911 fs2h32(dp->e2d_ino), dp->e2d_name, t);
 912 continue;
 913 }
 914 n->e_ino = fs2h32(dp->e2d_ino);
 915 n->e_type = dp->e2d_type;
 916 strcpy(n->e_name, dp->e2d_name);
 917 for (np = &names; *np; np = &(*np)->e_next) {
 918 if (strcmp(n->e_name, (*np)->e_name) < 0)
 919 break;
 920 }
 921 n->e_next = *np;
 922 *np = n;
 923 }
 924 fp->f_seekp += buf_size;
 925 }
 926
 927 if (names) {
 928 entry_t *p_names = names;
 929 do {
 930 n = p_names;
 931 printf("%d: %s (%s)\n",
 932 n->e_ino, n->e_name, typestr[n->e_type]);
 933 p_names = n->e_next;
 934 } while (p_names);
 935 } else {
 936 printf("not found\n");
 937 }
 938out:
 939 if (names) {
 940 do {
 941 n = names;
 942 names = n->e_next;
 943 dealloc(n, 0);
 944 } while (names);
 945 }
 946 return;
 947}
 948#endif
 949
806/* 950/*
807 * byte swap functions for big endian machines 951 * byte swap functions for big endian machines
808 * (ext2fs is always little endian) 952 * (ext2fs is always little endian)
809 * 953 *
810 * XXX: We should use src/sys/ufs/ext2fs/ext2fs_bswap.c 954 * XXX: We should use src/sys/ufs/ext2fs/ext2fs_bswap.c
811 */ 955 */
812 956
813/* These functions are only needed if native byte order is not big endian */ 957/* These functions are only needed if native byte order is not big endian */
814#if BYTE_ORDER == BIG_ENDIAN 958#if BYTE_ORDER == BIG_ENDIAN
815void 959void
816e2fs_sb_bswap(struct ext2fs *old, struct ext2fs *new) 960e2fs_sb_bswap(struct ext2fs *old, struct ext2fs *new)
817{ 961{
818 962

cvs diff -r1.10 -r1.11 src/sys/lib/libsa/nullfs.c (expand / switch to unified diff)

--- src/sys/lib/libsa/nullfs.c 2011/06/16 13:27:58 1.10
+++ src/sys/lib/libsa/nullfs.c 2011/12/25 06:09:08 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nullfs.c,v 1.10 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: nullfs.c,v 1.11 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * The Mach Operating System project at Carnegie-Mellon University. 8 * The Mach Operating System project at Carnegie-Mellon University.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -103,13 +103,22 @@ __compactcall off_t @@ -103,13 +103,22 @@ __compactcall off_t
103null_seek(struct open_file *f, off_t offset, int where) 103null_seek(struct open_file *f, off_t offset, int where)
104{ 104{
105 105
106 return (off_t)-1; 106 return (off_t)-1;
107} 107}
108#endif 108#endif
109 109
110__compactcall int 110__compactcall int
111null_stat(struct open_file *f, struct stat *sb) 111null_stat(struct open_file *f, struct stat *sb)
112{ 112{
113 113
114 return EIO; 114 return EIO;
115} 115}
 116
 117#if defined(LIBSA_ENABLE_LS_OP)
 118__compactcall void
 119null_ls(struct open_file *f, const char *pattern)
 120{
 121 printf("Currently ls command is unsupported by nullfs\n");
 122 return;
 123}
 124#endif

cvs diff -r1.4 -r1.5 src/sys/lib/libsa/ffsv1.c (expand / switch to unified diff)

--- src/sys/lib/libsa/ffsv1.c 2008/11/19 12:36:41 1.4
+++ src/sys/lib/libsa/ffsv1.c 2011/12/25 06:09:08 1.5
@@ -1,17 +1,20 @@ @@ -1,17 +1,20 @@
1/* $NetBSD: ffsv1.c,v 1.4 2008/11/19 12:36:41 ad Exp $ */ 1/* $NetBSD: ffsv1.c,v 1.5 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3#define LIBSA_FFSv1 3#define LIBSA_FFSv1
4 4
5#define ufs_open ffsv1_open 5#define ufs_open ffsv1_open
6#define ufs_close ffsv1_close 6#define ufs_close ffsv1_close
7#define ufs_read ffsv1_read 7#define ufs_read ffsv1_read
8#define ufs_write ffsv1_write 8#define ufs_write ffsv1_write
9#define ufs_seek ffsv1_seek 9#define ufs_seek ffsv1_seek
10#define ufs_stat ffsv1_stat 10#define ufs_stat ffsv1_stat
 11#if defined(LIBSA_ENABLE_LS_OP)
 12#define ufs_ls ffsv1_ls
 13#endif
11 14
12#define ufs_dinode ufs1_dinode 15#define ufs_dinode ufs1_dinode
13#define indp_t int32_t 16#define indp_t int32_t
14 17
15#define FSMOD "ffs" 18#define FSMOD "ffs"
16 19
17#include "ufs.c" 20#include "ufs.c"

cvs diff -r1.4 -r1.5 src/sys/lib/libsa/ffsv2.c (expand / switch to unified diff)

--- src/sys/lib/libsa/ffsv2.c 2008/11/19 12:36:41 1.4
+++ src/sys/lib/libsa/ffsv2.c 2011/12/25 06:09:08 1.5
@@ -1,17 +1,20 @@ @@ -1,17 +1,20 @@
1/* $NetBSD: ffsv2.c,v 1.4 2008/11/19 12:36:41 ad Exp $ */ 1/* $NetBSD: ffsv2.c,v 1.5 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3#define LIBSA_FFSv2 3#define LIBSA_FFSv2
4 4
5#define ufs_open ffsv2_open 5#define ufs_open ffsv2_open
6#define ufs_close ffsv2_close 6#define ufs_close ffsv2_close
7#define ufs_read ffsv2_read 7#define ufs_read ffsv2_read
8#define ufs_write ffsv2_write 8#define ufs_write ffsv2_write
9#define ufs_seek ffsv2_seek 9#define ufs_seek ffsv2_seek
10#define ufs_stat ffsv2_stat 10#define ufs_stat ffsv2_stat
 11#if defined(LIBSA_ENABLE_LS_OP)
 12#define ufs_ls ffsv2_ls
 13#endif
11 14
12#define ufs_dinode ufs2_dinode 15#define ufs_dinode ufs2_dinode
13#define indp_t int64_t 16#define indp_t int64_t
14 17
15#define FSMOD "ffs" 18#define FSMOD "ffs"
16 19
17#include "ufs.c" 20#include "ufs.c"

cvs diff -r1.3 -r1.4 src/sys/lib/libsa/lfsv1.c (expand / switch to unified diff)

--- src/sys/lib/libsa/lfsv1.c 2008/11/19 12:36:41 1.3
+++ src/sys/lib/libsa/lfsv1.c 2011/12/25 06:09:08 1.4
@@ -1,22 +1,25 @@ @@ -1,22 +1,25 @@
1/* $NetBSD: lfsv1.c,v 1.3 2008/11/19 12:36:41 ad Exp $ */ 1/* $NetBSD: lfsv1.c,v 1.4 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3#define LIBSA_LFS 3#define LIBSA_LFS
4#define REQUIRED_LFS_VERSION 1 4#define REQUIRED_LFS_VERSION 1
5 5
6#define ufs_open lfsv1_open 6#define ufs_open lfsv1_open
7#define ufs_close lfsv1_close 7#define ufs_close lfsv1_close
8#define ufs_read lfsv1_read 8#define ufs_read lfsv1_read
9#define ufs_write lfsv1_write 9#define ufs_write lfsv1_write
10#define ufs_seek lfsv1_seek 10#define ufs_seek lfsv1_seek
11#define ufs_stat lfsv1_stat 11#define ufs_stat lfsv1_stat
 12#if defined(LIBSA_ENABLE_LS_OP)
 13#define ufs_ls lfsv1_ls
 14#endif
12 15
13#define fs_bsize lfs_ibsize 16#define fs_bsize lfs_ibsize
14#define IFILE_Vx IFILE_V1 17#define IFILE_Vx IFILE_V1
15 18
16#define FSBTODB(fs, daddr) (daddr) /* LFSv1 uses sectors for addresses */ 19#define FSBTODB(fs, daddr) (daddr) /* LFSv1 uses sectors for addresses */
17#define INOPBx(fs) INOPB(fs) 20#define INOPBx(fs) INOPB(fs)
18 21
19#define FSMOD "lfs" 22#define FSMOD "lfs"
20#define FSMOD2 "ffs" 23#define FSMOD2 "ffs"
21 24
22#include "lib/libsa/ufs.c" 25#include "lib/libsa/ufs.c"

cvs diff -r1.3 -r1.4 src/sys/lib/libsa/lfsv2.c (expand / switch to unified diff)

--- src/sys/lib/libsa/lfsv2.c 2008/11/19 12:36:41 1.3
+++ src/sys/lib/libsa/lfsv2.c 2011/12/25 06:09:08 1.4
@@ -1,24 +1,27 @@ @@ -1,24 +1,27 @@
1/* $NetBSD: lfsv2.c,v 1.3 2008/11/19 12:36:41 ad Exp $ */ 1/* $NetBSD: lfsv2.c,v 1.4 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3#define LIBSA_LFS 3#define LIBSA_LFS
4#define REQUIRED_LFS_VERSION 2 4#define REQUIRED_LFS_VERSION 2
5 5
6#define ufs_open lfsv2_open 6#define ufs_open lfsv2_open
7#define ufs_close lfsv2_close 7#define ufs_close lfsv2_close
8#define ufs_read lfsv2_read 8#define ufs_read lfsv2_read
9#define ufs_write lfsv2_write 9#define ufs_write lfsv2_write
10#define ufs_seek lfsv2_seek 10#define ufs_seek lfsv2_seek
11#define ufs_stat lfsv2_stat 11#define ufs_stat lfsv2_stat
 12#if defined(LIBSA_ENABLE_LS_OP)
 13#define ufs_ls lfsv2_ls
 14#endif
12 15
13#define fs_bsize lfs_bsize 16#define fs_bsize lfs_bsize
14#define IFILE_Vx IFILE 17#define IFILE_Vx IFILE
15 18
16#ifdef LFS_IFILE_FRAG_ADDRESSING /* XXX see sys/ufs/lfs/ -- not tested */ 19#ifdef LFS_IFILE_FRAG_ADDRESSING /* XXX see sys/ufs/lfs/ -- not tested */
17#define INOPBx(fs) INOPF(fs) 20#define INOPBx(fs) INOPF(fs)
18#else 21#else
19#define INOPBx(fs) INOPB(fs) 22#define INOPBx(fs) INOPB(fs)
20#endif 23#endif
21 24
22#define FSMOD "lfs" 25#define FSMOD "lfs"
23#define FSMOD2 "ffs" 26#define FSMOD2 "ffs"
24 27

File Added: src/sys/lib/libsa/ls.c
/* $NetBSD: ls.c,v 1.3 2011/12/25 06:09:08 tsutsui Exp $ */

/*-
 * Copyright (c) 2011
 *      The NetBSD Foundation, Inc. All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Martin Husemann.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * Copyright (c) 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Copyright (c) 1996
 *	Matthias Drochner.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


#include "stand.h"
#include <sys/stat.h>
#include <lib/libkern/libkern.h>

void
ls(const char *path)
{
	int             fd;
	struct stat     sb;
	size_t          size;
	const char	*fname = 0;
	char		*p;
	struct open_file *f;

	if ((fd = open(path, 0)) < 0
	    || fstat(fd, &sb) < 0
	    || (sb.st_mode & S_IFMT) != S_IFDIR) {
		/* Path supplied isn't a directory, open parent
		   directory and list matching files. */
		if (fd >= 0)
			close(fd);
		fname = strrchr(path, '/');
		if (fname) {
			size = fname - path;
			p = alloc(size + 1);
			if (!p)
				goto out;
			memcpy(p, path, size);
			p[size] = 0;
			fd = open(p, 0);
			dealloc(p, size + 1);
		} else {
			fd = open("", 0);
			fname = path;
		}

		if (fd < 0) {
			printf("ls: %s\n", strerror(errno));
			return;
		}
		if (fstat(fd, &sb) < 0) {
			printf("stat: %s\n", strerror(errno));
			goto out;
		}
		if ((sb.st_mode & S_IFMT) != S_IFDIR) {
			printf("%s: %s\n", path, strerror(ENOTDIR));
			goto out;
		}
	}

	f = &files[fd];

#if !defined(LIBSA_NO_FD_CHECKING)
	if ((unsigned int)fd >= SOPEN_MAX || f->f_flags == 0) {
		errno = EBADF;
		goto out;
	}
#endif

#if !defined(LIBSA_NO_RAW_ACCESS)
	/* operation not defined on raw devices */
	if (f->f_flags & F_RAW) {
		errno = EOPNOTSUPP;
		goto out;
	}
#endif

	if (FS_LS(f->f_ops) != NULL)
		FS_LS(f->f_ops)(f, fname);
	else
		printf("no ls support for this file system\n");

out:
	close(fd);
}

cvs diff -r1.46 -r1.47 src/sys/lib/libsa/nfs.c (expand / switch to unified diff)

--- src/sys/lib/libsa/nfs.c 2011/06/16 13:27:58 1.46
+++ src/sys/lib/libsa/nfs.c 2011/12/25 06:09:08 1.47
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: nfs.c,v 1.46 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: nfs.c,v 1.47 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 John Brezak 4 * Copyright (c) 1993 John Brezak
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -645,13 +645,22 @@ nfs_stat(struct open_file *f, struct sta @@ -645,13 +645,22 @@ nfs_stat(struct open_file *f, struct sta
645 645
646 ftype = ntohl(fp->fa.fa_type); 646 ftype = ntohl(fp->fa.fa_type);
647 mode = ntohl(fp->fa.fa_mode); 647 mode = ntohl(fp->fa.fa_mode);
648 mode |= nfs_stat_types[ftype & 7]; 648 mode |= nfs_stat_types[ftype & 7];
649 649
650 sb->st_mode = mode; 650 sb->st_mode = mode;
651 sb->st_nlink = ntohl(fp->fa.fa_nlink); 651 sb->st_nlink = ntohl(fp->fa.fa_nlink);
652 sb->st_uid = ntohl(fp->fa.fa_uid); 652 sb->st_uid = ntohl(fp->fa.fa_uid);
653 sb->st_gid = ntohl(fp->fa.fa_gid); 653 sb->st_gid = ntohl(fp->fa.fa_gid);
654 sb->st_size = ntohl(fp->fa.fa_size); 654 sb->st_size = ntohl(fp->fa.fa_size);
655 655
656 return 0; 656 return 0;
657} 657}
 658
 659#if defined(LIBSA_ENABLE_LS_OP)
 660__compactcall void
 661nfs_ls(struct open_file *f, const char *pattern)
 662{
 663 printf("Currently ls command is unsupported by nfs\n");
 664 return;
 665}
 666#endif

cvs diff -r1.73 -r1.74 src/sys/lib/libsa/stand.h (expand / switch to unified diff)

--- src/sys/lib/libsa/stand.h 2011/07/17 20:54:52 1.73
+++ src/sys/lib/libsa/stand.h 2011/12/25 06:09:08 1.74
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: stand.h,v 1.73 2011/07/17 20:54:52 joerg Exp $ */ 1/* $NetBSD: stand.h,v 1.74 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. 4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -77,79 +77,108 @@ @@ -77,79 +77,108 @@
77 77
78#ifdef LIBSA_RENAME_PRINTF 78#ifdef LIBSA_RENAME_PRINTF
79#define getchar libsa_getchar 79#define getchar libsa_getchar
80#define gets libsa_gets 80#define gets libsa_gets
81#define printf libsa_printf 81#define printf libsa_printf
82#define putchar libsa_putchar 82#define putchar libsa_putchar
83#define sprintf libsa_sprintf 83#define sprintf libsa_sprintf
84#define vprintf libsa_vprintf 84#define vprintf libsa_vprintf
85#define vsprintf libsa_vsprintf 85#define vsprintf libsa_vsprintf
86#endif 86#endif
87 87
88struct open_file; 88struct open_file;
89 89
90#define FS_DEF(fs) \ 90#define FS_DEF_BASE(fs) \
91 extern __compactcall int __CONCAT(fs,_open)(const char *, struct open_file *); \ 91 extern __compactcall int __CONCAT(fs,_open)(const char *, struct open_file *); \
92 extern __compactcall int __CONCAT(fs,_close)(struct open_file *); \ 92 extern __compactcall int __CONCAT(fs,_close)(struct open_file *); \
93 extern __compactcall int __CONCAT(fs,_read)(struct open_file *, void *, \ 93 extern __compactcall int __CONCAT(fs,_read)(struct open_file *, void *, \
94 size_t, size_t *); \ 94 size_t, size_t *); \
95 extern __compactcall int __CONCAT(fs,_write)(struct open_file *, void *, \ 95 extern __compactcall int __CONCAT(fs,_write)(struct open_file *, void *, \
96 size_t, size_t *); \ 96 size_t, size_t *); \
97 extern __compactcall off_t __CONCAT(fs,_seek)(struct open_file *, off_t, int); \ 97 extern __compactcall off_t __CONCAT(fs,_seek)(struct open_file *, off_t, int); \
98 extern __compactcall int __CONCAT(fs,_stat)(struct open_file *, struct stat *) 98 extern __compactcall int __CONCAT(fs,_stat)(struct open_file *, struct stat *)
99 99
 100#if defined(LIBSA_ENABLE_LS_OP)
 101#define FS_DEF(fs) \
 102 FS_DEF_BASE(fs);\
 103 extern __compactcall void __CONCAT(fs,_ls)(struct open_file *, const char *)
 104#else
 105#define FS_DEF(fs) FS_DEF_BASE(fs)
 106#endif
 107
 108
100/* 109/*
101 * This structure is used to define file system operations in a file system 110 * This structure is used to define file system operations in a file system
102 * independent way. 111 * independent way.
103 */ 112 */
104extern char *fsmod; 113extern char *fsmod;
105extern char *fsmod2; 114extern char *fsmod2;
106 115
107#if !defined(LIBSA_SINGLE_FILESYSTEM) 116#if !defined(LIBSA_SINGLE_FILESYSTEM)
108struct fs_ops { 117struct fs_ops {
109 __compactcall int (*open)(const char *, struct open_file *); 118 __compactcall int (*open)(const char *, struct open_file *);
110 __compactcall int (*close)(struct open_file *); 119 __compactcall int (*close)(struct open_file *);
111 __compactcall int (*read)(struct open_file *, void *, size_t, size_t *); 120 __compactcall int (*read)(struct open_file *, void *, size_t, size_t *);
112 __compactcall int (*write)(struct open_file *, void *, size_t size, size_t *); 121 __compactcall int (*write)(struct open_file *, void *, size_t size, size_t *);
113 __compactcall off_t (*seek)(struct open_file *, off_t, int); 122 __compactcall off_t (*seek)(struct open_file *, off_t, int);
114 __compactcall int (*stat)(struct open_file *, struct stat *); 123 __compactcall int (*stat)(struct open_file *, struct stat *);
 124#if defined(LIBSA_ENABLE_LS_OP)
 125 __compactcall void (*ls)(struct open_file *, const char *);
 126#endif
115}; 127};
116 128
117extern struct fs_ops file_system[]; 129extern struct fs_ops file_system[];
118extern int nfsys; 130extern int nfsys;
119 131
 132#if defined(LIBSA_ENABLE_LS_OP)
 133#define FS_OPS(fs) { \
 134 __CONCAT(fs,_open), \
 135 __CONCAT(fs,_close), \
 136 __CONCAT(fs,_read), \
 137 __CONCAT(fs,_write), \
 138 __CONCAT(fs,_seek), \
 139 __CONCAT(fs,_stat), \
 140 __CONCAT(fs,_ls) }
 141#else
120#define FS_OPS(fs) { \ 142#define FS_OPS(fs) { \
121 __CONCAT(fs,_open), \ 143 __CONCAT(fs,_open), \
122 __CONCAT(fs,_close), \ 144 __CONCAT(fs,_close), \
123 __CONCAT(fs,_read), \ 145 __CONCAT(fs,_read), \
124 __CONCAT(fs,_write), \ 146 __CONCAT(fs,_write), \
125 __CONCAT(fs,_seek), \ 147 __CONCAT(fs,_seek), \
126 __CONCAT(fs,_stat) } 148 __CONCAT(fs,_stat) }
 149#endif
127 150
128#define FS_OPEN(fs) ((fs)->open) 151#define FS_OPEN(fs) ((fs)->open)
129#define FS_CLOSE(fs) ((fs)->close) 152#define FS_CLOSE(fs) ((fs)->close)
130#define FS_READ(fs) ((fs)->read) 153#define FS_READ(fs) ((fs)->read)
131#define FS_WRITE(fs) ((fs)->write) 154#define FS_WRITE(fs) ((fs)->write)
132#define FS_SEEK(fs) ((fs)->seek) 155#define FS_SEEK(fs) ((fs)->seek)
133#define FS_STAT(fs) ((fs)->stat) 156#define FS_STAT(fs) ((fs)->stat)
 157#if defined(LIBSA_ENABLE_LS_OP)
 158#define FS_LS(fs) ((fs)->ls)
 159#endif
134 160
135#else 161#else
136 162
137#define FS_OPEN(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_open) 163#define FS_OPEN(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_open)
138#define FS_CLOSE(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_close) 164#define FS_CLOSE(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_close)
139#define FS_READ(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_read) 165#define FS_READ(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_read)
140#define FS_WRITE(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_write) 166#define FS_WRITE(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_write)
141#define FS_SEEK(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_seek) 167#define FS_SEEK(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_seek)
142#define FS_STAT(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_stat) 168#define FS_STAT(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_stat)
 169#if defined(LIBSA_ENABLE_LS_OP)
 170#define FS_LS(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_ls)
 171#endif
143 172
144FS_DEF(LIBSA_SINGLE_FILESYSTEM); 173FS_DEF(LIBSA_SINGLE_FILESYSTEM);
145 174
146#endif 175#endif
147 176
148/* where values for lseek(2) */ 177/* where values for lseek(2) */
149#define SEEK_SET 0 /* set file offset to offset */ 178#define SEEK_SET 0 /* set file offset to offset */
150#define SEEK_CUR 1 /* set file offset to current plus offset */ 179#define SEEK_CUR 1 /* set file offset to current plus offset */
151#define SEEK_END 2 /* set file offset to EOF plus offset */ 180#define SEEK_END 2 /* set file offset to EOF plus offset */
152 181
153/* Device switch */ 182/* Device switch */
154#if !defined(LIBSA_SINGLE_DEVICE) 183#if !defined(LIBSA_SINGLE_DEVICE)
155 184
@@ -246,26 +275,29 @@ void *memcpy(void *, const void *, size_ @@ -246,26 +275,29 @@ void *memcpy(void *, const void *, size_
246void *memmove(void *, const void *, size_t); 275void *memmove(void *, const void *, size_t);
247int memcmp(const void *, const void *, size_t); 276int memcmp(const void *, const void *, size_t);
248void *memset(void *, int, size_t); 277void *memset(void *, int, size_t);
249void exec(char *, char *, int); 278void exec(char *, char *, int);
250int open(const char *, int); 279int open(const char *, int);
251int close(int); 280int close(int);
252void closeall(void); 281void closeall(void);
253ssize_t read(int, void *, size_t); 282ssize_t read(int, void *, size_t);
254ssize_t write(int, const void *, size_t); 283ssize_t write(int, const void *, size_t);
255off_t lseek(int, off_t, int); 284off_t lseek(int, off_t, int);
256int ioctl(int, u_long, char *); 285int ioctl(int, u_long, char *);
257int stat(const char *, struct stat *); 286int stat(const char *, struct stat *);
258int fstat(int, struct stat *); 287int fstat(int, struct stat *);
 288#if defined(LIBSA_ENABLE_LS_OP)
 289void ls(const char *);
 290#endif
259 291
260typedef int cmp_t(const void *, const void *); 292typedef int cmp_t(const void *, const void *);
261void qsort(void *, size_t, size_t, cmp_t *); 293void qsort(void *, size_t, size_t, cmp_t *);
262 294
263extern int opterr, optind, optopt, optreset; 295extern int opterr, optind, optopt, optreset;
264extern char *optarg; 296extern char *optarg;
265int getopt(int, char * const *, const char *); 297int getopt(int, char * const *, const char *);
266 298
267char *getpass(const char *); 299char *getpass(const char *);
268int checkpasswd(void); 300int checkpasswd(void);
269int check_password(const char *); 301int check_password(const char *);
270 302
271int nodev(void); 303int nodev(void);

cvs diff -r1.33 -r1.34 src/sys/lib/libsa/tftp.c (expand / switch to unified diff)

--- src/sys/lib/libsa/tftp.c 2011/07/30 03:43:20 1.33
+++ src/sys/lib/libsa/tftp.c 2011/12/25 06:09:08 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tftp.c,v 1.33 2011/07/30 03:43:20 jakllsch Exp $ */ 1/* $NetBSD: tftp.c,v 1.34 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 4 * Copyright (c) 1996
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -419,26 +419,35 @@ __compactcall int @@ -419,26 +419,35 @@ __compactcall int
419tftp_stat(struct open_file *f, struct stat *sb) 419tftp_stat(struct open_file *f, struct stat *sb)
420{ 420{
421 struct tftp_handle *tftpfile; 421 struct tftp_handle *tftpfile;
422 tftpfile = (struct tftp_handle *)f->f_fsdata; 422 tftpfile = (struct tftp_handle *)f->f_fsdata;
423 423
424 sb->st_mode = 0444; 424 sb->st_mode = 0444;
425 sb->st_nlink = 1; 425 sb->st_nlink = 1;
426 sb->st_uid = 0; 426 sb->st_uid = 0;
427 sb->st_gid = 0; 427 sb->st_gid = 0;
428 sb->st_size = tftp_size_of_file(tftpfile); 428 sb->st_size = tftp_size_of_file(tftpfile);
429 return 0; 429 return 0;
430} 430}
431 431
 432#if defined(LIBSA_ENABLE_LS_OP)
 433__compactcall void
 434tftp_ls(struct open_file *f, const char *pattern)
 435{
 436 printf("Currently ls command is unsupported by tftp\n");
 437 return;
 438}
 439#endif
 440
432__compactcall off_t 441__compactcall off_t
433tftp_seek(struct open_file *f, off_t offset, int where) 442tftp_seek(struct open_file *f, off_t offset, int where)
434{ 443{
435 struct tftp_handle *tftpfile; 444 struct tftp_handle *tftpfile;
436 tftpfile = (struct tftp_handle *)f->f_fsdata; 445 tftpfile = (struct tftp_handle *)f->f_fsdata;
437 446
438 switch (where) { 447 switch (where) {
439 case SEEK_SET: 448 case SEEK_SET:
440 tftpfile->off = offset; 449 tftpfile->off = offset;
441 break; 450 break;
442 case SEEK_CUR: 451 case SEEK_CUR:
443 tftpfile->off += offset; 452 tftpfile->off += offset;
444 break; 453 break;

cvs diff -r1.33 -r1.34 src/sys/lib/libsa/ustarfs.c (expand / switch to unified diff)

--- src/sys/lib/libsa/ustarfs.c 2011/06/16 13:27:58 1.33
+++ src/sys/lib/libsa/ustarfs.c 2011/12/25 06:09:08 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ustarfs.c,v 1.33 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: ustarfs.c,v 1.34 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/* [Notice revision 2.2] 3/* [Notice revision 2.2]
4 * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc. 4 * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Ross Harvey 7 * Author: Ross Harvey
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright and 12 * 1. Redistributions of source code must retain the above copyright and
13 * author notice, this list of conditions, and the following disclaimer. 13 * author notice, this list of conditions, and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -527,24 +527,34 @@ ustarfs_stat(struct open_file *f, struct @@ -527,24 +527,34 @@ ustarfs_stat(struct open_file *f, struct
527 return EINVAL; 527 return EINVAL;
528 ustf = f->f_fsdata; 528 ustf = f->f_fsdata;
529 memset(sb, 0, sizeof *sb); 529 memset(sb, 0, sizeof *sb);
530 ustarfs_sscanf(ustf->uas_active.ust_mode, "%8o", &mode); 530 ustarfs_sscanf(ustf->uas_active.ust_mode, "%8o", &mode);
531 ustarfs_sscanf(ustf->uas_active.ust_uid, "%8o", &uid); 531 ustarfs_sscanf(ustf->uas_active.ust_uid, "%8o", &uid);
532 ustarfs_sscanf(ustf->uas_active.ust_gid, "%8o", &gid); 532 ustarfs_sscanf(ustf->uas_active.ust_gid, "%8o", &gid);
533 sb->st_mode = mode; 533 sb->st_mode = mode;
534 sb->st_uid = uid; 534 sb->st_uid = uid;
535 sb->st_gid = gid; 535 sb->st_gid = gid;
536 sb->st_size = ustf->uas_filesize; 536 sb->st_size = ustf->uas_filesize;
537 return 0; 537 return 0;
538} 538}
539 539
 540
 541#if defined(LIBSA_ENABLE_LS_OP)
 542__compactcall void
 543ustarfs_ls(struct open_file *f, const char *pattern)
 544{
 545 printf("Currently ls command is unsupported by ustarfs\n");
 546 return;
 547}
 548#endif
 549
540#ifndef LIBSA_NO_FS_CLOSE 550#ifndef LIBSA_NO_FS_CLOSE
541__compactcall int 551__compactcall int
542ustarfs_close(struct open_file *f) 552ustarfs_close(struct open_file *f)
543{ 553{
544 if (f == NULL || f->f_fsdata == NULL) 554 if (f == NULL || f->f_fsdata == NULL)
545 return EINVAL; 555 return EINVAL;
546 dealloc(f->f_fsdata, sizeof(ust_active_t)); 556 dealloc(f->f_fsdata, sizeof(ust_active_t));
547 f->f_fsdata = 0; 557 f->f_fsdata = 0;
548 return 0; 558 return 0;
549} 559}
550#endif /* !LIBSA_NO_FS_CLOSE */ 560#endif /* !LIBSA_NO_FS_CLOSE */

cvs diff -r1.55 -r1.56 src/sys/lib/libsa/ufs.c (expand / switch to unified diff)

--- src/sys/lib/libsa/ufs.c 2011/06/16 13:27:58 1.55
+++ src/sys/lib/libsa/ufs.c 2011/12/25 06:09:08 1.56
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs.c,v 1.55 2011/06/16 13:27:58 joerg Exp $ */ 1/* $NetBSD: ufs.c,v 1.56 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * The Mach Operating System project at Carnegie-Mellon University. 8 * The Mach Operating System project at Carnegie-Mellon University.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -169,26 +169,86 @@ struct file { @@ -169,26 +169,86 @@ struct file {
169}; 169};
170 170
171static int read_inode(ino32_t, struct open_file *); 171static int read_inode(ino32_t, struct open_file *);
172static int block_map(struct open_file *, indp_t, indp_t *); 172static int block_map(struct open_file *, indp_t, indp_t *);
173static int buf_read_file(struct open_file *, char **, size_t *); 173static int buf_read_file(struct open_file *, char **, size_t *);
174static int search_directory(const char *, int, struct open_file *, ino32_t *); 174static int search_directory(const char *, int, struct open_file *, ino32_t *);
175#ifdef LIBSA_FFSv1 175#ifdef LIBSA_FFSv1
176static void ffs_oldfscompat(struct fs *); 176static void ffs_oldfscompat(struct fs *);
177#endif 177#endif
178#ifdef LIBSA_FFSv2 178#ifdef LIBSA_FFSv2
179static int ffs_find_superblock(struct open_file *, struct fs *); 179static int ffs_find_superblock(struct open_file *, struct fs *);
180#endif 180#endif
181 181
 182#if defined(LIBSA_ENABLE_LS_OP)
 183
 184#define NELEM(x) (sizeof (x) / sizeof(*x))
 185
 186typedef struct entry_t entry_t;
 187struct entry_t {
 188 entry_t *e_next;
 189 ino32_t e_ino;
 190 uint8_t e_type;
 191 char e_name[1];
 192};
 193
 194static const char *const typestr[] = {
 195 "unknown",
 196 "FIFO",
 197 "CHR",
 198 0,
 199 "DIR",
 200 0,
 201 "BLK",
 202 0,
 203 "REG",
 204 0,
 205 "LNK",
 206 0,
 207 "SOCK",
 208 0,
 209 "WHT"
 210};
 211
 212static int
 213fn_match(const char *fname, const char *pattern)
 214{
 215 char fc, pc;
 216
 217 do {
 218 fc = *fname++;
 219 pc = *pattern++;
 220 if (!fc && !pc)
 221 return 1;
 222 if (pc == '?' && fc)
 223 pc = fc;
 224 } while (fc == pc);
 225
 226 if (pc != '*')
 227 return 0;
 228 /*
 229 * Too hard (and unnecessary really) too check for "*?name" etc....
 230 * "**" will look for a '*' and "*?" a '?'
 231 */
 232 pc = *pattern++;
 233 if (!pc)
 234 return 1;
 235 while ((fname = strchr(fname, pc)))
 236 if (fn_match(++fname, pattern))
 237 return 1;
 238 return 0;
 239}
 240#endif /* LIBSA_ENABLE_LS_OP */
 241
182#ifdef LIBSA_LFS 242#ifdef LIBSA_LFS
183/* 243/*
184 * Find an inode's block. Look it up in the ifile. Whee! 244 * Find an inode's block. Look it up in the ifile. Whee!
185 */ 245 */
186static int 246static int
187find_inode_sector(ino32_t inumber, struct open_file *f, daddr_t *isp) 247find_inode_sector(ino32_t inumber, struct open_file *f, daddr_t *isp)
188{ 248{
189 struct file *fp = (struct file *)f->f_fsdata; 249 struct file *fp = (struct file *)f->f_fsdata;
190 struct fs *fs = fp->f_fs; 250 struct fs *fs = fp->f_fs;
191 daddr_t ifileent_blkno; 251 daddr_t ifileent_blkno;
192 char *ent_in_buf; 252 char *ent_in_buf;
193 size_t buf_after_ent; 253 size_t buf_after_ent;
194 int rc; 254 int rc;
@@ -842,26 +902,111 @@ __compactcall int @@ -842,26 +902,111 @@ __compactcall int
842ufs_stat(struct open_file *f, struct stat *sb) 902ufs_stat(struct open_file *f, struct stat *sb)
843{ 903{
844 struct file *fp = (struct file *)f->f_fsdata; 904 struct file *fp = (struct file *)f->f_fsdata;
845 905
846 /* only important stuff */ 906 /* only important stuff */
847 memset(sb, 0, sizeof *sb); 907 memset(sb, 0, sizeof *sb);
848 sb->st_mode = fp->f_di.di_mode; 908 sb->st_mode = fp->f_di.di_mode;
849 sb->st_uid = fp->f_di.di_uid; 909 sb->st_uid = fp->f_di.di_uid;
850 sb->st_gid = fp->f_di.di_gid; 910 sb->st_gid = fp->f_di.di_gid;
851 sb->st_size = fp->f_di.di_size; 911 sb->st_size = fp->f_di.di_size;
852 return 0; 912 return 0;
853} 913}
854 914
 915#if defined(LIBSA_ENABLE_LS_OP)
 916__compactcall void
 917ufs_ls(struct open_file *f, const char *pattern)
 918{
 919 struct file *fp = (struct file *)f->f_fsdata;
 920 char *buf;
 921 size_t buf_size;
 922 entry_t *names = 0, *n, **np;
 923
 924 fp->f_seekp = 0;
 925 while (fp->f_seekp < (off_t)fp->f_di.di_size) {
 926 struct direct *dp, *edp;
 927 int rc = buf_read_file(f, &buf, &buf_size);
 928 if (rc)
 929 goto out;
 930 /* some firmware might use block size larger than DEV_BSIZE */
 931 if (buf_size < DIRBLKSIZ)
 932 goto out;
 933
 934 dp = (struct direct *)buf;
 935 edp = (struct direct *)(buf + buf_size);
 936
 937 for (; dp < edp; dp = (void *)((char *)dp + dp->d_reclen)) {
 938 const char *t;
 939 if (dp->d_ino == 0)
 940 continue;
 941
 942 if (dp->d_type >= NELEM(typestr) ||
 943 !(t = typestr[dp->d_type])) {
 944 /*
 945 * This does not handle "old"
 946 * filesystems properly. On little
 947 * endian machines, we get a bogus
 948 * type name if the namlen matches a
 949 * valid type identifier. We could
 950 * check if we read namlen "0" and
 951 * handle this case specially, if
 952 * there were a pressing need...
 953 */
 954 printf("bad dir entry\n");
 955 goto out;
 956 }
 957 if (pattern && !fn_match(dp->d_name, pattern))
 958 continue;
 959 n = alloc(sizeof *n + strlen(dp->d_name));
 960 if (!n) {
 961 printf("%d: %s (%s)\n",
 962 dp->d_ino, dp->d_name, t);
 963 continue;
 964 }
 965 n->e_ino = dp->d_ino;
 966 n->e_type = dp->d_type;
 967 strcpy(n->e_name, dp->d_name);
 968 for (np = &names; *np; np = &(*np)->e_next) {
 969 if (strcmp(n->e_name, (*np)->e_name) < 0)
 970 break;
 971 }
 972 n->e_next = *np;
 973 *np = n;
 974 }
 975 fp->f_seekp += buf_size;
 976 }
 977
 978 if (names) {
 979 entry_t *p_names = names;
 980 do {
 981 n = p_names;
 982 printf("%d: %s (%s)\n",
 983 n->e_ino, n->e_name, typestr[n->e_type]);
 984 p_names = n->e_next;
 985 } while (p_names);
 986 } else {
 987 printf("not found\n");
 988 }
 989out:
 990 if (names) {
 991 do {
 992 n = names;
 993 names = n->e_next;
 994 dealloc(n, 0);
 995 } while (names);
 996 }
 997}
 998#endif /* LIBSA_ENABLE_LS_OP */
 999
855#ifdef LIBSA_FFSv1 1000#ifdef LIBSA_FFSv1
856/* 1001/*
857 * Sanity checks for old file systems. 1002 * Sanity checks for old file systems.
858 * 1003 *
859 * XXX - goes away some day. 1004 * XXX - goes away some day.
860 * Stripped of stuff libsa doesn't need..... 1005 * Stripped of stuff libsa doesn't need.....
861 */ 1006 */
862static void 1007static void
863ffs_oldfscompat(struct fs *fs) 1008ffs_oldfscompat(struct fs *fs)
864{ 1009{
865 1010
866#ifdef COMPAT_UFS 1011#ifdef COMPAT_UFS
867 /* 1012 /*

cvs diff -r1.9 -r1.10 src/sys/lib/libsa/ufs.h (expand / switch to unified diff)

--- src/sys/lib/libsa/ufs.h 2005/12/11 12:24:46 1.9
+++ src/sys/lib/libsa/ufs.h 2011/12/25 06:09:08 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs.h,v 1.9 2005/12/11 12:24:46 christos Exp $ */ 1/* $NetBSD: ufs.h,v 1.10 2011/12/25 06:09:08 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,15 +24,13 @@ @@ -24,15 +24,13 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * @(#)ufs.h 8.1 (Berkeley) 6/11/93 31 * @(#)ufs.h 8.1 (Berkeley) 6/11/93
32 */ 32 */
33 33
34FS_DEF(ufs); 34FS_DEF(ufs);
35FS_DEF(ffsv1); 35FS_DEF(ffsv1);
36FS_DEF(ffsv2); 36FS_DEF(ffsv2);
37 
38void ufs_ls(const char *); 

File Deleted: src/sys/lib/libsa/Attic/ufs_ls.c