Ram Yalamanchili
2007-Apr-18 08:38 UTC
[syslinux] [Patch]: Drive/Partition and extensible filesystem support for syslinux
Here is the patch for making syslinux enable opening partitions with fat filesystems (well, the architecture is in place to make it open other filesystems too). Usage is like this: #include <syslinux/io.h> #include <syslinux/partitions.h> #include <fs/fat/libfat.h> syslinux_devdesc dfd; struct libfat_filesystem* fs; diskinfo disk_info; char mbr[512]; static part_entry *partition; int fd; syslinux_get_disk_params(drive, &disk_info); // specify your drive number syslinux_read_disk(&disk_info, mbr, 0, 1); // Read mbr partition = PARTITION_ENTRY(mbr, 2); // 2 for partition 2 // this is the disk device/partition descriptor dfd.disk_info = &disk_info; dfd.partition = partition; // try opening libfat partition on the given partition descriptor fs = libfat_open(syslinux_fs_partition_read_handle, (intptr_t) &dfd); fd = fs->ops.open(fs, "MYFILE CFG", O_RDONLY); // This will give you a open descriptor // Now on, you can read files just like any other *nix file...! :) read(fd, mybuf, 128); // read 128 bytes from file.. OR you can use zlib funtionality of syslinux with: gzFile gzf = gzdopen(fd, "r"); gzread(gzf, mybuffer, 128); etc... //After you are done, you can close the descriptor with close(fd); // FS can be closed with libfat_close(fs); One thing which is missing is the way you specify file names for open. It is the short name format of DOS. Would appreciate if someone can add long file name search for libfat. thanks. -- Ram -------------- next part -------------- A non-text attachment was scrubbed... Name: drive_partition_fs_syslinux_patch Type: application/octet-stream Size: 43340 bytes Desc: not available URL: <http://www.zytor.com/pipermail/syslinux/attachments/20070418/d4b26280/attachment.obj>
Ram Yalamanchili
2007-Apr-18 08:46 UTC
[syslinux] [Patch]: Drive/Partition and extensible filesystem support for syslinux
Forgot two things: 1) the patch file's extension is missing 2) The diffs are made against the following tarball: http://www.kernel.org/pub/linux/utils/boot/syslinux/Testing/syslinux-3.50-pre5.tar.bz2 I'm attaching the same patch file with a .patch extension. -- Ram On 4/18/07, Ram Yalamanchili <ramyinc at gmail.com> wrote:> Here is the patch for making syslinux enable opening partitions with > fat filesystems (well, the architecture is in place to make it open > other filesystems too). > > Usage is like this: > > #include <syslinux/io.h> > #include <syslinux/partitions.h> > #include <fs/fat/libfat.h> > > syslinux_devdesc dfd; > struct libfat_filesystem* fs; > diskinfo disk_info; > char mbr[512]; > static part_entry *partition; > int fd; > > syslinux_get_disk_params(drive, &disk_info); // specify your drive number > syslinux_read_disk(&disk_info, mbr, 0, 1); // Read mbr > partition = PARTITION_ENTRY(mbr, 2); // 2 for partition 2 > > // this is the disk device/partition descriptor > dfd.disk_info = &disk_info; > dfd.partition = partition; > > // try opening libfat partition on the given partition descriptor > fs = libfat_open(syslinux_fs_partition_read_handle, (intptr_t) &dfd); > fd = fs->ops.open(fs, "MYFILE CFG", O_RDONLY); > // This will give you a open descriptor > > // Now on, you can read files just like any other *nix file...! :) > read(fd, mybuf, 128); // read 128 bytes from file.. > > OR > > you can use zlib funtionality of syslinux with: > > gzFile gzf = gzdopen(fd, "r"); > gzread(gzf, mybuffer, 128); > etc... > > //After you are done, you can close the descriptor with > close(fd); > > // FS can be closed with > libfat_close(fs); > > > > One thing which is missing is the way you specify file names for open. > It is the short name format of DOS. Would appreciate if someone can > add long file name search for libfat. > > thanks. > > -- > Ram > >-------------- next part -------------- A non-text attachment was scrubbed... Name: drive_partition_fs_syslinux.patch Type: text/x-patch Size: 43340 bytes Desc: not available URL: <http://www.zytor.com/pipermail/syslinux/attachments/20070418/2798ef44/attachment.bin>
Andrew Goodbody
2007-Apr-19 12:25 UTC
[syslinux] [Patch]: Drive/Partition and extensible filesystem support for syslinux
Ram Yalamanchili wrote:> Here is the patch for making syslinux enable opening partitions with > fat filesystems (well, the architecture is in place to make it open > other filesystems too).Thanks, this is great. I have just been put onto another task for a while but I got as far as opening a file on the hdd from a syslinux booted on a floppy partition which should be most of the battle. I hope to be able to let you know if it works for me when I get back to it later. Andrew
Seemingly Similar Threads
- Patch: Add io.c functions, and vfat library
- [PATCH] git tree: libfat, chain, mtools/syslinux, menu.txt
- [PATCH 2/2] com32/disk: Improve flow at disk_write_sectors and disk_read_sectors.
- [PATCH 2/2 v2] com32/disk: Improve flow at disk_write_sectors and disk_read_sectors.
- [PATCH 1/2] com32/lib/: Avoid unneeded allocation.