blob: 6571df62f0c3393c31c1c1acbaa56342eb756110 [file] [log] [blame]
Uma Shankar71014b62012-05-25 21:21:44 +05301/*
2 * (C) Copyright 2011 - 2012 Samsung Electronics
3 * EXT4 filesystem implementation in Uboot by
4 * Uma Shankar <uma.shankar@samsung.com>
5 * Manjunatha C Achar <a.manjunatha@samsung.com>
6 *
7 * ext4ls and ext4load : based on ext2 ls load support in Uboot.
8 *
9 * (C) Copyright 2004
10 * esd gmbh <www.esd-electronics.com>
11 * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
12 *
13 * based on code from grub2 fs/ext2.c and fs/fshelp.c by
14 * GRUB -- GRand Unified Bootloader
15 * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
16 *
Uma Shankara74a99a2012-05-25 21:22:49 +053017 * ext4write : Based on generic ext4 protocol.
18 *
Uma Shankar71014b62012-05-25 21:21:44 +053019 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#ifndef __EXT4_COMMON__
35#define __EXT4_COMMON__
36#include <ext_common.h>
37#include <ext4fs.h>
38#include <malloc.h>
39#include <asm/errno.h>
Stephen Warren4f8662d2012-10-22 06:43:50 +000040#if defined(CONFIG_EXT4_WRITE)
Uma Shankara74a99a2012-05-25 21:22:49 +053041#include "ext4_journal.h"
42#include "crc16.h"
43#endif
Uma Shankar71014b62012-05-25 21:21:44 +053044
45#define YES 1
46#define NO 0
Uma Shankar71014b62012-05-25 21:21:44 +053047#define RECOVER 1
48#define SCAN 0
49
50#define S_IFLNK 0120000 /* symbolic link */
51#define BLOCK_NO_ONE 1
Egbert Eich7b1b2552013-05-01 01:13:19 +000052#define SUPERBLOCK_START (2 * 512)
Uma Shankar71014b62012-05-25 21:21:44 +053053#define SUPERBLOCK_SIZE 1024
54#define F_FILE 1
55
Stephen Warren07639f22012-09-18 08:05:28 +000056static inline void *zalloc(size_t size)
57{
58 void *p = memalign(ARCH_DMA_MINALIGN, size);
59 memset(p, 0, size);
60 return p;
61}
Uma Shankar71014b62012-05-25 21:21:44 +053062
Uma Shankar71014b62012-05-25 21:21:44 +053063int ext4fs_read_inode(struct ext2_data *data, int ino,
64 struct ext2_inode *inode);
65int ext4fs_read_file(struct ext2fs_node *node, int pos,
66 unsigned int len, char *buf);
67int ext4fs_find_file(const char *path, struct ext2fs_node *rootnode,
68 struct ext2fs_node **foundnode, int expecttype);
69int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
70 struct ext2fs_node **fnode, int *ftype);
Uma Shankara74a99a2012-05-25 21:22:49 +053071
Stephen Warren4f8662d2012-10-22 06:43:50 +000072#if defined(CONFIG_EXT4_WRITE)
Uma Shankara74a99a2012-05-25 21:22:49 +053073uint32_t ext4fs_div_roundup(uint32_t size, uint32_t n);
74int ext4fs_checksum_update(unsigned int i);
75int ext4fs_get_parent_inode_num(const char *dirname, char *dname, int flags);
76void ext4fs_update_parent_dentry(char *filename, int *p_ino, int file_type);
77long int ext4fs_get_new_blk_no(void);
78int ext4fs_get_new_inode_no(void);
79void ext4fs_reset_block_bmap(long int blockno, unsigned char *buffer,
80 int index);
81int ext4fs_set_block_bmap(long int blockno, unsigned char *buffer, int index);
82int ext4fs_set_inode_bmap(int inode_no, unsigned char *buffer, int index);
83void ext4fs_reset_inode_bmap(int inode_no, unsigned char *buffer, int index);
84int ext4fs_iget(int inode_no, struct ext2_inode *inode);
85void ext4fs_allocate_blocks(struct ext2_inode *file_inode,
86 unsigned int total_remaining_blocks,
87 unsigned int *total_no_of_block);
88void put_ext4(uint64_t off, void *buf, uint32_t size);
89#endif
Uma Shankar71014b62012-05-25 21:21:44 +053090#endif