Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Apply the following patch submitted by Evgeniy Ivanov:



details:   https://anonhg.NetBSD.org/src/rev/46044ac625f9
branches:  trunk
changeset: 772228:46044ac625f9
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Dec 25 06:09:08 2011 +0000

description:
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

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

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

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

diffstat:

 sys/arch/ews4800mips/stand/boot/Makefile     |    5 +-
 sys/arch/ews4800mips/stand/common/devopen.c  |   10 +-
 sys/arch/ews4800mips/stand/common/diskutil.c |    8 +-
 sys/arch/i386/stand/boot/Makefile.boot       |    4 +-
 sys/arch/i386/stand/boot/boot2.c             |    4 +-
 sys/arch/i386/stand/dosboot/Makefile         |    5 +-
 sys/arch/i386/stand/dosboot/main.c           |    8 +-
 sys/arch/i386/stand/libsa/nfs.c              |   11 +-
 sys/arch/landisk/stand/boot/Makefile.boot    |    4 +-
 sys/arch/landisk/stand/boot/boot2.c          |    4 +-
 sys/arch/x68k/stand/boot/Makefile            |    3 +-
 sys/arch/x68k/stand/boot/boot.c              |   10 +-
 sys/arch/x68k/stand/libsa/Makefile           |    5 +-
 sys/arch/zaurus/stand/zboot/Makefile         |    5 +-
 sys/arch/zaurus/stand/zboot/boot.c           |    4 +-
 sys/lib/libsa/Makefile                       |    8 +-
 sys/lib/libsa/cd9660.c                       |   11 +-
 sys/lib/libsa/dosfs.c                        |   11 +-
 sys/lib/libsa/ext2fs.c                       |  146 ++++++++++++++++-
 sys/lib/libsa/ffsv1.c                        |    5 +-
 sys/lib/libsa/ffsv2.c                        |    5 +-
 sys/lib/libsa/lfsv1.c                        |    5 +-
 sys/lib/libsa/lfsv2.c                        |    5 +-
 sys/lib/libsa/ls.c                           |  161 ++++++++++++++++++
 sys/lib/libsa/nfs.c                          |   11 +-
 sys/lib/libsa/nullfs.c                       |   11 +-
 sys/lib/libsa/stand.h                        |   36 +++-
 sys/lib/libsa/tftp.c                         |   11 +-
 sys/lib/libsa/ufs.c                          |  147 +++++++++++++++++-
 sys/lib/libsa/ufs.h                          |    4 +-
 sys/lib/libsa/ufs_ls.c                       |  231 ---------------------------
 sys/lib/libsa/ustarfs.c                      |   12 +-
 32 files changed, 619 insertions(+), 291 deletions(-)

diffs (truncated from 1456 to 300 lines):

diff -r 95404f116f1d -r 46044ac625f9 sys/arch/ews4800mips/stand/boot/Makefile
--- a/sys/arch/ews4800mips/stand/boot/Makefile  Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/ews4800mips/stand/boot/Makefile  Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.14 2011/07/10 23:35:12 matt Exp $
+#      $NetBSD: Makefile,v 1.15 2011/12/25 06:09:08 tsutsui Exp $
 
 WARNS          ?= 1
 NOMAN          =
@@ -89,7 +89,8 @@
 .include "${S}/lib/libz/Makefile.inc"
 LIBZ=          ${ZLIB}
 
-SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes
+CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
+SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_USE_LOADFILE=yes SA_ENABLE_LS_OP=yes
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=         ${SALIB}
 
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/ews4800mips/stand/common/devopen.c
--- a/sys/arch/ews4800mips/stand/common/devopen.c       Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/ews4800mips/stand/common/devopen.c       Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.4 2008/04/28 20:23:18 martin Exp $       */
+/*     $NetBSD: devopen.c,v 1.5 2011/12/25 06:09:09 tsutsui Exp $      */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -46,12 +46,8 @@
 
 extern struct fs_ops datafs_ops;
 extern struct fs_ops bfs_ops;
-struct fs_ops ufs_ops = {
-       ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat
-};
-struct fs_ops nfs_ops = {
-       nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat
-};
+struct fs_ops ufs_ops = FS_OPS(ufs);
+struct fs_ops nfs_ops = FS_OPS(nfs);
 
 extern struct devsw netdevsw;
 extern struct devsw dkdevsw;
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/ews4800mips/stand/common/diskutil.c
--- a/sys/arch/ews4800mips/stand/common/diskutil.c      Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/ews4800mips/stand/common/diskutil.c      Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: diskutil.c,v 1.4 2008/04/28 20:23:18 martin Exp $      */
+/*     $NetBSD: diskutil.c,v 1.5 2011/12/25 06:09:09 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -85,14 +85,12 @@
        if (!device_attach(-1, -1, i))
                return 1;
        switch (fstype(i)) {
-       case FSTYPE_UFS:
-               ufs_ls("/");
-               break;
        case FSTYPE_BFS:
                bfs_ls();
                break;
        default:
-               return 1;
+               ls("/");
+               break;
        }
 
        return 0;
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/i386/stand/boot/Makefile.boot
--- a/sys/arch/i386/stand/boot/Makefile.boot    Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/i386/stand/boot/Makefile.boot    Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.boot,v 1.55 2011/08/22 09:43:08 mrg Exp $
+# $NetBSD: Makefile.boot,v 1.56 2011/12/25 06:09:09 tsutsui Exp $
 
 S=     ${.CURDIR}/../../../../..
 
@@ -76,6 +76,7 @@
 CPPFLAGS+= -DEPIA_HACK
 #CPPFLAGS+= -DDEBUG_MEMSIZE
 #CPPFLAGS+= -DBOOT_MSG_COM0
+CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
 # The biosboot code is linked to 'virtual' address of zero and is
 # loaded at physical address 0x10000.
@@ -113,6 +114,7 @@
 ### find out what to use for libsa
 SA_AS= library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA= ${SALIB}
 
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c  Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c  Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot2.c,v 1.56 2011/11/28 07:56:54 tls Exp $   */
+/*     $NetBSD: boot2.c,v 1.57 2011/12/25 06:09:09 tsutsui Exp $       */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -409,7 +409,7 @@
        const char *save = default_filename;
 
        default_filename = "/";
-       ufs_ls(arg);
+       ls(arg);
        default_filename = save;
 }
 
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/i386/stand/dosboot/Makefile
--- a/sys/arch/i386/stand/dosboot/Makefile      Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/i386/stand/dosboot/Makefile      Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.26 2011/05/20 22:29:55 joerg Exp $
+#      $NetBSD: Makefile,v 1.27 2011/12/25 06:09:09 tsutsui Exp $
 
 S=     ${.CURDIR}/../../../..
 
@@ -17,6 +17,7 @@
 CPPFLAGS+= -DSLOW      # for libz
 CPPFLAGS+= -DCOMPAT_386BSD_MBRPART
 CPPFLAGS+= -DXMS
+CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 #uncomment if there are problems with memory detection
 #CPPFLAGS+= -DCONSERVATIVE_MEMDETECT
 
@@ -30,7 +31,7 @@
 # XXX these should depend on the size of the image
 CPPFLAGS+= -DSTACK_START=0x10000
 SAMISCCPPFLAGS+= -DHEAP_START=0x20000 -DHEAP_LIMIT=0x50000
-SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no
+SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no SA_ENABLE_LS_OP=yes
 I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes
 
 VERSIONFILE= ${.CURDIR}/version
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/i386/stand/dosboot/main.c
--- a/sys/arch/i386/stand/dosboot/main.c        Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/i386/stand/dosboot/main.c        Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.30 2010/12/20 01:12:44 jakllsch Exp $        */
+/*     $NetBSD: main.c,v 1.31 2011/12/25 06:09:09 tsutsui Exp $         */
 
 /*
  * Copyright (c) 1996, 1997
@@ -323,12 +323,8 @@
 command_ls(char *arg)
 {
        char *help = default_filename;
-       if (strcmp(current_fsmode, "ufs")) {
-               printf("UFS only\n");
-               return;
-       }
        default_filename = "/";
-       ufs_ls(arg);
+       ls(arg);
        default_filename = help;
 }
 
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/i386/stand/libsa/nfs.c
--- a/sys/arch/i386/stand/libsa/nfs.c   Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/i386/stand/libsa/nfs.c   Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs.c,v 1.18 2011/06/16 13:27:59 joerg Exp $   */
+/*     $NetBSD: nfs.c,v 1.19 2011/12/25 06:09:09 tsutsui Exp $ */
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -630,3 +630,12 @@
 
        return (0);
 }
+
+#if defined(LIBSA_ENABLE_LS_OP)
+__compactcall void
+nfs_ls(struct open_file *f, const char *pattern)
+{
+       printf("Currently ls command is unsupported by nfs\n");
+       return;
+}
+#endif
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/landisk/stand/boot/Makefile.boot
--- a/sys/arch/landisk/stand/boot/Makefile.boot Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/landisk/stand/boot/Makefile.boot Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.boot,v 1.4 2011/01/22 19:19:19 joerg Exp $
+# $NetBSD: Makefile.boot,v 1.5 2011/12/25 06:09:09 tsutsui Exp $
 
 PROG?=         boot
 
@@ -22,10 +22,12 @@
 CPPFLAGS+=     -DSUPPORT_DOSFS
 CPPFLAGS+=     -DSUPPORT_USTARFS
 CPPFLAGS+=     -DDBMONITOR
+CPPFLAGS+=     -DLIBSA_ENABLE_LS_OP
 #CPPFLAGS+=    -DDEBUG
 
 SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
 
 .include "../Makefile.bootprogs"
 
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/landisk/stand/boot/boot2.c
--- a/sys/arch/landisk/stand/boot/boot2.c       Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/landisk/stand/boot/boot2.c       Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot2.c,v 1.2 2011/01/22 19:19:19 joerg Exp $  */
+/*     $NetBSD: boot2.c,v 1.3 2011/12/25 06:09:09 tsutsui Exp $        */
 
 /*
  * Copyright (c) 2003
@@ -329,7 +329,7 @@
        const char *save = default_filename;
 
        default_filename = "/";
-       ufs_ls(arg);
+       ls(arg);
        default_filename = save;
 }
 
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/x68k/stand/boot/Makefile
--- a/sys/arch/x68k/stand/boot/Makefile Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/x68k/stand/boot/Makefile Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.20 2011/04/12 14:07:35 tsutsui Exp $
+#      $NetBSD: Makefile,v 1.21 2011/12/25 06:09:09 tsutsui Exp $
 
 NOMAN=         # defined
 
@@ -40,6 +40,7 @@
 CPPFLAGS+=     -D_STANDALONE -DHEAP_VARIABLE
 CPPFLAGS+=     -DTEXTADDR="0x${TEXT}" 
 CPPFLAGS+=     -DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\"
+CPPFLAGS+=     -DLIBSA_ENABLE_LS_OP
 CFLAGS=                -Wno-main -Os -m68020-60
 LINKFLAGS=     -N -static -T ${.CURDIR}/boot.ldscript
 LIBIOCS!=      cd $M/stand/libiocs && ${PRINTOBJDIR}
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/x68k/stand/boot/boot.c
--- a/sys/arch/x68k/stand/boot/boot.c   Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/x68k/stand/boot/boot.c   Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.16 2011/01/22 19:19:24 joerg Exp $  */
+/*     $NetBSD: boot.c,v 1.17 2011/12/25 06:09:09 tsutsui Exp $        */
 
 /*
  * Copyright (c) 2001 Minoura Makoto
@@ -53,7 +53,7 @@
 static int get_scsi_host_adapter(void);
 static void doboot(const char *, int);
 static void boot(char *);
-static void ls(char *);
+static void cmd_ls(char *);
 int bootmenu(void);
 void bootmain(int);
 extern int detectmpu(void);
@@ -201,7 +201,7 @@
 }
 
 static void
-ls(char *arg)
+cmd_ls(char *arg)
 {
        char filename[80];
 
@@ -217,7 +217,7 @@
                if (*(strchr(arg, ':')+1) == 0)
                        strcat(filename, "/");
        }
-       ufs_ls(filename);
+       ls(filename);
        devopen_open_dir = 0;
 }
 
@@ -266,7 +266,7 @@
                else if ((strcmp("halt", p) == 0) ||(strcmp("reboot", p) == 0))
                        exit(0);
                else if (strcmp("ls", p) == 0)
-                       ls(options);
+                       cmd_ls(options);
                else
                        printf("Unknown command %s\n", p);
        }
diff -r 95404f116f1d -r 46044ac625f9 sys/arch/x68k/stand/libsa/Makefile
--- a/sys/arch/x68k/stand/libsa/Makefile        Sun Dec 25 02:23:09 2011 +0000
+++ b/sys/arch/x68k/stand/libsa/Makefile        Sun Dec 25 06:09:08 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.27 2011/10/11 13:07:06 tsutsui Exp $
+#      $NetBSD: Makefile,v 1.28 2011/12/25 06:09:09 tsutsui Exp $
 
 S=             ${.CURDIR}/../../../..
 
@@ -10,6 +10,7 @@
 CPPFLAGS+=     -DHEAP_VARIABLE
 CPPFLAGS+=     -DHAVE_CHANGEDISK_HOOK
 CPPFLAGS+=     -DUSTAR_SECT_PER_CYL=16
+CPPFLAGS+=     -DLIBSA_ENABLE_LS_OP
 #CPPFLAGS+=    -DDEBUG



Home | Main Index | Thread Index | Old Index