summaryrefslogtreecommitdiff
path: root/core/fs/fs.c
Commit message (Collapse)AuthorAgeFilesLines
* fix a few typosJonathan Boeing2015-05-031-1/+1
| | | | Signed-off-by: Jonathan Boeing <jonathan.n.boeing@gmail.com>
* core: Avoid initializing the cache more than onceRaphael S. Carvalho2014-04-031-2/+3
| | | | | | | | | | Most of file system drivers initialize the cache themselves. The problem is that the same cache could be again initialized later, then invalidating the previous one. This patch fixes this. Problem found while auditing the code. Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
* Add filesystem UUID to SYSAPPEND for FATSerj Kalichev2014-03-131-0/+12
| | | | | | | | | | Filesystem UUID shows the partition we boot kernel from. The kernel parameter has format like FSUUID=DA1A-0B2E. The SYSAPPEND bit is 0x40000. Now the FAT only supports FSUUID. The patch is based on 67aaaeeb228. Signed-off-by: Serj Kalichev <serj.kalichev@gmail.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Merge tag 'syslinux-5.11-pre2' into firmwareMatt Fleming2013-06-171-2/+0
|\ | | | | | | | | | | | | | | syslinux-5.11-pre2 Conflicts: core/elflink/load_env32.c version
| * PATH: use a linked list internallysyslinux-5.11-pre1Matt Fleming2013-06-131-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In retrospect, choosing the colon character as the entry separator for the PATH directive was not a smart move, as that character is also used in TFTP-style paths. This conflict manifests as PXELINUX being unable to find and load files. An example dnsmasq log looks like, dnsmasq-tftp: sent /arch/boot/syslinux/lpxelinux.0 to 192.168.0.90 dnsmasq-tftp: file /arch/ldlinux.c32 not found dnsmasq-tftp: file /arch//ldlinux.c32 not found dnsmasq-tftp: file /arch//boot/isolinux/ldlinux.c32 not found dnsmasq-tftp: file /arch//isolinux/ldlinux.c32 not found dnsmasq-tftp: file /arch//boot/syslinuxldlinux.c32 not found dnsmasq-tftp: sent /arch//boot/syslinux/ldlinux.c32 to 192.168.0.90 dnsmasq-tftp: error 0 No error, file close received from 192.168.0.90 dnsmasq-tftp: failed sending /arch//boot/syslinux/ldlinux.c32 to 192.168.0.90 dnsmasq-tftp: sent /arch/boot/syslinux/archiso.cfg to 192.168.0.90 dnsmasq-tftp: sent /arch/boot/syslinux/whichsys.c32 to 192.168.0.90 dnsmasq-tftp: file /arch/libcom32.c32 not found dnsmasq-tftp: file /arch//libcom32.c32 not found dnsmasq-tftp: file /arch/libcom32.c32 not found dnsmasq-tftp: file /arch//arch//boot/syslinux/libcom32.c32 not found The last line of the log is the indication that there's a problem. Internally, Syslinux adds the location of ldlinux.c32 to PATH by querying the current working directory once ldlinux.c32 is successfully loaded. Under PXELINUX that means the initial PATH string will be, "::/arch/boot/syslinux/" The PATH parsing code doesn't know how to correctly parse the "::" string and hence, the file is searched for relative to the 210 dhcp option directory - /arch/. Implement PATH with a linked list which *greatly* simplifies the path code, and means we no longer have to parse strings backwards and forwards. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | Merge tag 'syslinux-5.10-pre2' into for-hpa/elflink/firmwareMatt Fleming2013-03-221-7/+5
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | syslinux-5.10-pre2 Conflicts: NEWS com32/include/netinet/in.h com32/include/sys/cpu.h com32/lib/Makefile core/Makefile core/fs/diskio.c core/fs/pxe/pxe.h core/init.c core/mem/free.c core/mem/malloc.c mk/devel.mk version
| * Merge branch 'lwip' into elflinkMatt Fleming2013-02-261-7/+5
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Welcome to Syslinux 5.10. Conflicts: NEWS com32/lib/Makefile com32/lib/sys/open.c com32/lib/syslinux/ipappend.c com32/modules/Makefile com32/modules/prdhcp.c core/Makefile core/cmdline.inc core/com32.inc core/comboot.inc core/configinit.inc core/fs/chdir.c core/fs/fs.c core/fs/pxe/dnsresolv.c core/fs/pxe/pxe.c core/fs/pxe/pxe.h core/idle.c core/include/ctype.h core/init.inc core/mem/init.c core/parseconfig.inc core/runkernel.inc core/syslinux.ld core/ui.inc doc/comboot.txt version
| | * core: pass the file flags down through the stackH. Peter Anvin2011-05-011-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | Pass the file flags down through the stack. This allows us to distinguish between open for read, open for write, or opendir in the low-level filesystem functions; this will matter for the PXE methods. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| | * core: dynamically size the heapH. Peter Anvin2011-04-251-3/+0
| | | | | | | | | | | | | | | | | | Dynamically size the heap to 1/16 of available high memory. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | | Merge tag 'syslinux-5.01' into firmwaresyslinux-6.00-pre4Matt Fleming2013-01-291-112/+6
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile NEWS com32/cmenu/Makefile com32/elflink/ldlinux/Makefile com32/gfxboot/Makefile com32/gpllib/Makefile com32/include/sys/module.h com32/lib/Makefile com32/lib/sys/module/elf_module.c com32/menu/Makefile com32/rosh/Makefile com32/samples/Makefile core/init.c mk/elf.mk Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | core/fs: remove some stale functions, inode refcount debugH. Peter Anvin2013-01-171-112/+6
| | | | | | | | | | | | | | | | | | | | | | | | Remove some stale (16-bit compatibility) functions in fs.c. Add some debugging for inode refcounts. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | | Merge tag 'syslinux-5.00' into firmwaresyslinux-6.00-pre3Matt Fleming2012-12-071-116/+163
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile com32/elflink/ldlinux/Makefile com32/lib/sys/module/elf_module.c core/cleanup.c core/comboot.inc core/conio.c core/fs/fs.c core/init.c core/mem/free.c core/mem/malloc.c core/timer.inc diag/geodsp/Makefile extlinux/main.c mk/embedded.mk modules/Makefile Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | Symbol export whitelistMatt Fleming2012-12-051-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before modules were dynamically loaded the boundary between GPL and non-GPL code was implicit because of the separate link domains for each module. With dynamic modules we need an explicit whitelist of core symbols that non-GPL code can link against at runtime without needing to be re-licensed under the GPL. Mark such symbols with __export, so that it is explicitly clear which symbols in the core can be linked against by non-GPL code. Reduce the visibility of symbols in both the core and ldlinux.c32 with -fvisibility=hidden. __export changes the visibility to 'default'. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | fs: Fix searchdir resource leakShao Miller2012-11-291-108/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a significant rewrite of the generic lookup logic inside core/fs/fs.c's searchdir function. Previously, there was a memory leak if a path involved multiple directories. After a sufficiently large number of invocations, this could be observed. Reported-by: Ady <ady-sf@hotmail.com> Signed-off-by: Shao Miller <sha0.miller@gmail.com>
* | | firmware: Make disk->private an opaque typeMatt Fleming2012-11-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've currently got both the BIOS and EFI versions of struct disk_private in core/include/disk.h, which isn't ideal because this file shouldn't need to know about the inner-workings of the firmware's private disk info. Move the implementation of 'struct disk_private' into more suitable locations and use a void * for the 'private' member of struct disk. This change allows us to once and for all delete the gnu-efi header files from core/include/core.h and the gnu-efi include paths from mk/lib.mk. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | Debug prints to core/fs/fs.c and core/fs/fat.c have been added.Chandramouli Narayanan2012-09-041-0/+1
| | | | | | | | | | | | | | | Signed-off-by: Chandramouli Narayanan <chandramouli.narayanan@intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | Merge remote-tracking branch 'mfleming/elflink' into for-hpa/elflink/firmwareMatt Fleming2012-07-301-1/+15
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile com32/elflink/ldlinux/adv.c com32/elflink/ldlinux/kernel.c com32/elflink/ldlinux/ldlinux.c com32/include/bitsize/stddef.h com32/include/bitsize/stdint.h com32/include/stdint.h com32/include/sys/module.h com32/include/sys/x86_64/bitops.h com32/include/syslinux/linux.h com32/lib/Makefile com32/lib/sys/ansicon_write.c com32/lib/sys/module/elfutils.h com32/lib/sys/vesa/efi/fill.h com32/lib/syslinux/load_linux.c com32/lib/syslinux/serial.c com32/lib/syslinux/shuffle.c core/conio.c core/elflink/config.c core/elflink/load_env32.c core/graphics.c core/include/graphics.h core/init.c core/pxelinux.asm mk/elf.mk mk/lib.mk
| * | Merge remote-tracking branch 'origin/master' into elflinkH. Peter Anvin2012-06-281-0/+13
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: core/fs/lib/searchconfig.c Get the reverse pathname lookup fixes from the master branch.
| | * | Actually keep track of the pathnames for all elementssyslinux-4.06-pre9H. Peter Anvin2012-06-281-0/+13
| | |/ | | | | | | | | | | | | | | | | | | | | | Actually keep track of the pathnames for all elements for on-disk filesystems. This makes sure we can always reconstruct the correct path. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * | fs: Include header for close() prototypeMatt Fleming2012-04-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | ... which avoids the following build warning, fs/fs.c: In function ‘open_config’: fs/fs.c:97:2: warning: implicit declaration of function ‘close’ Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | ldlinux: Avoid initialised data memory corruptionMatt Fleming2012-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't realloc() 'PATH' because realloc() may just extend the malloc'd region if the adjacent region is free, as opposed to allocating a new region and then copying the data. This behaviour is fine in most circumstances but not with initialised string data, such as 'PATH'. The reason is that other string data pointers may point to characters in 'PATH' and if we modify it after realloc()'ing, we'll appear to corrupt unrelated string data. For example, the string "/" is used in chdir() and the address of that string is the last "/" in 'PATH'. If we realloc() and then append "foo" to 'PATH' the string pointer in chdir() will now point to "/foo". Initialise 'PATH' at runtime using malloc() and free() to avoid corrupting string data. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | firmware, diskio: Create struct disk_privateMatt Fleming2012-03-281-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | We need a way of passing firmware-specific information to the disk I/O subsystem. Split the BIOS code into diskio_bios.c so that we don't include any disk BIOS symbols in the EFI executable. This way, the code in core/fs/diskio.c is firmware independent. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | | disk: Add .disk_init() to firmware structMatt Fleming2011-12-161-11/+9
|/ / | | | | | | | | | | | | | | | | | | | | Each firmware has its own method of initialising a disk so allow each firmware backend to implement a separate disk_init() function. Make all the assembly callers of fs_init() jump through pm_fs_init(), which allows us to restrict the com32sys_t arguments to only those callers that really need it, e.g. the .asm files. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | core: Fix ldlinux.c32 failing to load when not installed in "/"Matt Fleming2011-07-121-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, if syslinux is installed in a directory other than "/" we will fail to load ldlinux.c32. Because we know where we were installed the simplest fix is to chdir() to the installation directory before attempting to load ldlinux.c32. This requires us to add "." to PATH so that we look in the current working directory when loading ELF modules. Changing to the install directory needs to handled differently for different file systems, which is the reason behind the new file system operation, .chdir_start(). Disk-based Syslinux variants should use generic_chdir_start() to chdir() to CurrentDirName, which is the installation path. By using this new fs operation, we can load ldlinux.c32 when we expand the "." in PATH, without having to search the entire filesystem for it. However, iso9660 file systems still require us to search some directories because it has no notion of an installation directory. Previously, changing into the install directory was handled when opening the config file, but because the config file parser is now part of the ldlinux.c32 ELF module, it needs to be done much earlier. Reported-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | Merge branch 'PATH-based-search' into for-hpa/elflink/ldlinuxMatt Fleming2011-06-071-0/+2
|\ \ | | | | | | | | | | | | Conflicts: com32/elflink/ldlinux/readconfig.c
| * | ldlinux: PATH-based module lookupMatt Fleming2011-06-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for specifying directories to search when loading modules. A new config directive, "PATH", instructs the module loading code to search the directories listed in a colon-separated list when loading a module. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | | core: Return a file descriptor from open_config()Matt Fleming2011-06-071-2/+25
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Wrap open_config() the same way that open() wraps open_file(). The only user of open_config() requires access to a file descriptor so it makes sense to return a file descriptor. The file handle implementation is a historic piece of code and this patch tries to hide it as they will likely be removed at a future point in time. Furthermore, the file handle code is very core-specific and should not be exposed to any callers of open_config(). Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
* | core: change load_config() to open_config()H. Peter Anvin2011-05-271-11/+4
|/ | | | | | | | Change load_config() to open_config(), which is a method that works just like open_file(). This we can use to get the original configuration file. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* core: define and use set_flags() helperH. Peter Anvin2010-07-261-2/+1
| | | | | | | Rather than opencoding the arithmetic flag mask, define an inline to make that happen properly. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* core: don't hang if no config file is foundH. Peter Anvin2010-07-251-1/+4
| | | | | | | | If we can't find a configuration file, we need to do something slightly more friendly than hanging. Reported-by: Sebastian Herbszt <herbszt@gmx.de> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core, fs: eliminate recursion in put_inode()H. Peter Anvin2010-06-261-5/+4
| | | | | | | We don't actually need recursion in put_inode(), so replace recursion with a loop. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core, fs: handle .. resolution in the filesystem coreH. Peter Anvin2010-06-251-9/+30
| | | | | | | | | | | Some filesystems, including btrfs, don't have .. directory entries. We already handle . in the filesystem core, handle .. as well. This means keeping chains of parent inodes for all open inodes, at least for the duration of a path search; we might as well hang onto them. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* fs: enforce filetypes in open_fileH. Peter Anvin2010-06-231-5/+13
| | | | | | Enforce that the file type in open_file is a plain file. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: fix "sector size" confusionsyslinux-4.00-pre45H. Peter Anvin2010-05-141-1/+34
| | | | | | | | | | | Fix the case where the "sector size" used by the pm filesystem driver isn't the same thing as the SECTOR_SIZE/SECTOR_SHIFT macros used in the assembly code. This is a per-device property, and in the particular case of isolinux hybrid, they are not even currently the same (for all others, they are the same for now, but not necessarily in the future.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* diskio: make maxtransfer per-device, cap to 127, imported from headsyslinux-4.00-pre43H. Peter Anvin2010-05-121-1/+2
| | | | | | | | | | Make the maxtransfer per device, as it should be; properly imported from the head loader (in case it is patched with -s). Also enforce capping to 127 for EBIOS and 63 for CBIOS. This is structured so that once EDD4 is approved we can remove the capping for that particular subcase. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* fs: get rid of enum inode_modeH. Peter Anvin2010-03-091-2/+2
| | | | Replace enum inode_mode with the equivalent enum dirent_type.
* pxe: use an inode structure for pxesyslinux-4.00-pre36H. Peter Anvin2010-03-061-5/+4
| | | | | | | | Use an inode structure for PXE as well. Even though this is really rather superfluous in the case of PXE, it eliminates an ugly special case in the generic code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Add 32-bit versions of open file/close fileH. Peter Anvin2010-03-061-2/+44
| | | | | | Add 32-bit API calls for open file and close file. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: get rid of unmangle_name completelysyslinux-4.00-pre31H. Peter Anvin2010-02-281-11/+0
| | | | | | | | | | | | The notion of "mangle name" is now restricted to producing a canonical representation, e.g. changing \ -> / for FAT filesystems. However, the resulting mangled name is now always human-readable, so there never is any reason to unmangle a name. Get rid of not just the mangling, but of the resulting unmangled-name buffers and so on. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: remove unmangle_nameH. Peter Anvin2010-02-281-10/+1
| | | | | | Remove the now-obsolete unmangle_name method. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* fat: use generic_getfssec(), fix generic_getfssec(), add dprintfH. Peter Anvin2010-02-261-1/+3
| | | | | | | | | | | | | Use generic_getfssec() for the FAT filesystem. Do a bunch of calculations based on clusters rather than on sectors, so we don't have to do the same thing N times for N sectors per cluster. Fix boundary conditions in generic_getfssec(). Adjust iso9660 to match the resulting interface change. Add dprintf's to generic_getfssec() and a few other routines. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* fs: searchdir: handle opening a directoryH. Peter Anvin2010-02-241-0/+2
| | | | | | Handle the case of opening a directory. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: fix double free of pathbuf, constify iget filename, fix iso9660H. Peter Anvin2010-02-241-1/+2
| | | | | | | | | | Fix double free of pathbuf in searchdir(). Constify the pathname passed to ->iget(). Major cleanups of the iso9660 filesystem; it would use insufficiently dimensioned stack variables and do compares in a rather inefficient manner. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: add a direct 32-bit APIH. Peter Anvin2010-02-231-0/+21
| | | | | | Add a direct 32-bit API to some functions; initially read file only. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* core: move fs-related C files into fs/H. Peter Anvin2010-02-161-0/+366
Move filesystem-related C files into the fs/ directory. Signed-off-by: H. Peter Anvin <hpa@zytor.com>