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.cdiff -r1.14 -r1.15 src/sys/arch/ews4800mips/stand/boot/Makefile
(tsutsui)
--- 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 | |||
3 | WARNS ?= 1 | 3 | WARNS ?= 1 | |
4 | NOMAN = | 4 | NOMAN = | |
5 | 5 | |||
6 | BINMODE = 444 | 6 | BINMODE = 444 | |
7 | 7 | |||
8 | S = ${.CURDIR}/../../../.. | 8 | S = ${.CURDIR}/../../../.. | |
9 | COMMON = ${.CURDIR}/../common | 9 | COMMON = ${.CURDIR}/../common | |
10 | 10 | |||
11 | LIBSADIR = ${S}/lib/libsa | 11 | LIBSADIR = ${S}/lib/libsa | |
12 | SYSVBFSDIR = ${S}/fs/sysvbfs | 12 | SYSVBFSDIR = ${S}/fs/sysvbfs | |
13 | EWS4800MIPSDIR = ${.CURDIR}/../../ews4800mips | 13 | EWS4800MIPSDIR = ${.CURDIR}/../../ews4800mips | |
14 | DEVDIR = ${.CURDIR}/../../dev | 14 | DEVDIR = ${.CURDIR}/../../dev | |
@@ -79,27 +79,28 @@ CPPFLAGS += -D__daddr_t=int32_t | @@ -79,27 +79,28 @@ CPPFLAGS += -D__daddr_t=int32_t | |||
79 | 79 | |||
80 | CLEANFILES += ${BINKERNEL_DUMMY_O} ${BINKERNEL_O} | 80 | CLEANFILES += ${BINKERNEL_DUMMY_O} ${BINKERNEL_O} | |
81 | CLEANFILES += ${PROG} ${PROG}.elf ${PROG}.coff ${PROG}.tmp ${PROG}.dis | 81 | CLEANFILES += ${PROG} ${PROG}.elf ${PROG}.coff ${PROG}.tmp ${PROG}.dis | |
82 | CLEANFILES += ${COFFHDRFIX} | 82 | CLEANFILES += ${COFFHDRFIX} | |
83 | CLEANFILES += ${BOOT_KERNEL} ${BOOT_KERNEL}.elf ${BOOT_KERNEL}.tmp | 83 | CLEANFILES += ${BOOT_KERNEL} ${BOOT_KERNEL}.elf ${BOOT_KERNEL}.tmp | |
84 | CLEANFILES += ${BOOT_KERNEL}.gz ${BOOT_KERNEL}.gz.tmp | 84 | CLEANFILES += ${BOOT_KERNEL}.gz ${BOOT_KERNEL}.gz.tmp | |
85 | 85 | |||
86 | .include "${S}/lib/libkern/Makefile.inc" | 86 | .include "${S}/lib/libkern/Makefile.inc" | |
87 | LIBKERN= ${KERNLIB} | 87 | LIBKERN= ${KERNLIB} | |
88 | 88 | |||
89 | .include "${S}/lib/libz/Makefile.inc" | 89 | .include "${S}/lib/libz/Makefile.inc" | |
90 | LIBZ= ${ZLIB} | 90 | LIBZ= ${ZLIB} | |
91 | 91 | |||
92 | SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes | 92 | CPPFLAGS+= -DLIBSA_ENABLE_LS_OP | |
93 | SAMISCMAKEFLAGS= 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" | |
94 | LIBSA= ${SALIB} | 95 | LIBSA= ${SALIB} | |
95 | 96 | |||
96 | LIBS = ${LIBSA} ${LIBZ} ${LIBKERN} | 97 | LIBS = ${LIBSA} ${LIBZ} ${LIBKERN} | |
97 | 98 | |||
98 | # fixup GNU binutils file offset error. | 99 | # fixup GNU binutils file offset error. | |
99 | coffhdrfix: ${COMMON}/coffhdrfix.c | 100 | coffhdrfix: ${COMMON}/coffhdrfix.c | |
100 | ${HOST_CC} -o ${COFFHDRFIX} ${COMMON}/coffhdrfix.c | 101 | ${HOST_CC} -o ${COFFHDRFIX} ${COMMON}/coffhdrfix.c | |
101 | 102 | |||
102 | clean cleandir distclean: .WAIT cleanlibdir | 103 | clean cleandir distclean: .WAIT cleanlibdir | |
103 | 104 | |||
104 | cleanlibdir: | 105 | cleanlibdir: | |
105 | -rm -rf lib | 106 | -rm -rf lib |
--- 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 | |||
44 | extern uint8_t kernel_binary[]; | 44 | extern uint8_t kernel_binary[]; | |
45 | extern int kernel_binary_size; | 45 | extern int kernel_binary_size; | |
46 | 46 | |||
47 | extern struct fs_ops datafs_ops; | 47 | extern struct fs_ops datafs_ops; | |
48 | extern struct fs_ops bfs_ops; | 48 | extern struct fs_ops bfs_ops; | |
49 | struct fs_ops ufs_ops = { | 49 | struct fs_ops ufs_ops = FS_OPS(ufs); | |
50 | ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat | 50 | struct fs_ops nfs_ops = FS_OPS(nfs); | |
51 | }; | |||
52 | struct fs_ops nfs_ops = { | |||
53 | nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat | |||
54 | }; | |||
55 | 51 | |||
56 | extern struct devsw netdevsw; | 52 | extern struct devsw netdevsw; | |
57 | extern struct devsw dkdevsw; | 53 | extern struct devsw dkdevsw; | |
58 | char fname[16]; | 54 | char fname[16]; | |
59 | 55 | |||
60 | /* Referenced by libsa/open.c */ | 56 | /* Referenced by libsa/open.c */ | |
61 | struct fs_ops file_system[1]; | 57 | struct fs_ops file_system[1]; | |
62 | int nfsys = 1; | 58 | int nfsys = 1; | |
63 | struct devsw devsw[1]; | 59 | struct devsw devsw[1]; | |
64 | int ndevs = 1; | 60 | int ndevs = 1; | |
65 | 61 | |||
66 | int | 62 | int | |
67 | devopen(struct open_file *f, const char *request, char **file) | 63 | devopen(struct open_file *f, const char *request, char **file) |
--- 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 | |||
101 | void | 99 | void | |
102 | bfs_ls(void) | 100 | bfs_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 |
--- 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 | |||
3 | S= ${.CURDIR}/../../../../.. | 3 | S= ${.CURDIR}/../../../../.. | |
4 | 4 | |||
5 | NOMAN= | 5 | NOMAN= | |
6 | PROG?= boot | 6 | PROG?= boot | |
7 | NEWVERSWHAT?= "BIOS Boot" | 7 | NEWVERSWHAT?= "BIOS Boot" | |
8 | VERSIONFILE?= ${.CURDIR}/../version | 8 | VERSIONFILE?= ${.CURDIR}/../version | |
9 | 9 | |||
10 | AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | 10 | AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | |
11 | 11 | |||
12 | SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c | 12 | SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c | |
13 | SRCS= ${SOURCES} | 13 | SRCS= ${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 | |||
66 | CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr | 66 | CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr | |
67 | CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap | 67 | CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap | |
68 | 68 | |||
69 | CPPFLAGS+= -DSUPPORT_CD9660 | 69 | CPPFLAGS+= -DSUPPORT_CD9660 | |
70 | CPPFLAGS+= -DSUPPORT_USTARFS | 70 | CPPFLAGS+= -DSUPPORT_USTARFS | |
71 | CPPFLAGS+= -DSUPPORT_DOSFS | 71 | CPPFLAGS+= -DSUPPORT_DOSFS | |
72 | CPPFLAGS+= -DSUPPORT_EXT2FS | 72 | CPPFLAGS+= -DSUPPORT_EXT2FS | |
73 | CPPFLAGS+= -DPASS_BIOSGEOM | 73 | CPPFLAGS+= -DPASS_BIOSGEOM | |
74 | CPPFLAGS+= -DPASS_MEMMAP | 74 | CPPFLAGS+= -DPASS_MEMMAP | |
75 | #CPPFLAGS+= -DBOOTPASSWD | 75 | #CPPFLAGS+= -DBOOTPASSWD | |
76 | CPPFLAGS+= -DEPIA_HACK | 76 | CPPFLAGS+= -DEPIA_HACK | |
77 | #CPPFLAGS+= -DDEBUG_MEMSIZE | 77 | #CPPFLAGS+= -DDEBUG_MEMSIZE | |
78 | #CPPFLAGS+= -DBOOT_MSG_COM0 | 78 | #CPPFLAGS+= -DBOOT_MSG_COM0 | |
79 | CPPFLAGS+= -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. | |
83 | SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000 | 84 | SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000 | |
84 | SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT | 85 | SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT | |
85 | SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels | 86 | SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels | |
86 | SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS | 87 | SAMISCMAKEFLAGS+= 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) | |
89 | CPPFLAGS+= -Wno-pointer-sign | 90 | CPPFLAGS+= -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 | |
109 | I386DIR= ${I386_STAND_DIR}/lib | 110 | I386DIR= ${I386_STAND_DIR}/lib | |
110 | .include "${I386DIR}/Makefile.inc" | 111 | .include "${I386DIR}/Makefile.inc" | |
111 | LIBI386= ${I386LIB} | 112 | LIBI386= ${I386LIB} | |
112 | 113 | |||
113 | ### find out what to use for libsa | 114 | ### find out what to use for libsa | |
114 | SA_AS= library | 115 | SA_AS= library | |
115 | SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" | 116 | SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" | |
117 | SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" | |||
116 | .include "${S}/lib/libsa/Makefile.inc" | 118 | .include "${S}/lib/libsa/Makefile.inc" | |
117 | LIBSA= ${SALIB} | 119 | LIBSA= ${SALIB} | |
118 | 120 | |||
119 | ### find out what to use for libkern | 121 | ### find out what to use for libkern | |
120 | KERN_AS= library | 122 | KERN_AS= library | |
121 | .include "${S}/lib/libkern/Makefile.inc" | 123 | .include "${S}/lib/libkern/Makefile.inc" | |
122 | LIBKERN= ${KERNLIB} | 124 | LIBKERN= ${KERNLIB} | |
123 | 125 | |||
124 | ### find out what to use for libz | 126 | ### find out what to use for libz | |
125 | Z_AS= library | 127 | Z_AS= library | |
126 | .include "${S}/lib/libz/Makefile.inc" | 128 | .include "${S}/lib/libz/Makefile.inc" | |
127 | LIBZ= ${ZLIB} | 129 | LIBZ= ${ZLIB} | |
128 | 130 |
--- 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 | |||
406 | void | 406 | void | |
407 | command_ls(char *arg) | 407 | command_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 */ | |
417 | void | 417 | void | |
418 | command_quit(char *arg) | 418 | command_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!"); |
--- 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 | |||
3 | S= ${.CURDIR}/../../../.. | 3 | S= ${.CURDIR}/../../../.. | |
4 | 4 | |||
5 | BASE= dosboot | 5 | BASE= dosboot | |
6 | PROG= ${BASE}.com | 6 | PROG= ${BASE}.com | |
7 | NOMAN= # defined | 7 | NOMAN= # defined | |
8 | NEWVERSWHAT= "DOS Boot" | 8 | NEWVERSWHAT= "DOS Boot" | |
9 | STARTFILE= ${DOSSTART} | 9 | STARTFILE= ${DOSSTART} | |
10 | RELOC= 0x100 | 10 | RELOC= 0x100 | |
11 | 11 | |||
12 | AFLAGS.dosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | 12 | AFLAGS.dosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | |
13 | AFLAGS.start_dos.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | 13 | AFLAGS.start_dos.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} | |
14 | 14 | |||
15 | SRCS= main.c devopen.c exec.c | 15 | SRCS= main.c devopen.c exec.c | |
16 | 16 | |||
17 | CPPFLAGS+= -DSLOW # for libz | 17 | CPPFLAGS+= -DSLOW # for libz | |
18 | CPPFLAGS+= -DCOMPAT_386BSD_MBRPART | 18 | CPPFLAGS+= -DCOMPAT_386BSD_MBRPART | |
19 | CPPFLAGS+= -DXMS | 19 | CPPFLAGS+= -DXMS | |
20 | CPPFLAGS+= -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 | |
24 | CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main | 25 | CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main | |
25 | 26 | |||
26 | # XXX should go into library | 27 | # XXX should go into library | |
27 | SRCS+= getopt.c | 28 | SRCS+= 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 | |
31 | CPPFLAGS+= -DSTACK_START=0x10000 | 32 | CPPFLAGS+= -DSTACK_START=0x10000 | |
32 | SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000 | 33 | SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000 | |
33 | SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no | 34 | SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no SA_ENABLE_LS_OP=yes | |
34 | I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes | 35 | I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes | |
35 | 36 | |||
36 | VERSIONFILE= ${.CURDIR}/version | 37 | VERSIONFILE= ${.CURDIR}/version | |
37 | 38 | |||
38 | PIE_CFLAGS= | 39 | PIE_CFLAGS= | |
39 | PIE_LDFLAGS= | 40 | PIE_LDFLAGS= | |
40 | PIE_AFLAGS= | 41 | PIE_AFLAGS= | |
41 | 42 | |||
42 | .include <bsd.own.mk> | 43 | .include <bsd.own.mk> | |
43 | 44 | |||
44 | release: check_RELEASEDIR | 45 | release: 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 |
--- 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 | |||
322 | void | 322 | void | |
323 | command_ls(char *arg) | 323 | command_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 */ | |
336 | void | 332 | void | |
337 | command_quit(char *arg) | 333 | command_quit(char *arg) | |
338 | { | 334 | { | |
339 | printf("Exiting... goodbye...\n"); | 335 | printf("Exiting... goodbye...\n"); | |
340 | _rtt(); | 336 | _rtt(); | |
341 | } | 337 | } | |
342 | 338 | |||
343 | void | 339 | void | |
344 | command_boot(char *arg) | 340 | command_boot(char *arg) |
--- 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 | |||
636 | nfs_ls(struct open_file *f, const char *pattern) | |||
637 | { | |||
638 | printf("Currently ls command is unsupported by nfs\n"); | |||
639 | return; | |||
640 | } | |||
641 | #endif |
--- 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 | |||
3 | PROG?= boot | 3 | PROG?= boot | |
4 | 4 | |||
5 | NEWVERSWHAT?= "Boot" | 5 | NEWVERSWHAT?= "Boot" | |
6 | VERSIONFILE?= ${.CURDIR}/../version | 6 | VERSIONFILE?= ${.CURDIR}/../version | |
7 | 7 | |||
8 | SRCS= boot.S boot2.c bootinfo.c conf.c devopen.c monitor.c | 8 | SRCS= boot.S boot2.c bootinfo.c conf.c devopen.c monitor.c | |
9 | SRCS+= delay.c getsecs.c | 9 | SRCS+= delay.c getsecs.c | |
10 | SRCS+= bios.S | 10 | SRCS+= bios.S | |
11 | SRCS+= biosdisk.c biosdisk_ll.c | 11 | SRCS+= biosdisk.c biosdisk_ll.c | |
12 | SRCS+= scifcons.c cons.c prf.c | 12 | SRCS+= scifcons.c cons.c prf.c | |
13 | .if !make(depend) | 13 | .if !make(depend) | |
14 | SRCS+= vers.c | 14 | SRCS+= vers.c | |
15 | .endif | 15 | .endif | |
16 | 16 | |||
17 | LDFLAGS+= -e boot_start | 17 | LDFLAGS+= -e boot_start | |
18 | 18 | |||
19 | CFLAGS= | 19 | CFLAGS= | |
20 | CPPFLAGS= -DSUPPORT_FFSv1 | 20 | CPPFLAGS= -DSUPPORT_FFSv1 | |
21 | CPPFLAGS+= -DSUPPORT_FFSv2 | 21 | CPPFLAGS+= -DSUPPORT_FFSv2 | |
22 | CPPFLAGS+= -DSUPPORT_DOSFS | 22 | CPPFLAGS+= -DSUPPORT_DOSFS | |
23 | CPPFLAGS+= -DSUPPORT_USTARFS | 23 | CPPFLAGS+= -DSUPPORT_USTARFS | |
24 | CPPFLAGS+= -DDBMONITOR | 24 | CPPFLAGS+= -DDBMONITOR | |
25 | CPPFLAGS+= -DLIBSA_ENABLE_LS_OP | |||
25 | #CPPFLAGS+= -DDEBUG | 26 | #CPPFLAGS+= -DDEBUG | |
26 | 27 | |||
27 | SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" | 28 | SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" | |
28 | SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" | 29 | SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" | |
30 | SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" | |||
29 | 31 | |||
30 | .include "../Makefile.bootprogs" | 32 | .include "../Makefile.bootprogs" | |
31 | 33 | |||
32 | LIBLIST= ${LIBSA} ${LIBZ} ${LIBKERN} | 34 | LIBLIST= ${LIBSA} ${LIBZ} ${LIBKERN} | |
33 | 35 | |||
34 | CLEANFILES+= ${PROG}.sym ${PROG}.map vers.c | 36 | CLEANFILES+= ${PROG}.sym ${PROG}.map vers.c | |
35 | 37 | |||
36 | vers.c: ${VERSIONFILE} ${SOURCES} ${.CURDIR}/../Makefile.boot | 38 | vers.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} \ |
--- 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 | |||
326 | static void | 326 | static void | |
327 | bootcmd_ls(char *arg) | 327 | bootcmd_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 */ | |
337 | static void | 337 | static void | |
338 | bootcmd_quit(char *arg) | 338 | bootcmd_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!"); |
--- 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 | |||
3 | NOMAN= # defined | 3 | NOMAN= # defined | |
4 | 4 | |||
5 | .include <bsd.own.mk> | 5 | .include <bsd.own.mk> | |
6 | 6 | |||
7 | BOOT= Multi-boot | 7 | BOOT= Multi-boot | |
8 | VERSIONFILE= ${.CURDIR}/version | 8 | VERSIONFILE= ${.CURDIR}/version | |
9 | VERSION!= ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \ | 9 | VERSION!= ${TOOL_AWK} -F: '$$1 ~ /^[0-9.]*$$/ { it = $$1; } \ | |
10 | END { print it }' ${VERSIONFILE} | 10 | END { print it }' ${VERSIONFILE} | |
11 | NEWVERSWHAT= "${BOOT}" | 11 | NEWVERSWHAT= "${BOOT}" | |
12 | 12 | |||
13 | # text address | 13 | # text address | |
14 | TEXT= 006000 | 14 | TEXT= 006000 | |
@@ -30,26 +30,27 @@ COMMONDIR= $M/stand/common | @@ -30,26 +30,27 @@ COMMONDIR= $M/stand/common | |||
30 | 30 | |||
31 | SRCS+= vers.c | 31 | SRCS+= vers.c | |
32 | CLEANFILES+= vers.c | 32 | CLEANFILES+= vers.c | |
33 | vers.c: ${VERSIONFILE} | 33 | vers.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 | |||
38 | CPPFLAGS+= -nostdinc -I$S -I${.OBJDIR} -I$M/stand/libsa | 38 | CPPFLAGS+= -nostdinc -I$S -I${.OBJDIR} -I$M/stand/libsa | |
39 | CPPFLAGS+= -I$M/stand/libiocs -I${COMMONDIR} | 39 | CPPFLAGS+= -I$M/stand/libiocs -I${COMMONDIR} | |
40 | CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE | 40 | CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE | |
41 | CPPFLAGS+= -DTEXTADDR="0x${TEXT}" | 41 | CPPFLAGS+= -DTEXTADDR="0x${TEXT}" | |
42 | CPPFLAGS+= -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\" | 42 | CPPFLAGS+= -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\" | |
43 | CPPFLAGS+= -DLIBSA_ENABLE_LS_OP | |||
43 | CFLAGS= -Wno-main -Os -m68020-60 | 44 | CFLAGS= -Wno-main -Os -m68020-60 | |
44 | LINKFLAGS= -N -static -T ${.CURDIR}/boot.ldscript | 45 | LINKFLAGS= -N -static -T ${.CURDIR}/boot.ldscript | |
45 | LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR} | 46 | LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR} | |
46 | LIBSA!= cd $M/stand/libsa && ${PRINTOBJDIR} | 47 | LIBSA!= cd $M/stand/libsa && ${PRINTOBJDIR} | |
47 | L= ${LIBSA}/lib | 48 | L= ${LIBSA}/lib | |
48 | LDLIBS= ${L}/sa/libsa.a ${L}/kern/libkern.a ${L}/z/libz.a | 49 | LDLIBS= ${L}/sa/libsa.a ${L}/kern/libkern.a ${L}/z/libz.a | |
49 | LDLIBS+= ${LIBIOCS}/libiocs.a | 50 | LDLIBS+= ${LIBIOCS}/libiocs.a | |
50 | 51 | |||
51 | .include "../Makefile.booters" | 52 | .include "../Makefile.booters" | |
52 | 53 | |||
53 | realall: ${PROG} | 54 | realall: ${PROG} | |
54 | ${PROG}: ${OBJS} ${LDLIBS} | 55 | ${PROG}: ${OBJS} ${LDLIBS} | |
55 | ${_MKTARGET_LINK} | 56 | ${_MKTARGET_LINK} |
--- 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 | |||
48 | char default_kernel[20] = "sd0a:netbsd"; | 48 | char default_kernel[20] = "sd0a:netbsd"; | |
49 | int mpu, hostadaptor; | 49 | int mpu, hostadaptor; | |
50 | int console_device = -1; | 50 | int console_device = -1; | |
51 | 51 | |||
52 | static void help(void); | 52 | static void help(void); | |
53 | static int get_scsi_host_adapter(void); | 53 | static int get_scsi_host_adapter(void); | |
54 | static void doboot(const char *, int); | 54 | static void doboot(const char *, int); | |
55 | static void boot(char *); | 55 | static void boot(char *); | |
56 | static void ls(char *); | 56 | static void cmd_ls(char *); | |
57 | int bootmenu(void); | 57 | int bootmenu(void); | |
58 | void bootmain(int); | 58 | void bootmain(int); | |
59 | extern int detectmpu(void); | 59 | extern int detectmpu(void); | |
60 | extern int badbaddr(void *); | 60 | extern int badbaddr(void *); | |
61 | 61 | |||
62 | /* from boot_ufs/bootmain.c */ | 62 | /* from boot_ufs/bootmain.c */ | |
63 | static int | 63 | static int | |
64 | get_scsi_host_adapter(void) | 64 | get_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 | |||
203 | static void | 203 | static void | |
204 | ls(char *arg) | 204 | cmd_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 | |||
224 | int | 224 | int | |
225 | bootmenu(void) | 225 | bootmenu(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 | |||
276 | extern const char bootprog_rev[]; | 276 | extern const char bootprog_rev[]; | |
277 | extern const char bootprog_name[]; | 277 | extern 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. |
--- 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 | |||
3 | S= ${.CURDIR}/../../../.. | 3 | S= ${.CURDIR}/../../../.. | |
4 | 4 | |||
5 | CFLAGS+= -m68020-60 | 5 | CFLAGS+= -m68020-60 | |
6 | 6 | |||
7 | CPPFLAGS+= -nostdinc -I${.OBJDIR} -I. -I${S} | 7 | CPPFLAGS+= -nostdinc -I${.OBJDIR} -I. -I${S} | |
8 | CPPFLAGS+= -I${.CURDIR}/../libiocs -I${.CURDIR}/../common | 8 | CPPFLAGS+= -I${.CURDIR}/../libiocs -I${.CURDIR}/../common | |
9 | CPPFLAGS+= -D_STANDALONE | 9 | CPPFLAGS+= -D_STANDALONE | |
10 | CPPFLAGS+= -DHEAP_VARIABLE | 10 | CPPFLAGS+= -DHEAP_VARIABLE | |
11 | CPPFLAGS+= -DHAVE_CHANGEDISK_HOOK | 11 | CPPFLAGS+= -DHAVE_CHANGEDISK_HOOK | |
12 | CPPFLAGS+= -DUSTAR_SECT_PER_CYL=16 | 12 | CPPFLAGS+= -DUSTAR_SECT_PER_CYL=16 | |
13 | CPPFLAGS+= -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 | |
20 | libinstall:: | 21 | libinstall:: | |
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 | |
25 | KERN_AS= library | 26 | KERN_AS= library | |
26 | .include "${S}/lib/libkern/Makefile.inc" | 27 | .include "${S}/lib/libkern/Makefile.inc" | |
27 | LIBKERN= ${KERNLIB} | 28 | LIBKERN= ${KERNLIB} | |
28 | 29 | |||
29 | ### find out what to use for libz | 30 | ### find out what to use for libz | |
30 | Z_AS= library | 31 | Z_AS= library | |
31 | .include "${S}/lib/libz/Makefile.inc" | 32 | .include "${S}/lib/libz/Makefile.inc" | |
32 | LIBZ= ${ZLIB} | 33 | LIBZ= ${ZLIB} | |
33 | 34 | |||
34 | ### find out what to use for libsa | 35 | ### find out what to use for libsa | |
35 | SA_AS= library | 36 | SA_AS= library | |
36 | SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes SA_EXTRADIR=${.CURDIR} | 37 | SAMISCMAKEFLAGS= 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" | |
38 | LIBSA= ${SALIB} | 39 | LIBSA= ${SALIB} | |
39 | 40 | |||
40 | LIBS= ${LIBKERN} ${LIBZ} ${LIBSA} | 41 | LIBS= ${LIBKERN} ${LIBZ} ${LIBSA} | |
41 | 42 | |||
42 | all realall: ${LIBS} | 43 | all realall: ${LIBS} | |
43 | 44 | |||
44 | cleandir distclean: .WAIT cleanlibdir | 45 | cleandir distclean: .WAIT cleanlibdir | |
45 | 46 | |||
46 | cleanlibdir: | 47 | cleanlibdir: | |
47 | -rm -rf lib | 48 | -rm -rf lib |
--- 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 | |||
3 | PROG= zboot | 3 | PROG= zboot | |
4 | 4 | |||
5 | S= ${.CURDIR}/../../../.. | 5 | S= ${.CURDIR}/../../../.. | |
6 | 6 | |||
7 | SRCS= crt0.c | 7 | SRCS= crt0.c | |
8 | SRCS+= boot.c bootinfo.c bootmenu.c conf.c devopen.c diskprobe.c | 8 | SRCS+= boot.c bootinfo.c bootmenu.c conf.c devopen.c diskprobe.c | |
9 | SRCS+= loadfile_zboot.c | 9 | SRCS+= loadfile_zboot.c | |
10 | SRCS+= getsecs.c termios.c unixcons.c unixdev.c unixsys.S | 10 | SRCS+= getsecs.c termios.c unixcons.c unixdev.c unixsys.S | |
11 | 11 | |||
12 | NOMAN= # defined | 12 | NOMAN= # defined | |
13 | 13 | |||
14 | .include <bsd.own.mk> | 14 | .include <bsd.own.mk> | |
15 | 15 | |||
16 | CFLAGS+= -Wall -Wno-main | 16 | CFLAGS+= -Wall -Wno-main | |
17 | CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith | 17 | CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith | |
18 | CFLAGS+= -fno-stack-protector -fno-builtin -ffreestanding | 18 | CFLAGS+= -fno-stack-protector -fno-builtin -ffreestanding | |
19 | CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -I${.OBJDIR} -I${S} | 19 | CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -I${.OBJDIR} -I${S} | |
20 | CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE | 20 | CPPFLAGS+= -D_STANDALONE -DHEAP_VARIABLE | |
21 | CPPFLAGS+= -DLIBSA_ENABLE_LS_OP | |||
21 | AFLAGS+= -D_LOCORE | 22 | AFLAGS+= -D_LOCORE | |
22 | LDFLAGS+= -nostdlib -Bstatic | 23 | LDFLAGS+= -nostdlib -Bstatic | |
23 | 24 | |||
24 | CLEANFILES+= vers.c vers.o | 25 | CLEANFILES+= vers.c vers.o | |
25 | 26 | |||
26 | LIBCRT0= crt0.o | 27 | LIBCRT0= crt0.o | |
27 | LIBC= # nothing | 28 | LIBC= # nothing | |
28 | LIBCRTBEGIN= # nothing | 29 | LIBCRTBEGIN= # nothing | |
29 | LIBCRTEND= # nothing | 30 | LIBCRTEND= # nothing | |
30 | 31 | |||
31 | NEWVERSWHAT?= "Boot" | 32 | NEWVERSWHAT?= "Boot" | |
32 | VERSIONFILE?= ${.CURDIR}/version | 33 | VERSIONFILE?= ${.CURDIR}/version | |
33 | 34 | |||
34 | ### find out what to use for libkern | 35 | ### find out what to use for libkern | |
35 | KERN_AS= library | 36 | KERN_AS= library | |
36 | .include "${S}/lib/libkern/Makefile.inc" | 37 | .include "${S}/lib/libkern/Makefile.inc" | |
37 | LIBKERN= ${KERNLIB} | 38 | LIBKERN= ${KERNLIB} | |
38 | 39 | |||
39 | ### find out what to use for libz | 40 | ### find out what to use for libz | |
40 | Z_AS= library | 41 | Z_AS= library | |
41 | .include "${S}/lib/libz/Makefile.inc" | 42 | .include "${S}/lib/libz/Makefile.inc" | |
42 | LIBZ= ${ZLIB} | 43 | LIBZ= ${ZLIB} | |
43 | 44 | |||
44 | ### find out what to use for libsa | 45 | ### find out what to use for libsa | |
45 | SA_AS= library | 46 | SA_AS= library | |
46 | SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes | 47 | SAMISCMAKEFLAGS= 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" | |
48 | LIBSA= ${SALIB} | 49 | LIBSA= ${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 | |||
59 | cleandir distclean: .WAIT cleanlibdir | 60 | cleandir distclean: .WAIT cleanlibdir |
--- 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 | |||
320 | static void | 320 | static void | |
321 | bootcmd_ls(char *arg) | 321 | bootcmd_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 | |||
330 | static void | 330 | static void | |
331 | bootcmd_boot(char *arg) | 331 | bootcmd_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 | } |
--- 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 | |||
3 | LIB= sa | 3 | LIB= sa | |
4 | NOPIC= # defined | 4 | NOPIC= # defined | |
5 | NOPROFILE=# defined | 5 | NOPROFILE=# defined | |
6 | 6 | |||
7 | SA_USE_CREAD?= no # Read compressed kernels | 7 | SA_USE_CREAD?= no # Read compressed kernels | |
8 | SA_INCLUDE_NET?= yes # Netboot via TFTP, NFS | 8 | SA_INCLUDE_NET?= yes # Netboot via TFTP, NFS | |
9 | SA_USE_LOADFILE?= no # Generic executable loading support | 9 | SA_USE_LOADFILE?= no # Generic executable loading support | |
10 | SA_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 | |
12 | CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \ | 13 | CPPFLAGS= -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" | |
37 | SRCS+= memcmp.c memcpy.c memmove.c memset.c strchr.c | 38 | SRCS+= memcmp.c memcpy.c memmove.c memset.c strchr.c | |
38 | .endif | 39 | .endif | |
39 | SRCS+= bcopy.c bzero.c # Remove me eventually. | 40 | SRCS+= bcopy.c bzero.c # Remove me eventually. | |
40 | 41 | |||
41 | # io routines | 42 | # io routines | |
42 | SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c | 43 | SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c | |
43 | SRCS+= close.c lseek.c open.c read.c write.c | 44 | SRCS+= close.c lseek.c open.c read.c write.c | |
44 | .if (${SA_USE_CREAD} == "yes") | 45 | .if (${SA_USE_CREAD} == "yes") | |
45 | CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD | 46 | CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD | |
46 | SRCS+= cread.c | 47 | SRCS+= cread.c | |
47 | .endif | 48 | .endif | |
49 | .if (${SA_ENABLE_LS_OP} == "yes") | |||
50 | SRCS+= ls.c | |||
51 | .endif | |||
48 | 52 | |||
49 | .if (${SA_USE_LOADFILE} == "yes") | 53 | .if (${SA_USE_LOADFILE} == "yes") | |
50 | SRCS+= loadfile.c loadfile_ecoff.c loadfile_elf32.c lookup_elf32.c \ | 54 | SRCS+= 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") | |
53 | SRCS+= loadfile_aout.c | 57 | SRCS+= 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 | |
59 | SRCS+= arp.c ether.c ether_sprintf.c ip_cksum.c net.c netif.c rpc.c udp.c ip.c | 63 | SRCS+= 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: | |
62 | SRCS+= bootp.c rarp.c bootparam.c | 66 | SRCS+= bootp.c rarp.c bootparam.c | |
63 | 67 | |||
64 | # boot filesystems | 68 | # boot filesystems | |
65 | SRCS+= nfs.c tftp.c | 69 | SRCS+= nfs.c tftp.c | |
66 | .endif | 70 | .endif | |
67 | 71 | |||
68 | SRCS+= ffsv1.c ffsv2.c ufs_ls.c | 72 | SRCS+= ffsv1.c ffsv2.c | |
69 | SRCS+= lfsv1.c lfsv2.c | 73 | SRCS+= lfsv1.c lfsv2.c | |
70 | SRCS+= cd9660.c | 74 | SRCS+= cd9660.c | |
71 | SRCS+= ustarfs.c | 75 | SRCS+= ustarfs.c | |
72 | SRCS+= dosfs.c | 76 | SRCS+= dosfs.c | |
73 | SRCS+= ext2fs.c | 77 | SRCS+= ext2fs.c | |
74 | # for historic compatibility ufs == ffsv1 | 78 | # for historic compatibility ufs == ffsv1 | |
75 | SRCS+= ufs.c | 79 | SRCS+= ufs.c | |
76 | 80 | |||
77 | # only needed during build | 81 | # only needed during build | |
78 | libinstall:: | 82 | libinstall:: | |
79 | 83 | |||
80 | .undef DESTDIR | 84 | .undef DESTDIR | |
81 | .include <bsd.lib.mk> | 85 | .include <bsd.lib.mk> |
--- 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 | |
389 | cd9660_stat(struct open_file *f, struct stat *sb) | 389 | cd9660_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 | |||
402 | cd9660_ls(struct open_file *f, const char *pattern) | |||
403 | { | |||
404 | printf("Currently ls command is unsupported by cd9660\n"); | |||
405 | return; | |||
406 | } | |||
407 | #endif |
--- 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 | |||
410 | dosfs_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 | */ | |
411 | static int | 420 | static int | |
412 | parsebs(DOS_FS *fs, DOS_BS *bs) | 421 | parsebs(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; |
--- 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; | |||
136 | struct file { | 136 | struct 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 | ||||
153 | typedef struct entry_t entry_t; | |||
154 | struct entry_t { | |||
155 | entry_t *e_next; | |||
156 | ino32_t e_ino; | |||
157 | uint8_t e_type; | |||
158 | char e_name[1]; | |||
159 | }; | |||
160 | ||||
161 | static const char *const typestr[] = { | |||
162 | "unknown", | |||
163 | "REG", | |||
164 | "DIR", | |||
165 | "CHR", | |||
166 | "BLK", | |||
167 | "FIFO", | |||
168 | "SOCK", | |||
169 | "LNK" | |||
170 | }; | |||
171 | ||||
172 | static int | |||
173 | fn_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 | ||||
149 | static int read_inode(ino32_t, struct open_file *); | 202 | static int read_inode(ino32_t, struct open_file *); | |
150 | static int block_map(struct open_file *, indp_t, indp_t *); | 203 | static int block_map(struct open_file *, indp_t, indp_t *); | |
151 | static int buf_read_file(struct open_file *, char **, size_t *); | 204 | static int buf_read_file(struct open_file *, char **, size_t *); | |
152 | static int search_directory(const char *, int, struct open_file *, ino32_t *); | 205 | static int search_directory(const char *, int, struct open_file *, ino32_t *); | |
153 | static int read_sblock(struct open_file *, struct m_ext2fs *); | 206 | static int read_sblock(struct open_file *, struct m_ext2fs *); | |
154 | static int read_gdblock(struct open_file *, struct m_ext2fs *); | 207 | static int read_gdblock(struct open_file *, struct m_ext2fs *); | |
155 | #ifdef EXT2FS_DEBUG | 208 | #ifdef EXT2FS_DEBUG | |
156 | static void dump_sblock(struct m_ext2fs *); | 209 | static 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 | |||
861 | ext2fs_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 | } | |||
938 | out: | |||
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 | |
815 | void | 959 | void | |
816 | e2fs_sb_bswap(struct ext2fs *old, struct ext2fs *new) | 960 | e2fs_sb_bswap(struct ext2fs *old, struct ext2fs *new) | |
817 | { | 961 | { | |
818 | 962 |
--- 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 | |||
103 | null_seek(struct open_file *f, off_t offset, int where) | 103 | null_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 | |
111 | null_stat(struct open_file *f, struct stat *sb) | 111 | null_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 | |||
119 | null_ls(struct open_file *f, const char *pattern) | |||
120 | { | |||
121 | printf("Currently ls command is unsupported by nullfs\n"); | |||
122 | return; | |||
123 | } | |||
124 | #endif |
--- 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" |
--- 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" |
--- 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" |
--- 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 |
/* $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);
}
--- 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 | |||
661 | nfs_ls(struct open_file *f, const char *pattern) | |||
662 | { | |||
663 | printf("Currently ls command is unsupported by nfs\n"); | |||
664 | return; | |||
665 | } | |||
666 | #endif |
--- 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 | |||
88 | struct open_file; | 88 | struct 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 | */ | |
104 | extern char *fsmod; | 113 | extern char *fsmod; | |
105 | extern char *fsmod2; | 114 | extern char *fsmod2; | |
106 | 115 | |||
107 | #if !defined(LIBSA_SINGLE_FILESYSTEM) | 116 | #if !defined(LIBSA_SINGLE_FILESYSTEM) | |
108 | struct fs_ops { | 117 | struct 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 | |||
117 | extern struct fs_ops file_system[]; | 129 | extern struct fs_ops file_system[]; | |
118 | extern int nfsys; | 130 | extern 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 | |||
144 | FS_DEF(LIBSA_SINGLE_FILESYSTEM); | 173 | FS_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_ | |||
246 | void *memmove(void *, const void *, size_t); | 275 | void *memmove(void *, const void *, size_t); | |
247 | int memcmp(const void *, const void *, size_t); | 276 | int memcmp(const void *, const void *, size_t); | |
248 | void *memset(void *, int, size_t); | 277 | void *memset(void *, int, size_t); | |
249 | void exec(char *, char *, int); | 278 | void exec(char *, char *, int); | |
250 | int open(const char *, int); | 279 | int open(const char *, int); | |
251 | int close(int); | 280 | int close(int); | |
252 | void closeall(void); | 281 | void closeall(void); | |
253 | ssize_t read(int, void *, size_t); | 282 | ssize_t read(int, void *, size_t); | |
254 | ssize_t write(int, const void *, size_t); | 283 | ssize_t write(int, const void *, size_t); | |
255 | off_t lseek(int, off_t, int); | 284 | off_t lseek(int, off_t, int); | |
256 | int ioctl(int, u_long, char *); | 285 | int ioctl(int, u_long, char *); | |
257 | int stat(const char *, struct stat *); | 286 | int stat(const char *, struct stat *); | |
258 | int fstat(int, struct stat *); | 287 | int fstat(int, struct stat *); | |
288 | #if defined(LIBSA_ENABLE_LS_OP) | |||
289 | void ls(const char *); | |||
290 | #endif | |||
259 | 291 | |||
260 | typedef int cmp_t(const void *, const void *); | 292 | typedef int cmp_t(const void *, const void *); | |
261 | void qsort(void *, size_t, size_t, cmp_t *); | 293 | void qsort(void *, size_t, size_t, cmp_t *); | |
262 | 294 | |||
263 | extern int opterr, optind, optopt, optreset; | 295 | extern int opterr, optind, optopt, optreset; | |
264 | extern char *optarg; | 296 | extern char *optarg; | |
265 | int getopt(int, char * const *, const char *); | 297 | int getopt(int, char * const *, const char *); | |
266 | 298 | |||
267 | char *getpass(const char *); | 299 | char *getpass(const char *); | |
268 | int checkpasswd(void); | 300 | int checkpasswd(void); | |
269 | int check_password(const char *); | 301 | int check_password(const char *); | |
270 | 302 | |||
271 | int nodev(void); | 303 | int nodev(void); |
--- 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 | |||
419 | tftp_stat(struct open_file *f, struct stat *sb) | 419 | tftp_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 | |||
434 | tftp_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 | |
433 | tftp_seek(struct open_file *f, off_t offset, int where) | 442 | tftp_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; |
--- 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 | |||
543 | ustarfs_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 | |
542 | ustarfs_close(struct open_file *f) | 552 | ustarfs_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 */ |
--- 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 | |||
171 | static int read_inode(ino32_t, struct open_file *); | 171 | static int read_inode(ino32_t, struct open_file *); | |
172 | static int block_map(struct open_file *, indp_t, indp_t *); | 172 | static int block_map(struct open_file *, indp_t, indp_t *); | |
173 | static int buf_read_file(struct open_file *, char **, size_t *); | 173 | static int buf_read_file(struct open_file *, char **, size_t *); | |
174 | static int search_directory(const char *, int, struct open_file *, ino32_t *); | 174 | static int search_directory(const char *, int, struct open_file *, ino32_t *); | |
175 | #ifdef LIBSA_FFSv1 | 175 | #ifdef LIBSA_FFSv1 | |
176 | static void ffs_oldfscompat(struct fs *); | 176 | static void ffs_oldfscompat(struct fs *); | |
177 | #endif | 177 | #endif | |
178 | #ifdef LIBSA_FFSv2 | 178 | #ifdef LIBSA_FFSv2 | |
179 | static int ffs_find_superblock(struct open_file *, struct fs *); | 179 | static 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 | ||||
186 | typedef struct entry_t entry_t; | |||
187 | struct entry_t { | |||
188 | entry_t *e_next; | |||
189 | ino32_t e_ino; | |||
190 | uint8_t e_type; | |||
191 | char e_name[1]; | |||
192 | }; | |||
193 | ||||
194 | static 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 | ||||
212 | static int | |||
213 | fn_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 | */ | |
186 | static int | 246 | static int | |
187 | find_inode_sector(ino32_t inumber, struct open_file *f, daddr_t *isp) | 247 | find_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 | |||
842 | ufs_stat(struct open_file *f, struct stat *sb) | 902 | ufs_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 | |||
917 | ufs_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 | } | |||
989 | out: | |||
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 | */ | |
862 | static void | 1007 | static void | |
863 | ffs_oldfscompat(struct fs *fs) | 1008 | ffs_oldfscompat(struct fs *fs) | |
864 | { | 1009 | { | |
865 | 1010 | |||
866 | #ifdef COMPAT_UFS | 1011 | #ifdef COMPAT_UFS | |
867 | /* | 1012 | /* |
--- 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 | |||
34 | FS_DEF(ufs); | 34 | FS_DEF(ufs); | |
35 | FS_DEF(ffsv1); | 35 | FS_DEF(ffsv1); | |
36 | FS_DEF(ffsv2); | 36 | FS_DEF(ffsv2); | |
37 | ||||
38 | void ufs_ls(const char *); |