2005-11-13 19:43:28 +00:00
|
|
|
/*
|
|
|
|
*
|
2013-09-05 12:39:22 +00:00
|
|
|
* (c) 2005 Laurent Vivier <Laurent@Vivier.EU>
|
2005-11-13 19:43:28 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-11-12 22:28:50 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
2007-10-09 19:21:14 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2005-11-12 22:28:50 +00:00
|
|
|
|
|
|
|
#include <libiso9660.h>
|
|
|
|
|
2005-11-13 19:43:28 +00:00
|
|
|
#include "device.h"
|
|
|
|
|
2008-04-20 16:35:55 +00:00
|
|
|
static void list(stream_VOLUME *volume, char *path)
|
2005-11-12 22:28:50 +00:00
|
|
|
{
|
|
|
|
char name_buf[256];
|
2008-04-20 16:35:55 +00:00
|
|
|
stream_DIR *dir;
|
2005-11-12 22:28:50 +00:00
|
|
|
struct iso_directory_record *idr;
|
|
|
|
|
2005-11-21 22:07:17 +00:00
|
|
|
dir = iso9660_opendir(volume, path);
|
2005-11-12 22:28:50 +00:00
|
|
|
if (dir == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((idr = iso9660_readdir(dir)) != NULL)
|
|
|
|
{
|
2008-04-20 16:35:55 +00:00
|
|
|
iso9660_name(volume, idr, name_buf);
|
2005-11-12 22:28:50 +00:00
|
|
|
|
|
|
|
if (iso9660_is_directory(idr)) {
|
|
|
|
printf("%s/\n", name_buf);
|
|
|
|
} else {
|
|
|
|
printf("%s\n", name_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iso9660_closedir(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
char *path;
|
2005-11-21 22:07:17 +00:00
|
|
|
device_io_t device;
|
2008-04-20 16:35:55 +00:00
|
|
|
stream_VOLUME *volume;
|
2006-09-08 22:57:36 +00:00
|
|
|
int arg = 1;
|
2005-11-12 22:28:50 +00:00
|
|
|
|
2007-10-09 19:21:14 +00:00
|
|
|
device_sector_size = 2048;
|
2006-09-08 22:57:36 +00:00
|
|
|
if (argc > 1)
|
2007-10-09 19:21:14 +00:00
|
|
|
device.data = (void*)device_open(argv[arg++], O_RDONLY);
|
2006-09-08 22:57:36 +00:00
|
|
|
else
|
2007-10-09 19:21:14 +00:00
|
|
|
device.data = (void*)device_open("/dev/cdrom", O_RDONLY);
|
2005-11-21 22:07:17 +00:00
|
|
|
device.read_sector = (stream_read_sector_t)device_read_sector;
|
|
|
|
device.close = (stream_close_t)device_close;
|
2007-10-10 16:47:03 +00:00
|
|
|
device.get_blocksize = (stream_get_blocksize_t)device_get_blocksize;
|
2005-11-13 19:43:28 +00:00
|
|
|
|
2005-11-21 22:07:17 +00:00
|
|
|
volume = iso9660_mount(&device);
|
|
|
|
if (volume == NULL)
|
2005-11-12 22:28:50 +00:00
|
|
|
return -1;
|
|
|
|
|
2006-09-08 22:57:36 +00:00
|
|
|
if (argc > arg)
|
|
|
|
path = argv[arg];
|
2005-11-12 22:28:50 +00:00
|
|
|
else
|
|
|
|
path = "/";
|
|
|
|
|
2005-11-21 22:07:17 +00:00
|
|
|
list(volume, path);
|
2005-11-12 22:28:50 +00:00
|
|
|
|
2005-11-21 22:07:17 +00:00
|
|
|
iso9660_umount(volume);
|
2005-11-12 22:28:50 +00:00
|
|
|
|
2005-11-21 22:07:17 +00:00
|
|
|
device_close(device.data);
|
2005-11-13 19:43:28 +00:00
|
|
|
|
2005-11-12 22:28:50 +00:00
|
|
|
return (0);
|
|
|
|
}
|