mirror of
				https://git.proxmox.com/git/grub2
				synced 2025-11-04 08:48:29 +00:00 
			
		
		
		
	* conf/i386-pc.rmk (kernel_img_SOURCES): Added kern/fshelp.c. (grub_mkimage_LDFLAGS): Likewise. (grub_emu_SOURCES): Likewise. (kernel_img_HEADERS): Added fshelp.h. * fs/ext2.c: Include <grub/fshelp.h>. (FILETYPE_REG): New macro. (FILETYPE_INO_REG): Likewise. (grub_ext_sblock): Renamed to `grub_ext2_sblock'. Changed all users. (ext2_block_group): Renamed to `grub_ext2_block_group'. Changed all users. (grub_fshelp_node): New struct. (grub_ext2_data): Added member `diropen'. Changed member `inode' to a pointer. (grub_ext2_get_file_block): Removed function. (grub_ext2_read_block): New function. (grub_ext2_read_file): Replaced parameter `data' by `node'. This function was written. (grub_ext2_mount): Read the root inode. Create a diropen struct. (grub_ext2_find_file): Removed function. (grub_ext2_read_symlink): New function. (grub_ext2_iterate_dir): Likewise. (grub_ext2_open): Rewritten. (grub_ext2_dir): Rewritten. * include/grub/fshelp.h: New file. * fs/fshelp.c: Likewise.
		
			
				
	
	
		
			76 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/* fshelp.h -- Filesystem helper functions */
 | 
						|
/*
 | 
						|
 *  GRUB  --  GRand Unified Bootloader
 | 
						|
 *  Copyright (C) 2004  Free Software Foundation, Inc.
 | 
						|
 *
 | 
						|
 *  GRUB is free software; you can redistribute it and/or modify
 | 
						|
 *  it under the terms of the GNU General Public License as published by
 | 
						|
 *  the Free Software Foundation; either version 2 of the License, or
 | 
						|
 *  (at your option) any later version.
 | 
						|
 *
 | 
						|
 *  This program is distributed in the hope that it will be useful,
 | 
						|
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
						|
 *  GNU General Public License for more details.
 | 
						|
 *
 | 
						|
 *  You should have received a copy of the GNU General Public License
 | 
						|
 *  along with GRUB; if not, write to the Free Software
 | 
						|
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef GRUB_FSHELP_HEADER
 | 
						|
#define GRUB_FSHELP_HEADER	1
 | 
						|
 | 
						|
#include <grub/types.h>
 | 
						|
#include <grub/symbol.h>
 | 
						|
#include <grub/err.h>
 | 
						|
 | 
						|
typedef struct grub_fshelp_node *grub_fshelp_node_t;
 | 
						|
 | 
						|
enum grub_fshelp_filetype
 | 
						|
  {
 | 
						|
    GRUB_FSHELP_UNKNOWN,
 | 
						|
    GRUB_FSHELP_REG,
 | 
						|
    GRUB_FSHELP_DIR,
 | 
						|
    GRUB_FSHELP_SYMLINK
 | 
						|
  };
 | 
						|
 | 
						|
/* Lookup the node PATH.  The node ROOTNODE describes the root of the
 | 
						|
   directory tree.  The node found is returned in FOUNDNODE, which is
 | 
						|
   either a ROOTNODE or a new malloc'ed node.  ITERATE_DIR is used to
 | 
						|
   iterate over all directory entries in the current node.
 | 
						|
   READ_SYMLINK is used to read the symlink if a node is a symlink.
 | 
						|
   EXPECTTYPE is the type node that is expected by the called, an
 | 
						|
   error is generated if the node is not of the expected type.  Make
 | 
						|
   sure you use the NESTED_FUNC_ATTR macro for HOOK, this is required
 | 
						|
   because GCC has a nasty bug when using regparm=3.  */
 | 
						|
grub_err_t
 | 
						|
EXPORT_FUNC(grub_fshelp_find_file) (const char *path,
 | 
						|
				    grub_fshelp_node_t rootnode,
 | 
						|
				    grub_fshelp_node_t *foundnode,
 | 
						|
				    int (*iterate_dir) (grub_fshelp_node_t dir,
 | 
						|
							int NESTED_FUNC_ATTR
 | 
						|
							(*hook) (const char *filename,
 | 
						|
								 enum grub_fshelp_filetype filetype,
 | 
						|
								 grub_fshelp_node_t node)),
 | 
						|
				    char *(*read_symlink) (grub_fshelp_node_t node),
 | 
						|
				    enum grub_fshelp_filetype expect);
 | 
						|
 | 
						|
 | 
						|
/* Read LEN bytes from the file NODE on disk DISK into the buffer BUF,
 | 
						|
   beginning with the block POS.  READ_HOOK should be set before
 | 
						|
   reading a block from the file.  GET_BLOCK is used to translate file
 | 
						|
   blocks to disk blocks.  The file is FILESIZE bytes big and the
 | 
						|
   blocks have a size of LOG2BLOCKSIZE (in log2).  */
 | 
						|
grub_ssize_t
 | 
						|
EXPORT_FUNC(grub_fshelp_read_file) (grub_disk_t disk, grub_fshelp_node_t node,
 | 
						|
				    void (*read_hook) (unsigned long sector,
 | 
						|
						       unsigned offset,
 | 
						|
						       unsigned length),
 | 
						|
				    int pos, unsigned int len, char *buf,
 | 
						|
				    int (*get_block) (grub_fshelp_node_t node,
 | 
						|
						      int block),
 | 
						|
				    unsigned int filesize, int log2blocksize);
 | 
						|
     
 | 
						|
#endif /* ! GRUB_FSHELP_HEADER */
 |