mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-21 18:30:20 +00:00
Add tools for ext2
This commit is contained in:
parent
18d598d5fa
commit
b1594201cb
@ -8,13 +8,14 @@ TOP=$(shell pwd)
|
||||
|
||||
PROGRAMS = emile-set-cmdline emile-first-tune emile-install \
|
||||
emile-set-output emile emile-map-set iso9660_ls \
|
||||
iso9660_cat minigzip read_vmlinuz emile-mkisofs
|
||||
iso9660_cat minigzip read_vmlinuz emile-mkisofs \
|
||||
ext2_ls ext2_cat
|
||||
|
||||
SOURCES = emile-set-cmdline.c Makefile emile-first-tune.c \
|
||||
emile-install.c emile-set-output.c emile.c \
|
||||
emile_scanbus.c emile-map-set.c iso9660_ls.c \
|
||||
iso9660_cat.c minigzip.c read_vmlinuz.c device.c gzio.c \
|
||||
emile-mkisofs.c emile_config.c
|
||||
emile-mkisofs.c emile_config.c ext2_ls.c ext2_cat.c
|
||||
|
||||
HEADERS = device.h emile_config.h
|
||||
|
||||
@ -23,10 +24,11 @@ DISTFILES =$(HEADERS) $(SOURCES) Makefile
|
||||
CPPFLAGS = $(CROSS_COMPILE_CPPFLAGS) -DSIGNATURE="\"$(SIGNATURE)\"" -DPREFIX=\"$(PREFIX)\" \
|
||||
-I../libemile -I../libiso9660 -I../libgzip -I../libstream \
|
||||
-I../libcontainer -I../libmacos -DFATFREE -DNO_GZCOMPRESS \
|
||||
-I../libconfig -I../libmap
|
||||
-I../libconfig -I../libmap -I../libext2
|
||||
|
||||
CFLAGS = -Wall -Werror -g
|
||||
LDLIBS = $(CROSS_COMPILE_LDFLAGS) -L../libemile -lemile -L../libiso9660/native -liso9660 -L../libgzip/native -lgzip -L../libconfig/native -lconfig -L../libmap/native -lmap
|
||||
LDLIBS = $(CROSS_COMPILE_LDFLAGS) -L../libemile -lemile -L../libiso9660/native -liso9660 -L../libgzip/native -lgzip -L../libconfig/native -lconfig -L../libmap/native -lmap \
|
||||
-L../libext2/native -lext2
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
@ -40,6 +42,10 @@ iso9660_ls: iso9660_ls.o device.o
|
||||
|
||||
iso9660_cat: iso9660_cat.o device.o
|
||||
|
||||
ext2_ls: ext2_ls.o device.o
|
||||
|
||||
ext2_cat: ext2_cat.o device.o
|
||||
|
||||
minigzip: minigzip.c gzio.c
|
||||
|
||||
read_vmlinuz: read_vmlinuz.o gzio.o
|
||||
|
69
tools/ext2_cat.c
Normal file
69
tools/ext2_cat.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include <libext2.h>
|
||||
#include <libstream.h>
|
||||
|
||||
#include "device.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *path;
|
||||
device_io_t device;
|
||||
ext2_FILE* file;
|
||||
ext2_VOLUME *volume;
|
||||
char buffer[512];
|
||||
ssize_t size;
|
||||
int arg = 1;
|
||||
char *devname;
|
||||
|
||||
if (argc <= arg)
|
||||
return 1;
|
||||
devname = argv[arg++];
|
||||
|
||||
if (argc > arg)
|
||||
path = argv[arg++];
|
||||
else
|
||||
path = "/";
|
||||
|
||||
device_sector_size = 512;
|
||||
device.data = (void*)device_open(devname, O_RDONLY);
|
||||
device.read_sector = (stream_read_sector_t)device_read_sector;
|
||||
device.close = (stream_close_t)device_close;
|
||||
device.get_blocksize = (stream_get_blocksize_t)device_get_blocksize;
|
||||
|
||||
volume = ext2_mount(&device);
|
||||
if (volume == NULL)
|
||||
return 1;
|
||||
|
||||
file = ext2_open(volume, path);
|
||||
if (file == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s not found\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while((size = ext2_read(file, buffer, 512)) > 0)
|
||||
write(STDOUT_FILENO, buffer, size);
|
||||
ext2_close(file);
|
||||
|
||||
ext2_umount(volume);
|
||||
|
||||
device_close(device.data);
|
||||
|
||||
return 0;
|
||||
}
|
73
tools/ext2_ls.c
Normal file
73
tools/ext2_ls.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include <libext2.h>
|
||||
|
||||
#include "device.h"
|
||||
|
||||
static void list(ext2_VOLUME *volume, char *path)
|
||||
{
|
||||
ext2_DIR *dir;
|
||||
struct ext2_dir_entry_2 *entry;
|
||||
|
||||
dir = ext2_opendir(volume, path);
|
||||
if (dir == NULL)
|
||||
return;
|
||||
while ((entry = ext2_readdir(dir)) != NULL)
|
||||
{
|
||||
if (entry->file_type == EXT2_FT_DIR)
|
||||
printf("%s/\n", entry->name);
|
||||
else
|
||||
printf("%s\n", entry->name);
|
||||
}
|
||||
ext2_closedir(dir);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *path;
|
||||
device_io_t device;
|
||||
ext2_VOLUME *volume;
|
||||
int arg = 1;
|
||||
|
||||
device_sector_size = 512;
|
||||
if (argc <= 1) {
|
||||
fprintf(stderr, "You must specify a device to open\n");
|
||||
exit(1);
|
||||
}
|
||||
device.data = (void*)device_open(argv[arg++], O_RDONLY);
|
||||
device.read_sector = (stream_read_sector_t)device_read_sector;
|
||||
device.close = (stream_close_t)device_close;
|
||||
device.get_blocksize = (stream_get_blocksize_t)device_get_blocksize;
|
||||
|
||||
volume = ext2_mount(&device);
|
||||
if (volume == NULL)
|
||||
return -1;
|
||||
|
||||
if (argc > arg)
|
||||
path = argv[arg];
|
||||
else
|
||||
path = "/";
|
||||
|
||||
list(volume, path);
|
||||
|
||||
ext2_umount(volume);
|
||||
|
||||
device_close(device.data);
|
||||
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user