summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2022-08-02 20:12:43 +0200
committerHelge Deller <deller@gmx.de>2022-08-02 20:17:27 +0200
commit01d9d5c44194976517589d2af6eb0434e4ca65dc (patch)
treea14da0e1ffad2feb7028b967cd21e4b7265ff6bd
parent4396b7cb82a35cb0c31df6dc00b1ef62e6b7d900 (diff)
downloadpalo-01d9d5c44194976517589d2af6eb0434e4ca65dc.tar.gz
ipl: Enhance "list partition" menu entry option
When listing the files of a directory, append "/" to directory entries and append "@" to files which symlink other files. In addition it's now possible to enter "l 2/." to list entries of the root directory of the filesystem in partition #2. Listing entries depends that the filesystem is inside the first 2GB of the disk. Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r--ipl/bootloader.h4
-rw-r--r--ipl/ext2.c6
-rw-r--r--ipl/ipl.c28
3 files changed, 25 insertions, 13 deletions
diff --git a/ipl/bootloader.h b/ipl/bootloader.h
index bbb6807..e954984 100644
--- a/ipl/bootloader.h
+++ b/ipl/bootloader.h
@@ -50,7 +50,9 @@ void describe(int fd, int *bufalign, int *blocksize);
int ext2_mount(long cons_dev, long p_offset, long quiet);
int ext2_open(const char *filename);
int ext2_filesize(int fd);
-const char * ext2_readdir(int fd, int rewind);
+const char * ext2_readdir(int fd, int rewind, unsigned char *file_type);
+#define EXT2_FT_DIR 2
+#define EXT2_FT_SYMLINK 7
void ext2_close(int fd);
/* lib.c */
diff --git a/ipl/ext2.c b/ipl/ext2.c
index 1b77c2d..9b46a37 100644
--- a/ipl/ext2.c
+++ b/ipl/ext2.c
@@ -862,10 +862,12 @@ static struct ext2_inode *ext2_namei(const char *name)
* Note: don't mix any kind of file lookup or other I/O with this or
* you will lose horribly (as it reuses blkbuf)
*/
-const char * ext2_readdir(int fd, int rewind)
+const char * ext2_readdir(int fd, int rewind, unsigned char *file_type)
{
struct ext2_inode * ip = fd2inode[fd];
struct ext2_dir_entry_2 * ent;
+ if (file_type)
+ *file_type = 0;
if (!S_ISDIR(ip->i_mode)) {
printf("fd %d (inode %d) is not a directory (mode %x)\n",
fd, inode_table[fd].inumber, ip->i_mode);
@@ -874,6 +876,8 @@ const char * ext2_readdir(int fd, int rewind)
ent = ext2_readdiri(ip, rewind);
if (ent) {
ent->name[ent->name_len] = '\0';
+ if (file_type)
+ *file_type = ent->file_type;
return ent->name;
} else {
return NULL;
diff --git a/ipl/ipl.c b/ipl/ipl.c
index da19572..ab8b8ee 100644
--- a/ipl/ipl.c
+++ b/ipl/ipl.c
@@ -310,6 +310,7 @@ ls(char *path)
char *p, kern_dir[256];
const char *dir;
int fd, part, part_fd;
+ unsigned char file_type;
parse_pfname(path, &part, kern_dir);
if ((p = strrchr(kern_dir, '/')) != NULL)
@@ -322,7 +323,7 @@ ls(char *path)
strcpy(kern_dir, "/.");
}
- printf("Directory listing of %s\n\n", kern_dir);
+ printf("Directory listing of %d%s\n\n", part, kern_dir);
partition_transform(&part, NULL);
@@ -339,9 +340,11 @@ ls(char *path)
return;
}
- while((dir = ext2_readdir(fd, 0)) != NULL)
+ while((dir = ext2_readdir(fd, 0, &file_type)) != NULL)
if(dir[0] != '.') /* skip hidden files and . and .. */
- printf(" %s\n", dir);
+ printf(" %s%s\n", dir,
+ file_type == EXT2_FT_SYMLINK ? "@" :
+ file_type == EXT2_FT_DIR ? "/" : "");
printf("\n");
ext2_close(fd);
@@ -356,7 +359,7 @@ interact(int *ok)
char *argv[MAX_ARGV], *p;
char orig[CMDLINELEN];
const char sep[] = " \t";
- char numbuf[4];
+ char numbuf[32];
char fieldbuf[200];
int i, argc, editfield;
@@ -390,13 +393,13 @@ interact(int *ok)
printf("%2d: %s\n", i, argv[i]);
}
printf("\n"
- "<#> edit the numbered field\n"
- "'b' boot with this command line\n"
- "'r' restore command line\n"
- "'l' list dir\n"
- "'x' reset and reboot machine\n"
+ "<#> edit the numbered field\n"
+ "'b' boot with this command line\n"
+ "'r' restore command line\n"
+ "'l <#/path> list dir from numbered partition with path\n"
+ "'x' reset and reboot machine\n"
#ifdef HIDDEN_COMMAND
- "'d' toggle debug mode\n"
+ "'d' toggle debug mode\n"
#endif
"? ");
numbuf[0] = '0';
@@ -419,7 +422,10 @@ interact(int *ok)
if (numbuf[0] == 'l')
{
join(commandline, argc, argv, ok);
- ls(argv[0]);
+ if (numbuf[1] == ' ')
+ ls(&numbuf[2]);
+ else
+ ls(argv[0]);
continue;
}