Subject: port-i386/1133: listing files with i386 bootblocks
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: Luke Mewburn <lukem@dodo.melb.cpr.itg.telecom.com.au>
List: netbsd-bugs
Date: 06/19/1995 22:50:17
>Number: 1133
>Category: port-i386
>Synopsis: listing files with i386 bootblocks (a la FreeBSD)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Jun 19 22:50:15 1995
>Originator: Luke Mewburn
>Organization:
" Telstra"
>Release: 1.0
>Environment:
System: NetBSD dodo 1.0 NetBSD 1.0 (DODO) #7: Fri Dec 16 17:01:27 EST 1994 simonb@dodo:/slab/0/src/sys/arch/i386/compile/DODO i386
>Description:
The bootblocks in FreeBSD 2.0.x have an option to list the
files on the given partition if you supply a name of '?'
I hacked this functionality into the NetBSD bootblocks.
I think my code is slightly cleaner that the FreeBSD stuff,
and it also puts suffixes like '/' and '@' a-la 'ls -F'...
I hope this gets put in, because often I can't remember the
name of an old kernel (I keep a lot around :), and this helps
me remember.
>How-To-Repeat:
>Fix:
Apply this patch. Install the new boot blocks.
And have fun!
(PS: It even works with a syntax like: sd(0,e)? which, in
my case, lists the rootdir of /var :)
--- cut here --- file: src/patches/boot.listfiles
--- boot.c.orig Mon Mar 20 17:36:50 1995
+++ boot.c Thu Jun 15 17:52:56 1995
@@ -78,6 +78,7 @@
printf("\n"
">> NetBSD BOOT: %d/%d k [%s]\n"
+ "use ? for file list, or carriage return for defaults\n"
"use hd(1,a)/netbsd to boot sd0 when wd0 is also installed\n",
argv[7] = memsize(0),
argv[8] = memsize(1),
@@ -95,14 +96,20 @@
name = names[currname++];
loadflags = 0;
- if (currname == NUMNAMES)
- currname = 0;
getbootdev(&loadflags);
- if (openrd()) {
+ switch(openrd()) {
+ case 0:
+ loadprog(loadflags);
+ break;
+ case -1:
+ currname--;
+ break;
+ default:
printf("Can't find %s\n", name);
- goto loadstart;
+ break;
}
- loadprog(loadflags);
+ if (currname == NUMNAMES)
+ currname = 0;
goto loadstart;
}
--- sys.c.orig Mon Mar 20 17:36:52 1995
+++ sys.c Thu Jun 15 17:36:32 1995
@@ -85,6 +85,10 @@
int block, off, loc, ino = ROOTINO, parent;
struct dirent *dp;
int nlinks = 0;
+ int list_only = 0;
+
+ if (strcmp(path, "?") == 0)
+ list_only = 1;
loop:
iodest = iobuf;
@@ -127,7 +131,11 @@
loc = 0;
do {
if (loc >= inode.i_size)
- return 0;
+ if (list_only) {
+ putchar('\n');
+ return -1;
+ } else
+ return 0;
if (!(off = blkoff(fs, loc))) {
int cnt2;
block = lblkno(fs, loc);
@@ -143,6 +151,20 @@
return 0;
}
loc += dp->d_reclen;
+ if (dp->d_fileno && list_only && dp->d_type != DT_WHT) {
+ printf("%s", dp->d_name);
+ switch(dp->d_type) {
+ case DT_DIR:
+ putchar('/');
+ break;
+ case DT_LNK:
+ putchar('@');
+ break;
+ default:
+ break;
+ }
+ putchar(' ');
+ }
} while (!dp->d_fileno || strcmp(path, dp->d_name));
ino = dp->d_fileno;
*(path = rest) = ch;
@@ -240,9 +262,12 @@
/***********************************************\
* Find the actual FILE on the mounted device *
\***********************************************/
- if (!find(cp))
+ switch(find(cp)) {
+ case -1:
+ return -1;
+ case 0:
return 1;
-
+ }
poff = 0;
name = cp;
return 0;
--- version.c.orig Mon Mar 20 17:36:53 1995
+++ version.c Thu Jun 15 17:37:52 1995
@@ -3,6 +3,9 @@
/*
* NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.
*
+ * 1.27 -> 1.28
+ * implement 'list files' (Luke Mewburn <lukem@telstra.com.au>)
+ *
* 1.26 -> 1.27
* size reduction and code cleanup. (mycroft)
*
@@ -49,4 +52,4 @@
* look in boot.c revision logs
*/
-char *version = "1.27";
+char *version = "1.28";
--- cut here ---
>Audit-Trail:
>Unformatted: