13839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 23839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * ext2fs.h --- ext2fs 3efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o * 419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. 519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * 619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * %Begin-Header% 7543547a52a20cb7e69d74921b2f691078fd55d83Theodore Ts'o * This file may be redistributed under the terms of the GNU Library 8543547a52a20cb7e69d74921b2f691078fd55d83Theodore Ts'o * General Public License, version 2. 919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * %End-Header% 103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 129abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o#ifndef _EXT2FS_EXT2FS_H 139abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o#define _EXT2FS_EXT2FS_H 149abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o 15544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o#ifdef __GNUC__ 16544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o#define EXT2FS_ATTR(x) __attribute__(x) 17544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o#else 18544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o#define EXT2FS_ATTR(x) 19544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o#endif 20544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o 21fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o#ifdef __cplusplus 22fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'oextern "C" { 23fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o#endif 24fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o 253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 2619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * Non-GNU C compilers won't necessarily understand inline 2719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 2876f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07Theodore Ts'o#if (!defined(__GNUC__) && !defined(__WATCOMC__)) 2919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define NO_INLINE_FUNCS 3019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#endif 3119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 3219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Where the master copy of the superblock is located, and how big 343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * superblocks are supposed to be. We define SUPERBLOCK_SIZE because 353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * the size of the superblock structure is not necessarily trustworthy 363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * (some versions have the padding set up so that the superblock is 373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * 1032 bytes long). 383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 393839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define SUPERBLOCK_OFFSET 1024 40e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define SUPERBLOCK_SIZE 1024 413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 42f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o/* 43f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o * The last ext2fs revision level that this version of the library is 44f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o * able to support. 45f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o */ 46e5b38a5fafe4807b54d90a2e70bddf4b41b1695bTheodore Ts'o#define EXT2_LIB_CURRENT_REV EXT2_DYNAMIC_REV 47f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 48d40259fd552d942903f2fd0b426c75a5c2516017Theodore Ts'o#ifdef HAVE_SYS_TYPES_H 491e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#include <sys/types.h> 50d40259fd552d942903f2fd0b426c75a5c2516017Theodore Ts'o#endif 51d40259fd552d942903f2fd0b426c75a5c2516017Theodore Ts'o 523e69906495d5898849a6154b0311b5d4a84a27aeTheodore Ts'o#include <stdio.h> 535be8dc2143c7b3b21a9b8fb56797dd855ee87560Theodore Ts'o#include <stdlib.h> 54a82a57025c4368de330ecac9a430d84137ae2268Theodore Ts'o#include <string.h> 55023a1df091f9d42f826ee3737190db5de9c823b0Theodore Ts'o#include <errno.h> 561ac2aa23ef030863f51fc77b42715e173967c44dAndreas Dilger 575953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#if EXT2_FLAT_INCLUDES 585953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#include "e2_types.h" 593e69906495d5898849a6154b0311b5d4a84a27aeTheodore Ts'o#include "ext2_fs.h" 6089dd65704f4397c49d40ae8c171928831e6a74bfTheodore Ts'o#include "ext3_extents.h" 615953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#else 62797f5ef14e92294b329e52971d467d7af5b2993eTheodore Ts'o#include <ext2fs/ext2_types.h> 633e69906495d5898849a6154b0311b5d4a84a27aeTheodore Ts'o#include <ext2fs/ext2_fs.h> 6489dd65704f4397c49d40ae8c171928831e6a74bfTheodore Ts'o#include <ext2fs/ext3_extents.h> 65e589f678e1ed5efa8dd4450f37bee0486caa3504Theodore Ts'o#endif /* EXT2_FLAT_INCLUDES */ 6650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 67e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#ifdef __CHECK_ENDIAN__ 68e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define __bitwise __attribute__((bitwise)) 69e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#else 70e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define __bitwise 71e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif 72e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 73e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u32 __bitwise ext2_ino_t; 74e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u32 __bitwise blk_t; 75e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u64 __bitwise blk64_t; 76e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u32 __bitwise dgrp_t; 77e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u32 __bitwise ext2_off_t; 78e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u64 __bitwise ext2_off64_t; 79e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __s64 __bitwise e2_blkcnt_t; 80e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef __u32 __bitwise ext2_dirhash_t; 813839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 82b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#if EXT2_FLAT_INCLUDES 83b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#include "com_err.h" 84b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#include "ext2_io.h" 85b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#include "ext2_err.h" 86fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilger#include "ext2_ext_attr.h" 87b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#else 887c2d25699f2da458ba8201a375b00562d7a2469eTheodore Ts'o#include <et/com_err.h> 897c2d25699f2da458ba8201a375b00562d7a2469eTheodore Ts'o#include <ext2fs/ext2_io.h> 907c2d25699f2da458ba8201a375b00562d7a2469eTheodore Ts'o#include <ext2fs/ext2_err.h> 91fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilger#include <ext2fs/ext2_ext_attr.h> 92b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o#endif 933839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 944c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o/* 954c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o * Portability help for Microsoft Visual C++ 964c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o */ 974c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o#ifdef _MSC_VER 984c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o#define EXT2_QSORT_TYPE int __cdecl 994c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o#else 1004c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o#define EXT2_QSORT_TYPE int 1014c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o#endif 1024c77fe50d97a773e32a4756c79dade3adbb6a601Theodore Ts'o 103f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'otypedef struct struct_ext2_filsys *ext2_filsys; 104f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 1051e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define EXT2FS_MARK_ERROR 0 1061e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define EXT2FS_UNMARK_ERROR 1 1071e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define EXT2FS_TEST_ERROR 2 108f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 1091e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'otypedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap; 1101e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'otypedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap; 1111e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'otypedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap; 112f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 1137f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s) 114067911ae734bb5fef7c5780a639533847b5b578cAndreas Dilger 1157f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o 1163839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 117067911ae734bb5fef7c5780a639533847b5b578cAndreas Dilger * Badblocks list definitions 11819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 11919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 120b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'otypedef struct ext2_struct_u32_list *ext2_badblocks_list; 121b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'otypedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate; 122b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'o 123b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'otypedef struct ext2_struct_u32_list *ext2_u32_list; 124b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'otypedef struct ext2_struct_u32_iterate *ext2_u32_iterate; 12519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 12619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* old */ 127b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'otypedef struct ext2_struct_u32_list *badblocks_list; 128b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'otypedef struct ext2_struct_u32_iterate *badblocks_iterate; 12919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 13019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define BADBLOCKS_FLAG_DIRTY 1 13119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 13219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 13319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * ext2_dblist structure and abstractions (see dblist.c) 13419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 135e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallstruct ext2_db_entry2 { 136e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2_ino_t ino; 137e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk; 138e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall e2_blkcnt_t blockcnt; 139e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall}; 140e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 141e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* Ye Olde 32-bit version */ 14219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'ostruct ext2_db_entry { 14331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t ino; 14419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o blk_t blk; 14519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int blockcnt; 14619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o}; 14719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 14819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'otypedef struct ext2_struct_dblist *ext2_dblist; 14919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 15019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define DBLIST_ABORT 1 15119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 15219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 15330fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o * ext2_fileio definitions 15430fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o */ 15530fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 15630fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_FILE_WRITE 0x0001 15730fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_FILE_CREATE 0x0002 15830fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 15930fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_FILE_MASK 0x00FF 16030fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 16130fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_FILE_BUF_DIRTY 0x4000 16230fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_FILE_BUF_VALID 0x2000 16330fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 16430fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'otypedef struct ext2_file *ext2_file_t; 16530fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 16630fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_SEEK_SET 0 16730fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_SEEK_CUR 1 16830fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o#define EXT2_SEEK_END 2 16930fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 17030fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o/* 171a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'o * Flags for the ext2_filsys structure and for ext2fs_open() 1723839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 17319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_RW 0x01 17419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_CHANGED 0x02 17519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_DIRTY 0x04 17619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_VALID 0x08 17719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_IB_DIRTY 0x10 17819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_BB_DIRTY 0x20 1795c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o#define EXT2_FLAG_SWAP_BYTES 0x40 1805c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o#define EXT2_FLAG_SWAP_BYTES_READ 0x80 1815c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o#define EXT2_FLAG_SWAP_BYTES_WRITE 0x100 1825c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o#define EXT2_FLAG_MASTER_SB_ONLY 0x200 18319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_FLAG_FORCE 0x400 18443ec8734f2ecd0a345e831f45fd3dfb077426811Theodore Ts'o#define EXT2_FLAG_SUPER_ONLY 0x800 185a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'o#define EXT2_FLAG_JOURNAL_DEV_OK 0x1000 186a78926effb15bbabb1c0ed3e438b03be25c4d48cTheodore Ts'o#define EXT2_FLAG_IMAGE_FILE 0x2000 18739c47ce6417b81aa74596fd0d4d98d542525a444Theodore Ts'o#define EXT2_FLAG_EXCLUSIVE 0x4000 188cf8272e1081f69d898d5182ed516e28807135deaTheodore Ts'o#define EXT2_FLAG_SOFTSUPP_FEATURES 0x8000 189ab52e12a904b4a31fc3416f0ef7d959f0c38e773Theodore Ts'o#define EXT2_FLAG_NOFREE_ON_ERROR 0x10000 190e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_FLAG_64BITS 0x20000 191e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_FLAG_PRINT_PROGRESS 0x40000 19273fbe2323af6a2b4d807c80069657bf1449b3bffTheodore Ts'o#define EXT2_FLAG_DIRECT_IO 0x80000 193e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_FLAG_SKIP_MMP 0x100000 1943839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1957f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o/* 1967f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o * Special flag in the ext2 inode i_flag field that means that this is 1977f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o * a new inode. (So that ext2_write_inode() can clear extra fields.) 1987f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o */ 1997f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o#define EXT2_NEW_INODE_FL 0x80000000 2007f88b04341d88c5df0360d930832c38040303b61Theodore Ts'o 2014e246704eab31407ac15be9ab206c6f929507cf0Theodore Ts'o/* 2024e246704eab31407ac15be9ab206c6f929507cf0Theodore Ts'o * Flags for mkjournal 2034e246704eab31407ac15be9ab206c6f929507cf0Theodore Ts'o */ 204e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_MKJOURNAL_V1_SUPER 0x0000001 /* create V1 superblock (deprecated) */ 205e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_MKJOURNAL_LAZYINIT 0x0000002 /* don't zero journal inode before use*/ 206e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_MKJOURNAL_NO_MNT_CHECK 0x0000004 /* don't check mount status */ 207e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 208e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallstruct opaque_ext2_group_desc; 209efe0b401465a3ee836180614b5b435acbb84fc27Eric Sandeen 2103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'ostruct struct_ext2_filsys { 2114cbe8af4b0d0c72fb28bb500c1bd8a46b00fdde3Theodore Ts'o errcode_t magic; 2123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o io_channel io; 2133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o int flags; 2143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o char * device_name; 2153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o struct ext2_super_block * super; 216544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o unsigned int blocksize; 2173fbfad558e01ffbacc14e5a536c4dfec0a0af4f5Theodore Ts'o int fragsize; 2182eb374c9401079aa56aa12f0047ca3866e69b754Theodore Ts'o dgrp_t group_desc_count; 2193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o unsigned long desc_blocks; 220e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct opaque_ext2_group_desc * group_desc; 221e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall unsigned int inode_blocks_per_group; 222f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o ext2fs_inode_bitmap inode_map; 223f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o ext2fs_block_bitmap block_map; 224e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall /* XXX FIXME-64: not 64-bit safe, but not used? */ 22531dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks); 22631dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino); 2273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o errcode_t (*write_bitmaps)(ext2_filsys fs); 22831dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o errcode_t (*read_inode)(ext2_filsys fs, ext2_ino_t ino, 2291e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o struct ext2_inode *inode); 23031dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o errcode_t (*write_inode)(ext2_filsys fs, ext2_ino_t ino, 2311e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o struct ext2_inode *inode); 232b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'o ext2_badblocks_list badblocks; 23319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2_dblist dblist; 234a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o __u32 stride; /* for mke2fs */ 235c180ac86533bcbfb1560bd4aa01464785a760f70Theodore Ts'o struct ext2_super_block * orig_super; 236a78926effb15bbabb1c0ed3e438b03be25c4d48cTheodore Ts'o struct ext2_image_hdr * image_header; 2376a525069a99787ef3ae1156f12230044b3568f4bTheodore Ts'o __u32 umask; 2389b9a780f5a5823865f62f0c9fd194d262f63a06fTheodore Ts'o time_t now; 239e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int cluster_ratio_bits; 240e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u16 default_bitmap_type; 241e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u16 pad; 24219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o /* 24319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * Reserved for future expansion 24419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 245e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 reserved[5]; 2463839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 2473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o /* 248a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o * Reserved for the use of the calling application. 2493839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 250b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void * priv_data; 251a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o 252a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o /* 253a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o * Inode cache 254a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o */ 255a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o struct ext2_inode_cache *icache; 2561ad54a940c499a66241f624882f1ffa03ce56d90Theodore Ts'o io_channel image_io; 257f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o 258f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o /* 2595fff8636e54f762fcfe7312ec7c0428924ff7292Theodore Ts'o * More callback functions 2605fff8636e54f762fcfe7312ec7c0428924ff7292Theodore Ts'o */ 2615fff8636e54f762fcfe7312ec7c0428924ff7292Theodore Ts'o errcode_t (*get_alloc_block)(ext2_filsys fs, blk64_t goal, 2625fff8636e54f762fcfe7312ec7c0428924ff7292Theodore Ts'o blk64_t *ret); 2635fff8636e54f762fcfe7312ec7c0428924ff7292Theodore Ts'o void (*block_alloc_stats)(ext2_filsys fs, blk64_t blk, int inuse); 264e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 265e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall /* 266e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * Buffers for Multiple mount protection(MMP) block. 267e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall */ 268e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *mmp_buf; 269e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *mmp_cmp; 270e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int mmp_fd; 271e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 272e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall /* 273e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * Time at which e2fsck last updated the MMP block. 274e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall */ 275e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall long mmp_last_written; 2763839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o}; 2773839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 2785953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#if EXT2_FLAT_INCLUDES 2795953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#include "e2_bitops.h" 2805953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#else 2817c2d25699f2da458ba8201a375b00562d7a2469eTheodore Ts'o#include <ext2fs/bitops.h> 2825953b9de9ce59661640f851b217421d734bb0302Theodore Ts'o#endif 283d40259fd552d942903f2fd0b426c75a5c2516017Theodore Ts'o 2843839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 285e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * 64-bit bitmap backend types 286e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall */ 287e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_BMAP64_BITARRAY 1 288e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_BMAP64_RBTREE 2 289e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_BMAP64_AUTODIR 3 290e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 291e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* 2923839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Return flags for the block iterator functions 2933839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 2943839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define BLOCK_CHANGED 1 2953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define BLOCK_ABORT 2 2963839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define BLOCK_ERROR 4 2973839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 2983839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 2993839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Block interate flags 30050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * 30150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * BLOCK_FLAG_APPEND, or BLOCK_FLAG_HOLE, indicates that the interator 30250e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * function should be called on blocks where the block number is zero. 30350e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * This is used by ext2fs_expand_dir() to be able to add a new block 30450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * to an inode. It can also be used for programs that want to be able 30550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * to deal with files that contain "holes". 306efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o * 3077447921dff38ef06a78355c0a7a23df9392102a4Theodore Ts'o * BLOCK_FLAG_DEPTH_TRAVERSE indicates that the iterator function for 3087447921dff38ef06a78355c0a7a23df9392102a4Theodore Ts'o * the indirect, doubly indirect, etc. blocks should be called after 3097447921dff38ef06a78355c0a7a23df9392102a4Theodore Ts'o * all of the blocks containined in the indirect blocks are processed. 31050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * This is useful if you are going to be deallocating blocks from an 31150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * inode. 3121e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o * 3131e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be 3141e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o * called for data blocks only. 315674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o * 316efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o * BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not 317357d1863d64ce807c2904e101fc87d3f6be2f3caTheodore Ts'o * modify returned block number. 318357d1863d64ce807c2904e101fc87d3f6be2f3caTheodore Ts'o * 319674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o * BLOCK_FLAG_NO_LARGE is for internal use only. It informs 32036a43d675ef61d0f5d5b2ad62d2e670c408d14acTheodore Ts'o * ext2fs_block_iterate2 that large files won't be accepted. 3213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 3223839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define BLOCK_FLAG_APPEND 1 32350e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define BLOCK_FLAG_HOLE 1 3243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define BLOCK_FLAG_DEPTH_TRAVERSE 2 3251e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define BLOCK_FLAG_DATA_ONLY 4 326357d1863d64ce807c2904e101fc87d3f6be2f3caTheodore Ts'o#define BLOCK_FLAG_READ_ONLY 8 3271e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 328674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o#define BLOCK_FLAG_NO_LARGE 0x1000 329674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o 3301e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o/* 3311e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o * Magic "block count" return values for the block iterator function. 3321e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o */ 3331e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define BLOCK_COUNT_IND (-1) 3341e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define BLOCK_COUNT_DIND (-2) 3351e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define BLOCK_COUNT_TIND (-3) 3361e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define BLOCK_COUNT_TRANSLATOR (-4) 3373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 3384a31c48b827f378f386b28461fd14b41d709e4ebTheodore Ts'o#if 0 3393839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 3401e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o * Flags for ext2fs_move_blocks 3411e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o */ 342efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o#define EXT2_BMOVE_GET_DBLIST 0x0001 34336f21439f5d8b2233d13e042833d4d921a5c2c40Theodore Ts'o#define EXT2_BMOVE_DEBUG 0x0002 3444a31c48b827f378f386b28461fd14b41d709e4ebTheodore Ts'o#endif 3451e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o 3461e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o/* 3473eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o * Generic (non-filesystem layout specific) extents structure 3483eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o */ 3493eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 3503eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_FLAGS_LEAF 0x0001 3513eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_FLAGS_UNINIT 0x0002 3523eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_FLAGS_SECOND_VISIT 0x0004 3533eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 3543eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'ostruct ext2fs_extent { 3553eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o blk64_t e_pblk; /* first physical block */ 3563eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o blk64_t e_lblk; /* first logical block extent covers */ 3573eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o __u32 e_len; /* number of blocks covered by extent */ 3583eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o __u32 e_flags; /* extent flags */ 3593eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o}; 3603eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 3613eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'otypedef struct ext2_extent_handle *ext2_extent_handle_t; 3623eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'otypedef struct ext2_extent_path *ext2_extent_path_t; 3633eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 3643eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o/* 3653eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o * Flags used by ext2fs_extent_get() 3663eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o */ 3673eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_CURRENT 0x0000 3683eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_MOVE_MASK 0x000F 3693eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_ROOT 0x0001 3703eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_LAST_LEAF 0x0002 3713eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_FIRST_SIB 0x0003 3723eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_LAST_SIB 0x0004 3733eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_NEXT_SIB 0x0005 3743eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_PREV_SIB 0x0006 3753eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_NEXT_LEAF 0x0007 3763eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_PREV_LEAF 0x0008 3773eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_NEXT 0x0009 3783eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_PREV 0x000A 3793eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_UP 0x000B 3803eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_DOWN 0x000C 3813eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o#define EXT2_EXTENT_DOWN_AND_LAST 0x000D 3823eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 3833eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o/* 3843eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o * Flags used by ext2fs_extent_insert() 3853eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o */ 38601229db57ee71518f81d87d6bf900c62fe1de100Eric Sandeen#define EXT2_EXTENT_INSERT_AFTER 0x0001 /* insert after handle loc'n */ 38701229db57ee71518f81d87d6bf900c62fe1de100Eric Sandeen#define EXT2_EXTENT_INSERT_NOSPLIT 0x0002 /* insert may not cause split */ 3883eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 3893eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o/* 390c802ad9ed6c6756dfb65d31f0f559e90df3825d5Eric Sandeen * Flags used by ext2fs_extent_delete() 391c802ad9ed6c6756dfb65d31f0f559e90df3825d5Eric Sandeen */ 392c802ad9ed6c6756dfb65d31f0f559e90df3825d5Eric Sandeen#define EXT2_EXTENT_DELETE_KEEP_EMPTY 0x001 /* keep node if last extnt gone */ 393c802ad9ed6c6756dfb65d31f0f559e90df3825d5Eric Sandeen 394c802ad9ed6c6756dfb65d31f0f559e90df3825d5Eric Sandeen/* 395f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen * Flags used by ext2fs_extent_set_bmap() 396f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen */ 397f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen#define EXT2_EXTENT_SET_BMAP_UNINIT 0x0001 398f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen 399f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen/* 4003eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o * Data structure returned by ext2fs_extent_get_info() 4013eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o */ 4023eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'ostruct ext2_extent_info { 4033eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int curr_entry; 4043eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int curr_level; 4053eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int num_entries; 4063eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int max_entries; 4073eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int max_depth; 4083eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int bytes_avail; 4093eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o blk64_t max_lblk; 4103eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o blk64_t max_pblk; 4113eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o __u32 max_len; 4123eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o __u32 max_uninit_len; 4133eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o}; 4143eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 4153eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o/* 416f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o * Flags for directory block reading and writing functions 417f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o */ 418f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o#define EXT2_DIRBLOCK_V2_STRUCT 0x0001 419f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o 420f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o/* 4213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Return flags for the directory iterator functions 4223839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 4233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define DIRENT_CHANGED 1 4243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define DIRENT_ABORT 2 4253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define DIRENT_ERROR 3 4263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 4273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 4283839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Directory iterator flags 4293839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 4303839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 4313839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define DIRENT_FLAG_INCLUDE_EMPTY 1 4328bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o#define DIRENT_FLAG_INCLUDE_REMOVED 2 43319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 43419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define DIRENT_DOT_FILE 1 43519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define DIRENT_DOT_DOT_FILE 2 43619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define DIRENT_OTHER_FILE 3 4378bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o#define DIRENT_DELETED_FILE 4 43819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 4393839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 4403839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Inode scan definitions 4413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 442f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'otypedef struct ext2_struct_inode_scan *ext2_inode_scan; 443f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 44419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 44519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * ext2fs_scan flags 44619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 44719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_SF_CHK_BADBLOCKS 0x0001 44819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_SF_BAD_INODE_BLK 0x0002 44919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_SF_BAD_EXTRA_BYTES 0x0004 45019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_SF_SKIP_MISSING_ITABLE 0x0008 451f5fa20078bfc05b554294fe9c5505375d7913e8cTheodore Ts'o#define EXT2_SF_DO_LAZY 0x0010 4523839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 453f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o/* 45450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * ext2fs_check_if_mounted flags 45550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o */ 45650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define EXT2_MF_MOUNTED 1 45750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define EXT2_MF_ISROOT 2 45819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_MF_READONLY 4 45907cefe7a7051e32f14b93d9003a6dbb308597bd3Theodore Ts'o#define EXT2_MF_SWAP 8 4602fa8f37ffff4687228d9f204062f2d27b0e5b919Theodore Ts'o#define EXT2_MF_BUSY 16 46150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 46250e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o/* 46350e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * Ext2/linux mode flags. We define them here so that we don't need 46450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * to depend on the OS's sys/stat.h, since we may be compiling on a 46550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o * non-Linux system. 46650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o */ 46750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFMT 00170000 46850e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFSOCK 0140000 46950e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFLNK 0120000 47050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFREG 0100000 47150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFBLK 0060000 47250e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFDIR 0040000 47350e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFCHR 0020000 47450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_IFIFO 0010000 47550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISUID 0004000 47650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISGID 0002000 47750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISVTX 0001000 47850e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 4791e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IRWXU 00700 4801e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IRUSR 00400 4811e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IWUSR 00200 4821e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IXUSR 00100 4831e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 4841e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IRWXG 00070 4851e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IRGRP 00040 4861e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IWGRP 00020 4871e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IXGRP 00010 4881e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 4891e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IRWXO 00007 4901e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IROTH 00004 4911e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IWOTH 00002 4921e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o#define LINUX_S_IXOTH 00001 4931e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 49450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISLNK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFLNK) 49550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISREG(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFREG) 49650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISDIR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFDIR) 49750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISCHR(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFCHR) 49850e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISBLK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFBLK) 49950e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISFIFO(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFIFO) 50050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#define LINUX_S_ISSOCK(m) (((m) & LINUX_S_IFMT) == LINUX_S_IFSOCK) 50150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 50250e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o/* 503819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'o * ext2 size of an inode 504819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'o */ 505819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'o#define EXT2_I_SIZE(i) ((i)->i_size | ((__u64) (i)->i_size_high << 32)) 506819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'o 507819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'o/* 50819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o * ext2_icount_t abstraction 50919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o */ 51019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o#define EXT2_ICOUNT_OPT_INCREMENT 0x01 51119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 51219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'otypedef struct ext2_icount *ext2_icount_t; 51319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 51419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* 51530fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o * Flags for ext2fs_bmap 51630fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o */ 5171d667534e93e78eedbf2efcef6d7844041675f26Theodore Ts'o#define BMAP_ALLOC 0x0001 5181d667534e93e78eedbf2efcef6d7844041675f26Theodore Ts'o#define BMAP_SET 0x0002 51930fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 52030fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o/* 521cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o * Returned flags from ext2fs_bmap 522cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o */ 523cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o#define BMAP_RET_UNINIT 0x0001 524cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o 525cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o/* 52672ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o * Flags for imager.c functions 52772ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o */ 52872ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o#define IMAGER_FLAG_INODEMAP 1 52972ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o#define IMAGER_FLAG_SPARSEWRITE 2 53072ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o 53172ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o/* 532f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o * For checking structure magic numbers... 533f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o */ 5343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 535f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o#define EXT2_CHECK_MAGIC(struct, code) \ 536f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o if ((struct)->magic != (code)) return (code) 5371e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 5381e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 5391e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o/* 540e5b38a5fafe4807b54d90a2e70bddf4b41b1695bTheodore Ts'o * For ext2 compression support 5411e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o */ 5425d38ef1d049bf56d1c1e88b8b4d287c0f9470e61Valerie Clement#define EXT2FS_COMPRESSED_BLKADDR ((blk_t) -1) 5435a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o#define HOLE_BLKADDR(_b) ((_b) == 0 || (_b) == EXT2FS_COMPRESSED_BLKADDR) 5445a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o 545521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o/* 546426d734ff06e769cf5117053b6264c4a9decd3b2Theodore Ts'o * Features supported by this version of the library 547521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o */ 5483a5f8eaa9741f6f14520ddd263a996e2764dd437Theodore Ts'o#define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\ 5493a5f8eaa9741f6f14520ddd263a996e2764dd437Theodore Ts'o EXT2_FEATURE_COMPAT_IMAGIC_INODES|\ 550342d847db355d81299218e07a1e58ece82080a04Theodore Ts'o EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ 551d323f8fb369089b97d6f3bf0f8d64ceeab0b10f5Theodore Ts'o EXT2_FEATURE_COMPAT_RESIZE_INODE|\ 55252783e0ca72a80c549e9d266b3472f78fc61bdb2Theodore Ts'o EXT2_FEATURE_COMPAT_DIR_INDEX|\ 553342d847db355d81299218e07a1e58ece82080a04Theodore Ts'o EXT2_FEATURE_COMPAT_EXT_ATTR) 5542fe1efe2e56dc9f8223992301aec3844dd9563e6Theodore Ts'o 5555a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o/* This #ifdef is temporary until compression is fully supported */ 5565a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o#ifdef ENABLE_COMPRESSION 557e589f678e1ed5efa8dd4450f37bee0486caa3504Theodore Ts'o#ifndef I_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL 558e589f678e1ed5efa8dd4450f37bee0486caa3504Theodore Ts'o/* If the below warning bugs you, then have 559e589f678e1ed5efa8dd4450f37bee0486caa3504Theodore Ts'o `CPPFLAGS=-DI_KNOW_THAT_COMPRESSION_IS_EXPERIMENTAL' in your 560e589f678e1ed5efa8dd4450f37bee0486caa3504Theodore Ts'o environment at configure time. */ 561cdaf1fa78f6d63457eb5337c14b23e567d1346a7Theodore Ts'o #warning "Compression support is experimental" 562e589f678e1ed5efa8dd4450f37bee0486caa3504Theodore Ts'o#endif 5635a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\ 564ab146766e3c773ef532381328772ec5e9db9e40bTheodore Ts'o EXT2_FEATURE_INCOMPAT_COMPRESSION|\ 565a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'o EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\ 566c046ac7f2e4c53e20cf1e909bbe511f91074b396Theodore Ts'o EXT2_FEATURE_INCOMPAT_META_BG|\ 567c2d4300b8a4a13d8a78b86c386f76259f23feec2Jose R. Santos EXT3_FEATURE_INCOMPAT_RECOVER|\ 56815d482ba6e46b6979d8d9e9b3b28e0942b626c2eTheodore Ts'o EXT3_FEATURE_INCOMPAT_EXTENTS|\ 569e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_INCOMPAT_FLEX_BG|\ 570e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_INCOMPAT_MMP|\ 571e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_INCOMPAT_64BIT) 5725a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o#else 573ab146766e3c773ef532381328772ec5e9db9e40bTheodore Ts'o#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\ 574a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'o EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\ 575c046ac7f2e4c53e20cf1e909bbe511f91074b396Theodore Ts'o EXT2_FEATURE_INCOMPAT_META_BG|\ 576c2d4300b8a4a13d8a78b86c386f76259f23feec2Jose R. Santos EXT3_FEATURE_INCOMPAT_RECOVER|\ 57715d482ba6e46b6979d8d9e9b3b28e0942b626c2eTheodore Ts'o EXT3_FEATURE_INCOMPAT_EXTENTS|\ 578e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_INCOMPAT_FLEX_BG|\ 579e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_INCOMPAT_MMP|\ 580e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_INCOMPAT_64BIT) 5815a63dd28f23e31f4ed47073b558fc701adf83536Theodore Ts'o#endif 582e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#ifdef CONFIG_QUOTA 583674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\ 5841ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'o EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\ 585a7c9cb7d0dc464eda26958595b728a6c3a4cacbcAndreas Dilger EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\ 586d4f34d41be97e23db07d5ed606fcc1a26f5a3c76Jose R. Santos EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\ 5872be8fe43976537b75a6ee154ff3ba47e538b55fbTheodore Ts'o EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\ 588e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\ 589e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_BIGALLOC|\ 590e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_QUOTA) 591e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#else 592e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\ 593e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\ 594e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\ 595e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\ 596e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\ 597e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\ 598e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT4_FEATURE_RO_COMPAT_BIGALLOC) 599e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif 600cf8272e1081f69d898d5182ed516e28807135deaTheodore Ts'o 601cf8272e1081f69d898d5182ed516e28807135deaTheodore Ts'o/* 602cf8272e1081f69d898d5182ed516e28807135deaTheodore Ts'o * These features are only allowed if EXT2_FLAG_SOFTSUPP_FEATURES is passed 603cf8272e1081f69d898d5182ed516e28807135deaTheodore Ts'o * to ext2fs_openfs() 604cf8272e1081f69d898d5182ed516e28807135deaTheodore Ts'o */ 6051ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'o#define EXT2_LIB_SOFTSUPP_INCOMPAT (0) 606e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_LIB_SOFTSUPP_RO_COMPAT (EXT4_FEATURE_RO_COMPAT_REPLICA) 607e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 608e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 609e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* Translate a block number to a cluster number */ 610e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_CLUSTER_RATIO(fs) (1 << (fs)->cluster_ratio_bits) 611e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_CLUSTER_MASK(fs) (EXT2FS_CLUSTER_RATIO(fs) - 1) 612e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_B2C(fs, blk) ((blk) >> (fs)->cluster_ratio_bits) 613e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* Translate a cluster number to a block number */ 614e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_C2B(fs, cluster) ((cluster) << (fs)->cluster_ratio_bits) 615e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* Translate # of blks to # of clusters */ 616e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2FS_NUM_B2C(fs, blks) (((blks) + EXT2FS_CLUSTER_MASK(fs)) >> \ 617e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall (fs)->cluster_ratio_bits) 618e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 619e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED) 620e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef struct stat64 ext2fs_struct_stat; 621e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#else 622e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgralltypedef struct stat ext2fs_struct_stat; 623e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif 624e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 625e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* 626e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * For ext2fs_close2() and ext2fs_flush2(), this flag allows you to 627e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * avoid the fsync call. 628e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall */ 629e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define EXT2_FLAG_FLUSH_NO_SYNC 1 6309d9a53e651fa877eb4f9df0bfd97fbcc5f514293Richard W.M. Jones 6319d9a53e651fa877eb4f9df0bfd97fbcc5f514293Richard W.M. Jones/* 6323839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * function prototypes 6333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 6343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 635e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* The LARGE_FILE feature should be set if we have stored files 2GB+ in size */ 636e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallstatic inline int ext2fs_needs_large_file_feature(unsigned long long file_size) 637e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall{ 638e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return file_size >= 0x80000000ULL; 639e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall} 640e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 6413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* alloc.c */ 64231dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode, 64331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2fs_inode_bitmap map, ext2_ino_t *ret); 6443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, 645f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o ext2fs_block_bitmap map, blk_t *ret); 646e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal, 647e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_block_bitmap map, blk64_t *ret); 6483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, 649f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o blk_t finish, int num, 650f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o ext2fs_block_bitmap map, 6513839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o blk_t *ret); 652e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, 653e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t finish, int num, 654e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_block_bitmap map, 655e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *ret); 65630fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'oextern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, 65730fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o char *block_buf, blk_t *ret); 658e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal, 659e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall char *block_buf, blk64_t *ret); 660efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern void ext2fs_set_alloc_block_callback(ext2_filsys fs, 661f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o errcode_t (*func)(ext2_filsys fs, 662f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o blk64_t goal, 663f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o blk64_t *ret), 664f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o errcode_t (**old)(ext2_filsys fs, 665f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o blk64_t goal, 666f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o blk64_t *ret)); 6673839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 668ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o/* alloc_sb.c */ 669efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, 670ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o dgrp_t group, 671ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o ext2fs_block_bitmap bmap); 672efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, 673f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o void (*func)(ext2_filsys fs, 674f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o blk64_t blk, 675f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o int inuse), 676f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o void (**old)(ext2_filsys fs, 677f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o blk64_t blk, 678f5c562e2324a8950d659ebfc8db4356121d6104eTheodore Ts'o int inuse)); 679ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o 6808bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o/* alloc_stats.c */ 6818bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'ovoid ext2fs_inode_alloc_stats(ext2_filsys fs, ext2_ino_t ino, int inuse); 6827f961d424b1ba527e835d01ad24e0e4c3f4088c5Theodore Ts'ovoid ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino, 6837f961d424b1ba527e835d01ad24e0e4c3f4088c5Theodore Ts'o int inuse, int isdir); 6848bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'ovoid ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse); 685e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallvoid ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse); 6868bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o 6871e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o/* alloc_tables.c */ 6881e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'oextern errcode_t ext2fs_allocate_tables(ext2_filsys fs); 6892eb374c9401079aa56aa12f0047ca3866e69b754Theodore Ts'oextern errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, 6901e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o ext2fs_block_bitmap bmap); 69119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 6923839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* badblocks.c */ 693b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern errcode_t ext2fs_u32_list_create(ext2_u32_list *ret, int size); 694b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk); 695544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'oextern int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk); 696b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern int ext2fs_u32_list_test(ext2_u32_list bb, blk_t blk); 697b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb, 698b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'o ext2_u32_iterate *ret); 699b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern int ext2fs_u32_list_iterate(ext2_u32_iterate iter, blk_t *blk); 700b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern void ext2fs_u32_list_iterate_end(ext2_u32_iterate iter); 701b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest); 702b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern int ext2fs_u32_list_equal(ext2_u32_list bb1, ext2_u32_list bb2); 703b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'o 70419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, 70519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int size); 70619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern errcode_t ext2fs_badblocks_list_add(ext2_badblocks_list bb, 70719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o blk_t blk); 70819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern int ext2fs_badblocks_list_test(ext2_badblocks_list bb, 70919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o blk_t blk); 7107d7bdd578b307cad1dc248310eb279c6fb73b682Theodore Ts'oextern int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk); 7117d7bdd578b307cad1dc248310eb279c6fb73b682Theodore Ts'oextern void ext2fs_badblocks_list_del(ext2_u32_list bb, __u32 blk); 71219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern errcode_t 71319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2fs_badblocks_list_iterate_begin(ext2_badblocks_list bb, 71419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2_badblocks_iterate *ret); 71519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern int ext2fs_badblocks_list_iterate(ext2_badblocks_iterate iter, 71619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o blk_t *blk); 71719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter); 718a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern errcode_t ext2fs_badblocks_copy(ext2_badblocks_list src, 719a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o ext2_badblocks_list *dest); 72057dca85467cf3fc61565e916a5f2e35db8020d88Theodore Ts'oextern int ext2fs_badblocks_equal(ext2_badblocks_list bb1, 72157dca85467cf3fc61565e916a5f2e35db8020d88Theodore Ts'o ext2_badblocks_list bb2); 722220c0040fb4a5e8a2a091a9e3a936bb8a85223d8Theodore Ts'oextern int ext2fs_u32_list_count(ext2_u32_list bb); 72319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 72419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* bb_compat */ 7253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t badblocks_list_create(badblocks_list *ret, int size); 7263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t badblocks_list_add(badblocks_list bb, blk_t blk); 7273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern int badblocks_list_test(badblocks_list bb, blk_t blk); 7283839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t badblocks_list_iterate_begin(badblocks_list bb, 7293839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o badblocks_iterate *ret); 7303839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern int badblocks_list_iterate(badblocks_iterate iter, blk_t *blk); 7313839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void badblocks_list_iterate_end(badblocks_iterate iter); 732a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern void badblocks_list_free(badblocks_list bb); 7333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 7343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* bb_inode.c */ 7353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_update_bb_inode(ext2_filsys fs, 73619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2_badblocks_list bb_list); 7373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 7383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* bitmaps.c */ 739a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap); 740a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap); 741f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src, 742f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o ext2fs_generic_bitmap *dest); 7433839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs); 7443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs); 7453839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs); 7463839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs); 74750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, 74850e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o const char *descr, 74950e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o ext2fs_block_bitmap *ret); 750e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_allocate_subcluster_bitmap(ext2_filsys fs, 751e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall const char *descr, 752e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_block_bitmap *ret); 753e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_get_bitmap_granularity(ext2fs_block_bitmap bitmap); 75450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, 75550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o const char *descr, 75650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o ext2fs_inode_bitmap *ret); 75750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_fudge_inode_bitmap_end(ext2fs_inode_bitmap bitmap, 75831dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t end, ext2_ino_t *oend); 75950e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_fudge_block_bitmap_end(ext2fs_block_bitmap bitmap, 76050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o blk_t end, blk_t *oend); 761e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_fudge_block_bitmap_end2(ext2fs_block_bitmap bitmap, 762e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t end, blk64_t *oend); 76350e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern void ext2fs_clear_inode_bitmap(ext2fs_inode_bitmap bitmap); 76450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap); 7653839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_read_bitmaps(ext2_filsys fs); 7663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_write_bitmaps(ext2_filsys fs); 76750448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'oextern errcode_t ext2fs_resize_inode_bitmap(__u32 new_end, __u32 new_real_end, 76850448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_inode_bitmap bmap); 769e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_resize_inode_bitmap2(__u64 new_end, 770e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 new_real_end, 771e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_inode_bitmap bmap); 77250448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'oextern errcode_t ext2fs_resize_block_bitmap(__u32 new_end, __u32 new_real_end, 77350448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_block_bitmap bmap); 774e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_resize_block_bitmap2(__u64 new_end, 775e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 new_real_end, 776e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_block_bitmap bmap); 77750448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'oextern errcode_t ext2fs_compare_block_bitmap(ext2fs_block_bitmap bm1, 77850448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_block_bitmap bm2); 77950448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'oextern errcode_t ext2fs_compare_inode_bitmap(ext2fs_inode_bitmap bm1, 78050448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_inode_bitmap bm2); 781f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_set_inode_bitmap_range(ext2fs_inode_bitmap bmap, 782f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o ext2_ino_t start, unsigned int num, 783f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o void *in); 784e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_set_inode_bitmap_range2(ext2fs_inode_bitmap bmap, 785e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 start, size_t num, 786e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *in); 787f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap, 788f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o ext2_ino_t start, unsigned int num, 789f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o void *out); 790e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_inode_bitmap_range2(ext2fs_inode_bitmap bmap, 791e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 start, size_t num, 792e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *out); 793f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap, 794f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o blk_t start, unsigned int num, 795f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o void *in); 796e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_set_block_bitmap_range2(ext2fs_block_bitmap bmap, 797e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t start, size_t num, 798e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *in); 799f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_get_block_bitmap_range(ext2fs_block_bitmap bmap, 800f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o blk_t start, unsigned int num, 801f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o void *out); 802e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_block_bitmap_range2(ext2fs_block_bitmap bmap, 803e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t start, size_t num, 804e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *out); 805e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 806e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* blknum.c */ 807e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t); 808e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group); 809e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_group_last_block2(ext2_filsys fs, dgrp_t group); 810e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_group_blocks_count(ext2_filsys fs, dgrp_t group); 811e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_inode_data_blocks2(ext2_filsys fs, 812e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_inode *inode); 813e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_inode_i_blocks(ext2_filsys fs, 814e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_inode *inode); 815e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_blocks_count(struct ext2_super_block *super); 816e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_blocks_count_set(struct ext2_super_block *super, 817e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 818e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_blocks_count_add(struct ext2_super_block *super, 819e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 820e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_r_blocks_count(struct ext2_super_block *super); 821e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_r_blocks_count_set(struct ext2_super_block *super, 822e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 823e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_r_blocks_count_add(struct ext2_super_block *super, 824e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 825e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_free_blocks_count(struct ext2_super_block *super); 826e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_free_blocks_count_set(struct ext2_super_block *super, 827e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 828e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_free_blocks_count_add(struct ext2_super_block *super, 829e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 830e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* Block group descriptor accessor functions */ 831e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs, 832e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct opaque_ext2_group_desc *gdp, 833e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall dgrp_t group); 834e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_block_bitmap_loc(ext2_filsys fs, dgrp_t group); 835e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group, 836e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 837e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group); 838e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_inode_bitmap_loc_set(ext2_filsys fs, dgrp_t group, 839e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 840e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_inode_table_loc(ext2_filsys fs, dgrp_t group); 841e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_inode_table_loc_set(ext2_filsys fs, dgrp_t group, 842e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk); 843e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u32 ext2fs_bg_free_blocks_count(ext2_filsys fs, dgrp_t group); 844e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_free_blocks_count_set(ext2_filsys fs, dgrp_t group, 845e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 n); 846e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u32 ext2fs_bg_free_inodes_count(ext2_filsys fs, dgrp_t group); 847e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_free_inodes_count_set(ext2_filsys fs, dgrp_t group, 848e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 n); 849e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u32 ext2fs_bg_used_dirs_count(ext2_filsys fs, dgrp_t group); 850e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_used_dirs_count_set(ext2_filsys fs, dgrp_t group, 851e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 n); 852e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u32 ext2fs_bg_itable_unused(ext2_filsys fs, dgrp_t group); 853e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_itable_unused_set(ext2_filsys fs, dgrp_t group, 854e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 n); 855e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u16 ext2fs_bg_flags(ext2_filsys fs, dgrp_t group); 856e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_flags_zap(ext2_filsys fs, dgrp_t group); 857e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_bg_flags_test(ext2_filsys fs, dgrp_t group, __u16 bg_flag); 858e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags); 859e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flags); 860e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u16 ext2fs_bg_checksum(ext2_filsys fs, dgrp_t group); 861e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_bg_checksum_set(ext2_filsys fs, dgrp_t group, __u16 checksum); 862e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_file_acl_block(ext2_filsys fs, 863e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall const struct ext2_inode *inode); 864e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_file_acl_block_set(ext2_filsys fs, 865e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_inode *inode, blk64_t blk); 8663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 8673839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* block.c */ 8683839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_block_iterate(ext2_filsys fs, 86931dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t ino, 8703839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o int flags, 8713839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o char *block_buf, 8723839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o int (*func)(ext2_filsys fs, 8733839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o blk_t *blocknr, 8743839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o int blockcnt, 875b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data), 876b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data); 87719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oerrcode_t ext2fs_block_iterate2(ext2_filsys fs, 87831dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t ino, 87919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int flags, 88019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o char *block_buf, 88119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int (*func)(ext2_filsys fs, 88219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o blk_t *blocknr, 88303673dbb04a3458ce78a394f27d17d434b51a714Theodore Ts'o e2_blkcnt_t blockcnt, 884674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o blk_t ref_blk, 885674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o int ref_offset, 886674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o void *priv_data), 887674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o void *priv_data); 888e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_block_iterate3(ext2_filsys fs, 889e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2_ino_t ino, 890e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int flags, 891e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall char *block_buf, 892e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int (*func)(ext2_filsys fs, 893e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *blocknr, 894e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall e2_blkcnt_t blockcnt, 895e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t ref_blk, 896e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int ref_offset, 897e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *priv_data), 898e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *priv_data); 89919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 90030fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o/* bmap.c */ 90131dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, 902efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o struct ext2_inode *inode, 90330fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o char *block_buf, int bmap_flags, 90430fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o blk_t block, blk_t *phys_blk); 905efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, 906cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o struct ext2_inode *inode, 907cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o char *block_buf, int bmap_flags, blk64_t block, 908cc9bf5d246fc23267e14cc328728f146aee142e2Theodore Ts'o int *ret_flags, blk64_t *phys_blk); 909e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino, 910e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_inode *inode, blk64_t lblk, 911e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *pblk); 91230fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 9134a31c48b827f378f386b28461fd14b41d709e4ebTheodore Ts'o#if 0 9141e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o/* bmove.c */ 9151e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'oextern errcode_t ext2fs_move_blocks(ext2_filsys fs, 9161e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o ext2fs_block_bitmap reserve, 9179941fb73f530b11d3d1dcc97a585f63449703f5aTheodore Ts'o ext2fs_block_bitmap alloc_map, 9181e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o int flags); 9194a31c48b827f378f386b28461fd14b41d709e4ebTheodore Ts'o#endif 9201e1da29fbd4204a267ebd7c64d37e1f95a9dad08Theodore Ts'o 921f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o/* check_desc.c */ 922f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'oextern errcode_t ext2fs_check_desc(ext2_filsys fs); 923f3db3566b5e1342e49dffc5ec3f418a838584194Theodore Ts'o 9243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* closefs.c */ 9253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_close(ext2_filsys fs); 926e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_close2(ext2_filsys fs, int flags); 9273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_flush(ext2_filsys fs); 928e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_flush2(ext2_filsys fs, int flags); 929e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group_block); 930e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs, 931e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall dgrp_t group, 932e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *ret_super_blk, 933e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *ret_old_desc_blk, 934e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *ret_new_desc_blk, 935e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk_t *ret_used_blks); 936efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern int ext2fs_super_and_bgd_loc(ext2_filsys fs, 937ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o dgrp_t group, 938ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o blk_t *ret_super_blk, 939ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o blk_t *ret_old_desc_blk, 940ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o blk_t *ret_new_desc_blk, 941ef344e13d2125e9dae3764b98f9fe3a170cd79e2Theodore Ts'o int *ret_meta_bg); 9421b4cd9c7464d5bd0f5b416c7303bcc827e312473Theodore Ts'oextern void ext2fs_update_dynamic_rev(ext2_filsys fs); 9433839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 944e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* crc32c.c */ 945e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u32 ext2fs_crc32c_be(__u32 crc, unsigned char const *p, size_t len); 946e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u32 ext2fs_crc32c_le(__u32 crc, unsigned char const *p, size_t len); 947e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 948ca2634a46ab9da85a3a015a7772770d9dbe5848eJose R. Santos/* csum.c */ 949ca2634a46ab9da85a3a015a7772770d9dbe5848eJose R. Santosextern void ext2fs_group_desc_csum_set(ext2_filsys fs, dgrp_t group); 950ca2634a46ab9da85a3a015a7772770d9dbe5848eJose R. Santosextern int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group); 951f628acea2671dda839fc086f1017718e41e34ecaAndreas Dilgerextern errcode_t ext2fs_set_gdt_csum(ext2_filsys fs); 952e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u16 ext2fs_group_desc_csum(ext2_filsys fs, dgrp_t group); 953ca2634a46ab9da85a3a015a7772770d9dbe5848eJose R. Santos 95419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* dblist.c */ 95519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 95631dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs); 957a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern errcode_t ext2fs_init_dblist(ext2_filsys fs, ext2_dblist *ret_dblist); 95831dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, 959a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o blk_t blk, int blockcnt); 960e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino, 961e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk, e2_blkcnt_t blockcnt); 962ea1959f01523ffc105747d660ccc5b7f02805928Theodore Ts'oextern void ext2fs_dblist_sort(ext2_dblist dblist, 963ea1959f01523ffc105747d660ccc5b7f02805928Theodore Ts'o EXT2_QSORT_TYPE (*sortfunc)(const void *, 964ea1959f01523ffc105747d660ccc5b7f02805928Theodore Ts'o const void *)); 965e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_dblist_sort2(ext2_dblist dblist, 966e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall EXT2_QSORT_TYPE (*sortfunc)(const void *, 967e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall const void *)); 968a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, 969a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o int (*func)(ext2_filsys fs, struct ext2_db_entry *db_info, 970b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data), 971b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data); 972e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_dblist_iterate2(ext2_dblist dblist, 973e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int (*func)(ext2_filsys fs, struct ext2_db_entry2 *db_info, 974e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *priv_data), 975e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *priv_data); 97631dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, 977a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o blk_t blk, int blockcnt); 978e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_set_dir_block2(ext2_dblist dblist, ext2_ino_t ino, 979e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t blk, e2_blkcnt_t blockcnt); 980a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern errcode_t ext2fs_copy_dblist(ext2_dblist src, 981a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o ext2_dblist *dest); 982549860c5c7a5a2974c103a55d881fbd5701aff13Theodore Ts'oextern int ext2fs_dblist_count(ext2_dblist dblist); 983e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_dblist_count2(ext2_dblist dblist); 984efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, 98552b1dd5e496c199e9cbcc238f26fd2264a07a2cfTheodore Ts'o struct ext2_db_entry **entry); 986e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_dblist_get_last2(ext2_dblist dblist, 987e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_db_entry2 **entry); 98852b1dd5e496c199e9cbcc238f26fd2264a07a2cfTheodore Ts'oextern errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist); 98919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 99019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* dblist_dir.c */ 99119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern errcode_t 99219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2fs_dblist_dir_iterate(ext2_dblist dblist, 99319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int flags, 99419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o char *block_buf, 99531dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o int (*func)(ext2_ino_t dir, 99619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int entry, 99719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o struct ext2_dir_entry *dirent, 99819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int offset, 99919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int blocksize, 100019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o char *buf, 1001b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data), 1002b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data); 100350e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 100450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o/* dirblock.c */ 100550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block, 100650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o void *buf); 1007f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'oextern errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block, 1008f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o void *buf, int flags); 1009e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_read_dir_block3(ext2_filsys fs, blk64_t block, 1010e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *buf, int flags); 101150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_write_dir_block(ext2_filsys fs, blk_t block, 101250e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o void *buf); 1013f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'oextern errcode_t ext2fs_write_dir_block2(ext2_filsys fs, blk_t block, 1014f9190c8a95c6b76eac567d5896b3ed06ed2a3adaTheodore Ts'o void *buf, int flags); 1015e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_write_dir_block3(ext2_filsys fs, blk64_t block, 1016e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *buf, int flags); 101750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 101852783e0ca72a80c549e9d266b3472f78fc61bdb2Theodore Ts'o/* dirhash.c */ 101952783e0ca72a80c549e9d266b3472f78fc61bdb2Theodore Ts'oextern errcode_t ext2fs_dirhash(int version, const char *name, int len, 1020b33278c4d640c3fc8f99a314b637b7e502fceb9cTheodore Ts'o const __u32 *seed, 1021503f9e7f6eb331c5b75d7f1ad126f71bcdcfb4e3Theodore Ts'o ext2_dirhash_t *ret_hash, 1022503f9e7f6eb331c5b75d7f1ad126f71bcdcfb4e3Theodore Ts'o ext2_dirhash_t *ret_minor_hash); 102352783e0ca72a80c549e9d266b3472f78fc61bdb2Theodore Ts'o 102452783e0ca72a80c549e9d266b3472f78fc61bdb2Theodore Ts'o 102519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* dir_iterate.c */ 10268a480350952f6f0fdbce54326b6d847e66368897Theodore Ts'oextern errcode_t ext2fs_get_rec_len(ext2_filsys fs, 10278a480350952f6f0fdbce54326b6d847e66368897Theodore Ts'o struct ext2_dir_entry *dirent, 10288a480350952f6f0fdbce54326b6d847e66368897Theodore Ts'o unsigned int *rec_len); 10298a480350952f6f0fdbce54326b6d847e66368897Theodore Ts'oextern errcode_t ext2fs_set_rec_len(ext2_filsys fs, 10308a480350952f6f0fdbce54326b6d847e66368897Theodore Ts'o unsigned int len, 10318a480350952f6f0fdbce54326b6d847e66368897Theodore Ts'o struct ext2_dir_entry *dirent); 1032efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_dir_iterate(ext2_filsys fs, 103331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t dir, 103419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int flags, 103519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o char *block_buf, 103619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int (*func)(struct ext2_dir_entry *dirent, 103719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int offset, 103819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int blocksize, 103919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o char *buf, 1040b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data), 1041b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void *priv_data); 1042efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_dir_iterate2(ext2_filsys fs, 10438bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o ext2_ino_t dir, 10448bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o int flags, 10458bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o char *block_buf, 10468bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o int (*func)(ext2_ino_t dir, 10478bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o int entry, 10488bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o struct ext2_dir_entry *dirent, 10498bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o int offset, 10508bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o int blocksize, 10518bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o char *buf, 10528bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o void *priv_data), 10538bd0c95908baa3af706b9e731daff9472bec74c9Theodore Ts'o void *priv_data); 105419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 1055a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'o/* dupfs.c */ 1056a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest); 105719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o 10583839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* expanddir.c */ 105931dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir); 10603839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1061342d847db355d81299218e07a1e58ece82080a04Theodore Ts'o/* ext_attr.c */ 1062fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilgerextern __u32 ext2fs_ext_attr_hash_entry(struct ext2_ext_attr_entry *entry, 1063fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilger void *data); 1064342d847db355d81299218e07a1e58ece82080a04Theodore Ts'oextern errcode_t ext2fs_read_ext_attr(ext2_filsys fs, blk_t block, void *buf); 1065e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_read_ext_attr2(ext2_filsys fs, blk64_t block, 1066e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *buf); 10670684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'oextern errcode_t ext2fs_write_ext_attr(ext2_filsys fs, blk_t block, 10680684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o void *buf); 1069e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_write_ext_attr2(ext2_filsys fs, blk64_t block, 1070e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *buf); 10710684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'oextern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk, 10720684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o char *block_buf, 10730684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o int adjust, __u32 *newcount); 1074e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_adjust_ea_refcount2(ext2_filsys fs, blk64_t blk, 1075e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall char *block_buf, 1076e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int adjust, __u32 *newcount); 10770684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o 10783eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o/* extent.c */ 10793eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_header_verify(void *ptr, int size); 10803eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino, 10813eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o ext2_extent_handle_t *handle); 108284b239aea4da04c7a569b428d3abf6c720e82645numberextern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino, 108384b239aea4da04c7a569b428d3abf6c720e82645number struct ext2_inode *inode, 108484b239aea4da04c7a569b428d3abf6c720e82645number ext2_extent_handle_t *ret_handle); 10852d328bb76d2d63bdfdba923b54c28bd686bd8fecTheodore Ts'oextern void ext2fs_extent_free(ext2_extent_handle_t handle); 10863eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle, 10873eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o int flags, struct ext2fs_extent *extent); 1088e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle); 10893eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags, 10903eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o struct ext2fs_extent *extent); 10913eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_insert(ext2_extent_handle_t handle, int flags, 10923eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o struct ext2fs_extent *extent); 1093f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeenextern errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle, 1094f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen blk64_t logical, blk64_t physical, 1095f4e9963c0966734d8dc16877753698193b83cd65Eric Sandeen int flags); 10963eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags); 10973eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_get_info(ext2_extent_handle_t handle, 10983eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o struct ext2_extent_info *info); 10993eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'oextern errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle, 11003eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o blk64_t blk); 1101e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_extent_goto2(ext2_extent_handle_t handle, 1102e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int leaf_level, blk64_t blk); 1103e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle); 11043eb07f649350acfd9e145584d57aac3c1b65d0baTheodore Ts'o 110530fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o/* fileio.c */ 1106a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'oextern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, 1107a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o struct ext2_inode *inode, 1108a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o int flags, ext2_file_t *ret); 110931dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino, 111030fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o int flags, ext2_file_t *ret); 111179a90bdad033e101c38bb3c3207c8f4be47a2de7Theodore Ts'oextern ext2_filsys ext2fs_file_get_fs(ext2_file_t file); 1112e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallstruct ext2_inode *ext2fs_file_get_inode(ext2_file_t file); 1113e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern ext2_ino_t ext2fs_file_get_inode_num(ext2_file_t file); 111430fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'oextern errcode_t ext2fs_file_close(ext2_file_t file); 1115f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern errcode_t ext2fs_file_flush(ext2_file_t file); 111630fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'oextern errcode_t ext2fs_file_read(ext2_file_t file, void *buf, 111779a90bdad033e101c38bb3c3207c8f4be47a2de7Theodore Ts'o unsigned int wanted, unsigned int *got); 1118f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, 111979a90bdad033e101c38bb3c3207c8f4be47a2de7Theodore Ts'o unsigned int nbytes, unsigned int *written); 1120819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'oextern errcode_t ext2fs_file_llseek(ext2_file_t file, __u64 offset, 1121819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'o int whence, __u64 *ret_pos); 1122674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'oextern errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset, 1123674a4ee1e3e05133ddad701730bfc21c283272a4Theodore Ts'o int whence, ext2_off_t *ret_pos); 1124819157db798cd514aa2f3ae421d64e2e0c9b7fa8Theodore Ts'oerrcode_t ext2fs_file_get_lsize(ext2_file_t file, __u64 *ret_size); 112579a90bdad033e101c38bb3c3207c8f4be47a2de7Theodore Ts'oextern ext2_off_t ext2fs_file_get_size(ext2_file_t file); 112679a90bdad033e101c38bb3c3207c8f4be47a2de7Theodore Ts'oextern errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size); 1127e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size); 112830fab293065b7fc6d7d138e8e9eea533a3560873Theodore Ts'o 1129de23aa1d177a67283f5f5a1f172b00527fe3b63aTheodore Ts'o/* finddev.c */ 1130de23aa1d177a67283f5f5a1f172b00527fe3b63aTheodore Ts'oextern char *ext2fs_find_block_device(dev_t device); 1131de23aa1d177a67283f5f5a1f172b00527fe3b63aTheodore Ts'o 11324d0f3e17a5b7556505fe437680070fe3bb140d67Theodore Ts'o/* flushb.c */ 11334d0f3e17a5b7556505fe437680070fe3bb140d67Theodore Ts'oextern errcode_t ext2fs_sync_device(int fd, int flushb); 11344d0f3e17a5b7556505fe437680070fe3bb140d67Theodore Ts'o 11353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* freefs.c */ 11363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_free(ext2_filsys fs); 1137a29f4d30f24d68f1f1c75548e020689ede532c05Theodore Ts'oextern void ext2fs_free_dblist(ext2_dblist dblist); 1138b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern void ext2fs_badblocks_list_free(ext2_badblocks_list bb); 1139b7a00563b22b0ea47ddc7117508c0b8e0d65df43Theodore Ts'oextern void ext2fs_u32_list_free(ext2_u32_list bb); 114050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 1141a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o/* gen_bitmap.c */ 1142a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap); 1143efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, 1144efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o __u32 start, __u32 end, 1145a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o __u32 real_end, 1146a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o const char *descr, char *init_map, 1147a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o ext2fs_generic_bitmap *ret); 1148a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern errcode_t ext2fs_allocate_generic_bitmap(__u32 start, 1149a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o __u32 end, 1150a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o __u32 real_end, 1151a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o const char *descr, 1152a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o ext2fs_generic_bitmap *ret); 1153a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, 1154a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o ext2fs_generic_bitmap *dest); 1155a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap); 1156a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, 1157efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o errcode_t magic, 1158a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o errcode_t neq, 1159efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o ext2_ino_t end, 1160a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'o ext2_ino_t *oend); 1161a0553c9d6e8dd6f538f18ae447c45e52f3c40eb6Theodore Ts'oextern void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map); 116250448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'oextern errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, 116350448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o __u32 new_end, 116450448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o __u32 new_real_end, 116550448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_generic_bitmap bmap); 116650448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'oextern errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq, 116750448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_generic_bitmap bm1, 116850448d3dffc66f86592ee0d4b16e4bbe9d08449eTheodore Ts'o ext2fs_generic_bitmap bm2); 1169f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_get_generic_bitmap_range(ext2fs_generic_bitmap bmap, 1170f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o errcode_t magic, 1171f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o __u32 start, __u32 num, 1172f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o void *out); 1173f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'oextern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap, 1174f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o errcode_t magic, 1175f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o __u32 start, __u32 num, 1176f1f115a78f5ea599fc5f8815a741d43fedd5840dTheodore Ts'o void *in); 1177e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_find_first_zero_generic_bitmap(ext2fs_generic_bitmap bitmap, 1178e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 start, __u32 end, 1179e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 *out); 1180e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1181e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* gen_bitmap64.c */ 1182e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1183e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* Generate and print bitmap usage statistics */ 1184e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define BMAP_STATS 1185e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1186e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallvoid ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap); 1187e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, 1188e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall int type, __u64 start, __u64 end, 1189e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 real_end, 1190e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall const char *descr, 1191e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_generic_bitmap *ret); 1192e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src, 1193e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_generic_bitmap *dest); 1194e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallvoid ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap); 1195e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap, 1196e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall errcode_t neq, 1197e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 end, __u64 *oend); 1198e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallvoid ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap); 1199e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap, 1200e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 new_end, 1201e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 new_real_end); 1202e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_compare_generic_bmap(errcode_t neq, 1203e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_generic_bitmap bm1, 1204e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_generic_bitmap bm2); 1205e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap, 1206e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 start, unsigned int num, 1207e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *out); 1208e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap, 1209e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u64 start, unsigned int num, 1210e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *in); 1211e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs, 1212e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall ext2fs_block_bitmap *bitmap); 12138f82ef9860339039b54a324be137fbc09b762358Valerie Aurora Henson 121450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o/* getsize.c */ 121550e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_get_device_size(const char *file, int blocksize, 121650e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o blk_t *retblocks); 1217beab8de477110970785077fb3204f171d3fcc485Jose R. Santosextern errcode_t ext2fs_get_device_size2(const char *file, int blocksize, 1218beab8de477110970785077fb3204f171d3fcc485Jose R. Santos blk64_t *retblocks); 12193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 122093d5c38791a3778eed18fe968cdd136d23d0fa07Theodore Ts'o/* getsectsize.c */ 1221e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_get_dio_alignment(int fd); 122293d5c38791a3778eed18fe968cdd136d23d0fa07Theodore Ts'oerrcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize); 1223bb1158b92ed8a12ab9e9317ca6ddd97bc12447d3Theodore Ts'oerrcode_t ext2fs_get_device_phys_sectsize(const char *file, int *sectsize); 122493d5c38791a3778eed18fe968cdd136d23d0fa07Theodore Ts'o 12251ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'o/* i_block.c */ 12261ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'oerrcode_t ext2fs_iblk_add_blocks(ext2_filsys fs, struct ext2_inode *inode, 12271ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'o blk64_t num_blocks); 12281ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'oerrcode_t ext2fs_iblk_sub_blocks(ext2_filsys fs, struct ext2_inode *inode, 12291ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'o blk64_t num_blocks); 12301ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'oerrcode_t ext2fs_iblk_set(ext2_filsys fs, struct ext2_inode *inode, blk64_t b); 12311ca1059fd0126fd2c065f272a566c18f14bab16dTheodore Ts'o 123272ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o/* imager.c */ 123372ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags); 123472ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags); 123572ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags); 123672ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags); 123772ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags); 123872ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags); 123972ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'o 1240dc8ce3463791366ac844d3f0436709511fa09c49Theodore Ts'o/* ind_block.c */ 1241dc8ce3463791366ac844d3f0436709511fa09c49Theodore Ts'oerrcode_t ext2fs_read_ind_block(ext2_filsys fs, blk_t blk, void *buf); 1242dc8ce3463791366ac844d3f0436709511fa09c49Theodore Ts'oerrcode_t ext2fs_write_ind_block(ext2_filsys fs, blk_t blk, void *buf); 1243dc8ce3463791366ac844d3f0436709511fa09c49Theodore Ts'o 12443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* initialize.c */ 12453839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_initialize(const char *name, int flags, 12463839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o struct ext2_super_block *param, 12473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o io_manager manager, ext2_filsys *ret_fs); 12483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1249f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o/* icount.c */ 1250f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern void ext2fs_free_icount(ext2_icount_t icount); 12511b9d8cb7057387afae106ffa662613205f07e131Theodore Ts'oextern errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir, 12521b9d8cb7057387afae106ffa662613205f07e131Theodore Ts'o int flags, ext2_icount_t *ret); 1253efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, 1254544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o unsigned int size, 1255f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o ext2_icount_t hint, ext2_icount_t *ret); 1256efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, 1257544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o unsigned int size, 1258f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o ext2_icount_t *ret); 1259f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, 1260f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o __u16 *ret); 1261f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern errcode_t ext2fs_icount_increment(ext2_icount_t icount, ext2_ino_t ino, 1262f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o __u16 *ret); 1263f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern errcode_t ext2fs_icount_decrement(ext2_icount_t icount, ext2_ino_t ino, 1264f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o __u16 *ret); 1265f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern errcode_t ext2fs_icount_store(ext2_icount_t icount, ext2_ino_t ino, 1266f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o __u16 count); 1267f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern ext2_ino_t ext2fs_get_icount_size(ext2_icount_t icount); 1268f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oerrcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *); 1269f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o 1270e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* inline.c */ 1271e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1272e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_memalign(unsigned long size, 1273e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall unsigned long align, void *ptr); 1274e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 12753839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* inode.c */ 127672ed12648368b3f3ea14e8102e20bf5d3a3be6d3Theodore Ts'oextern errcode_t ext2fs_flush_icache(ext2_filsys fs); 1277efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, 12787331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o ext2_ino_t *ino, 1279efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o struct ext2_inode *inode, 12807331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o int bufsize); 12813839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, 12823839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o ext2_inode_scan *ret_scan); 12833839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_close_inode_scan(ext2_inode_scan scan); 128431dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_get_next_inode(ext2_inode_scan scan, ext2_ino_t *ino, 12853839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o struct ext2_inode *inode); 128619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan, 128719c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int group); 128819c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern void ext2fs_set_inode_callback 128919c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o (ext2_inode_scan scan, 129019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o errcode_t (*done_group)(ext2_filsys fs, 129119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2_inode_scan scan, 129219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o dgrp_t group, 1293b5abe6fac9c9e7caf4710501d1657d30e4857ef6Theodore Ts'o void * priv_data), 129419c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o void *done_group_data); 129519c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags, 129619c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o int clear_flags); 12977331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'oextern errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, 1298efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o struct ext2_inode * inode, 12997331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o int bufsize); 130031dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino, 13013839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o struct ext2_inode * inode); 13027331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'oextern errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, 1303efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o struct ext2_inode * inode, 13047331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o int bufsize); 130531dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, 13063839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o struct ext2_inode * inode); 1307030970ed750b6a169c32ffb8b19bce3150198629Theodore Ts'oextern errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, 1308030970ed750b6a169c32ffb8b19bce3150198629Theodore Ts'o struct ext2_inode * inode); 130931dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks); 131031dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino); 13113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1312f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'o/* inode_io.c */ 1313f12e285ffd9ff0b37c4f91d5ab2b021ed1eb43beTheodore Ts'oextern io_manager inode_io_manager; 1314efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, 1315546a1ff18cc912003883ff67ba3e87c69f700fc4Theodore Ts'o char **name); 1316a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'oextern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino, 1317a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o struct ext2_inode *inode, 1318a435ec3449694a8fa299337197cc09624960a3a6Theodore Ts'o char **name); 1319efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o 132050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o/* ismounted.c */ 132150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags); 132243ec8734f2ecd0a345e831f45fd3dfb077426811Theodore Ts'oextern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, 132343ec8734f2ecd0a345e831f45fd3dfb077426811Theodore Ts'o char *mtpt, int mtlen); 132450e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 1325e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* punch.c */ 1326e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* 1327e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * NOTE: This function removes from an inode the blocks "start", "end", and 1328e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * every block in between. 1329e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall */ 1330e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino, 1331e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_inode *inode, 1332e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall char *block_buf, blk64_t start, 1333e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t end); 1334e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 13353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* namei.c */ 133631dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name, 133731dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o int namelen, char *buf, ext2_ino_t *inode); 133831dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, 133931dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o const char *name, ext2_ino_t *inode); 134031dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oerrcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, 134131dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o const char *name, ext2_ino_t *inode); 134231dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, 134331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t inode, ext2_ino_t *res_inode); 13441e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o 13451e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o/* native.c */ 13461e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'oint ext2fs_native_flag(void); 13473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 13483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* newdir.c */ 134931dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino, 135031dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t parent_ino, char **block); 13513839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 13523839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* mkdir.c */ 135331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, 13543839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o const char *name); 13553839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1356d3cd93cabeac8c153c8ae7b1b7358d6ced86b15eTheodore Ts'o/* mkjournal.c */ 1357c86085044195c8b721fe9ee327d790316399781eTheodore Ts'oextern errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num, 1358c86085044195c8b721fe9ee327d790316399781eTheodore Ts'o blk_t *ret_blk, int *ret_count); 1359e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num, 1360e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t *ret_blk, int *ret_count); 1361a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'oextern errcode_t ext2fs_create_journal_superblock(ext2_filsys fs, 1362e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall __u32 num_blocks, int flags, 1363a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'o char **ret_jsb); 1364a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'oextern errcode_t ext2fs_add_journal_device(ext2_filsys fs, 1365a112847b39386f9e7332ba5e5a0a5e54cfe301ccTheodore Ts'o ext2_filsys journal_dev); 1366e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t num_blocks, 136731a17b36d5f7d875f9de8e86501eaf2338f94d2bTheodore Ts'o int flags); 1368e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_default_journal_size(__u64 num_blocks); 1369d3cd93cabeac8c153c8ae7b1b7358d6ced86b15eTheodore Ts'o 13703839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* openfs.c */ 13713839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern errcode_t ext2fs_open(const char *name, int flags, int superblock, 1372544349270e4c74a6feb971123884a8cf5052a7eeTheodore Ts'o unsigned int block_size, io_manager manager, 13733839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o ext2_filsys *ret_fs); 1374efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_open2(const char *name, const char *io_options, 1375efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o int flags, int superblock, 13762e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o unsigned int block_size, io_manager manager, 13772e8ca9a26b0bd7dae546a3f9a98df67b043fe3beTheodore Ts'o ext2_filsys *ret_fs); 1378e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, 1379e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall blk64_t group_block, dgrp_t i); 1380efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, 1381c046ac7f2e4c53e20cf1e909bbe511f91074b396Theodore Ts'o dgrp_t i); 13821ad54a940c499a66241f624882f1ffa03ce56d90Theodore Ts'oerrcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io); 13831ad54a940c499a66241f624882f1ffa03ce56d90Theodore Ts'oerrcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io); 13841ad54a940c499a66241f624882f1ffa03ce56d90Theodore Ts'oerrcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io); 13853839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 13863839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* get_pathname.c */ 138731dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino, 13883839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o char **name); 13893839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 13903839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* link.c */ 139131dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oerrcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name, 139231dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t ino, int flags); 139331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oerrcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, const char *name, 139431dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o ext2_ino_t ino, int flags); 13953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1396e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* symlink.c */ 1397e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino, 1398e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall const char *name, char *target); 1399e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1400e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* mmp.c */ 1401e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf); 1402e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf); 1403e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_clear(ext2_filsys fs); 1404e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_init(ext2_filsys fs); 1405e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_start(ext2_filsys fs); 1406e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_update(ext2_filsys fs); 1407e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallerrcode_t ext2fs_mmp_stop(ext2_filsys fs); 1408e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallunsigned ext2fs_mmp_new_seq(void); 1409e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 14103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* read_bb.c */ 141119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'oextern errcode_t ext2fs_read_bb_inode(ext2_filsys fs, 141219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2_badblocks_list *bb_list); 14133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 14143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* read_bb_file.c */ 1415efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, 141657dca85467cf3fc61565e916a5f2e35db8020d88Theodore Ts'o ext2_badblocks_list *bb_list, 141750cd7e06e26d8cb232819b3d94b67e37ade80c0fTheodore Ts'o void *priv_data, 141857dca85467cf3fc61565e916a5f2e35db8020d88Theodore Ts'o void (*invalid)(ext2_filsys fs, 141957dca85467cf3fc61565e916a5f2e35db8020d88Theodore Ts'o blk_t blk, 142057dca85467cf3fc61565e916a5f2e35db8020d88Theodore Ts'o char *badstr, 142150cd7e06e26d8cb232819b3d94b67e37ade80c0fTheodore Ts'o void *priv_data)); 1422efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, 142319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o ext2_badblocks_list *bb_list, 14243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o void (*invalid)(ext2_filsys fs, 14253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o blk_t blk)); 14263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1427d323f8fb369089b97d6f3bf0f8d64ceeab0b10f5Theodore Ts'o/* res_gdt.c */ 1428d323f8fb369089b97d6f3bf0f8d64ceeab0b10f5Theodore Ts'oextern errcode_t ext2fs_create_resize_inode(ext2_filsys fs); 1429d323f8fb369089b97d6f3bf0f8d64ceeab0b10f5Theodore Ts'o 143050e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o/* swapfs.c */ 1431efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'oextern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, 14327331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o int has_header); 1433fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilgerextern void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header, 1434fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilger struct ext2_ext_attr_header *from_hdr); 1435fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilgerextern void ext2fs_swap_ext_attr_entry(struct ext2_ext_attr_entry *to_entry, 1436fefaef39e046781ddc75d15a8f12369f17dbd17dAndreas Dilger struct ext2_ext_attr_entry *from_entry); 143750e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern void ext2fs_swap_super(struct ext2_super_block * super); 143850e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'oextern void ext2fs_swap_group_desc(struct ext2_group_desc *gdp); 1439e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_swap_group_desc2(ext2_filsys, struct ext2_group_desc *gdp); 14407331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'oextern void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, 14417331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o struct ext2_inode_large *f, int hostorder, 14427331196a16e57ef80dd6ae40eeeab14747ce2f5dTheodore Ts'o int bufsize); 14431e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'oextern void ext2fs_swap_inode(ext2_filsys fs,struct ext2_inode *t, 14441e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o struct ext2_inode *f, int hostorder); 1445e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern void ext2fs_swap_mmp(struct mmp_struct *mmp); 1446e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1447e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall/* unix_io.c */ 1448e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_open_file(const char *pathname, int flags, mode_t mode); 1449e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_stat(const char *path, ext2fs_struct_stat *buf); 1450e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_fstat(int fd, ext2fs_struct_stat *buf); 1451ab3f5c5aad6310be1d1891c05f1bc8cf7ccf0cefTheodore Ts'o 145219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o/* valid_blk.c */ 1453521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'oextern int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode); 1454e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern int ext2fs_inode_has_valid_blocks2(ext2_filsys fs, 1455e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall struct ext2_inode *inode); 1456521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o 1457521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o/* version.c */ 1458521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'oextern int ext2fs_parse_version_string(const char *ver_string); 1459521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'oextern int ext2fs_get_library_version(const char **ver_string, 1460521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o const char **date_string); 146150e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o 146231dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o/* write_bb_file.c */ 146331dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'oextern errcode_t ext2fs_write_bb_FILE(ext2_badblocks_list bb_list, 146431dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o unsigned int flags, 146531dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o FILE *f); 146631dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o 146731dbecd482405e0d3a67eb58e1a1c8cb9f2ad83eTheodore Ts'o 14683839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* inline functions */ 1469e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#ifdef NO_INLINE_FUNCS 1470c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'oextern errcode_t ext2fs_get_mem(unsigned long size, void *ptr); 1471e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_memzero(unsigned long size, void *ptr); 1472e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_array(unsigned long count, 1473e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall unsigned long size, void *ptr); 1474e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern errcode_t ext2fs_get_arrayzero(unsigned long count, 1475e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall unsigned long size, void *ptr); 1476c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'oextern errcode_t ext2fs_free_mem(void *ptr); 147776f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07Theodore Ts'oextern errcode_t ext2fs_resize_mem(unsigned long old_size, 1478c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o unsigned long size, void *ptr); 14793839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_mark_super_dirty(ext2_filsys fs); 14803839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_mark_changed(ext2_filsys fs); 14813839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern int ext2fs_test_changed(ext2_filsys fs); 14823839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_mark_valid(ext2_filsys fs); 14833839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_unmark_valid(ext2_filsys fs); 14843839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern int ext2fs_test_valid(ext2_filsys fs); 14853839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_mark_ib_dirty(ext2_filsys fs); 14863839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern void ext2fs_mark_bb_dirty(ext2_filsys fs); 14873839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern int ext2fs_test_ib_dirty(ext2_filsys fs); 14883839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oextern int ext2fs_test_bb_dirty(ext2_filsys fs); 1489e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk); 1490e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino); 1491abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeenextern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group); 1492abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeenextern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group); 14930684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'oextern blk_t ext2fs_inode_data_blocks(ext2_filsys fs, 14940684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o struct ext2_inode *inode); 149569022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'oextern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b); 1496e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrallextern __u64 ext2fs_div64_ceil(__u64 a, __u64 b); 1497e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif 14983839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 14993839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 15003839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * The actual inlined functions definitions themselves... 15013839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * 15023839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * If NO_INLINE_FUNCS is defined, then we won't try to do inline 15033839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * functions at all! 15043839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 15053839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) 15063839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#ifdef INCLUDE_INLINE_FUNCS 15073839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define _INLINE_ extern 15083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#else 1509e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#if (__STDC_VERSION__ >= 199901L) 1510e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#define _INLINE_ inline 1511e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#else 151276f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07Theodore Ts'o#ifdef __GNUC__ 15133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#define _INLINE_ extern __inline__ 151476f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07Theodore Ts'o#else /* For Watcom C */ 151576f875daa1c9c2cdc72f0c6f0f7be4bbc7f0fc07Theodore Ts'o#define _INLINE_ extern inline 1516e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif /* __GNUC__ */ 1517e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall#endif /* __STDC_VERSION__ >= 199901L */ 15183839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#endif 15193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 15207b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o#ifndef EXT2_CUSTOM_MEMORY_ROUTINES 152168a7f959c0af3d6e32cf9339433667f04b8a1c56Matthias Andree#include <string.h> 15227b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o/* 1523e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * Allocate memory. The 'ptr' arg must point to a pointer. 15247b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o */ 1525c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o_INLINE_ errcode_t ext2fs_get_mem(unsigned long size, void *ptr) 15267b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o{ 15272694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o void *pp; 1528c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o 15292694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o pp = malloc(size); 15302694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o if (!pp) 1531291c9049ba70bb6256099a066243cec1359c9c15Theodore Ts'o return EXT2_ET_NO_MEMORY; 15322694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o memcpy(ptr, &pp, sizeof (pp)); 15337b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o return 0; 15347b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o} 1535e5aace908e9d1161a594944d9360f9f0cdd18099Theodore Ts'o 1536e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall_INLINE_ errcode_t ext2fs_get_memzero(unsigned long size, void *ptr) 1537ffec46fea48f1f05fbe2fb863b44fd2dd718c50fLukas Czerner{ 1538e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *pp; 153965f0aab98b20b5994a726ab90d355248bcddfffdJP Abgrall 1540e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall pp = malloc(size); 1541e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall if (!pp) 1542ffec46fea48f1f05fbe2fb863b44fd2dd718c50fLukas Czerner return EXT2_ET_NO_MEMORY; 1543e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall memset(pp, 0, size); 1544e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall memcpy(ptr, &pp, sizeof(pp)); 1545ffec46fea48f1f05fbe2fb863b44fd2dd718c50fLukas Czerner return 0; 1546ffec46fea48f1f05fbe2fb863b44fd2dd718c50fLukas Czerner} 1547ffec46fea48f1f05fbe2fb863b44fd2dd718c50fLukas Czerner 1548ee01079a17bfecd17292ccd60058056fb3a8ba6cTheodore Ts'o_INLINE_ errcode_t ext2fs_get_array(unsigned long count, unsigned long size, void *ptr) 1549ee01079a17bfecd17292ccd60058056fb3a8ba6cTheodore Ts'o{ 1550ee01079a17bfecd17292ccd60058056fb3a8ba6cTheodore Ts'o if (count && (-1UL)/count<size) 1551e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return EXT2_ET_NO_MEMORY; 1552ee01079a17bfecd17292ccd60058056fb3a8ba6cTheodore Ts'o return ext2fs_get_mem(count*size, ptr); 1553ee01079a17bfecd17292ccd60058056fb3a8ba6cTheodore Ts'o} 15547b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o 1555e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall_INLINE_ errcode_t ext2fs_get_arrayzero(unsigned long count, 1556e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall unsigned long size, void *ptr) 1557e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall{ 1558e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall void *pp; 1559e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1560e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall if (count && (-1UL)/count<size) 1561e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return EXT2_ET_NO_MEMORY; 1562e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall pp = calloc(count, size); 1563e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall if (!pp) 1564e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return EXT2_ET_NO_MEMORY; 1565e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall memcpy(ptr, &pp, sizeof(pp)); 1566e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return 0; 1567e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall} 1568e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 15697b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o/* 1570e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * Free memory. The 'ptr' arg must point to a pointer. 15717b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o */ 1572c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o_INLINE_ errcode_t ext2fs_free_mem(void *ptr) 15737b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o{ 15742694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o void *p; 1575c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o 15762694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o memcpy(&p, ptr, sizeof(p)); 15772694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o free(p); 15782694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o p = 0; 15792694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o memcpy(ptr, &p, sizeof(p)); 15807b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o return 0; 15817b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o} 1582efc6f628e15de95bcd13e4f0ee223cb42115d520Theodore Ts'o 15837b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o/* 1584e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall * Resize memory. The 'ptr' arg must point to a pointer. 15857b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o */ 1586e47fd8414d3bd4632792cc52310e53edcfeea27cTheodore Ts'o_INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size, 1587c4e3d3f374b409500e3dd05c0b0eca6ac98a6b4eTheodore Ts'o unsigned long size, void *ptr) 15887b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o{ 15897b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o void *p; 15907b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o 159139c191f5b3bffc5aee56d6335fe54041c582e05dStephen Tweedie /* Use "memcpy" for pointer assignments here to avoid problems 159239c191f5b3bffc5aee56d6335fe54041c582e05dStephen Tweedie * with C99 strict type aliasing rules. */ 15932694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o memcpy(&p, ptr, sizeof(p)); 159439c191f5b3bffc5aee56d6335fe54041c582e05dStephen Tweedie p = realloc(p, size); 15957b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o if (!p) 1596291c9049ba70bb6256099a066243cec1359c9c15Theodore Ts'o return EXT2_ET_NO_MEMORY; 15972694f31946f0c168cc8d098f3970f0ae08d94e7bTheodore Ts'o memcpy(ptr, &p, sizeof(p)); 15987b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o return 0; 15997b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o} 16007b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o#endif /* Custom memory routines */ 16017b4e4534f9361b21d3fafdd88a58f133decee38cTheodore Ts'o 16023839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16033839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Mark a filesystem superblock as dirty 16043839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16053839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ void ext2fs_mark_super_dirty(ext2_filsys fs) 16063839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16073839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_CHANGED; 16083839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16093839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Mark a filesystem as changed 16123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ void ext2fs_mark_changed(ext2_filsys fs) 16143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o fs->flags |= EXT2_FLAG_CHANGED; 16163839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16173839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16183839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Check to see if a filesystem has changed 16203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ int ext2fs_test_changed(ext2_filsys fs) 16223839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o return (fs->flags & EXT2_FLAG_CHANGED); 16243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Mark a filesystem as valid 16283839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16293839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ void ext2fs_mark_valid(ext2_filsys fs) 16303839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16313839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o fs->flags |= EXT2_FLAG_VALID; 16323839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Mark a filesystem as NOT valid 16363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ void ext2fs_unmark_valid(ext2_filsys fs) 16383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16393839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o fs->flags &= ~EXT2_FLAG_VALID; 16403839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16423839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16433839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Check to see if a filesystem is valid 16443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16453839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ int ext2fs_test_valid(ext2_filsys fs) 16463839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o return (fs->flags & EXT2_FLAG_VALID); 16483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16493839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16503839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16513839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Mark the inode bitmap as dirty 16523839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16533839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ void ext2fs_mark_ib_dirty(ext2_filsys fs) 16543839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16553839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o fs->flags |= EXT2_FLAG_IB_DIRTY | EXT2_FLAG_CHANGED; 16563839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16573839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16583839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16593839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Mark the block bitmap as dirty 16603839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16613839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs) 16623839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16633839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o fs->flags |= EXT2_FLAG_BB_DIRTY | EXT2_FLAG_CHANGED; 16643839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16653839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16663839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16673839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Check to see if a filesystem's inode bitmap is dirty 16683839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16693839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs) 16703839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16713839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o return (fs->flags & EXT2_FLAG_IB_DIRTY); 16723839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16733839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16743839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16753839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Check to see if a filesystem's block bitmap is dirty 16763839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 16773839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o_INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs) 16783839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16793839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o return (fs->flags & EXT2_FLAG_BB_DIRTY); 16803839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16813839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 16823839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16833839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Return the group # of a block 16843839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 1685e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall_INLINE_ dgrp_t ext2fs_group_of_blk(ext2_filsys fs, blk_t blk) 16863839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 1687e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return ext2fs_group_of_blk2(fs, blk); 16883839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16893839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/* 16903839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Return the group # of an inode number 16913839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */ 1692e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall_INLINE_ dgrp_t ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino) 16933839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{ 16943839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o return (ino - 1) / fs->super->s_inodes_per_group; 16953839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o} 16960684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o 1697abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen/* 1698abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen * Return the first block (inclusive) in a group 1699abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen */ 1700abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group) 1701abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen{ 1702e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return (blk_t) ext2fs_group_first_block2(fs, group); 1703abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen} 1704abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen 1705abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen/* 1706abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen * Return the last block (inclusive) in a group 1707abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen */ 1708abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen_INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group) 1709abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen{ 1710e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return (blk_t) ext2fs_group_last_block2(fs, group); 1711abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen} 1712abf23439d51a3ddbca475b931abebd381ff7ceeaEric Sandeen 17130684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o_INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs, 17140684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o struct ext2_inode *inode) 17150684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o{ 1716e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return (blk_t) ext2fs_inode_data_blocks2(fs, inode); 17170684a4f33b5c268fe12f57fcbc77a880c79ab282Theodore Ts'o} 171869022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o 171969022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o/* 172069022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o * This is an efficient, overflow safe way of calculating ceil((1.0 * a) / b) 172169022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o */ 172269022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o_INLINE_ unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b) 172369022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o{ 172469022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o if (!a) 172569022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o return 0; 172669022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o return ((a - 1) / b) + 1; 172769022e029f3273b3b860bf701219cd3fe615f76bTheodore Ts'o} 1728e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 1729e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall_INLINE_ __u64 ext2fs_div64_ceil(__u64 a, __u64 b) 1730e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall{ 1731e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall if (!a) 1732e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return 0; 1733e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall return ((a - 1) / b) + 1; 1734e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall} 1735e0ed7404719a9ddd2ba427a80db5365c8bad18c0JP Abgrall 17363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#undef _INLINE_ 17373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#endif 17383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o 1739fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o#ifdef __cplusplus 1740fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o} 1741fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o#endif 1742fa7ef7176ee66aaaec58a24c5a5523c4afb550ddTheodore Ts'o 17439abd2ce914f9373fb676f0bb620ffba3a0e3c49eTheodore Ts'o#endif /* _EXT2FS_EXT2FS_H */ 1744