pmt: initial 2.9.1 update
This commit is contained in:
@@ -16,8 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_DEPRECATES_H
|
||||
#define __PMT_DEPRECATES_H
|
||||
#pragma once
|
||||
|
||||
#define deprecated_opt 1
|
||||
#define changed_opt 2
|
||||
@@ -40,7 +39,8 @@
|
||||
#define v260 "2.6.0"
|
||||
#define v270 "2.7.0"
|
||||
#define v280 "2.8.0"
|
||||
#define vUNK NULL
|
||||
#define v290 "2.9.0"
|
||||
#define vUNK nullptr
|
||||
|
||||
struct pmt_deprecates {
|
||||
int depr_type;
|
||||
@@ -57,15 +57,16 @@ static struct pmt_deprecates depr_table[] = {
|
||||
{deprecated_opt, 'r', not_changed, "format", not_changed_long, v210},
|
||||
{deprecated_opt, 'L', not_changed, "license", not_changed_long, v250},
|
||||
{changed_opt, 'D', 'p', "list", not_changed_long, v210},
|
||||
{changed_opt, 'c', 'P', "context", "search-path", v290},
|
||||
{end_depr_pointer, not_changed, not_changed, not_changed_long, not_changed_long, vUNK}
|
||||
};
|
||||
|
||||
static void
|
||||
__deprecated_opt_handle(int opt, const string opt_long, const char* depr_msg)
|
||||
__process_deprecated_opts(int opt, const string& opt_long, const char* depr_msg)
|
||||
{
|
||||
static string long_e_msg;
|
||||
|
||||
if (opt_long == "")
|
||||
if (opt_long.empty())
|
||||
long_e_msg = PartitionManager::Display::UsingDispString->not_changed_opt;
|
||||
else
|
||||
long_e_msg = opt_long;
|
||||
@@ -91,12 +92,10 @@ __deprecated_opt_handle(int opt, const string opt_long, const char* depr_msg)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#define DEPR_HANDLE(x, y, z) __deprecated_opt_handle(x, y, z)
|
||||
|
||||
#endif /* __PMT_DEPRECATES_H */
|
||||
#define DEPR_HANDLE(x, y, z) \
|
||||
__process_deprecated_opts(x, y, z)
|
||||
|
||||
/* end of code */
|
||||
|
||||
25
include/PartitionManager/FileSystemUtils.h
Executable file
25
include/PartitionManager/FileSystemUtils.h
Executable file
@@ -0,0 +1,25 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
int mke2fs_main(int argc, char* argv[]);
|
||||
}
|
||||
|
||||
/* end of code */
|
||||
@@ -16,8 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_HELP_MSGS_H
|
||||
#define __PMT_HELP_MSGS_H
|
||||
#pragma once
|
||||
|
||||
namespace PartitionManager {
|
||||
namespace Functions {
|
||||
@@ -25,6 +24,4 @@ namespace PartitionManager {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* end */
|
||||
|
||||
26
include/PartitionManager/PartSizeMacros.h
Executable file
26
include/PartitionManager/PartSizeMacros.h
Executable file
@@ -0,0 +1,26 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License";
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define VIEW_AS_BYTE 1
|
||||
#define VIEW_AS_KIB 2
|
||||
#define VIEW_AS_MIB 3
|
||||
#define VIEW_AS_GIB 4
|
||||
|
||||
/* end of code */
|
||||
@@ -16,12 +16,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(__clang__) && !defined(__NDK_BUILD)
|
||||
#error "Your compiler is NOT clang. Please build with LLVM clang."
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#ifndef __PMT_H_
|
||||
#define __PMT_H_
|
||||
#if !defined(__clang__) && !defined(__NDK_BUILD)
|
||||
#error "Your compiler is NOT clang. Please build with (LLVM) clang."
|
||||
#endif
|
||||
|
||||
#ifdef INC_MAIN_LIBS
|
||||
#include <iostream>
|
||||
@@ -30,8 +29,10 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
#include <clocale>
|
||||
|
||||
#ifdef IS_MAIN
|
||||
#include <clocale>
|
||||
#endif
|
||||
#if !defined(HELP) || !defined(VERSIONING)
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
@@ -52,7 +53,9 @@
|
||||
#include <cerrno>
|
||||
#endif
|
||||
#ifdef INC_TOOLS_REQS
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
typedef unsigned short ushort_t;
|
||||
#endif
|
||||
#ifdef INC_LIBGEN
|
||||
#include <libgen.h>
|
||||
@@ -68,16 +71,17 @@ typedef enum {
|
||||
LOG_LEVEL_DEBUG
|
||||
} LogLevel;
|
||||
|
||||
/* fast error processing without errno entry
|
||||
/**
|
||||
* Fast error processing without errno entry
|
||||
* but errno can be given in the entrance
|
||||
*/
|
||||
char* strqerror(int errno_macro = errno);
|
||||
extern "C" char* strqerror(int errno_macro = errno);
|
||||
|
||||
/* create a special namespace */
|
||||
namespace PartitionManager {
|
||||
namespace Strings {
|
||||
extern string OutputName;
|
||||
extern string CustomContext;
|
||||
extern string CustomSearchPath;
|
||||
extern string TargetPartition;
|
||||
extern string TargetFlashFile;
|
||||
extern string TargetFormatFS;
|
||||
@@ -86,19 +90,24 @@ namespace PartitionManager {
|
||||
extern string CurrentLanguage;
|
||||
} /* namespace Strings */
|
||||
|
||||
namespace Integers {
|
||||
extern int PartSizeViewType;
|
||||
} /* namespace Integers */
|
||||
|
||||
namespace Booleans {
|
||||
extern bool UseLogical;
|
||||
extern bool UseCustomContext;
|
||||
extern bool UseCustomSearchPath;
|
||||
extern bool UsesSlots;
|
||||
extern bool UsesLogical;
|
||||
extern bool OnlyViewSize;
|
||||
extern bool SilentEnabled;
|
||||
extern bool FlashMode;
|
||||
extern bool BackupMode;
|
||||
extern bool FormatMode;
|
||||
extern bool PartSizeViewMode;
|
||||
extern bool ForceMode;
|
||||
extern bool VerboseMode;
|
||||
extern bool InstalledOnTermux;
|
||||
extern bool ActivateRoot;
|
||||
} /* namespace Booleans */
|
||||
|
||||
namespace Display {
|
||||
@@ -135,6 +144,7 @@ namespace PartitionManager {
|
||||
#define LOGD(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
/* verbose logging macros */
|
||||
#define VLOGF(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define VLOGE(fmt, ...) \
|
||||
@@ -144,6 +154,4 @@ namespace PartitionManager {
|
||||
#define VLOGD(fmt, ...) \
|
||||
PartitionManager::Functions::DisplayVerboseLog(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_STRINGKEYS_
|
||||
#define __PMT_STRINGKEYS_
|
||||
#pragma once
|
||||
|
||||
/* The struct is a very good option for setting the languages of texts etc. */
|
||||
struct langdb_general {
|
||||
@@ -38,9 +37,10 @@ struct langdb_general {
|
||||
const char* _Nonnull expected_backup_arg;
|
||||
const char* _Nonnull expected_flash_arg;
|
||||
const char* _Nonnull expected_format_arg;
|
||||
const char* _Nonnull expected_partsz_arg;
|
||||
const char* _Nonnull missing_operand;
|
||||
const char* _Nonnull multiple_wiewers;
|
||||
const char* _Nonnull common_symbol_rule;
|
||||
const char* _Nonnull symbol_rule;
|
||||
const char* _Nonnull req_part_name;
|
||||
const char* _Nonnull part_not_found;
|
||||
const char* _Nonnull unsupported_fs;
|
||||
@@ -48,16 +48,19 @@ struct langdb_general {
|
||||
const char* _Nonnull ffile_more_part;
|
||||
const char* _Nonnull cannot_get_bsz;
|
||||
const char* _Nonnull format_fail;
|
||||
const char* _Nonnull fail_get_psize;
|
||||
const char* _Nonnull depr_backup_opt;
|
||||
const char* _Nonnull depr_flash_opt;
|
||||
const char* _Nonnull depr_format_opt;
|
||||
const char* _Nonnull depr_Vlicense_opt;
|
||||
const char* _Nonnull depr_ch_list_opt;
|
||||
const char* _Nonnull depr_ch_sp_opt;
|
||||
const char* _Nonnull not_spec_opt;
|
||||
const char* _Nonnull some_spec;
|
||||
const char* _Nonnull logical_warn;
|
||||
const char* _Nonnull ab_warn;
|
||||
const char* _Nonnull out_not_spec;
|
||||
const char* _Nonnull no_found_on_process;
|
||||
const char* _Nonnull please_rerun;
|
||||
const char* _Nonnull part_disk_sz;
|
||||
const char* _Nonnull flash_file_sz;
|
||||
@@ -74,6 +77,7 @@ struct langdb_general {
|
||||
const char* _Nonnull warn;
|
||||
const char* _Nonnull fatal;
|
||||
const char* _Nonnull is_requires_arg;
|
||||
const char* _Nonnull only_partsz_args;
|
||||
const char* _Nonnull unknw_arg;
|
||||
const char* _Nonnull switching_lang;
|
||||
const char* _Nonnull welcome;
|
||||
@@ -88,9 +92,13 @@ struct langdb_general {
|
||||
const char* _Nonnull compiler_str;
|
||||
const char* _Nonnull version_str;
|
||||
const char* _Nonnull bin_str;
|
||||
const char* _Nonnull part_name;
|
||||
const char* _Nonnull part_type;
|
||||
const char* _Nonnull fs_str;
|
||||
const char* _Nonnull unknw_str;
|
||||
const char* _Nonnull by_str;
|
||||
const char* _Nonnull yes;
|
||||
const char* _Nonnull no;
|
||||
};
|
||||
|
||||
/* docs etc. */
|
||||
@@ -110,10 +118,15 @@ struct langdb_docs {
|
||||
const char* _Nonnull docs_strs_l13;
|
||||
const char* _Nonnull docs_strs_l14;
|
||||
const char* _Nonnull docs_strs_l15;
|
||||
const char* _Nonnull docs_strs_l16;
|
||||
const char* _Nonnull docs_strs_l17;
|
||||
const char* _Nonnull docs_strs_l18;
|
||||
const char* _Nonnull docs_strs_l19;
|
||||
const char* _Nonnull docs_strs_l20;
|
||||
const char* _Nonnull docs_strs_l21;
|
||||
const char* _Nonnull docs_strs_l22;
|
||||
const char* _Nonnull or_str;
|
||||
const char* _Nonnull usage_docstr;
|
||||
};
|
||||
|
||||
#endif /* __PMT_STRINGKEYS_ */
|
||||
|
||||
/* end of code */
|
||||
|
||||
@@ -16,18 +16,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __PMT_VERSIONING_H
|
||||
#define __PMT_VERSIONING_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __NDK_BUILD
|
||||
#include <android/ndk-version.h>
|
||||
#include <PartitionManager/generated/clang-version.h>
|
||||
#endif
|
||||
#include <e2fsprogs/version.h>
|
||||
|
||||
/* versioning */
|
||||
#define PMT_MAJOR 2
|
||||
#define PMT_MINOR 8
|
||||
#define PMT_PATCHLEVEL 0
|
||||
#define PMT_MINOR 9
|
||||
#define PMT_PATCHLEVEL 1
|
||||
|
||||
namespace PartitionManager {
|
||||
namespace Functions {
|
||||
@@ -35,6 +35,4 @@ namespace PartitionManager {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* end */
|
||||
|
||||
204
include/e2fsprogs/blkid/blkidP.h
Executable file
204
include/e2fsprogs/blkid/blkidP.h
Executable file
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* blkidP.h - Internal interfaces for libblkid
|
||||
*
|
||||
* Copyright (C) 2001 Andreas Dilger
|
||||
* Copyright (C) 2003 Theodore Ts'o
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the
|
||||
* GNU Lesser General Public License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _BLKID_BLKIDP_H
|
||||
#define _BLKID_BLKIDP_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <blkid/blkid_local.h>
|
||||
|
||||
#include <blkid/list.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define __BLKID_ATTR(x) __attribute__(x)
|
||||
#else
|
||||
#define __BLKID_ATTR(x)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This describes the attributes of a specific device.
|
||||
* We can traverse all of the tags by bid_tags (linking to the tag bit_names).
|
||||
* The bid_label and bid_uuid fields are shortcuts to the LABEL and UUID tag
|
||||
* values, if they exist.
|
||||
*/
|
||||
struct blkid_struct_dev
|
||||
{
|
||||
struct list_head bid_devs; /* All devices in the cache */
|
||||
struct list_head bid_tags; /* All tags for this device */
|
||||
blkid_cache bid_cache; /* Dev belongs to this cache */
|
||||
char *bid_name; /* Device inode pathname */
|
||||
char *bid_type; /* Preferred device TYPE */
|
||||
int bid_pri; /* Device priority */
|
||||
dev_t bid_devno; /* Device major/minor number */
|
||||
time_t bid_time; /* Last update time of device */
|
||||
unsigned int bid_flags; /* Device status bitflags */
|
||||
char *bid_label; /* Shortcut to device LABEL */
|
||||
char *bid_uuid; /* Shortcut to binary UUID */
|
||||
};
|
||||
|
||||
#define BLKID_BID_FL_VERIFIED 0x0001 /* Device data validated from disk */
|
||||
#define BLKID_BID_FL_INVALID 0x0004 /* Device is invalid */
|
||||
|
||||
/*
|
||||
* Each tag defines a NAME=value pair for a particular device. The tags
|
||||
* are linked via bit_names for a single device, so that traversing the
|
||||
* names list will get you a list of all tags associated with a device.
|
||||
* They are also linked via bit_values for all devices, so one can easily
|
||||
* search all tags with a given NAME for a specific value.
|
||||
*/
|
||||
struct blkid_struct_tag
|
||||
{
|
||||
struct list_head bit_tags; /* All tags for this device */
|
||||
struct list_head bit_names; /* All tags with given NAME */
|
||||
char *bit_name; /* NAME of tag (shared) */
|
||||
char *bit_val; /* value of tag */
|
||||
blkid_dev bit_dev; /* pointer to device */
|
||||
};
|
||||
typedef struct blkid_struct_tag *blkid_tag;
|
||||
|
||||
/*
|
||||
* Minimum number of seconds between device probes, even when reading
|
||||
* from the cache. This is to avoid re-probing all devices which were
|
||||
* just probed by another program that does not share the cache.
|
||||
*/
|
||||
#define BLKID_PROBE_MIN 2
|
||||
|
||||
/*
|
||||
* Time in seconds an entry remains verified in the in-memory cache
|
||||
* before being reverified (in case of long-running processes that
|
||||
* keep a cache in memory and continue to use it for a long time).
|
||||
*/
|
||||
#define BLKID_PROBE_INTERVAL 200
|
||||
|
||||
/* This describes an entire blkid cache file and probed devices.
|
||||
* We can traverse all of the found devices via bic_list.
|
||||
* We can traverse all of the tag types by bic_tags, which hold empty tags
|
||||
* for each tag type. Those tags can be used as list_heads for iterating
|
||||
* through all devices with a specific tag type (e.g. LABEL).
|
||||
*/
|
||||
struct blkid_struct_cache
|
||||
{
|
||||
struct list_head bic_devs; /* List head of all devices */
|
||||
struct list_head bic_tags; /* List head of all tag types */
|
||||
time_t bic_time; /* Last probe time */
|
||||
time_t bic_ftime; /* Mod time of the cachefile */
|
||||
unsigned int bic_flags; /* Status flags of the cache */
|
||||
char *bic_filename; /* filename of cache */
|
||||
};
|
||||
|
||||
#define BLKID_BIC_FL_PROBED 0x0002 /* We probed /proc/partition devices */
|
||||
#define BLKID_BIC_FL_CHANGED 0x0004 /* Cache has changed from disk */
|
||||
|
||||
extern char *blkid_strdup(const char *s);
|
||||
extern char *blkid_strndup(const char *s, const int length);
|
||||
|
||||
#define BLKID_CACHE_FILE "/etc/blkid.tab"
|
||||
|
||||
#define BLKID_ERR_IO 5
|
||||
#define BLKID_ERR_PROC 9
|
||||
#define BLKID_ERR_MEM 12
|
||||
#define BLKID_ERR_CACHE 14
|
||||
#define BLKID_ERR_DEV 19
|
||||
#define BLKID_ERR_PARAM 22
|
||||
#define BLKID_ERR_BIG 27
|
||||
|
||||
/*
|
||||
* Priority settings for different types of devices
|
||||
*/
|
||||
#define BLKID_PRI_DM 40
|
||||
#define BLKID_PRI_EVMS 30
|
||||
#define BLKID_PRI_LVM 20
|
||||
#define BLKID_PRI_MD 10
|
||||
|
||||
#if defined(TEST_PROGRAM) && !defined(CONFIG_BLKID_DEBUG)
|
||||
#define CONFIG_BLKID_DEBUG
|
||||
#endif
|
||||
|
||||
#define DEBUG_CACHE 0x0001
|
||||
#define DEBUG_DUMP 0x0002
|
||||
#define DEBUG_DEV 0x0004
|
||||
#define DEBUG_DEVNAME 0x0008
|
||||
#define DEBUG_DEVNO 0x0010
|
||||
#define DEBUG_PROBE 0x0020
|
||||
#define DEBUG_READ 0x0040
|
||||
#define DEBUG_RESOLVE 0x0080
|
||||
#define DEBUG_SAVE 0x0100
|
||||
#define DEBUG_TAG 0x0200
|
||||
#define DEBUG_INIT 0x8000
|
||||
#define DEBUG_ALL 0xFFFF
|
||||
|
||||
#ifdef CONFIG_BLKID_DEBUG
|
||||
#include <stdio.h>
|
||||
extern int blkid_debug_mask;
|
||||
#define DBG(m,x) if ((m) & blkid_debug_mask) x;
|
||||
#else
|
||||
#define DBG(m,x)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLKID_DEBUG
|
||||
extern void blkid_debug_dump_dev(blkid_dev dev);
|
||||
extern void blkid_debug_dump_tag(blkid_tag tag);
|
||||
#endif
|
||||
|
||||
static inline int blkidP_is_disk_device(mode_t mode)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
return S_ISBLK(mode) || S_ISCHR(mode);
|
||||
#else
|
||||
return S_ISBLK(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* devno.c */
|
||||
struct dir_list {
|
||||
char *name;
|
||||
struct dir_list *next;
|
||||
};
|
||||
extern void blkid__scan_dir(const char *, dev_t, struct dir_list **, char **);
|
||||
|
||||
/* lseek.c */
|
||||
extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence);
|
||||
|
||||
/* read.c */
|
||||
extern void blkid_read_cache(blkid_cache cache);
|
||||
|
||||
/* save.c */
|
||||
extern int blkid_flush_cache(blkid_cache cache);
|
||||
|
||||
/*
|
||||
* Functions to create and find a specific tag type: tag.c
|
||||
*/
|
||||
extern void blkid_free_tag(blkid_tag tag);
|
||||
extern blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type);
|
||||
extern int blkid_set_tag(blkid_dev dev, const char *name,
|
||||
const char *value, const int vlength);
|
||||
|
||||
/*
|
||||
* Functions to create and find a specific tag type: dev.c
|
||||
*/
|
||||
extern blkid_dev blkid_new_dev(void);
|
||||
extern void blkid_free_dev(blkid_dev dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLKID_BLKIDP_H */
|
||||
110
include/e2fsprogs/blkid/blkid_local.h
Executable file
110
include/e2fsprogs/blkid/blkid_local.h
Executable file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* blkid.h - Interface for libblkid, a library to identify block devices
|
||||
*
|
||||
* Copyright (C) 2001 Andreas Dilger
|
||||
* Copyright (C) 2003 Theodore Ts'o
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the
|
||||
* GNU Lesser General Public License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _BLKID_BLKID_H
|
||||
#define _BLKID_BLKID_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <blkid/blkid_types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLKID_VERSION "1.0.0"
|
||||
#define BLKID_DATE "12-Feb-2003"
|
||||
|
||||
typedef struct blkid_struct_dev *blkid_dev;
|
||||
typedef struct blkid_struct_cache *blkid_cache;
|
||||
typedef __s64 blkid_loff_t;
|
||||
|
||||
typedef struct blkid_struct_tag_iterate *blkid_tag_iterate;
|
||||
typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
|
||||
|
||||
/*
|
||||
* Flags for blkid_get_dev
|
||||
*
|
||||
* BLKID_DEV_CREATE Create an empty device structure if not found
|
||||
* in the cache.
|
||||
* BLKID_DEV_VERIFY Make sure the device structure corresponds
|
||||
* with reality.
|
||||
* BLKID_DEV_FIND Just look up a device entry, and return NULL
|
||||
* if it is not found.
|
||||
* BLKID_DEV_NORMAL Get a valid device structure, either from the
|
||||
* cache or by probing the device.
|
||||
*/
|
||||
#define BLKID_DEV_FIND 0x0000
|
||||
#define BLKID_DEV_CREATE 0x0001
|
||||
#define BLKID_DEV_VERIFY 0x0002
|
||||
#define BLKID_DEV_NORMAL (BLKID_DEV_CREATE | BLKID_DEV_VERIFY)
|
||||
|
||||
/* cache.c */
|
||||
extern void blkid_put_cache(blkid_cache cache);
|
||||
extern int blkid_get_cache(blkid_cache *cache, const char *filename);
|
||||
extern void blkid_gc_cache(blkid_cache cache);
|
||||
|
||||
/* dev.c */
|
||||
extern const char *blkid_dev_devname(blkid_dev dev);
|
||||
|
||||
extern blkid_dev_iterate blkid_dev_iterate_begin(blkid_cache cache);
|
||||
extern int blkid_dev_set_search(blkid_dev_iterate iter,
|
||||
char *search_type, char *search_value);
|
||||
extern int blkid_dev_next(blkid_dev_iterate iterate, blkid_dev *dev);
|
||||
extern void blkid_dev_iterate_end(blkid_dev_iterate iterate);
|
||||
|
||||
/* devno.c */
|
||||
extern char *blkid_devno_to_devname(dev_t devno);
|
||||
|
||||
/* devname.c */
|
||||
extern int blkid_probe_all(blkid_cache cache);
|
||||
extern int blkid_probe_all_new(blkid_cache cache);
|
||||
extern blkid_dev blkid_get_dev(blkid_cache cache, const char *devname,
|
||||
int flags);
|
||||
|
||||
/* getsize.c */
|
||||
extern blkid_loff_t blkid_get_dev_size(int fd);
|
||||
|
||||
/* probe.c */
|
||||
int blkid_known_fstype(const char *fstype);
|
||||
extern blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev);
|
||||
|
||||
/* read.c */
|
||||
|
||||
/* resolve.c */
|
||||
extern char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
|
||||
const char *devname);
|
||||
extern char *blkid_get_devname(blkid_cache cache, const char *token,
|
||||
const char *value);
|
||||
|
||||
/* tag.c */
|
||||
extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev);
|
||||
extern int blkid_tag_next(blkid_tag_iterate iterate,
|
||||
const char **type, const char **value);
|
||||
extern void blkid_tag_iterate_end(blkid_tag_iterate iterate);
|
||||
extern int blkid_dev_has_tag(blkid_dev dev, const char *type,
|
||||
const char *value);
|
||||
extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
|
||||
const char *type,
|
||||
const char *value);
|
||||
extern int blkid_parse_tag_string(const char *token, char **ret_type,
|
||||
char **ret_val);
|
||||
|
||||
/* version.c */
|
||||
extern int blkid_parse_version_string(const char *ver_string);
|
||||
extern int blkid_get_library_version(const char **ver_string,
|
||||
const char **date_string);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLKID_BLKID_H */
|
||||
45
include/e2fsprogs/blkid/blkid_types.h
Executable file
45
include/e2fsprogs/blkid/blkid_types.h
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* If linux/types.h is already been included, assume it has defined
|
||||
* everything we need. (cross fingers) Other header files may have
|
||||
* also defined the types that we need.
|
||||
*/
|
||||
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
|
||||
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
|
||||
#define _BLKID_TYPES_H
|
||||
|
||||
typedef unsigned char __u8;
|
||||
typedef __signed__ char __s8;
|
||||
typedef unsigned short __u16;
|
||||
typedef __signed__ short __s16;
|
||||
typedef unsigned int __u32;
|
||||
typedef __signed__ int __s32;
|
||||
typedef unsigned long long __u64;
|
||||
typedef __signed__ long long __s64;
|
||||
#endif
|
||||
|
||||
#include <stdint.h> //uintptr_t
|
||||
|
||||
/* endian checking stuff */
|
||||
#ifndef EXT2_ENDIAN_H_
|
||||
#define EXT2_ENDIAN_H_
|
||||
|
||||
#ifdef __CHECKER__
|
||||
#ifndef __bitwise
|
||||
#define __bitwise __attribute__((bitwise))
|
||||
#endif
|
||||
#define __force __attribute__((force))
|
||||
#else
|
||||
#ifndef __bitwise
|
||||
#define __bitwise
|
||||
#endif
|
||||
#define __force
|
||||
#endif
|
||||
|
||||
typedef __u16 __bitwise __le16;
|
||||
typedef __u32 __bitwise __le32;
|
||||
typedef __u64 __bitwise __le64;
|
||||
typedef __u16 __bitwise __be16;
|
||||
typedef __u32 __bitwise __be32;
|
||||
typedef __u64 __bitwise __be64;
|
||||
|
||||
#endif /* EXT2_ENDIAN_H_ */
|
||||
184
include/e2fsprogs/blkid/list.h
Executable file
184
include/e2fsprogs/blkid/list.h
Executable file
@@ -0,0 +1,184 @@
|
||||
#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD_INIT)
|
||||
#define _BLKID_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _INLINE_ static __inline__
|
||||
#else /* For Watcom C */
|
||||
#define _INLINE_ static inline
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
_INLINE_ void __list_add(struct list_head * add,
|
||||
struct list_head * prev,
|
||||
struct list_head * next)
|
||||
{
|
||||
next->prev = add;
|
||||
add->next = next;
|
||||
add->prev = prev;
|
||||
prev->next = add;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add - add a new entry
|
||||
* @add: new entry to be added
|
||||
* @head: list head to add it after
|
||||
*
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
_INLINE_ void list_add(struct list_head *add, struct list_head *head)
|
||||
{
|
||||
__list_add(add, head, head->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @add: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
_INLINE_ void list_add_tail(struct list_head *add, struct list_head *head)
|
||||
{
|
||||
__list_add(add, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
_INLINE_ void __list_del(struct list_head * prev,
|
||||
struct list_head * next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
*
|
||||
* list_empty() on @entry does not return true after this, @entry is
|
||||
* in an undefined state.
|
||||
*/
|
||||
_INLINE_ void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
_INLINE_ void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
_INLINE_ int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
_INLINE_ void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
|
||||
if (first != list) {
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(unsigned long)(intptr_t)(&((type *)0)->member)))
|
||||
|
||||
/**
|
||||
* list_for_each - iterate over elements in a list
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_safe - iterate over elements in a list, but don't dereference
|
||||
* pos after the body is done (in case it is freed)
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @pnext: the &struct list_head to use as a pointer to the next item.
|
||||
* @head: the head for your list (not included in iteration).
|
||||
*/
|
||||
#define list_for_each_safe(pos, pnext, head) \
|
||||
for (pos = (head)->next, pnext = pos->next; pos != (head); \
|
||||
pos = pnext, pnext = pos->next)
|
||||
|
||||
#undef _INLINE_
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLKID_LIST_H */
|
||||
852
include/e2fsprogs/blkid/probe.h
Executable file
852
include/e2fsprogs/blkid/probe.h
Executable file
@@ -0,0 +1,852 @@
|
||||
/*
|
||||
* probe.h - constants and on-disk structures for extracting device data
|
||||
*
|
||||
* Copyright (C) 1999 by Andries Brouwer
|
||||
* Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
|
||||
* Copyright (C) 2001 by Andreas Dilger
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the
|
||||
* GNU Lesser General Public License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _BLKID_PROBE_H
|
||||
#define _BLKID_PROBE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <blkid/blkid_types.h>
|
||||
|
||||
struct blkid_magic;
|
||||
|
||||
#define SB_BUFFER_SIZE 0x11000
|
||||
|
||||
struct blkid_probe {
|
||||
int fd;
|
||||
blkid_cache cache;
|
||||
blkid_dev dev;
|
||||
unsigned char *sbbuf;
|
||||
size_t sb_valid;
|
||||
unsigned char *buf;
|
||||
size_t buf_max;
|
||||
};
|
||||
|
||||
typedef int (*blkid_probe_t)(struct blkid_probe *probe,
|
||||
struct blkid_magic *id, unsigned char *buf);
|
||||
|
||||
struct blkid_magic {
|
||||
const char *bim_type; /* type name for this magic */
|
||||
long bim_kboff; /* kilobyte offset of superblock */
|
||||
unsigned bim_sboff; /* byte offset within superblock */
|
||||
unsigned bim_len; /* length of magic */
|
||||
const char *bim_magic; /* magic string */
|
||||
blkid_probe_t bim_probe; /* probe function */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structures for each of the content types we want to extract information
|
||||
* from. We do not necessarily need the magic field here, because we have
|
||||
* already identified the content type before we get this far. It may still
|
||||
* be useful if there are probe functions which handle multiple content types.
|
||||
*/
|
||||
struct ext2_super_block {
|
||||
__u32 s_inodes_count;
|
||||
__u32 s_blocks_count;
|
||||
__u32 s_r_blocks_count;
|
||||
__u32 s_free_blocks_count;
|
||||
__u32 s_free_inodes_count;
|
||||
__u32 s_first_data_block;
|
||||
__u32 s_log_block_size;
|
||||
__u32 s_dummy3[7];
|
||||
unsigned char s_magic[2];
|
||||
__u16 s_state;
|
||||
__u32 s_dummy5[8];
|
||||
__u32 s_feature_compat;
|
||||
__u32 s_feature_incompat;
|
||||
__u32 s_feature_ro_compat;
|
||||
unsigned char s_uuid[16];
|
||||
char s_volume_name[16];
|
||||
char s_last_mounted[64];
|
||||
__u32 s_algorithm_usage_bitmap;
|
||||
__u8 s_prealloc_blocks;
|
||||
__u8 s_prealloc_dir_blocks;
|
||||
__u16 s_reserved_gdt_blocks;
|
||||
__u8 s_journal_uuid[16];
|
||||
__u32 s_journal_inum;
|
||||
__u32 s_journal_dev;
|
||||
__u32 s_last_orphan;
|
||||
__u32 s_hash_seed[4];
|
||||
__u8 s_def_hash_version;
|
||||
__u8 s_jnl_backup_type;
|
||||
__u16 s_reserved_word_pad;
|
||||
__u32 s_default_mount_opts;
|
||||
__u32 s_first_meta_bg;
|
||||
__u32 s_mkfs_time;
|
||||
__u32 s_jnl_blocks[17];
|
||||
__u32 s_blocks_count_hi;
|
||||
__u32 s_r_blocks_count_hi;
|
||||
__u32 s_free_blocks_hi;
|
||||
__u16 s_min_extra_isize;
|
||||
__u16 s_want_extra_isize;
|
||||
__u32 s_flags;
|
||||
__u16 s_raid_stride;
|
||||
__u16 s_mmp_interval;
|
||||
__u64 s_mmp_block;
|
||||
__u32 s_raid_stripe_width;
|
||||
__u32 s_reserved[163];
|
||||
};
|
||||
|
||||
/* for s_flags */
|
||||
#define EXT2_FLAGS_TEST_FILESYS 0x0004
|
||||
|
||||
/* for s_feature_compat */
|
||||
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
|
||||
|
||||
/* for s_feature_ro_compat */
|
||||
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
|
||||
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
|
||||
#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
|
||||
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
|
||||
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
|
||||
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
|
||||
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
|
||||
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
|
||||
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
|
||||
|
||||
/* for s_feature_incompat */
|
||||
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
|
||||
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
|
||||
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
|
||||
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
|
||||
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
|
||||
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
|
||||
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
|
||||
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
|
||||
|
||||
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
|
||||
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
|
||||
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
|
||||
EXT2_FEATURE_INCOMPAT_META_BG)
|
||||
#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP
|
||||
#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP
|
||||
|
||||
#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
|
||||
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
|
||||
#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
|
||||
EXT3_FEATURE_INCOMPAT_RECOVER| \
|
||||
EXT2_FEATURE_INCOMPAT_META_BG)
|
||||
#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED ~EXT3_FEATURE_INCOMPAT_SUPP
|
||||
#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED ~EXT3_FEATURE_RO_COMPAT_SUPP
|
||||
|
||||
|
||||
struct xfs_super_block {
|
||||
unsigned char xs_magic[4];
|
||||
__u32 xs_blocksize;
|
||||
__u64 xs_dblocks;
|
||||
__u64 xs_rblocks;
|
||||
__u32 xs_dummy1[2];
|
||||
unsigned char xs_uuid[16];
|
||||
__u32 xs_dummy2[15];
|
||||
char xs_fname[12];
|
||||
__u32 xs_dummy3[2];
|
||||
__u64 xs_icount;
|
||||
__u64 xs_ifree;
|
||||
__u64 xs_fdblocks;
|
||||
};
|
||||
|
||||
struct reiserfs_super_block {
|
||||
__u32 rs_blocks_count;
|
||||
__u32 rs_free_blocks;
|
||||
__u32 rs_root_block;
|
||||
__u32 rs_journal_block;
|
||||
__u32 rs_journal_dev;
|
||||
__u32 rs_orig_journal_size;
|
||||
__u32 rs_dummy2[5];
|
||||
__u16 rs_blocksize;
|
||||
__u16 rs_dummy3[3];
|
||||
unsigned char rs_magic[12];
|
||||
__u32 rs_dummy4[5];
|
||||
unsigned char rs_uuid[16];
|
||||
char rs_label[16];
|
||||
};
|
||||
|
||||
struct reiser4_super_block {
|
||||
unsigned char rs4_magic[16];
|
||||
__u16 rs4_dummy[2];
|
||||
unsigned char rs4_uuid[16];
|
||||
unsigned char rs4_label[16];
|
||||
__u64 rs4_dummy2;
|
||||
};
|
||||
|
||||
struct jfs_super_block {
|
||||
unsigned char js_magic[4];
|
||||
__u32 js_version;
|
||||
__u64 js_size;
|
||||
__u32 js_bsize; /* 4: aggregate block size in bytes */
|
||||
__u16 js_l2bsize; /* 2: log2 of s_bsize */
|
||||
__u16 js_l2bfactor; /* 2: log2(s_bsize/hardware block size) */
|
||||
__u32 js_pbsize; /* 4: hardware/LVM block size in bytes */
|
||||
__u16 js_l2pbsize; /* 2: log2 of s_pbsize */
|
||||
__u16 js_pad; /* 2: padding necessary for alignment */
|
||||
__u32 js_dummy2[26];
|
||||
unsigned char js_uuid[16];
|
||||
unsigned char js_label[16];
|
||||
unsigned char js_loguuid[16];
|
||||
};
|
||||
|
||||
struct romfs_super_block {
|
||||
unsigned char ros_magic[8];
|
||||
__u32 ros_dummy1[2];
|
||||
unsigned char ros_volume[16];
|
||||
};
|
||||
|
||||
struct cramfs_super_block {
|
||||
__u8 magic[4];
|
||||
__u32 size;
|
||||
__u32 flags;
|
||||
__u32 future;
|
||||
__u8 signature[16];
|
||||
struct cramfs_info {
|
||||
__u32 crc;
|
||||
__u32 edition;
|
||||
__u32 blocks;
|
||||
__u32 files;
|
||||
} info;
|
||||
__u8 name[16];
|
||||
};
|
||||
|
||||
struct swap_id_block {
|
||||
/* unsigned char sws_boot[1024]; */
|
||||
__u32 sws_version;
|
||||
__u32 sws_lastpage;
|
||||
__u32 sws_nrbad;
|
||||
unsigned char sws_uuid[16];
|
||||
char sws_volume[16];
|
||||
unsigned char sws_pad[117];
|
||||
__u32 sws_badpg;
|
||||
};
|
||||
|
||||
/* Yucky misaligned values */
|
||||
struct vfat_super_block {
|
||||
/* 00*/ unsigned char vs_ignored[3];
|
||||
/* 03*/ unsigned char vs_sysid[8];
|
||||
/* 0b*/ unsigned char vs_sector_size[2];
|
||||
/* 0d*/ __u8 vs_cluster_size;
|
||||
/* 0e*/ __u16 vs_reserved;
|
||||
/* 10*/ __u8 vs_fats;
|
||||
/* 11*/ unsigned char vs_dir_entries[2];
|
||||
/* 13*/ unsigned char vs_sectors[2];
|
||||
/* 15*/ unsigned char vs_media;
|
||||
/* 16*/ __u16 vs_fat_length;
|
||||
/* 18*/ __u16 vs_secs_track;
|
||||
/* 1a*/ __u16 vs_heads;
|
||||
/* 1c*/ __u32 vs_hidden;
|
||||
/* 20*/ __u32 vs_total_sect;
|
||||
/* 24*/ __u32 vs_fat32_length;
|
||||
/* 28*/ __u16 vs_flags;
|
||||
/* 2a*/ __u8 vs_version[2];
|
||||
/* 2c*/ __u32 vs_root_cluster;
|
||||
/* 30*/ __u16 vs_insfo_sector;
|
||||
/* 32*/ __u16 vs_backup_boot;
|
||||
/* 34*/ __u16 vs_reserved2[6];
|
||||
/* 40*/ unsigned char vs_unknown[3];
|
||||
/* 43*/ unsigned char vs_serno[4];
|
||||
/* 47*/ unsigned char vs_label[11];
|
||||
/* 52*/ unsigned char vs_magic[8];
|
||||
/* 5a*/ unsigned char vs_dummy2[164];
|
||||
/*1fe*/ unsigned char vs_pmagic[2];
|
||||
};
|
||||
|
||||
/* Yucky misaligned values */
|
||||
struct msdos_super_block {
|
||||
/* 00*/ unsigned char ms_ignored[3];
|
||||
/* 03*/ unsigned char ms_sysid[8];
|
||||
/* 0b*/ unsigned char ms_sector_size[2];
|
||||
/* 0d*/ __u8 ms_cluster_size;
|
||||
/* 0e*/ __u16 ms_reserved;
|
||||
/* 10*/ __u8 ms_fats;
|
||||
/* 11*/ unsigned char ms_dir_entries[2];
|
||||
/* 13*/ unsigned char ms_sectors[2];
|
||||
/* 15*/ unsigned char ms_media;
|
||||
/* 16*/ __u16 ms_fat_length;
|
||||
/* 18*/ __u16 ms_secs_track;
|
||||
/* 1a*/ __u16 ms_heads;
|
||||
/* 1c*/ __u32 ms_hidden;
|
||||
/* 20*/ __u32 ms_total_sect;
|
||||
/* 24*/ unsigned char ms_unknown[3];
|
||||
/* 27*/ unsigned char ms_serno[4];
|
||||
/* 2b*/ unsigned char ms_label[11];
|
||||
/* 36*/ unsigned char ms_magic[8];
|
||||
/* 3d*/ unsigned char ms_dummy2[192];
|
||||
/*1fe*/ unsigned char ms_pmagic[2];
|
||||
};
|
||||
|
||||
struct vfat_dir_entry {
|
||||
__u8 name[11];
|
||||
__u8 attr;
|
||||
__u16 time_creat;
|
||||
__u16 date_creat;
|
||||
__u16 time_acc;
|
||||
__u16 date_acc;
|
||||
__u16 cluster_high;
|
||||
__u16 time_write;
|
||||
__u16 date_write;
|
||||
__u16 cluster_low;
|
||||
__u32 size;
|
||||
};
|
||||
|
||||
/* maximum number of clusters */
|
||||
#define FAT12_MAX 0xFF4
|
||||
#define FAT16_MAX 0xFFF4
|
||||
#define FAT32_MAX 0x0FFFFFF6
|
||||
|
||||
struct minix_super_block {
|
||||
__u16 ms_ninodes;
|
||||
__u16 ms_nzones;
|
||||
__u16 ms_imap_blocks;
|
||||
__u16 ms_zmap_blocks;
|
||||
__u16 ms_firstdatazone;
|
||||
__u16 ms_log_zone_size;
|
||||
__u32 ms_max_size;
|
||||
unsigned char ms_magic[2];
|
||||
__u16 ms_state;
|
||||
__u32 ms_zones;
|
||||
};
|
||||
|
||||
struct mdp_superblock_s {
|
||||
__u32 md_magic;
|
||||
__u32 major_version;
|
||||
__u32 minor_version;
|
||||
__u32 patch_version;
|
||||
__u32 gvalid_words;
|
||||
__u32 set_uuid0;
|
||||
__u32 ctime;
|
||||
__u32 level;
|
||||
__u32 size;
|
||||
__u32 nr_disks;
|
||||
__u32 raid_disks;
|
||||
__u32 md_minor;
|
||||
__u32 not_persistent;
|
||||
__u32 set_uuid1;
|
||||
__u32 set_uuid2;
|
||||
__u32 set_uuid3;
|
||||
};
|
||||
|
||||
struct hfs_super_block {
|
||||
char h_magic[2];
|
||||
char h_dummy[18];
|
||||
__u32 h_blksize;
|
||||
};
|
||||
|
||||
struct ocfs_volume_header {
|
||||
unsigned char minor_version[4];
|
||||
unsigned char major_version[4];
|
||||
unsigned char signature[128];
|
||||
char mount[128];
|
||||
unsigned char mount_len[2];
|
||||
};
|
||||
|
||||
struct ocfs_volume_label {
|
||||
unsigned char disk_lock[48];
|
||||
char label[64];
|
||||
unsigned char label_len[2];
|
||||
unsigned char vol_id[16];
|
||||
unsigned char vol_id_len[2];
|
||||
};
|
||||
|
||||
#define ocfsmajor(o) ((__u32)o.major_version[0] \
|
||||
+ (((__u32) o.major_version[1]) << 8) \
|
||||
+ (((__u32) o.major_version[2]) << 16) \
|
||||
+ (((__u32) o.major_version[3]) << 24))
|
||||
#define ocfslabellen(o) ((__u32)o.label_len[0] + (((__u32) o.label_len[1]) << 8))
|
||||
#define ocfsmountlen(o) ((__u32)o.mount_len[0] + (((__u32) o.mount_len[1])<<8))
|
||||
|
||||
#define OCFS_MAGIC "OracleCFS"
|
||||
|
||||
struct ocfs2_super_block {
|
||||
unsigned char signature[8];
|
||||
unsigned char s_dummy1[184];
|
||||
unsigned char s_dummy2[80];
|
||||
char s_label[64];
|
||||
unsigned char s_uuid[16];
|
||||
};
|
||||
|
||||
#define OCFS2_MIN_BLOCKSIZE 512
|
||||
#define OCFS2_MAX_BLOCKSIZE 4096
|
||||
|
||||
#define OCFS2_SUPER_BLOCK_BLKNO 2
|
||||
|
||||
#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
|
||||
|
||||
struct oracle_asm_disk_label {
|
||||
char dummy[32];
|
||||
char dl_tag[8];
|
||||
char dl_id[24];
|
||||
};
|
||||
|
||||
#define ORACLE_ASM_DISK_LABEL_MARKED "ORCLDISK"
|
||||
#define ORACLE_ASM_DISK_LABEL_OFFSET 32
|
||||
|
||||
struct iso_volume_descriptor {
|
||||
unsigned char vd_type;
|
||||
unsigned char vd_id[5];
|
||||
unsigned char vd_version;
|
||||
unsigned char flags;
|
||||
unsigned char system_id[32];
|
||||
unsigned char volume_id[32];
|
||||
unsigned char unused[8];
|
||||
unsigned char space_size[8];
|
||||
unsigned char escape_sequences[8];
|
||||
};
|
||||
|
||||
/* Common gfs/gfs2 constants: */
|
||||
#define GFS_MAGIC 0x01161970
|
||||
#define GFS_DEFAULT_BSIZE 4096
|
||||
#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE)
|
||||
#define GFS_METATYPE_SB 1
|
||||
#define GFS_FORMAT_SB 100
|
||||
#define GFS_LOCKNAME_LEN 64
|
||||
|
||||
/* gfs1 constants: */
|
||||
#define GFS_FORMAT_FS 1309
|
||||
#define GFS_FORMAT_MULTI 1401
|
||||
/* gfs2 constants: */
|
||||
#define GFS2_FORMAT_FS 1801
|
||||
#define GFS2_FORMAT_MULTI 1900
|
||||
|
||||
struct gfs2_meta_header {
|
||||
__u32 mh_magic;
|
||||
__u32 mh_type;
|
||||
__u64 __pad0; /* Was generation number in gfs1 */
|
||||
__u32 mh_format;
|
||||
__u32 __pad1; /* Was incarnation number in gfs1 */
|
||||
};
|
||||
|
||||
struct gfs2_inum {
|
||||
__u64 no_formal_ino;
|
||||
__u64 no_addr;
|
||||
};
|
||||
|
||||
struct gfs2_sb {
|
||||
struct gfs2_meta_header sb_header;
|
||||
|
||||
__u32 sb_fs_format;
|
||||
__u32 sb_multihost_format;
|
||||
__u32 __pad0; /* Was superblock flags in gfs1 */
|
||||
|
||||
__u32 sb_bsize;
|
||||
__u32 sb_bsize_shift;
|
||||
__u32 __pad1; /* Was journal segment size in gfs1 */
|
||||
|
||||
struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
|
||||
struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
|
||||
struct gfs2_inum sb_root_dir;
|
||||
|
||||
char sb_lockproto[GFS_LOCKNAME_LEN];
|
||||
char sb_locktable[GFS_LOCKNAME_LEN];
|
||||
/* In gfs1, quota and license dinodes followed */
|
||||
};
|
||||
|
||||
struct ntfs_super_block {
|
||||
__u8 jump[3];
|
||||
__u8 oem_id[8];
|
||||
__u8 bios_parameter_block[25];
|
||||
__u16 unused[2];
|
||||
__u64 number_of_sectors;
|
||||
__u64 mft_cluster_location;
|
||||
__u64 mft_mirror_cluster_location;
|
||||
__s8 cluster_per_mft_record;
|
||||
__u8 reserved1[3];
|
||||
__s8 cluster_per_index_record;
|
||||
__u8 reserved2[3];
|
||||
__u64 volume_serial;
|
||||
__u16 checksum;
|
||||
};
|
||||
|
||||
struct master_file_table_record {
|
||||
__u32 magic;
|
||||
__u16 usa_ofs;
|
||||
__u16 usa_count;
|
||||
__u64 lsn;
|
||||
__u16 sequence_number;
|
||||
__u16 link_count;
|
||||
__u16 attrs_offset;
|
||||
__u16 flags;
|
||||
__u32 bytes_in_use;
|
||||
__u32 bytes_allocated;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct file_attribute {
|
||||
__u32 type;
|
||||
__u32 len;
|
||||
__u8 non_resident;
|
||||
__u8 name_len;
|
||||
__u16 name_offset;
|
||||
__u16 flags;
|
||||
__u16 instance;
|
||||
__u32 value_len;
|
||||
__u16 value_offset;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#define MFT_RECORD_VOLUME 3
|
||||
#define MFT_RECORD_ATTR_VOLUME_NAME 0x60
|
||||
#define MFT_RECORD_ATTR_VOLUME_INFO 0x70
|
||||
#define MFT_RECORD_ATTR_OBJECT_ID 0x40
|
||||
#define MFT_RECORD_ATTR_END 0xffffffffu
|
||||
|
||||
/* HFS / HFS+ */
|
||||
struct hfs_finder_info {
|
||||
__u32 boot_folder;
|
||||
__u32 start_app;
|
||||
__u32 open_folder;
|
||||
__u32 os9_folder;
|
||||
__u32 reserved;
|
||||
__u32 osx_folder;
|
||||
__u8 id[8];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct hfs_mdb {
|
||||
__u8 signature[2];
|
||||
__u32 cr_date;
|
||||
__u32 ls_Mod;
|
||||
__u16 atrb;
|
||||
__u16 nm_fls;
|
||||
__u16 vbm_st;
|
||||
__u16 alloc_ptr;
|
||||
__u16 nm_al_blks;
|
||||
__u32 al_blk_size;
|
||||
__u32 clp_size;
|
||||
__u16 al_bl_st;
|
||||
__u32 nxt_cnid;
|
||||
__u16 free_bks;
|
||||
__u8 label_len;
|
||||
__u8 label[27];
|
||||
__u32 vol_bkup;
|
||||
__u16 vol_seq_num;
|
||||
__u32 wr_cnt;
|
||||
__u32 xt_clump_size;
|
||||
__u32 ct_clump_size;
|
||||
__u16 num_root_dirs;
|
||||
__u32 file_count;
|
||||
__u32 dir_count;
|
||||
struct hfs_finder_info finder_info;
|
||||
__u8 embed_sig[2];
|
||||
__u16 embed_startblock;
|
||||
__u16 embed_blockcount;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
#define HFS_NODE_LEAF 0xff
|
||||
#define HFSPLUS_POR_CNID 1
|
||||
|
||||
struct hfsplus_bnode_descriptor {
|
||||
__u32 next;
|
||||
__u32 prev;
|
||||
__u8 type;
|
||||
__u8 height;
|
||||
__u16 num_recs;
|
||||
__u16 reserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct hfsplus_bheader_record {
|
||||
__u16 depth;
|
||||
__u32 root;
|
||||
__u32 leaf_count;
|
||||
__u32 leaf_head;
|
||||
__u32 leaf_tail;
|
||||
__u16 node_size;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct hfsplus_catalog_key {
|
||||
__u16 key_len;
|
||||
__u32 parent_id;
|
||||
__u16 unicode_len;
|
||||
__u8 unicode[255 * 2];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct hfsplus_extent {
|
||||
__u32 start_block;
|
||||
__u32 block_count;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define HFSPLUS_EXTENT_COUNT 8
|
||||
struct hfsplus_fork {
|
||||
__u64 total_size;
|
||||
__u32 clump_size;
|
||||
__u32 total_blocks;
|
||||
struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct hfsplus_vol_header {
|
||||
__u8 signature[2];
|
||||
__u16 version;
|
||||
__u32 attributes;
|
||||
__u32 last_mount_vers;
|
||||
__u32 reserved;
|
||||
__u32 create_date;
|
||||
__u32 modify_date;
|
||||
__u32 backup_date;
|
||||
__u32 checked_date;
|
||||
__u32 file_count;
|
||||
__u32 folder_count;
|
||||
__u32 blocksize;
|
||||
__u32 total_blocks;
|
||||
__u32 free_blocks;
|
||||
__u32 next_alloc;
|
||||
__u32 rsrc_clump_sz;
|
||||
__u32 data_clump_sz;
|
||||
__u32 next_cnid;
|
||||
__u32 write_count;
|
||||
__u64 encodings_bmp;
|
||||
struct hfs_finder_info finder_info;
|
||||
struct hfsplus_fork alloc_file;
|
||||
struct hfsplus_fork ext_file;
|
||||
struct hfsplus_fork cat_file;
|
||||
struct hfsplus_fork attr_file;
|
||||
struct hfsplus_fork start_file;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/* this is lvm's label_header & pv_header combined. */
|
||||
|
||||
#define LVM2_ID_LEN 32
|
||||
|
||||
struct lvm2_pv_label_header {
|
||||
/* label_header */
|
||||
__u8 id[8]; /* LABELONE */
|
||||
__u64 sector_xl; /* Sector number of this label */
|
||||
__u32 crc_xl; /* From next field to end of sector */
|
||||
__u32 offset_xl; /* Offset from start of struct to contents */
|
||||
__u8 type[8]; /* LVM2 001 */
|
||||
/* pv_header */
|
||||
__u8 pv_uuid[LVM2_ID_LEN];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*
|
||||
* this is a very generous portion of the super block, giving us
|
||||
* room to translate 14 chunks with 3 stripes each.
|
||||
*/
|
||||
#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
|
||||
#define BTRFS_LABEL_SIZE 256
|
||||
#define BTRFS_UUID_SIZE 16
|
||||
#define BTRFS_FSID_SIZE 16
|
||||
#define BTRFS_CSUM_SIZE 32
|
||||
|
||||
struct btrfs_dev_item {
|
||||
/* the internal btrfs device id */
|
||||
__u64 devid;
|
||||
|
||||
/* size of the device */
|
||||
__u64 total_bytes;
|
||||
|
||||
/* bytes used */
|
||||
__u64 bytes_used;
|
||||
|
||||
/* optimal io alignment for this device */
|
||||
__u32 io_align;
|
||||
|
||||
/* optimal io width for this device */
|
||||
__u32 io_width;
|
||||
|
||||
/* minimal io size for this device */
|
||||
__u32 sector_size;
|
||||
|
||||
/* type and info about this device */
|
||||
__u64 type;
|
||||
|
||||
/* expected generation for this device */
|
||||
__u64 generation;
|
||||
|
||||
/*
|
||||
* starting byte of this partition on the device,
|
||||
* to allow for stripe alignment in the future
|
||||
*/
|
||||
__u64 start_offset;
|
||||
|
||||
/* grouping information for allocation decisions */
|
||||
__u32 dev_group;
|
||||
|
||||
/* seek speed 0-100 where 100 is fastest */
|
||||
__u8 seek_speed;
|
||||
|
||||
/* bandwidth 0-100 where 100 is fastest */
|
||||
__u8 bandwidth;
|
||||
|
||||
/* btrfs generated uuid for this device */
|
||||
__u8 uuid[BTRFS_UUID_SIZE];
|
||||
|
||||
/* uuid of FS who owns this device */
|
||||
__u8 fsid[BTRFS_UUID_SIZE];
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
/*
|
||||
* the super block basically lists the main trees of the FS
|
||||
* it currently lacks any block count etc etc
|
||||
*/
|
||||
struct btrfs_super_block {
|
||||
__u8 csum[BTRFS_CSUM_SIZE];
|
||||
/* the first 3 fields must match struct btrfs_header */
|
||||
__u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
|
||||
__u64 bytenr; /* this block number */
|
||||
__u64 flags;
|
||||
|
||||
/* allowed to be different from the btrfs_header from here own down */
|
||||
__u64 magic;
|
||||
__u64 generation;
|
||||
__u64 root;
|
||||
__u64 chunk_root;
|
||||
__u64 log_root;
|
||||
|
||||
/* this will help find the new super based on the log root */
|
||||
__u64 log_root_transid;
|
||||
__u64 total_bytes;
|
||||
__u64 bytes_used;
|
||||
__u64 root_dir_objectid;
|
||||
__u64 num_devices;
|
||||
__u32 sectorsize;
|
||||
__u32 nodesize;
|
||||
__u32 leafsize;
|
||||
__u32 stripesize;
|
||||
__u32 sys_chunk_array_size;
|
||||
__u64 chunk_root_generation;
|
||||
__u64 compat_flags;
|
||||
__u64 compat_ro_flags;
|
||||
__u64 incompat_flags;
|
||||
__u16 csum_type;
|
||||
__u8 root_level;
|
||||
__u8 chunk_root_level;
|
||||
__u8 log_root_level;
|
||||
struct btrfs_dev_item dev_item;
|
||||
|
||||
char label[BTRFS_LABEL_SIZE];
|
||||
|
||||
/* future expansion */
|
||||
__u64 reserved[32];
|
||||
__u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
#define F2FS_MAX_EXTENSION 64 /* # of extension entries */
|
||||
|
||||
struct f2fs_super_block {
|
||||
__u32 magic; /* Magic Number */
|
||||
__u16 major_ver; /* Major Version */
|
||||
__u16 minor_ver; /* Minor Version */
|
||||
__u32 log_sectorsize; /* log2 sector size in bytes */
|
||||
__u32 log_sectors_per_block; /* log2 # of sectors per block */
|
||||
__u32 log_blocksize; /* log2 block size in bytes */
|
||||
__u32 log_blocks_per_seg; /* log2 # of blocks per segment */
|
||||
__u32 segs_per_sec; /* # of segments per section */
|
||||
__u32 secs_per_zone; /* # of sections per zone */
|
||||
__u32 checksum_offset; /* checksum offset inside super block */
|
||||
__u64 block_count; /* total # of user blocks */
|
||||
__u32 section_count; /* total # of sections */
|
||||
__u32 segment_count; /* total # of segments */
|
||||
__u32 segment_count_ckpt; /* # of segments for checkpoint */
|
||||
__u32 segment_count_sit; /* # of segments for SIT */
|
||||
__u32 segment_count_nat; /* # of segments for NAT */
|
||||
__u32 segment_count_ssa; /* # of segments for SSA */
|
||||
__u32 segment_count_main; /* # of segments for main area */
|
||||
__u32 segment0_blkaddr; /* start block address of segment 0 */
|
||||
__u32 cp_blkaddr; /* start block address of checkpoint */
|
||||
__u32 sit_blkaddr; /* start block address of SIT */
|
||||
__u32 nat_blkaddr; /* start block address of NAT */
|
||||
__u32 ssa_blkaddr; /* start block address of SSA */
|
||||
__u32 main_blkaddr; /* start block address of main area */
|
||||
__u32 root_ino; /* root inode number */
|
||||
__u32 node_ino; /* node inode number */
|
||||
__u32 meta_ino; /* meta inode number */
|
||||
__u8 uuid[16]; /* 128-bit uuid for volume */
|
||||
__u16 volume_name[512]; /* volume name */
|
||||
__u32 extension_count; /* # of extensions below */
|
||||
__u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct exfat_super_block {
|
||||
uint8_t jump[3];
|
||||
uint8_t oem_name[8];
|
||||
uint8_t __unused1[53];
|
||||
uint64_t block_start;
|
||||
uint64_t block_count;
|
||||
uint32_t fat_block_start;
|
||||
uint32_t fat_block_count;
|
||||
uint32_t cluster_block_start;
|
||||
uint32_t cluster_count;
|
||||
uint32_t rootdir_cluster;
|
||||
uint8_t volume_serial[4];
|
||||
struct {
|
||||
uint8_t vermin;
|
||||
uint8_t vermaj;
|
||||
} version;
|
||||
uint16_t volume_state;
|
||||
uint8_t block_bits;
|
||||
uint8_t bpc_bits;
|
||||
uint8_t fat_count;
|
||||
uint8_t drive_no;
|
||||
uint8_t allocated_percent;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct exfat_entry_label {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
uint8_t name[30];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#define BLOCK_SIZE(sb) (1 << (sb)->block_bits)
|
||||
#define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
|
||||
|
||||
#define EXFAT_FIRST_DATA_CLUSTER 2
|
||||
#define EXFAT_LAST_DATA_CLUSTER 0xffffff6
|
||||
#define EXFAT_ENTRY_SIZE 32
|
||||
|
||||
#define EXFAT_ENTRY_EOD 0x00
|
||||
#define EXFAT_ENTRY_LABEL 0x83
|
||||
|
||||
/*
|
||||
* Byte swap functions
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define _INLINE_ static __inline__
|
||||
#else /* For Watcom C */
|
||||
#define _INLINE_ static inline
|
||||
#endif
|
||||
|
||||
_INLINE_ __u16 blkid_swab16(__u16 val)
|
||||
{
|
||||
return (val >> 8) | (val << 8);
|
||||
}
|
||||
|
||||
_INLINE_ __u32 blkid_swab32(__u32 val)
|
||||
{
|
||||
return ((val>>24) | ((val>>8)&0xFF00) |
|
||||
((val<<8)&0xFF0000) | (val<<24));
|
||||
}
|
||||
|
||||
_INLINE_ __u64 blkid_swab64(__u64 val)
|
||||
{
|
||||
return (blkid_swab32(val >> 32) |
|
||||
(((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32));
|
||||
}
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define blkid_le16(x) blkid_swab16(x)
|
||||
#define blkid_le32(x) blkid_swab32(x)
|
||||
#define blkid_le64(x) blkid_swab64(x)
|
||||
#define blkid_be16(x) (x)
|
||||
#define blkid_be32(x) (x)
|
||||
#define blkid_be64(x) (x)
|
||||
#else
|
||||
#define blkid_le16(x) (x)
|
||||
#define blkid_le32(x) (x)
|
||||
#define blkid_le64(x) (x)
|
||||
#define blkid_be16(x) blkid_swab16(x)
|
||||
#define blkid_be32(x) blkid_swab32(x)
|
||||
#define blkid_be64(x) blkid_swab64(x)
|
||||
#endif
|
||||
|
||||
#undef _INLINE_
|
||||
|
||||
#endif /* _BLKID_PROBE_H */
|
||||
678
include/e2fsprogs/config.h
Executable file
678
include/e2fsprogs/config.h
Executable file
@@ -0,0 +1,678 @@
|
||||
/* lib/config.h. Generated from config.h.in by configure. */
|
||||
/* lib/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* Define to 1 if debugging the blkid library */
|
||||
/* #undef CONFIG_BLKID_DEBUG */
|
||||
|
||||
/* Define to 1 to compile findfs */
|
||||
/* #undef CONFIG_BUILD_FINDFS */
|
||||
|
||||
/* Define to 1 for features for use by ext4 developers */
|
||||
/* #undef CONFIG_DEVELOPER_FEATURES */
|
||||
|
||||
/* Define to 1 if using dlopen to access libarchive */
|
||||
#define CONFIG_DLOPEN_LIBARCHIVE 1
|
||||
|
||||
/* Define to 1 if debugging ext3/4 journal code */
|
||||
/* #undef CONFIG_JBD_DEBUG */
|
||||
|
||||
/* Define to 1 to enable mmp support */
|
||||
#define CONFIG_MMP 1
|
||||
|
||||
/* Define to 1 to enable tdb support */
|
||||
#define CONFIG_TDB 1
|
||||
|
||||
/* Define to 1 if the testio I/O manager should be enabled */
|
||||
#define CONFIG_TESTIO_DEBUG 1
|
||||
|
||||
/* Define to 1 to disable use of backtrace */
|
||||
/* #undef DISABLE_BACKTRACE */
|
||||
|
||||
/* Define to 1 to enable bitmap stats. */
|
||||
#define ENABLE_BMAP_STATS 1
|
||||
|
||||
/* Define to 1 to enable bitmap stats. */
|
||||
/* #undef ENABLE_BMAP_STATS_OPS */
|
||||
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
/* #undef ENABLE_NLS */
|
||||
|
||||
/* Define to the version of FUSE to use */
|
||||
#define FUSE_USE_VERSION 29
|
||||
|
||||
/* Define to 1 if you have the `add_key' function. */
|
||||
/* #undef HAVE_ADD_KEY */
|
||||
|
||||
/* Define to 1 if you have the <archive.h> header file. */
|
||||
#define HAVE_ARCHIVE_H 1
|
||||
|
||||
/* Define to 1 if you have the <attr/xattr.h> header file. */
|
||||
/* #undef HAVE_ATTR_XATTR_H */
|
||||
|
||||
/* Define to 1 if you have the `backtrace' function. */
|
||||
#define HAVE_BACKTRACE 1
|
||||
|
||||
/* Define to 1 if blkid has blkid_probe_enable_partitions */
|
||||
// #define HAVE_BLKID_PROBE_ENABLE_PARTITIONS 1
|
||||
|
||||
/* Define to 1 if blkid has blkid_probe_get_topology */
|
||||
/* #undef HAVE_BLKID_PROBE_GET_TOPOLOGY */
|
||||
|
||||
/* Define to 1 if blkid has blkid_topology_get_dax */
|
||||
/* #undef HAVE_BLKID_TOPOLOGY_GET_DAX */
|
||||
|
||||
/* Define to 1 if you have the BSD-style 'qsort_r' function. */
|
||||
/* #undef HAVE_BSD_QSORT_R */
|
||||
|
||||
/* Define to 1 if you have the Mac OS X function
|
||||
CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */
|
||||
/* #undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES */
|
||||
|
||||
/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
|
||||
the CoreFoundation framework. */
|
||||
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
|
||||
|
||||
/* Define to 1 if you have the `chflags' function. */
|
||||
/* #undef HAVE_CHFLAGS */
|
||||
|
||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||
*/
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file. */
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define to 1 if you have the `dlopen' function. */
|
||||
#define HAVE_DLOPEN 1
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
#define HAVE_EXECINFO_H 1
|
||||
|
||||
/* Define to 1 if Ext2 ioctls present */
|
||||
#define HAVE_EXT2_IOCTLS 1
|
||||
|
||||
/* Define to 1 if you have the `fadvise64' function. */
|
||||
/* #undef HAVE_FADVISE64 */
|
||||
|
||||
/* Define to 1 if you have the `fallocate' function. */
|
||||
#define HAVE_FALLOCATE 1
|
||||
|
||||
/* Define to 1 if you have the `fallocate64' function. */
|
||||
#define HAVE_FALLOCATE64 1
|
||||
|
||||
/* Define to 1 if you have the `fchown' function. */
|
||||
#define HAVE_FCHOWN 1
|
||||
|
||||
/* Define to 1 if you have the `fcntl' function. */
|
||||
#define HAVE_FCNTL 1
|
||||
|
||||
/* Define to 1 if you have the `fdatasync' function. */
|
||||
#define HAVE_FDATASYNC 1
|
||||
|
||||
/* Define to 1 if fsmap_sizeof() is declared in linux/fsmap.h */
|
||||
/* #undef HAVE_FSMAP_SIZEOF */
|
||||
|
||||
/* Define to 1 if you have the `fstat64' function. */
|
||||
#define HAVE_FSTAT64 1
|
||||
|
||||
/* Define to 1 if you have the `fsync' function. */
|
||||
#define HAVE_FSYNC 1
|
||||
|
||||
/* Define to 1 if you have the `ftruncate64' function. */
|
||||
#define HAVE_FTRUNCATE64 1
|
||||
|
||||
/* Define to 1 if you have the <fuse.h> header file. */
|
||||
#define HAVE_FUSE_H 1
|
||||
|
||||
/* Define to 1 if you have the `futimes' function. */
|
||||
#define HAVE_FUTIMES 1
|
||||
|
||||
/* Define to 1 if you have the `getcwd' function. */
|
||||
#define HAVE_GETCWD 1
|
||||
|
||||
/* Define to 1 if you have the `getdtablesize' function. */
|
||||
/* #undef HAVE_GETDTABLESIZE */
|
||||
|
||||
/* Define to 1 if you have the `getentropy' function. */
|
||||
#define HAVE_GETENTROPY 1
|
||||
|
||||
/* Define to 1 if you have the `gethostname' function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the `getmntinfo' function. */
|
||||
/* #undef HAVE_GETMNTINFO */
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
/* Define to 1 if you have the `getpwuid_r' function. */
|
||||
#define HAVE_GETPWUID_R 1
|
||||
|
||||
/* Define to 1 if you have the `getrandom' function. */
|
||||
#define HAVE_GETRANDOM 1
|
||||
|
||||
/* Define to 1 if you have the `getrlimit' function. */
|
||||
#define HAVE_GETRLIMIT 1
|
||||
|
||||
/* Define to 1 if you have the `getrusage' function. */
|
||||
#define HAVE_GETRUSAGE 1
|
||||
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
/* #undef HAVE_GETTEXT */
|
||||
|
||||
/* Define to 1 if you have the GNU-style 'qsort_r' function. */
|
||||
/* #undef HAVE_GNU_QSORT_R */
|
||||
|
||||
/* Define if you have the iconv() function and it works. */
|
||||
#define HAVE_ICONV 1
|
||||
|
||||
/* Define to 1 if the system has the type `intptr_t'. */
|
||||
#define HAVE_INTPTR_T 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `jrand48' function. */
|
||||
#define HAVE_JRAND48 1
|
||||
|
||||
/* Define to 1 if you have the `keyctl' function. */
|
||||
/* #undef HAVE_KEYCTL */
|
||||
|
||||
/* Define to 1 if you have the <linux/falloc.h> header file. */
|
||||
#define HAVE_LINUX_FALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/fd.h> header file. */
|
||||
#define HAVE_LINUX_FD_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/fsmap.h> header file. */
|
||||
#define HAVE_LINUX_FSMAP_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/loop.h> header file. */
|
||||
#define HAVE_LINUX_LOOP_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/major.h> header file. */
|
||||
#define HAVE_LINUX_MAJOR_H 1
|
||||
|
||||
/* Define to 1 if you have the <linux/types.h> header file. */
|
||||
#define HAVE_LINUX_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `llistxattr' function. */
|
||||
#define HAVE_LLISTXATTR 1
|
||||
|
||||
/* Define to 1 if you have the `llseek' function. */
|
||||
/* #undef HAVE_LLSEEK */
|
||||
|
||||
/* Define to 1 if llseek declared in unistd.h */
|
||||
/* #undef HAVE_LLSEEK_PROTOTYPE */
|
||||
|
||||
/* Define to 1 if you have the `lseek64' function. */
|
||||
#define HAVE_LSEEK64 1
|
||||
|
||||
/* Define to 1 if lseek64 declared in unistd.h */
|
||||
#define HAVE_LSEEK64_PROTOTYPE 1
|
||||
|
||||
/* Define to 1 if you have the <magic.h> header file. */
|
||||
#define HAVE_MAGIC_H 1
|
||||
|
||||
/* Define to 1 if you have the `mallinfo' function. */
|
||||
#define HAVE_MALLINFO 1
|
||||
|
||||
/* Define to 1 if you have the `mallinfo2' function. */
|
||||
/* #undef HAVE_MALLINFO2 */
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the `mbstowcs' function. */
|
||||
#define HAVE_MBSTOWCS 1
|
||||
|
||||
/* Define to 1 if you have the `memalign' function. */
|
||||
#define HAVE_MEMALIGN 1
|
||||
|
||||
/* Define to 1 if you have the `mempcpy' function. */
|
||||
#define HAVE_MEMPCPY 1
|
||||
|
||||
/* Define to 1 if you have the <minix/config.h> header file. */
|
||||
/* #undef HAVE_MINIX_CONFIG_H */
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#define HAVE_MMAP 1
|
||||
|
||||
/* Define to 1 if you have the <mntent.h> header file. */
|
||||
#define HAVE_MNTENT_H 1
|
||||
|
||||
/* Define to 1 if mount supports nodev. */
|
||||
#define HAVE_MOUNT_NODEV 1
|
||||
|
||||
/* Define to 1 if mount supports nosuid. */
|
||||
#define HAVE_MOUNT_NOSUID 1
|
||||
|
||||
/* Define to 1 if you have the `msync' function. */
|
||||
#define HAVE_MSYNC 1
|
||||
|
||||
/* Define to 1 if you have the `nanosleep' function. */
|
||||
#define HAVE_NANOSLEEP 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if_dl.h> header file. */
|
||||
/* #undef HAVE_NET_IF_DL_H */
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have the `open64' function. */
|
||||
#define HAVE_OPEN64 1
|
||||
|
||||
/* Define to 1 if optreset for getopt is present */
|
||||
/* #undef HAVE_OPTRESET */
|
||||
|
||||
/* Define to 1 if you have the `pathconf' function. */
|
||||
#define HAVE_PATHCONF 1
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#define HAVE_PATHS_H 1
|
||||
|
||||
/* Define to 1 if you have the `posix_fadvise' function. */
|
||||
#define HAVE_POSIX_FADVISE 1
|
||||
|
||||
/* Define to 1 if you have the `posix_fadvise64' function. */
|
||||
#define HAVE_POSIX_FADVISE64 1
|
||||
|
||||
/* Define to 1 if you have the `posix_memalign' function. */
|
||||
#define HAVE_POSIX_MEMALIGN 1
|
||||
|
||||
/* Define to 1 if you have the `prctl' function. */
|
||||
#define HAVE_PRCTL 1
|
||||
|
||||
/* Define to 1 if you have the `pread' function. */
|
||||
#define HAVE_PREAD 1
|
||||
|
||||
/* Define to 1 if you have the `pread64' function. */
|
||||
#define HAVE_PREAD64 1
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#define HAVE_PTHREAD 1
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#define HAVE_PTHREAD_H 1
|
||||
|
||||
/* Have PTHREAD_PRIO_INHERIT. */
|
||||
#define HAVE_PTHREAD_PRIO_INHERIT 1
|
||||
|
||||
/* Define to 1 if you have the `pwrite' function. */
|
||||
#define HAVE_PWRITE 1
|
||||
|
||||
/* Define to 1 if you have the `pwrite64' function. */
|
||||
#define HAVE_PWRITE64 1
|
||||
|
||||
/* Define to 1 if you have the `qsort_r' function. */
|
||||
/* #undef HAVE_QSORT_R */
|
||||
|
||||
/* Define to 1 if dirent has d_reclen */
|
||||
#define HAVE_RECLEN_DIRENT 1
|
||||
|
||||
/* Define to 1 if if struct sockaddr contains sa_len */
|
||||
/* #undef HAVE_SA_LEN */
|
||||
|
||||
/* Define to 1 if you have the `secure_getenv' function. */
|
||||
/* #undef HAVE_SECURE_GETENV */
|
||||
|
||||
/* Define to 1 if you have the <semaphore.h> header file. */
|
||||
#define HAVE_SEMAPHORE_H 1
|
||||
|
||||
/* Define to 1 if sem_init() exists */
|
||||
/* #undef HAVE_SEM_INIT */
|
||||
|
||||
/* Define to 1 if you have the <setjmp.h> header file. */
|
||||
#define HAVE_SETJMP_H 1
|
||||
|
||||
/* Define to 1 if you have the `setmntent' function. */
|
||||
#define HAVE_SETMNTENT 1
|
||||
|
||||
/* Define to 1 if you have the `setresgid' function. */
|
||||
#define HAVE_SETRESGID 1
|
||||
|
||||
/* Define to 1 if you have the `setresuid' function. */
|
||||
#define HAVE_SETRESUID 1
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `srandom' function. */
|
||||
#define HAVE_SRANDOM 1
|
||||
|
||||
/* Define to 1 if struct stat has st_flags */
|
||||
/* #undef HAVE_STAT_FLAGS */
|
||||
|
||||
/* Define to 1 if you have the <stdarg.h> header file. */
|
||||
#define HAVE_STDARG_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#define HAVE_STDIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `stpcpy' function. */
|
||||
#define HAVE_STPCPY 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strnlen' function. */
|
||||
#define HAVE_STRNLEN 1
|
||||
|
||||
/* Define to 1 if you have the `strptime' function. */
|
||||
#define HAVE_STRPTIME 1
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
#define HAVE_STRTOULL 1
|
||||
|
||||
/* Define to 1 if `st_atim' is a member of `struct stat'. */
|
||||
#define HAVE_STRUCT_STAT_ST_ATIM 1
|
||||
|
||||
/* Define to 1 if you have the `sync_file_range' function. */
|
||||
#define HAVE_SYNC_FILE_RANGE 1
|
||||
|
||||
/* Define to 1 if you have the `sysconf' function. */
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
/* Define to 1 if you have the <sys/acl.h> header file. */
|
||||
/* #undef HAVE_SYS_ACL_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/disklabel.h> header file. */
|
||||
/* #undef HAVE_SYS_DISKLABEL_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/disk.h> header file. */
|
||||
/* #undef HAVE_SYS_DISK_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/file.h> header file. */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/key.h> header file. */
|
||||
/* #undef HAVE_SYS_KEY_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/mkdev.h> header file. */
|
||||
/* #undef HAVE_SYS_MKDEV_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#define HAVE_SYS_MMAN_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/mount.h> header file. */
|
||||
#define HAVE_SYS_MOUNT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/prctl.h> header file. */
|
||||
#define HAVE_SYS_PRCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/random.h> header file. */
|
||||
#define HAVE_SYS_RANDOM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#define HAVE_SYS_SELECT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKIO_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/syscall.h> header file. */
|
||||
#define HAVE_SYS_SYSCALL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
|
||||
#define HAVE_SYS_SYSMACROS_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/un.h> header file. */
|
||||
#define HAVE_SYS_UN_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/xattr.h> header file. */
|
||||
#define HAVE_SYS_XATTR_H 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <termio.h> header file. */
|
||||
#define HAVE_TERMIO_H 1
|
||||
|
||||
/* Define to 1 if ssize_t declared */
|
||||
#define HAVE_TYPE_SSIZE_T 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `usleep' function. */
|
||||
#define HAVE_USLEEP 1
|
||||
|
||||
/* Define to 1 if you have the `utime' function. */
|
||||
#define HAVE_UTIME 1
|
||||
|
||||
/* Define to 1 if you have the `utimes' function. */
|
||||
#define HAVE_UTIMES 1
|
||||
|
||||
/* Define to 1 if you have the <utime.h> header file. */
|
||||
#define HAVE_UTIME_H 1
|
||||
|
||||
/* Define to 1 if you have the `valloc' function. */
|
||||
/* #undef HAVE_VALLOC */
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#define HAVE_VPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <wchar.h> header file. */
|
||||
#define HAVE_WCHAR_H 1
|
||||
|
||||
/* Define to 1 if you have the `__secure_getenv' function. */
|
||||
/* #undef HAVE___SECURE_GETENV */
|
||||
|
||||
/* package name for gettext */
|
||||
#define PACKAGE "e2fsprogs"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME ""
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING ""
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME ""
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION ""
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
/* #undef PTHREAD_CREATE_JOINABLE */
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG 8
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The size of `off_t', as computed by sizeof. */
|
||||
#define SIZEOF_OFF_T 8
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* The size of `time_t', as computed by sizeof. */
|
||||
#define SIZEOF_TIME_T 8
|
||||
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* If the compiler supports a TLS storage class define it to that here */
|
||||
#define TLS __thread
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE 1
|
||||
#endif
|
||||
/* Enable general extensions on macOS. */
|
||||
#ifndef _DARWIN_C_SOURCE
|
||||
# define _DARWIN_C_SOURCE 1
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# define __EXTENSIONS__ 1
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
/* Enable X/Open compliant socket functions that do not require linking
|
||||
with -lxnet on HP-UX 11.11. */
|
||||
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
|
||||
# define _HPUX_ALT_XOPEN_SOCKET_API 1
|
||||
#endif
|
||||
/* Identify the host operating system as Minix.
|
||||
This macro does not affect the system headers' behavior.
|
||||
A future release of Autoconf may stop defining this macro. */
|
||||
#ifndef _MINIX
|
||||
/* # undef _MINIX */
|
||||
#endif
|
||||
/* Enable general extensions on NetBSD.
|
||||
Enable NetBSD compatibility extensions on Minix. */
|
||||
#ifndef _NETBSD_SOURCE
|
||||
# define _NETBSD_SOURCE 1
|
||||
#endif
|
||||
/* Enable OpenBSD compatibility extensions on NetBSD.
|
||||
Oddly enough, this does nothing on OpenBSD. */
|
||||
#ifndef _OPENBSD_SOURCE
|
||||
# define _OPENBSD_SOURCE 1
|
||||
#endif
|
||||
/* Define to 1 if needed for POSIX-compatible behavior. */
|
||||
#ifndef _POSIX_SOURCE
|
||||
/* # undef _POSIX_SOURCE */
|
||||
#endif
|
||||
/* Define to 2 if needed for POSIX-compatible behavior. */
|
||||
#ifndef _POSIX_1_SOURCE
|
||||
/* # undef _POSIX_1_SOURCE */
|
||||
#endif
|
||||
/* Enable POSIX-compatible threading on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# define _POSIX_PTHREAD_SEMANTICS 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
|
||||
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
|
||||
# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
|
||||
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
|
||||
# define __STDC_WANT_IEC_60559_BFP_EXT__ 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
|
||||
# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
|
||||
# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||
# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
|
||||
#ifndef __STDC_WANT_LIB_EXT2__
|
||||
# define __STDC_WANT_LIB_EXT2__ 1
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC 24747:2009. */
|
||||
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
|
||||
# define __STDC_WANT_MATH_SPEC_FUNCS__ 1
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# define _TANDEM_SOURCE 1
|
||||
#endif
|
||||
/* Enable X/Open extensions. Define to 500 only if necessary
|
||||
to make mbstate_t available. */
|
||||
#ifndef _XOPEN_SOURCE
|
||||
/* # undef _XOPEN_SOURCE */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define to 1 to build uuidd */
|
||||
#define USE_UUIDD 1
|
||||
|
||||
/* version for gettext */
|
||||
#define VERSION "0.14.1"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define to 1 if Apple Darwin libintl workaround is needed */
|
||||
/* #undef _INTL_REDIRECT_MACROS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
#include <dirpaths.h>
|
||||
10
include/e2fsprogs/dirpaths.h
Executable file
10
include/e2fsprogs/dirpaths.h
Executable file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* This file contains the path names for various directories as
|
||||
* controlled by the configure script.
|
||||
*/
|
||||
|
||||
/* Where to put the messages file for internationalization support */
|
||||
#define LOCALEDIR "/usr/share/locale"
|
||||
|
||||
/* Where to find the mke2fs.conf and e2fsck.conf files */
|
||||
#define ROOT_SYSCONFDIR "/etc"
|
||||
92
include/e2fsprogs/e2p/e2p.h
Executable file
92
include/e2fsprogs/e2p/e2p.h
Executable file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* e2p.h --- header file for the e2p library
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include <sys/types.h> /* Needed by dirent.h on netbsd */
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <ext2fs/ext2_fs.h>
|
||||
|
||||
#define E2P_FEATURE_COMPAT 0
|
||||
#define E2P_FEATURE_INCOMPAT 1
|
||||
#define E2P_FEATURE_RO_INCOMPAT 2
|
||||
#define E2P_FEATURE_TYPE_MASK 0x03
|
||||
|
||||
#define E2P_FEATURE_NEGATE_FLAG 0x80
|
||||
|
||||
#define E2P_FS_FEATURE 0
|
||||
#define E2P_JOURNAL_FEATURE 1
|
||||
|
||||
/* `options' for print_flags() */
|
||||
|
||||
#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */
|
||||
|
||||
|
||||
int fgetflags (const char * name, unsigned long * flags);
|
||||
int fgetversion (const char * name, unsigned long * version);
|
||||
int fsetflags (const char * name, unsigned long flags);
|
||||
int fsetversion (const char * name, unsigned long version);
|
||||
int fgetproject(const char *name, unsigned long *project);
|
||||
int fsetproject(const char *name, unsigned long project);
|
||||
int getflags (int fd, unsigned long * flags);
|
||||
int getversion (int fd, unsigned long * version);
|
||||
int iterate_on_dir (const char * dir_name,
|
||||
int (*func) (const char *, struct dirent *, void *),
|
||||
void * private_arg);
|
||||
void list_super(struct ext2_super_block * s);
|
||||
void list_super2(struct ext2_super_block * s, FILE *f);
|
||||
void print_fs_errors (FILE * f, unsigned short errors);
|
||||
void print_flags (FILE * f, unsigned long flags, unsigned options);
|
||||
void print_fs_state (FILE * f, unsigned short state);
|
||||
int setflags (int fd, unsigned long flags);
|
||||
int setversion (int fd, unsigned long version);
|
||||
|
||||
#define E2P_LIST_JOURNAL_FLAG_FC 0x1
|
||||
void e2p_list_journal_super(FILE *f, char *journal_sb_buf,
|
||||
int exp_block_size, int flags);
|
||||
|
||||
void e2p_feature_to_string(int compat, unsigned int mask, char *buf,
|
||||
size_t buf_len);
|
||||
const char *e2p_feature2string(int compat, unsigned int mask);
|
||||
const char *e2p_jrnl_feature2string(int compat, unsigned int mask);
|
||||
int e2p_string2feature(char *string, int *compat, unsigned int *mask);
|
||||
int e2p_jrnl_string2feature(char *string, int *compat_type, unsigned int *mask);
|
||||
int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array);
|
||||
int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array,
|
||||
__u32 *clear_ok_array, int *type_err,
|
||||
unsigned int *mask_err);
|
||||
|
||||
int e2p_is_null_uuid(void *uu);
|
||||
void e2p_uuid_to_str(void *uu, char *out);
|
||||
const char *e2p_uuid2str(void *uu);
|
||||
|
||||
const char *e2p_hash2string(int num);
|
||||
int e2p_string2hash(char *string);
|
||||
|
||||
const char *e2p_mntopt2string(unsigned int mask);
|
||||
int e2p_string2mntopt(char *string, unsigned int *mask);
|
||||
int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok);
|
||||
|
||||
unsigned long parse_num_blocks(const char *arg, int log_block_size);
|
||||
unsigned long long parse_num_blocks2(const char *arg, int log_block_size);
|
||||
|
||||
char *e2p_os2string(int os_type);
|
||||
int e2p_string2os(char *str);
|
||||
|
||||
unsigned int e2p_percent(int percent, unsigned int base);
|
||||
|
||||
const char *e2p_encmode2string(int num);
|
||||
int e2p_string2encmode(char *string);
|
||||
|
||||
int e2p_str2encoding(const char *string);
|
||||
const char *e2p_encoding2str(int encoding);
|
||||
int e2p_get_encoding_flags(int encoding);
|
||||
int e2p_str2encoding_flags(int encoding, char *param, __u16 *flags);
|
||||
|
||||
const char *e2p_errcode2str(unsigned int err);
|
||||
27
include/e2fsprogs/e2p/project.h
Executable file
27
include/e2fsprogs/e2p/project.h
Executable file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* project.h
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#include <ext2fs/ext2_fs.h>
|
||||
|
||||
#if defined(__linux__) && !defined(FS_IOC_FSGETXATTR)
|
||||
#define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
|
||||
#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
|
||||
|
||||
/*
|
||||
* Structure for FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR.
|
||||
*/
|
||||
struct fsxattr {
|
||||
__u32 fsx_xflags; /* xflags field value (get/set) */
|
||||
__u32 fsx_extsize; /* extsize field value (get/set)*/
|
||||
__u32 fsx_nextents; /* nextents field value (get) */
|
||||
__u32 fsx_projid; /* project identifier (get/set) */
|
||||
unsigned char fsx_pad[12];
|
||||
};
|
||||
#endif
|
||||
|
||||
68
include/e2fsprogs/et/com_err.h
Executable file
68
include/e2fsprogs/et/com_err.h
Executable file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Header file for common error description library.
|
||||
*
|
||||
* Copyright 1988, Student Information Processing Board of the
|
||||
* Massachusetts Institute of Technology.
|
||||
*
|
||||
* For copyright and distribution info, see the documentation supplied
|
||||
* with this package.
|
||||
*/
|
||||
|
||||
#if !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define COM_ERR_ATTR(x) __attribute__(x)
|
||||
#else
|
||||
#define COM_ERR_ATTR(x)
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef long errcode_t;
|
||||
|
||||
struct error_table {
|
||||
char const * const * msgs;
|
||||
long base;
|
||||
int n_msgs;
|
||||
};
|
||||
struct et_list;
|
||||
|
||||
extern void com_err (const char *, long, const char *, ...)
|
||||
COM_ERR_ATTR((format(printf, 3, 4)));
|
||||
|
||||
extern void com_err_va (const char *whoami, errcode_t code, const char *fmt,
|
||||
va_list args)
|
||||
COM_ERR_ATTR((format(printf, 3, 0)));
|
||||
|
||||
extern char const *error_message (long);
|
||||
extern void (*com_err_hook) (const char *, long, const char *, va_list);
|
||||
extern void (*set_com_err_hook (void (*) (const char *, long,
|
||||
const char *, va_list)))
|
||||
(const char *, long, const char *, va_list);
|
||||
extern void (*reset_com_err_hook (void)) (const char *, long,
|
||||
const char *, va_list);
|
||||
extern int init_error_table(const char * const *msgs, long base, int count);
|
||||
extern char *(*set_com_err_gettext (char *(*) (const char *)))
|
||||
(const char *);
|
||||
|
||||
extern errcode_t add_error_table(const struct error_table * et);
|
||||
extern errcode_t remove_error_table(const struct error_table * et);
|
||||
extern void add_to_error_table(struct et_list *new_table);
|
||||
|
||||
/* Provided for Heimdall compatibility */
|
||||
extern const char *com_right(struct et_list *list, long code);
|
||||
extern const char *com_right_r(struct et_list *list, long code, char *str, size_t len);
|
||||
extern void initialize_error_table_r(struct et_list **list,
|
||||
const char **messages,
|
||||
int num_errors,
|
||||
long base);
|
||||
extern void free_error_table(struct et_list *et);
|
||||
|
||||
/* Provided for compatibility with other com_err libraries */
|
||||
extern int et_list_lock(void);
|
||||
extern int et_list_unlock(void);
|
||||
|
||||
#define __COM_ERR_H
|
||||
#define __COM_ERR_H__
|
||||
#endif /* !defined(__COM_ERR_H) && !defined(__COM_ERR_H__)*/
|
||||
29
include/e2fsprogs/et/error_table.h
Executable file
29
include/e2fsprogs/et/error_table.h
Executable file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 1988 by the Student Information Processing Board of the
|
||||
* Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose is hereby granted, provided that
|
||||
* the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
|
||||
* advertising or publicity pertaining to distribution of the software
|
||||
* without specific, written prior permission. M.I.T. and the
|
||||
* M.I.T. S.I.P.B. make no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is" without
|
||||
* express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifndef _ET_H
|
||||
|
||||
struct et_list {
|
||||
struct et_list *next;
|
||||
const struct error_table *table;
|
||||
};
|
||||
extern struct et_list *_et_list, *_et_dynamic_list;
|
||||
|
||||
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
|
||||
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
|
||||
|
||||
extern const char *error_table_name(errcode_t num);
|
||||
|
||||
#define _ET_H
|
||||
#endif
|
||||
19
include/e2fsprogs/et/internal.h
Executable file
19
include/e2fsprogs/et/internal.h
Executable file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* internal include file for com_err package
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose is hereby granted, provided that
|
||||
* the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
|
||||
* advertising or publicity pertaining to distribution of the software
|
||||
* without specific, written prior permission. M.I.T. and the
|
||||
* M.I.T. S.I.P.B. make no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is" without
|
||||
* express or implied warranty.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef NEED_SYS_ERRLIST
|
||||
extern char const * const sys_errlist[];
|
||||
extern const int sys_nerr;
|
||||
#endif
|
||||
606
include/e2fsprogs/ext2fs/bitops.h
Executable file
606
include/e2fsprogs/ext2fs/bitops.h
Executable file
@@ -0,0 +1,606 @@
|
||||
/*
|
||||
* bitops.h --- Bitmap frobbing code. The byte swapping routines are
|
||||
* also included here.
|
||||
*
|
||||
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define ext2fs_cpu_to_le64(x) ((__force __le64)ext2fs_swab64((__u64)(x)))
|
||||
#define ext2fs_le64_to_cpu(x) ext2fs_swab64((__force __u64)(__le64)(x))
|
||||
#define ext2fs_cpu_to_le32(x) ((__force __le32)ext2fs_swab32((__u32)(x)))
|
||||
#define ext2fs_le32_to_cpu(x) ext2fs_swab32((__force __u32)(__le32)(x))
|
||||
#define ext2fs_cpu_to_le16(x) ((__force __le16)ext2fs_swab16((__u16)(x)))
|
||||
#define ext2fs_le16_to_cpu(x) ext2fs_swab16((__force __u16)(__le16)(x))
|
||||
|
||||
#define ext2fs_cpu_to_be64(x) ((__force __be64)(__u64)(x))
|
||||
#define ext2fs_be64_to_cpu(x) ((__force __u64)(__be64)(x))
|
||||
#define ext2fs_cpu_to_be32(x) ((__force __be32)(__u32)(x))
|
||||
#define ext2fs_be32_to_cpu(x) ((__force __u32)(__be32)(x))
|
||||
#define ext2fs_cpu_to_be16(x) ((__force __be16)(__u16)(x))
|
||||
#define ext2fs_be16_to_cpu(x) ((__force __u16)(__be16)(x))
|
||||
#else
|
||||
#define ext2fs_cpu_to_le64(x) ((__force __le64)(__u64)(x))
|
||||
#define ext2fs_le64_to_cpu(x) ((__force __u64)(__le64)(x))
|
||||
#define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
|
||||
#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
|
||||
#define ext2fs_cpu_to_le16(x) ((__force __le16)(__u16)(x))
|
||||
#define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
|
||||
|
||||
#define ext2fs_cpu_to_be64(x) ((__force __be64)ext2fs_swab64((__u64)(x)))
|
||||
#define ext2fs_be64_to_cpu(x) ext2fs_swab64((__force __u64)(__be64)(x))
|
||||
#define ext2fs_cpu_to_be32(x) ((__force __be32)ext2fs_swab32((__u32)(x)))
|
||||
#define ext2fs_be32_to_cpu(x) ext2fs_swab32((__force __u32)(__be32)(x))
|
||||
#define ext2fs_cpu_to_be16(x) ((__force __be16)ext2fs_swab16((__u16)(x)))
|
||||
#define ext2fs_be16_to_cpu(x) ext2fs_swab16((__force __u16)(__be16)(x))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* EXT2FS bitmap manipulation routines.
|
||||
*/
|
||||
|
||||
/* Support for sending warning messages from the inline subroutines */
|
||||
extern const char *ext2fs_block_string;
|
||||
extern const char *ext2fs_inode_string;
|
||||
extern const char *ext2fs_mark_string;
|
||||
extern const char *ext2fs_unmark_string;
|
||||
extern const char *ext2fs_test_string;
|
||||
extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
|
||||
const char *description);
|
||||
extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
|
||||
int code, unsigned long arg);
|
||||
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
|
||||
extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
|
||||
extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
|
||||
extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
|
||||
extern __u16 ext2fs_swab16(__u16 val);
|
||||
extern __u32 ext2fs_swab32(__u32 val);
|
||||
extern __u64 ext2fs_swab64(__u64 val);
|
||||
|
||||
extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
|
||||
extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
|
||||
|
||||
extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
|
||||
extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
|
||||
|
||||
extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block);
|
||||
|
||||
extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
|
||||
extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
|
||||
|
||||
extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
#endif
|
||||
|
||||
/* These functions routines moved to gen_bitmap.c */
|
||||
extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode, int num);
|
||||
extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
__u32 bitno);
|
||||
extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
|
||||
blk_t bitno);
|
||||
extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num);
|
||||
extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
|
||||
extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
|
||||
extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
|
||||
|
||||
/* 64-bit versions */
|
||||
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
|
||||
extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
|
||||
extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block);
|
||||
|
||||
extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode);
|
||||
extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out);
|
||||
extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out);
|
||||
extern errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out);
|
||||
extern errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out);
|
||||
extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
|
||||
extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
|
||||
extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
|
||||
|
||||
extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num);
|
||||
extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num);
|
||||
extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num);
|
||||
#endif
|
||||
|
||||
/* These routines moved to gen_bitmap64.c */
|
||||
extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
|
||||
extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
|
||||
ext2fs_generic_bitmap bm1,
|
||||
ext2fs_generic_bitmap bm2);
|
||||
extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
|
||||
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
blk64_t bitno);
|
||||
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
blk64_t bitno);
|
||||
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
blk64_t bitno);
|
||||
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
|
||||
extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
|
||||
extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block, unsigned int num);
|
||||
extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, __u64 end,
|
||||
__u64 *out);
|
||||
extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, __u64 end,
|
||||
__u64 *out);
|
||||
|
||||
/*
|
||||
* The inline routines themselves...
|
||||
*
|
||||
* If NO_INLINE_FUNCS is defined, then we won't try to do inline
|
||||
* functions at all; they will be included as normal functions in
|
||||
* inline.c
|
||||
*/
|
||||
|
||||
#if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||
#ifdef INCLUDE_INLINE_FUNCS
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ extern inline
|
||||
#else
|
||||
#define _INLINE_ inline
|
||||
#endif
|
||||
#else /* !INCLUDE_INLINE FUNCS */
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ inline
|
||||
#else /* not C99 */
|
||||
#ifdef __GNUC__
|
||||
#define _INLINE_ extern __inline__
|
||||
#else /* For Watcom C */
|
||||
#define _INLINE_ extern inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
#endif /* INCLUDE_INLINE_FUNCS */
|
||||
|
||||
/*
|
||||
* Fast bit set/clear functions that doesn't need to return the
|
||||
* previous bit value.
|
||||
*/
|
||||
|
||||
_INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR |= (unsigned char) (1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
|
||||
_INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR |= (unsigned char) (1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
|
||||
{
|
||||
unsigned char *ADDR = (unsigned char *) addr;
|
||||
|
||||
ADDR += nr >> 3;
|
||||
*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
|
||||
}
|
||||
|
||||
_INLINE_ __u16 ext2fs_swab16(__u16 val)
|
||||
{
|
||||
return (val >> 8) | (__u16) (val << 8);
|
||||
}
|
||||
|
||||
_INLINE_ __u32 ext2fs_swab32(__u32 val)
|
||||
{
|
||||
return ((val>>24) | ((val>>8)&0xFF00) |
|
||||
((val<<8)&0xFF0000) | (val<<24));
|
||||
}
|
||||
|
||||
_INLINE_ __u64 ext2fs_swab64(__u64 val)
|
||||
{
|
||||
return (ext2fs_swab32((__u32) (val >> 32)) |
|
||||
(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
|
||||
blk_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num)
|
||||
{
|
||||
return ext2fs_test_block_bitmap_range(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num)
|
||||
{
|
||||
ext2fs_mark_block_bitmap_range(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
|
||||
blk_t block, int num)
|
||||
{
|
||||
ext2fs_unmark_block_bitmap_range(bitmap, block, num);
|
||||
}
|
||||
|
||||
/* 64-bit versions */
|
||||
|
||||
_INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
block);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t inode)
|
||||
{
|
||||
return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
inode);
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = (ext2_ino_t) o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t start,
|
||||
blk64_t end,
|
||||
blk64_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
|
||||
ext2_ino_t start,
|
||||
ext2_ino_t end,
|
||||
ext2_ino_t *out)
|
||||
{
|
||||
__u64 o;
|
||||
errcode_t rv;
|
||||
|
||||
rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
|
||||
start, end, &o);
|
||||
if (!rv)
|
||||
*out = (ext2_ino_t) o;
|
||||
return rv;
|
||||
}
|
||||
|
||||
_INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
|
||||
{
|
||||
return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
|
||||
{
|
||||
return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
|
||||
}
|
||||
|
||||
_INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num)
|
||||
{
|
||||
return ext2fs_test_block_bitmap_range2(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num)
|
||||
{
|
||||
ext2fs_mark_block_bitmap_range2(bitmap, block, num);
|
||||
}
|
||||
|
||||
_INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
|
||||
blk64_t block,
|
||||
unsigned int num)
|
||||
{
|
||||
ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
|
||||
}
|
||||
|
||||
#undef _INLINE_
|
||||
#endif
|
||||
|
||||
extern int ext2fs_set_bit(unsigned int nr,void * addr);
|
||||
extern int ext2fs_clear_bit(unsigned int nr, void * addr);
|
||||
extern int ext2fs_test_bit(unsigned int nr, const void * addr);
|
||||
extern int ext2fs_set_bit64(__u64 nr,void * addr);
|
||||
extern int ext2fs_clear_bit64(__u64 nr, void * addr);
|
||||
extern int ext2fs_test_bit64(__u64 nr, const void * addr);
|
||||
extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
|
||||
106
include/e2fsprogs/ext2fs/bmap64.h
Executable file
106
include/e2fsprogs/ext2fs/bmap64.h
Executable file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* bmap64.h --- 64-bit bitmap structure
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_bmap_statistics {
|
||||
int type;
|
||||
struct timeval created;
|
||||
|
||||
#ifdef ENABLE_BMAP_STATS_OPS
|
||||
unsigned long copy_count;
|
||||
unsigned long resize_count;
|
||||
unsigned long mark_count;
|
||||
unsigned long unmark_count;
|
||||
unsigned long test_count;
|
||||
unsigned long mark_ext_count;
|
||||
unsigned long unmark_ext_count;
|
||||
unsigned long test_ext_count;
|
||||
unsigned long set_range_count;
|
||||
unsigned long get_range_count;
|
||||
unsigned long clear_count;
|
||||
|
||||
blk64_t last_marked;
|
||||
blk64_t last_tested;
|
||||
blk64_t mark_back;
|
||||
blk64_t test_back;
|
||||
|
||||
unsigned long mark_seq;
|
||||
unsigned long test_seq;
|
||||
#endif /* ENABLE_BMAP_STATS_OPS */
|
||||
};
|
||||
|
||||
|
||||
struct ext2fs_struct_generic_bitmap_64 {
|
||||
errcode_t magic;
|
||||
ext2_filsys fs;
|
||||
struct ext2_bitmap_ops *bitmap_ops;
|
||||
int flags;
|
||||
__u64 start, end;
|
||||
__u64 real_end;
|
||||
int cluster_bits;
|
||||
char *description;
|
||||
void *private;
|
||||
errcode_t base_error_code;
|
||||
#ifdef ENABLE_BMAP_STATS
|
||||
struct ext2_bmap_statistics stats;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct ext2fs_struct_generic_bitmap_64 *ext2fs_generic_bitmap_64;
|
||||
|
||||
#define EXT2FS_IS_32_BITMAP(bmap) \
|
||||
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
|
||||
|
||||
#define EXT2FS_IS_64_BITMAP(bmap) \
|
||||
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
|
||||
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
|
||||
|
||||
struct ext2_bitmap_ops {
|
||||
int type;
|
||||
/* Generic bmap operators */
|
||||
errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap_64 bmap);
|
||||
void (*free_bmap)(ext2fs_generic_bitmap_64 bitmap);
|
||||
errcode_t (*copy_bmap)(ext2fs_generic_bitmap_64 src,
|
||||
ext2fs_generic_bitmap_64 dest);
|
||||
errcode_t (*resize_bmap)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 new_end,
|
||||
__u64 new_real_end);
|
||||
/* bit set/test operators */
|
||||
int (*mark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
|
||||
int (*unmark_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
|
||||
int (*test_bmap)(ext2fs_generic_bitmap_64 bitmap, __u64 arg);
|
||||
void (*mark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
|
||||
unsigned int num);
|
||||
void (*unmark_bmap_extent)(ext2fs_generic_bitmap_64 bitmap, __u64 arg,
|
||||
unsigned int num);
|
||||
int (*test_clear_bmap_extent)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 arg, unsigned int num);
|
||||
errcode_t (*set_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, size_t num, void *in);
|
||||
errcode_t (*get_bmap_range)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, size_t num, void *out);
|
||||
void (*clear_bmap)(ext2fs_generic_bitmap_64 bitmap);
|
||||
void (*print_stats)(ext2fs_generic_bitmap_64);
|
||||
|
||||
/* Find the first zero bit between start and end, inclusive.
|
||||
* May be NULL, in which case a generic function is used. */
|
||||
errcode_t (*find_first_zero)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, __u64 end, __u64 *out);
|
||||
/* Find the first set bit between start and end, inclusive.
|
||||
* May be NULL, in which case a generic function is used. */
|
||||
errcode_t (*find_first_set)(ext2fs_generic_bitmap_64 bitmap,
|
||||
__u64 start, __u64 end, __u64 *out);
|
||||
};
|
||||
|
||||
extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
|
||||
extern struct ext2_bitmap_ops ext2fs_blkmap64_rbtree;
|
||||
86
include/e2fsprogs/ext2fs/brel.h
Executable file
86
include/e2fsprogs/ext2fs/brel.h
Executable file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* brel.h
|
||||
*
|
||||
* Copyright (C) 1996, 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_block_relocate_entry {
|
||||
blk64_t new;
|
||||
__s16 offset;
|
||||
__u16 flags;
|
||||
union {
|
||||
blk64_t block_ref;
|
||||
ext2_ino_t inode_ref;
|
||||
} owner;
|
||||
};
|
||||
|
||||
#define RELOCATE_TYPE_REF 0x0007
|
||||
#define RELOCATE_BLOCK_REF 0x0001
|
||||
#define RELOCATE_INODE_REF 0x0002
|
||||
|
||||
typedef struct ext2_block_relocation_table *ext2_brel;
|
||||
|
||||
struct ext2_block_relocation_table {
|
||||
__u32 magic;
|
||||
char *name;
|
||||
blk64_t current;
|
||||
void *priv_data;
|
||||
|
||||
/*
|
||||
* Add a block relocation entry.
|
||||
*/
|
||||
errcode_t (*put)(ext2_brel brel, blk64_t old,
|
||||
struct ext2_block_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Get a block relocation entry.
|
||||
*/
|
||||
errcode_t (*get)(ext2_brel brel, blk64_t old,
|
||||
struct ext2_block_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Initialize for iterating over the block relocation entries.
|
||||
*/
|
||||
errcode_t (*start_iter)(ext2_brel brel);
|
||||
|
||||
/*
|
||||
* The iterator function for the inode relocation entries.
|
||||
* Returns an inode number of 0 when out of entries.
|
||||
*/
|
||||
errcode_t (*next)(ext2_brel brel, blk64_t *old,
|
||||
struct ext2_block_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Move the inode relocation table from one block number to
|
||||
* another.
|
||||
*/
|
||||
errcode_t (*move)(ext2_brel brel, blk64_t old, blk_t new);
|
||||
|
||||
/*
|
||||
* Remove a block relocation entry.
|
||||
*/
|
||||
errcode_t (*delete)(ext2_brel brel, blk64_t old);
|
||||
|
||||
|
||||
/*
|
||||
* Free the block relocation table.
|
||||
*/
|
||||
errcode_t (*free)(ext2_brel brel);
|
||||
};
|
||||
|
||||
errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
|
||||
ext2_brel *brel);
|
||||
|
||||
#define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
|
||||
#define ext2fs_brel_get(brel, old, ent) ((brel)->get((brel), old, ent))
|
||||
#define ext2fs_brel_start_iter(brel) ((brel)->start_iter((brel)))
|
||||
#define ext2fs_brel_next(brel, old, ent) ((brel)->next((brel), old, ent))
|
||||
#define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
|
||||
#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
|
||||
#define ext2fs_brel_free(brel) ((brel)->free((brel)))
|
||||
|
||||
26
include/e2fsprogs/ext2fs/compiler.h
Executable file
26
include/e2fsprogs/ext2fs/compiler.h
Executable file
@@ -0,0 +1,26 @@
|
||||
#ifndef _EXT2FS_COMPILER_H
|
||||
#define _EXT2FS_COMPILER_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
#define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
#define __GNUC_PREREQ(maj, min) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
__typeof__( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#else
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr) - offsetof(type, member)))
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _EXT2FS_COMPILER_H */
|
||||
74
include/e2fsprogs/ext2fs/crc16.c
Executable file
74
include/e2fsprogs/ext2fs/crc16.c
Executable file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* crc16.c
|
||||
*
|
||||
* This source code is licensed under the GNU General Public License,
|
||||
* Version 2. See the file COPYING for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <ext2fs/ext2_types.h>
|
||||
|
||||
#include "crc16.h"
|
||||
|
||||
/** CRC table for the CRC-16. The poly is 0x8005 (x16 + x15 + x2 + 1) */
|
||||
static __u16 const crc16_table[256] = {
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
||||
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
|
||||
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
|
||||
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
|
||||
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
|
||||
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
|
||||
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
|
||||
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
|
||||
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
|
||||
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
|
||||
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
|
||||
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
|
||||
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
|
||||
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
|
||||
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
|
||||
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
|
||||
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
|
||||
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
|
||||
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
|
||||
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
|
||||
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
|
||||
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
|
||||
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
|
||||
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
|
||||
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
|
||||
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
|
||||
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
/**
|
||||
* Compute the CRC-16 for the data buffer
|
||||
*
|
||||
* @param crc previous CRC value
|
||||
* @param buffer data pointer
|
||||
* @param len number of bytes in the buffer
|
||||
* @return the updated CRC value
|
||||
*/
|
||||
crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len)
|
||||
{
|
||||
const unsigned char *cp = buffer;
|
||||
|
||||
while (len--)
|
||||
/*
|
||||
* for an unknown reason, PPC treats __u16 as signed
|
||||
* and keeps doing sign extension on the value.
|
||||
* Instead, use only the low 16 bits of an unsigned
|
||||
* int for holding the CRC value to avoid this.
|
||||
*/
|
||||
crc = (((crc >> 8) & 0xffU) ^
|
||||
crc16_table[(crc ^ *cp++) & 0xffU]) & 0x0000ffffU;
|
||||
return crc;
|
||||
}
|
||||
26
include/e2fsprogs/ext2fs/crc16.h
Executable file
26
include/e2fsprogs/ext2fs/crc16.h
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* crc16.h - CRC-16 routine
|
||||
*
|
||||
* Implements the standard CRC-16:
|
||||
* Width 16
|
||||
* Poly 0x8005 (x16 + x15 + x2 + 1)
|
||||
* Init 0
|
||||
*
|
||||
* Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
|
||||
*
|
||||
* This source code is licensed under the GNU General Public License,
|
||||
* Version 2. See the file COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CRC16_H
|
||||
#define __CRC16_H
|
||||
|
||||
/* for an unknown reason, PPC treats __u16 as signed and keeps doing sign
|
||||
* extension on the value. Instead, use only the low 16 bits of an
|
||||
* unsigned int for holding the CRC value to avoid this.
|
||||
*/
|
||||
typedef unsigned int crc16_t;
|
||||
|
||||
extern crc16_t ext2fs_crc16(crc16_t crc, const void *buffer, unsigned int len);
|
||||
|
||||
#endif /* __CRC16_H */
|
||||
59
include/e2fsprogs/ext2fs/crc32c_defs.h
Executable file
59
include/e2fsprogs/ext2fs/crc32c_defs.h
Executable file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* There are multiple 16-bit CRC polynomials in common use, but this is
|
||||
* *the* standard CRC-32 polynomial, first popularized by Ethernet.
|
||||
* x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
|
||||
*/
|
||||
#define CRCPOLY_LE 0xedb88320
|
||||
#define CRCPOLY_BE 0x04c11db7
|
||||
|
||||
/*
|
||||
* This is the CRC32c polynomial, as outlined by Castagnoli.
|
||||
* x^32+x^28+x^27+x^26+x^25+x^23+x^22+x^20+x^19+x^18+x^14+x^13+x^11+x^10+x^9+
|
||||
* x^8+x^6+x^0
|
||||
*/
|
||||
#define CRC32C_POLY_LE 0x82F63B78
|
||||
#define CRC32C_POLY_BE 0x1EDC6F41
|
||||
|
||||
/* How many bits at a time to use. Valid values are 1, 2, 4, 8, 32 and 64. */
|
||||
/* For less performance-sensitive, use 4 */
|
||||
#ifndef CRC_LE_BITS
|
||||
# define CRC_LE_BITS 64
|
||||
#endif
|
||||
#ifndef CRC_BE_BITS
|
||||
# define CRC_BE_BITS 64
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Little-endian CRC computation. Used with serial bit streams sent
|
||||
* lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
|
||||
*/
|
||||
#if CRC_LE_BITS > 64 || CRC_LE_BITS < 1 || CRC_LE_BITS == 16 || \
|
||||
CRC_LE_BITS & CRC_LE_BITS-1
|
||||
# error "CRC_LE_BITS must be one of {1, 2, 4, 8, 32, 64}"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Big-endian CRC computation. Used with serial bit streams sent
|
||||
* msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
|
||||
*/
|
||||
#if CRC_BE_BITS > 64 || CRC_BE_BITS < 1 || CRC_BE_BITS == 16 || \
|
||||
CRC_BE_BITS & CRC_BE_BITS-1
|
||||
# error "CRC_BE_BITS must be one of {1, 2, 4, 8, 32, 64}"
|
||||
#endif
|
||||
|
||||
|
||||
#define ___constant_swab32(x) \
|
||||
((uint32_t)( \
|
||||
(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
|
||||
(((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
|
||||
(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
|
||||
(((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
|
||||
|
||||
|
||||
#if (__GNUC__ >= 3)
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
1044
include/e2fsprogs/ext2fs/crc32c_table.h
Executable file
1044
include/e2fsprogs/ext2fs/crc32c_table.h
Executable file
File diff suppressed because it is too large
Load Diff
157
include/e2fsprogs/ext2fs/dosio.h
Executable file
157
include/e2fsprogs/ext2fs/dosio.h
Executable file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* v1.0
|
||||
*
|
||||
* Disk I/O include file for the ext2fs/DOS library.
|
||||
*
|
||||
* Copyright (c) 1997 Mark Habersack
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef __diskio_h
|
||||
#define __diskio_h
|
||||
#ifdef __TURBOC__
|
||||
#ifndef __LARGE__
|
||||
# error "ext2fs/DOS library requires LARGE model!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include "msdos.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A helper structure used in LBA => CHS conversion
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned short cyl; /* Cylinder (or track) */
|
||||
unsigned short head;
|
||||
unsigned short sector;
|
||||
unsigned short offset; /* Offset of byte within the sector */
|
||||
} CHS;
|
||||
|
||||
/*
|
||||
* All partition data we need is here
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *dev; /* _Linux_ device name (like "/dev/hda1") */
|
||||
unsigned char phys; /* Physical DOS drive number */
|
||||
unsigned long start; /* LBA address of partition start */
|
||||
unsigned long len; /* length of partition in sectors */
|
||||
unsigned char pno; /* Partition number (read from *dev) */
|
||||
|
||||
/* This partition's drive geometry */
|
||||
unsigned short cyls;
|
||||
unsigned short heads;
|
||||
unsigned short sects;
|
||||
} PARTITION;
|
||||
|
||||
/*
|
||||
* PC partition table entry format
|
||||
*/
|
||||
#ifdef __DJGPP__
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
typedef struct
|
||||
{
|
||||
unsigned char active;
|
||||
unsigned char start_head;
|
||||
unsigned char start_sec;
|
||||
unsigned char start_cyl;
|
||||
unsigned char type;
|
||||
unsigned char end_head;
|
||||
unsigned char end_sec;
|
||||
unsigned char end_cyl;
|
||||
unsigned long first_sec_rel;
|
||||
unsigned long size;
|
||||
} PTABLE_ENTRY;
|
||||
#ifdef __DJGPP__
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* INT 0x13 operation codes
|
||||
*/
|
||||
#define DISK_READ 0x02
|
||||
#define DISK_WRITE 0x03
|
||||
#define DISK_GET_GEOMETRY 0x08
|
||||
#define DISK_READY 0x10
|
||||
|
||||
/*
|
||||
* Errors to put in _dio_error
|
||||
*/
|
||||
#define ERR_BADDEV 0x00000001L
|
||||
#define ERR_HARDWARE 0x00000002L
|
||||
#define ERR_NOTSUPP 0x00000003L
|
||||
#define ERR_NOTEXT2FS 0x00000004L
|
||||
#define ERR_EMPTYPART 0x00000005L
|
||||
#define ERR_LINUXSWAP 0x00000006L
|
||||
|
||||
/*
|
||||
* Functions in diskio.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Variable contains last module's error
|
||||
*/
|
||||
extern unsigned long _dio_error;
|
||||
|
||||
/*
|
||||
* This one contains last hardware error (if _dio_error == ERR_HARDWARE)
|
||||
*/
|
||||
extern unsigned long _dio_hw_error;
|
||||
|
||||
/*
|
||||
* Macros to check for disk hardware errors
|
||||
*/
|
||||
#define HW_OK() ((unsigned char)_dio_hw_error == 0x00)
|
||||
#define HW_BAD_CMD() ((unsigned char)_dio_hw_error == 0x01)
|
||||
#define HW_NO_ADDR_MARK() ((unsigned char)_dio_hw_error == 0x02)
|
||||
#define HW_WRITE_PROT() ((unsigned char)_dio_hw_error == 0x03)
|
||||
#define HW_NO_SECTOR() ((unsigned char)_dio_hw_error == 0x04)
|
||||
#define HW_RESET_FAIL() ((unsigned char)_dio_hw_error == 0x05)
|
||||
#define HW_DISK_CHANGED() ((unsigned char)_dio_hw_error == 0x06)
|
||||
#define HW_DRIVE_FAIL() ((unsigned char)_dio_hw_error == 0x07)
|
||||
#define HW_DMA_OVERRUN() ((unsigned char)_dio_hw_error == 0x08)
|
||||
#define HW_DMA_BOUNDARY() ((unsigned char)_dio_hw_error == 0x09)
|
||||
#define HW_BAD_SECTOR() ((unsigned char)_dio_hw_error == 0x0A)
|
||||
#define HW_BAD_TRACK() ((unsigned char)_dio_hw_error == 0x0B)
|
||||
#define HW_UNSUPP_TRACK() ((unsigned char)_dio_hw_error == 0x0C)
|
||||
#define HW_BAD_CRC_ECC() ((unsigned char)_dio_hw_error == 0x10)
|
||||
#define HW_CRC_ECC_CORR() ((unsigned char)_dio_hw_error == 0x11)
|
||||
#define HW_CONTR_FAIL() ((unsigned char)_dio_hw_error == 0x20)
|
||||
#define HW_SEEK_FAIL() ((unsigned char)_dio_hw_error == 0x40)
|
||||
#define HW_ATTACH_FAIL() ((unsigned char)_dio_hw_error == 0x80)
|
||||
#define HW_DRIVE_NREADY() ((unsigned char)_dio_hw_error == 0xAA)
|
||||
#define HW_UNDEF_ERROR() ((unsigned char)_dio_hw_error == 0xBB)
|
||||
#define HW_WRITE_FAULT() ((unsigned char)_dio_hw_error == 0xCC)
|
||||
#define HW_STATUS_ERROR() ((unsigned char)_dio_hw_error == 0xE0)
|
||||
#define HW_SENSE_FAIL() ((unsigned char)_dio_hw_error == 0xFF)
|
||||
|
||||
|
||||
/*
|
||||
* Open the specified partition.
|
||||
* String 'dev' must have a format:
|
||||
*
|
||||
* /dev/{sd|hd|fd}[X]
|
||||
*
|
||||
* where,
|
||||
*
|
||||
* only one of the option in curly braces can be used and X is an optional
|
||||
* partition number for the given device. If X is not specified, function
|
||||
* scans the drive's partition table in search for the first Linux ext2fs
|
||||
* partition (signature 0x83). Along the way it dives into every extended
|
||||
* partition encountered.
|
||||
* Scan ends if either (a) there are no more used partition entries, or
|
||||
* (b) there is no Xth partition.
|
||||
*
|
||||
* Routine returns 0 on success and !=0 otherwise.
|
||||
*/
|
||||
int open_partition(char *dev);
|
||||
|
||||
#endif /* __diskio_h */
|
||||
37
include/e2fsprogs/ext2fs/e2image.h
Executable file
37
include/e2fsprogs/ext2fs/e2image.h
Executable file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* e2image.h --- header file describing the ext2 image format
|
||||
*
|
||||
* Copyright (C) 2000 Theodore Ts'o.
|
||||
*
|
||||
* Note: this uses the POSIX IO interfaces, unlike most of the other
|
||||
* functions in this library. So sue me.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_image_hdr {
|
||||
__u32 magic_number; /* This must be EXT2_ET_MAGIC_E2IMAGE */
|
||||
char magic_descriptor[16]; /* "Ext2 Image 1.0", w/ null padding */
|
||||
char fs_hostname[64];/* Hostname of machine of image */
|
||||
char fs_netaddr[32]; /* Network address */
|
||||
__u32 fs_netaddr_type;/* 0 = IPV4, 1 = IPV6, etc. */
|
||||
__u32 fs_device; /* Device number of image */
|
||||
char fs_device_name[64]; /* Device name */
|
||||
char fs_uuid[16]; /* UUID of filesystem */
|
||||
__u32 fs_blocksize; /* Block size of the filesystem */
|
||||
__u32 fs_reserved[8];
|
||||
|
||||
__u32 image_device; /* Device number of image file */
|
||||
__u32 image_inode; /* Inode number of image file */
|
||||
__u32 image_time; /* Time of image creation */
|
||||
__u32 image_reserved[8];
|
||||
|
||||
__u32 offset_super; /* Byte offset of the sb and descriptors */
|
||||
__u32 offset_inode; /* Byte offset of the inode table */
|
||||
__u32 offset_inodemap; /* Byte offset of the inode bitmaps */
|
||||
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
|
||||
__u32 offset_reserved[8];
|
||||
};
|
||||
201
include/e2fsprogs/ext2fs/ext2_err.h
Executable file
201
include/e2fsprogs/ext2fs/ext2_err.h
Executable file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* ext2_err.h:
|
||||
* This file is automatically generated; please do not edit it.
|
||||
*/
|
||||
|
||||
#include <et/com_err.h>
|
||||
|
||||
#define EXT2_ET_BASE (2133571328L)
|
||||
#define EXT2_ET_MAGIC_EXT2FS_FILSYS (2133571329L)
|
||||
#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L)
|
||||
#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L)
|
||||
#define EXT2_ET_MAGIC_INODE_SCAN (2133571332L)
|
||||
#define EXT2_ET_MAGIC_IO_CHANNEL (2133571333L)
|
||||
#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL (2133571334L)
|
||||
#define EXT2_ET_MAGIC_IO_MANAGER (2133571335L)
|
||||
#define EXT2_ET_MAGIC_BLOCK_BITMAP (2133571336L)
|
||||
#define EXT2_ET_MAGIC_INODE_BITMAP (2133571337L)
|
||||
#define EXT2_ET_MAGIC_GENERIC_BITMAP (2133571338L)
|
||||
#define EXT2_ET_MAGIC_TEST_IO_CHANNEL (2133571339L)
|
||||
#define EXT2_ET_MAGIC_DBLIST (2133571340L)
|
||||
#define EXT2_ET_MAGIC_ICOUNT (2133571341L)
|
||||
#define EXT2_ET_MAGIC_PQ_IO_CHANNEL (2133571342L)
|
||||
#define EXT2_ET_MAGIC_EXT2_FILE (2133571343L)
|
||||
#define EXT2_ET_MAGIC_E2IMAGE (2133571344L)
|
||||
#define EXT2_ET_MAGIC_INODE_IO_CHANNEL (2133571345L)
|
||||
#define EXT2_ET_MAGIC_EXTENT_HANDLE (2133571346L)
|
||||
#define EXT2_ET_BAD_MAGIC (2133571347L)
|
||||
#define EXT2_ET_REV_TOO_HIGH (2133571348L)
|
||||
#define EXT2_ET_RO_FILSYS (2133571349L)
|
||||
#define EXT2_ET_GDESC_READ (2133571350L)
|
||||
#define EXT2_ET_GDESC_WRITE (2133571351L)
|
||||
#define EXT2_ET_GDESC_BAD_BLOCK_MAP (2133571352L)
|
||||
#define EXT2_ET_GDESC_BAD_INODE_MAP (2133571353L)
|
||||
#define EXT2_ET_GDESC_BAD_INODE_TABLE (2133571354L)
|
||||
#define EXT2_ET_INODE_BITMAP_WRITE (2133571355L)
|
||||
#define EXT2_ET_INODE_BITMAP_READ (2133571356L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_WRITE (2133571357L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_READ (2133571358L)
|
||||
#define EXT2_ET_INODE_TABLE_WRITE (2133571359L)
|
||||
#define EXT2_ET_INODE_TABLE_READ (2133571360L)
|
||||
#define EXT2_ET_NEXT_INODE_READ (2133571361L)
|
||||
#define EXT2_ET_UNEXPECTED_BLOCK_SIZE (2133571362L)
|
||||
#define EXT2_ET_DIR_CORRUPTED (2133571363L)
|
||||
#define EXT2_ET_SHORT_READ (2133571364L)
|
||||
#define EXT2_ET_SHORT_WRITE (2133571365L)
|
||||
#define EXT2_ET_DIR_NO_SPACE (2133571366L)
|
||||
#define EXT2_ET_NO_INODE_BITMAP (2133571367L)
|
||||
#define EXT2_ET_NO_BLOCK_BITMAP (2133571368L)
|
||||
#define EXT2_ET_BAD_INODE_NUM (2133571369L)
|
||||
#define EXT2_ET_BAD_BLOCK_NUM (2133571370L)
|
||||
#define EXT2_ET_EXPAND_DIR_ERR (2133571371L)
|
||||
#define EXT2_ET_TOOSMALL (2133571372L)
|
||||
#define EXT2_ET_BAD_BLOCK_MARK (2133571373L)
|
||||
#define EXT2_ET_BAD_BLOCK_UNMARK (2133571374L)
|
||||
#define EXT2_ET_BAD_BLOCK_TEST (2133571375L)
|
||||
#define EXT2_ET_BAD_INODE_MARK (2133571376L)
|
||||
#define EXT2_ET_BAD_INODE_UNMARK (2133571377L)
|
||||
#define EXT2_ET_BAD_INODE_TEST (2133571378L)
|
||||
#define EXT2_ET_FUDGE_BLOCK_BITMAP_END (2133571379L)
|
||||
#define EXT2_ET_FUDGE_INODE_BITMAP_END (2133571380L)
|
||||
#define EXT2_ET_BAD_IND_BLOCK (2133571381L)
|
||||
#define EXT2_ET_BAD_DIND_BLOCK (2133571382L)
|
||||
#define EXT2_ET_BAD_TIND_BLOCK (2133571383L)
|
||||
#define EXT2_ET_NEQ_BLOCK_BITMAP (2133571384L)
|
||||
#define EXT2_ET_NEQ_INODE_BITMAP (2133571385L)
|
||||
#define EXT2_ET_BAD_DEVICE_NAME (2133571386L)
|
||||
#define EXT2_ET_MISSING_INODE_TABLE (2133571387L)
|
||||
#define EXT2_ET_CORRUPT_SUPERBLOCK (2133571388L)
|
||||
#define EXT2_ET_BAD_GENERIC_MARK (2133571389L)
|
||||
#define EXT2_ET_BAD_GENERIC_UNMARK (2133571390L)
|
||||
#define EXT2_ET_BAD_GENERIC_TEST (2133571391L)
|
||||
#define EXT2_ET_SYMLINK_LOOP (2133571392L)
|
||||
#define EXT2_ET_CALLBACK_NOTHANDLED (2133571393L)
|
||||
#define EXT2_ET_BAD_BLOCK_IN_INODE_TABLE (2133571394L)
|
||||
#define EXT2_ET_UNSUPP_FEATURE (2133571395L)
|
||||
#define EXT2_ET_RO_UNSUPP_FEATURE (2133571396L)
|
||||
#define EXT2_ET_LLSEEK_FAILED (2133571397L)
|
||||
#define EXT2_ET_NO_MEMORY (2133571398L)
|
||||
#define EXT2_ET_INVALID_ARGUMENT (2133571399L)
|
||||
#define EXT2_ET_BLOCK_ALLOC_FAIL (2133571400L)
|
||||
#define EXT2_ET_INODE_ALLOC_FAIL (2133571401L)
|
||||
#define EXT2_ET_NO_DIRECTORY (2133571402L)
|
||||
#define EXT2_ET_TOO_MANY_REFS (2133571403L)
|
||||
#define EXT2_ET_FILE_NOT_FOUND (2133571404L)
|
||||
#define EXT2_ET_FILE_RO (2133571405L)
|
||||
#define EXT2_ET_DB_NOT_FOUND (2133571406L)
|
||||
#define EXT2_ET_DIR_EXISTS (2133571407L)
|
||||
#define EXT2_ET_UNIMPLEMENTED (2133571408L)
|
||||
#define EXT2_ET_CANCEL_REQUESTED (2133571409L)
|
||||
#define EXT2_ET_FILE_TOO_BIG (2133571410L)
|
||||
#define EXT2_ET_JOURNAL_NOT_BLOCK (2133571411L)
|
||||
#define EXT2_ET_NO_JOURNAL_SB (2133571412L)
|
||||
#define EXT2_ET_JOURNAL_TOO_SMALL (2133571413L)
|
||||
#define EXT2_ET_JOURNAL_UNSUPP_VERSION (2133571414L)
|
||||
#define EXT2_ET_LOAD_EXT_JOURNAL (2133571415L)
|
||||
#define EXT2_ET_NO_JOURNAL (2133571416L)
|
||||
#define EXT2_ET_DIRHASH_UNSUPP (2133571417L)
|
||||
#define EXT2_ET_BAD_EA_BLOCK_NUM (2133571418L)
|
||||
#define EXT2_ET_TOO_MANY_INODES (2133571419L)
|
||||
#define EXT2_ET_NOT_IMAGE_FILE (2133571420L)
|
||||
#define EXT2_ET_RES_GDT_BLOCKS (2133571421L)
|
||||
#define EXT2_ET_RESIZE_INODE_CORRUPT (2133571422L)
|
||||
#define EXT2_ET_SET_BMAP_NO_IND (2133571423L)
|
||||
#define EXT2_ET_TDB_SUCCESS (2133571424L)
|
||||
#define EXT2_ET_TDB_ERR_CORRUPT (2133571425L)
|
||||
#define EXT2_ET_TDB_ERR_IO (2133571426L)
|
||||
#define EXT2_ET_TDB_ERR_LOCK (2133571427L)
|
||||
#define EXT2_ET_TDB_ERR_OOM (2133571428L)
|
||||
#define EXT2_ET_TDB_ERR_EXISTS (2133571429L)
|
||||
#define EXT2_ET_TDB_ERR_NOLOCK (2133571430L)
|
||||
#define EXT2_ET_TDB_ERR_EINVAL (2133571431L)
|
||||
#define EXT2_ET_TDB_ERR_NOEXIST (2133571432L)
|
||||
#define EXT2_ET_TDB_ERR_RDONLY (2133571433L)
|
||||
#define EXT2_ET_DBLIST_EMPTY (2133571434L)
|
||||
#define EXT2_ET_RO_BLOCK_ITERATE (2133571435L)
|
||||
#define EXT2_ET_MAGIC_EXTENT_PATH (2133571436L)
|
||||
#define EXT2_ET_MAGIC_GENERIC_BITMAP64 (2133571437L)
|
||||
#define EXT2_ET_MAGIC_BLOCK_BITMAP64 (2133571438L)
|
||||
#define EXT2_ET_MAGIC_INODE_BITMAP64 (2133571439L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_13 (2133571440L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_14 (2133571441L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_15 (2133571442L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_16 (2133571443L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_17 (2133571444L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_18 (2133571445L)
|
||||
#define EXT2_ET_MAGIC_RESERVED_19 (2133571446L)
|
||||
#define EXT2_ET_EXTENT_HEADER_BAD (2133571447L)
|
||||
#define EXT2_ET_EXTENT_INDEX_BAD (2133571448L)
|
||||
#define EXT2_ET_EXTENT_LEAF_BAD (2133571449L)
|
||||
#define EXT2_ET_EXTENT_NO_SPACE (2133571450L)
|
||||
#define EXT2_ET_INODE_NOT_EXTENT (2133571451L)
|
||||
#define EXT2_ET_EXTENT_NO_NEXT (2133571452L)
|
||||
#define EXT2_ET_EXTENT_NO_PREV (2133571453L)
|
||||
#define EXT2_ET_EXTENT_NO_UP (2133571454L)
|
||||
#define EXT2_ET_EXTENT_NO_DOWN (2133571455L)
|
||||
#define EXT2_ET_NO_CURRENT_NODE (2133571456L)
|
||||
#define EXT2_ET_OP_NOT_SUPPORTED (2133571457L)
|
||||
#define EXT2_ET_CANT_INSERT_EXTENT (2133571458L)
|
||||
#define EXT2_ET_CANT_SPLIT_EXTENT (2133571459L)
|
||||
#define EXT2_ET_EXTENT_NOT_FOUND (2133571460L)
|
||||
#define EXT2_ET_EXTENT_NOT_SUPPORTED (2133571461L)
|
||||
#define EXT2_ET_EXTENT_INVALID_LENGTH (2133571462L)
|
||||
#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64 (2133571463L)
|
||||
#define EXT2_ET_NO_MTAB_FILE (2133571464L)
|
||||
#define EXT2_ET_CANT_USE_LEGACY_BITMAPS (2133571465L)
|
||||
#define EXT2_ET_MMP_MAGIC_INVALID (2133571466L)
|
||||
#define EXT2_ET_MMP_FAILED (2133571467L)
|
||||
#define EXT2_ET_MMP_FSCK_ON (2133571468L)
|
||||
#define EXT2_ET_MMP_BAD_BLOCK (2133571469L)
|
||||
#define EXT2_ET_MMP_UNKNOWN_SEQ (2133571470L)
|
||||
#define EXT2_ET_MMP_CHANGE_ABORT (2133571471L)
|
||||
#define EXT2_ET_MMP_OPEN_DIRECT (2133571472L)
|
||||
#define EXT2_ET_BAD_DESC_SIZE (2133571473L)
|
||||
#define EXT2_ET_INODE_CSUM_INVALID (2133571474L)
|
||||
#define EXT2_ET_INODE_BITMAP_CSUM_INVALID (2133571475L)
|
||||
#define EXT2_ET_EXTENT_CSUM_INVALID (2133571476L)
|
||||
#define EXT2_ET_DIR_NO_SPACE_FOR_CSUM (2133571477L)
|
||||
#define EXT2_ET_DIR_CSUM_INVALID (2133571478L)
|
||||
#define EXT2_ET_EXT_ATTR_CSUM_INVALID (2133571479L)
|
||||
#define EXT2_ET_SB_CSUM_INVALID (2133571480L)
|
||||
#define EXT2_ET_UNKNOWN_CSUM (2133571481L)
|
||||
#define EXT2_ET_MMP_CSUM_INVALID (2133571482L)
|
||||
#define EXT2_ET_FILE_EXISTS (2133571483L)
|
||||
#define EXT2_ET_BLOCK_BITMAP_CSUM_INVALID (2133571484L)
|
||||
#define EXT2_ET_INLINE_DATA_CANT_ITERATE (2133571485L)
|
||||
#define EXT2_ET_EA_BAD_NAME_LEN (2133571486L)
|
||||
#define EXT2_ET_EA_BAD_VALUE_SIZE (2133571487L)
|
||||
#define EXT2_ET_BAD_EA_HASH (2133571488L)
|
||||
#define EXT2_ET_BAD_EA_HEADER (2133571489L)
|
||||
#define EXT2_ET_EA_KEY_NOT_FOUND (2133571490L)
|
||||
#define EXT2_ET_EA_NO_SPACE (2133571491L)
|
||||
#define EXT2_ET_MISSING_EA_FEATURE (2133571492L)
|
||||
#define EXT2_ET_NO_INLINE_DATA (2133571493L)
|
||||
#define EXT2_ET_INLINE_DATA_NO_BLOCK (2133571494L)
|
||||
#define EXT2_ET_INLINE_DATA_NO_SPACE (2133571495L)
|
||||
#define EXT2_ET_MAGIC_EA_HANDLE (2133571496L)
|
||||
#define EXT2_ET_INODE_IS_GARBAGE (2133571497L)
|
||||
#define EXT2_ET_EA_BAD_VALUE_OFFSET (2133571498L)
|
||||
#define EXT2_ET_JOURNAL_FLAGS_WRONG (2133571499L)
|
||||
#define EXT2_ET_UNDO_FILE_CORRUPT (2133571500L)
|
||||
#define EXT2_ET_UNDO_FILE_WRONG (2133571501L)
|
||||
#define EXT2_ET_FILESYSTEM_CORRUPTED (2133571502L)
|
||||
#define EXT2_ET_BAD_CRC (2133571503L)
|
||||
#define EXT2_ET_CORRUPT_JOURNAL_SB (2133571504L)
|
||||
#define EXT2_ET_INODE_CORRUPTED (2133571505L)
|
||||
#define EXT2_ET_EA_INODE_CORRUPTED (2133571506L)
|
||||
#define EXT2_ET_NO_GDESC (2133571507L)
|
||||
#define EXT2_FILSYS_CORRUPTED (2133571508L)
|
||||
#define EXT2_ET_EXTENT_CYCLE (2133571509L)
|
||||
#define EXT2_ET_EXTERNAL_JOURNAL_NOSUPP (2133571510L)
|
||||
extern const struct error_table et_ext2_error_table;
|
||||
extern void initialize_ext2_error_table(void);
|
||||
|
||||
/* For compatibility with Heimdal */
|
||||
extern void initialize_ext2_error_table_r(struct et_list **list);
|
||||
|
||||
#define ERROR_TABLE_BASE_ext2 (2133571328L)
|
||||
|
||||
/* for compatibility with older versions... */
|
||||
#define init_ext2_err_tbl initialize_ext2_error_table
|
||||
#define ext2_err_base ERROR_TABLE_BASE_ext2
|
||||
73
include/e2fsprogs/ext2fs/ext2_ext_attr.h
Executable file
73
include/e2fsprogs/ext2fs/ext2_ext_attr.h
Executable file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
File: linux/ext2_ext_attr.h
|
||||
|
||||
On-disk format of extended attributes for the ext2 filesystem.
|
||||
|
||||
(C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
|
||||
*/
|
||||
|
||||
#ifndef _EXT2_EXT_ATTR_H
|
||||
#define _EXT2_EXT_ATTR_H
|
||||
/* Magic value in attribute blocks */
|
||||
#define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
|
||||
#define EXT2_EXT_ATTR_MAGIC 0xEA020000
|
||||
|
||||
/* Maximum number of references to one attribute block */
|
||||
#define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
|
||||
|
||||
struct ext2_ext_attr_header {
|
||||
__u32 h_magic; /* magic number for identification */
|
||||
__u32 h_refcount; /* reference count */
|
||||
__u32 h_blocks; /* number of disk blocks used */
|
||||
__u32 h_hash; /* hash value of all attributes */
|
||||
__u32 h_checksum; /* crc32c(uuid+id+xattrs) */
|
||||
/* id = inum if refcount = 1, else blknum */
|
||||
__u32 h_reserved[3]; /* zero right now */
|
||||
};
|
||||
|
||||
struct ext2_ext_attr_entry {
|
||||
__u8 e_name_len; /* length of name */
|
||||
__u8 e_name_index; /* attribute name index */
|
||||
__u16 e_value_offs; /* offset in disk block of value */
|
||||
__u32 e_value_inum; /* inode in which the value is stored */
|
||||
__u32 e_value_size; /* size of attribute value */
|
||||
__u32 e_hash; /* hash value of name and value */
|
||||
#if 0
|
||||
char e_name[0]; /* attribute name */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define EXT2_EXT_ATTR_PAD_BITS 2
|
||||
#define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
|
||||
#define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
|
||||
#define EXT2_EXT_ATTR_LEN(name_len) \
|
||||
(((name_len) + EXT2_EXT_ATTR_ROUND + \
|
||||
sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
|
||||
#define EXT2_EXT_ATTR_NEXT(entry) \
|
||||
( (struct ext2_ext_attr_entry *)( \
|
||||
(char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
|
||||
#define EXT2_EXT_ATTR_SIZE(size) \
|
||||
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
|
||||
#define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
|
||||
#define EXT2_EXT_ATTR_NAME(entry) \
|
||||
(((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
|
||||
#define EXT2_XATTR_LEN(name_len) \
|
||||
(((name_len) + EXT2_EXT_ATTR_ROUND + \
|
||||
sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
|
||||
#define EXT2_XATTR_SIZE(size) \
|
||||
(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
# ifdef CONFIG_EXT2_FS_EXT_ATTR
|
||||
extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
|
||||
extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
|
||||
extern void ext2_ext_attr_free_inode(struct inode *inode);
|
||||
extern void ext2_ext_attr_put_super(struct super_block *sb);
|
||||
extern int ext2_ext_attr_init(void);
|
||||
extern void ext2_ext_attr_done(void);
|
||||
# else
|
||||
# define ext2_get_ext_attr NULL
|
||||
# define ext2_set_ext_attr NULL
|
||||
# endif
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* _EXT2_EXT_ATTR_H */
|
||||
1189
include/e2fsprogs/ext2fs/ext2_fs.h
Executable file
1189
include/e2fsprogs/ext2fs/ext2_fs.h
Executable file
File diff suppressed because it is too large
Load Diff
179
include/e2fsprogs/ext2fs/ext2_io.h
Executable file
179
include/e2fsprogs/ext2fs/ext2_io.h
Executable file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* io.h --- the I/O manager abstraction
|
||||
*
|
||||
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _EXT2FS_EXT2_IO_H
|
||||
#define _EXT2FS_EXT2_IO_H
|
||||
|
||||
#include <ext2fs/ext2_types.h>
|
||||
|
||||
/*
|
||||
* ext2_loff_t is defined here since unix_io.c needs it.
|
||||
*/
|
||||
#if defined(__GNUC__) || defined(HAS_LONG_LONG)
|
||||
typedef long long ext2_loff_t;
|
||||
#else
|
||||
typedef long ext2_loff_t;
|
||||
#endif
|
||||
|
||||
/* llseek.c */
|
||||
ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int);
|
||||
|
||||
typedef struct struct_io_manager *io_manager;
|
||||
typedef struct struct_io_channel *io_channel;
|
||||
typedef struct struct_io_stats *io_stats;
|
||||
|
||||
#define CHANNEL_FLAGS_WRITETHROUGH 0x01
|
||||
#define CHANNEL_FLAGS_DISCARD_ZEROES 0x02
|
||||
#define CHANNEL_FLAGS_BLOCK_DEVICE 0x04
|
||||
#define CHANNEL_FLAGS_THREADS 0x08
|
||||
|
||||
#define io_channel_discard_zeroes_data(i) (i->flags & CHANNEL_FLAGS_DISCARD_ZEROES)
|
||||
|
||||
struct struct_io_channel {
|
||||
errcode_t magic;
|
||||
io_manager manager;
|
||||
char *name;
|
||||
int block_size;
|
||||
errcode_t (*read_error)(io_channel channel,
|
||||
unsigned long block,
|
||||
int count,
|
||||
void *data,
|
||||
size_t size,
|
||||
int actual_bytes_read,
|
||||
errcode_t error);
|
||||
errcode_t (*write_error)(io_channel channel,
|
||||
unsigned long block,
|
||||
int count,
|
||||
const void *data,
|
||||
size_t size,
|
||||
int actual_bytes_written,
|
||||
errcode_t error);
|
||||
int refcount;
|
||||
int flags;
|
||||
long reserved[14];
|
||||
void *private_data;
|
||||
void *app_data;
|
||||
int align;
|
||||
};
|
||||
|
||||
struct struct_io_stats {
|
||||
int num_fields;
|
||||
int reserved;
|
||||
unsigned long long bytes_read;
|
||||
unsigned long long bytes_written;
|
||||
};
|
||||
|
||||
struct struct_io_manager {
|
||||
errcode_t magic;
|
||||
const char *name;
|
||||
errcode_t (*open)(const char *name, int flags, io_channel *channel);
|
||||
errcode_t (*close)(io_channel channel);
|
||||
errcode_t (*set_blksize)(io_channel channel, int blksize);
|
||||
errcode_t (*read_blk)(io_channel channel, unsigned long block,
|
||||
int count, void *data);
|
||||
errcode_t (*write_blk)(io_channel channel, unsigned long block,
|
||||
int count, const void *data);
|
||||
errcode_t (*flush)(io_channel channel);
|
||||
errcode_t (*write_byte)(io_channel channel, unsigned long offset,
|
||||
int count, const void *data);
|
||||
errcode_t (*set_option)(io_channel channel, const char *option,
|
||||
const char *arg);
|
||||
errcode_t (*get_stats)(io_channel channel, io_stats *io_stats);
|
||||
errcode_t (*read_blk64)(io_channel channel, unsigned long long block,
|
||||
int count, void *data);
|
||||
errcode_t (*write_blk64)(io_channel channel, unsigned long long block,
|
||||
int count, const void *data);
|
||||
errcode_t (*discard)(io_channel channel, unsigned long long block,
|
||||
unsigned long long count);
|
||||
errcode_t (*cache_readahead)(io_channel channel,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
errcode_t (*zeroout)(io_channel channel, unsigned long long block,
|
||||
unsigned long long count);
|
||||
long reserved[14];
|
||||
};
|
||||
|
||||
#define IO_FLAG_RW 0x0001
|
||||
#define IO_FLAG_EXCLUSIVE 0x0002
|
||||
#define IO_FLAG_DIRECT_IO 0x0004
|
||||
#define IO_FLAG_FORCE_BOUNCE 0x0008
|
||||
#define IO_FLAG_THREADS 0x0010
|
||||
#define IO_FLAG_NOCACHE 0x0020
|
||||
|
||||
/*
|
||||
* Convenience functions....
|
||||
*/
|
||||
#define io_channel_close(c) ((c)->manager->close((c)))
|
||||
#define io_channel_set_blksize(c,s) ((c)->manager->set_blksize((c),s))
|
||||
#define io_channel_read_blk(c,b,n,d) ((c)->manager->read_blk((c),b,n,d))
|
||||
#define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d))
|
||||
#define io_channel_flush(c) ((c)->manager->flush((c)))
|
||||
#define io_channel_bumpcount(c) ((c)->refcount++)
|
||||
|
||||
/* io_manager.c */
|
||||
extern errcode_t io_channel_set_options(io_channel channel,
|
||||
const char *options);
|
||||
extern errcode_t io_channel_write_byte(io_channel channel,
|
||||
unsigned long offset,
|
||||
int count, const void *data);
|
||||
extern errcode_t io_channel_read_blk64(io_channel channel,
|
||||
unsigned long long block,
|
||||
int count, void *data);
|
||||
extern errcode_t io_channel_write_blk64(io_channel channel,
|
||||
unsigned long long block,
|
||||
int count, const void *data);
|
||||
extern errcode_t io_channel_discard(io_channel channel,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
extern errcode_t io_channel_zeroout(io_channel channel,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
extern errcode_t io_channel_alloc_buf(io_channel channel,
|
||||
int count, void *ptr);
|
||||
extern errcode_t io_channel_cache_readahead(io_channel io,
|
||||
unsigned long long block,
|
||||
unsigned long long count);
|
||||
|
||||
#ifdef _WIN32
|
||||
/* windows_io.c */
|
||||
extern io_manager windows_io_manager;
|
||||
#define default_io_manager windows_io_manager
|
||||
#else
|
||||
/* unix_io.c */
|
||||
extern io_manager unix_io_manager;
|
||||
extern io_manager unixfd_io_manager;
|
||||
#define default_io_manager unix_io_manager
|
||||
#endif
|
||||
|
||||
/* sparse_io.c */
|
||||
extern io_manager sparse_io_manager;
|
||||
extern io_manager sparsefd_io_manager;
|
||||
|
||||
/* undo_io.c */
|
||||
extern io_manager undo_io_manager;
|
||||
extern errcode_t set_undo_io_backing_manager(io_manager manager);
|
||||
extern errcode_t set_undo_io_backup_file(char *file_name);
|
||||
|
||||
/* test_io.c */
|
||||
extern io_manager test_io_manager, test_io_backing_manager;
|
||||
extern void (*test_io_cb_read_blk)
|
||||
(unsigned long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_write_blk)
|
||||
(unsigned long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_read_blk64)
|
||||
(unsigned long long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_write_blk64)
|
||||
(unsigned long long block, int count, errcode_t err);
|
||||
extern void (*test_io_cb_set_blksize)
|
||||
(int blksize, errcode_t err);
|
||||
|
||||
#endif /* _EXT2FS_EXT2_IO_H */
|
||||
|
||||
45
include/e2fsprogs/ext2fs/ext2_types.h
Executable file
45
include/e2fsprogs/ext2fs/ext2_types.h
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* If linux/types.h is already been included, assume it has defined
|
||||
* everything we need. (cross fingers) Other header files may have
|
||||
* also defined the types that we need.
|
||||
*/
|
||||
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
|
||||
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
|
||||
#define _EXT2_TYPES_H
|
||||
|
||||
typedef unsigned char __u8;
|
||||
typedef __signed__ char __s8;
|
||||
typedef unsigned short __u16;
|
||||
typedef __signed__ short __s16;
|
||||
typedef unsigned int __u32;
|
||||
typedef __signed__ int __s32;
|
||||
typedef unsigned long long __u64;
|
||||
typedef __signed__ long long __s64;
|
||||
#endif
|
||||
|
||||
#include <stdint.h> //uintptr_t
|
||||
|
||||
/* endian checking stuff */
|
||||
#ifndef EXT2_ENDIAN_H_
|
||||
#define EXT2_ENDIAN_H_
|
||||
|
||||
#ifdef __CHECKER__
|
||||
#ifndef __bitwise
|
||||
#define __bitwise __attribute__((bitwise))
|
||||
#endif
|
||||
#define __force __attribute__((force))
|
||||
#else
|
||||
#ifndef __bitwise
|
||||
#define __bitwise
|
||||
#endif
|
||||
#define __force
|
||||
#endif
|
||||
|
||||
typedef __u16 __bitwise __le16;
|
||||
typedef __u32 __bitwise __le32;
|
||||
typedef __u64 __bitwise __le64;
|
||||
typedef __u16 __bitwise __be16;
|
||||
typedef __u32 __bitwise __be32;
|
||||
typedef __u64 __bitwise __be64;
|
||||
|
||||
#endif /* EXT2_ENDIAN_H_ */
|
||||
2191
include/e2fsprogs/ext2fs/ext2fs.h
Executable file
2191
include/e2fsprogs/ext2fs/ext2fs.h
Executable file
File diff suppressed because it is too large
Load Diff
210
include/e2fsprogs/ext2fs/ext2fsP.h
Executable file
210
include/e2fsprogs/ext2fs/ext2fsP.h
Executable file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* ext2fsP.h --- private header file for ext2 library
|
||||
*
|
||||
* Copyright (C) 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#if HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "ext2fs.h"
|
||||
|
||||
#define EXT2FS_MAX_NESTED_LINKS 8
|
||||
|
||||
static inline int ext2fsP_is_disk_device(mode_t mode)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
return S_ISBLK(mode) || S_ISCHR(mode);
|
||||
#else
|
||||
return S_ISBLK(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Badblocks list
|
||||
*/
|
||||
struct ext2_struct_u32_list {
|
||||
int magic;
|
||||
int num;
|
||||
int size;
|
||||
__u32 *list;
|
||||
int badblocks_flags;
|
||||
};
|
||||
|
||||
struct ext2_struct_u32_iterate {
|
||||
int magic;
|
||||
ext2_u32_list bb;
|
||||
int ptr;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Directory block iterator definition
|
||||
*/
|
||||
struct ext2_struct_dblist {
|
||||
int magic;
|
||||
ext2_filsys fs;
|
||||
unsigned long long size;
|
||||
unsigned long long count;
|
||||
int sorted;
|
||||
struct ext2_db_entry2 * list;
|
||||
};
|
||||
|
||||
/*
|
||||
* For directory iterators
|
||||
*/
|
||||
struct dir_context {
|
||||
ext2_ino_t dir;
|
||||
int flags;
|
||||
char *buf;
|
||||
unsigned int buflen;
|
||||
int (*func)(ext2_ino_t dir,
|
||||
int entry,
|
||||
struct ext2_dir_entry *dirent,
|
||||
int offset,
|
||||
int blocksize,
|
||||
char *buf,
|
||||
void *priv_data);
|
||||
void *priv_data;
|
||||
errcode_t errcode;
|
||||
};
|
||||
|
||||
/*
|
||||
* Inode cache structure
|
||||
*/
|
||||
struct ext2_inode_cache {
|
||||
void * buffer;
|
||||
blk64_t buffer_blk;
|
||||
int cache_last;
|
||||
unsigned int cache_size;
|
||||
int refcount;
|
||||
struct ext2_inode_cache_ent *cache;
|
||||
};
|
||||
|
||||
struct ext2_inode_cache_ent {
|
||||
ext2_ino_t ino;
|
||||
struct ext2_inode *inode;
|
||||
};
|
||||
|
||||
/*
|
||||
* NLS definitions
|
||||
*/
|
||||
struct ext2fs_nls_table {
|
||||
int version;
|
||||
const struct ext2fs_nls_ops *ops;
|
||||
};
|
||||
|
||||
struct ext2fs_nls_ops {
|
||||
int (*casefold)(const struct ext2fs_nls_table *charset,
|
||||
const unsigned char *str, size_t len,
|
||||
unsigned char *dest, size_t dlen);
|
||||
int (*validate)(const struct ext2fs_nls_table *table,
|
||||
char *s, size_t len, char **pos);
|
||||
int (*casefold_cmp)(const struct ext2fs_nls_table *table,
|
||||
const unsigned char *str1, size_t len1,
|
||||
const unsigned char *str2, size_t len2);
|
||||
};
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
extern int ext2fs_process_dir_block(ext2_filsys fs,
|
||||
blk64_t *blocknr,
|
||||
e2_blkcnt_t blockcnt,
|
||||
blk64_t ref_block,
|
||||
int ref_offset,
|
||||
void *priv_data);
|
||||
|
||||
extern errcode_t ext2fs_inline_data_ea_remove(ext2_filsys fs, ext2_ino_t ino);
|
||||
extern errcode_t ext2fs_inline_data_expand(ext2_filsys fs, ext2_ino_t ino);
|
||||
extern int ext2fs_inline_data_dir_iterate(ext2_filsys fs,
|
||||
ext2_ino_t ino,
|
||||
void *priv_data);
|
||||
|
||||
/* Generic numeric progress meter */
|
||||
|
||||
struct ext2fs_numeric_progress_struct {
|
||||
__u64 max;
|
||||
int log_max;
|
||||
int skip_progress;
|
||||
};
|
||||
|
||||
/*
|
||||
* progress callback functions
|
||||
*/
|
||||
struct ext2fs_progress_ops {
|
||||
void (*init)(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *label, __u64 max);
|
||||
void (*update)(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
__u64 val);
|
||||
void (*close)(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *message);
|
||||
};
|
||||
|
||||
extern struct ext2fs_progress_ops ext2fs_numeric_progress_ops;
|
||||
|
||||
extern void ext2fs_numeric_progress_init(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *label, __u64 max);
|
||||
extern void ext2fs_numeric_progress_update(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
__u64 val);
|
||||
extern void ext2fs_numeric_progress_close(ext2_filsys fs,
|
||||
struct ext2fs_numeric_progress_struct * progress,
|
||||
const char *message);
|
||||
|
||||
/*
|
||||
* 64-bit bitmap support
|
||||
*/
|
||||
|
||||
extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
|
||||
int type, __u64 start, __u64 end,
|
||||
__u64 real_end,
|
||||
const char * description,
|
||||
ext2fs_generic_bitmap *bmap);
|
||||
|
||||
extern void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap);
|
||||
|
||||
extern errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap src,
|
||||
ext2fs_generic_bitmap *dest);
|
||||
|
||||
extern errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
|
||||
__u64 new_end,
|
||||
__u64 new_real_end);
|
||||
extern errcode_t ext2fs_fudge_generic_bmap_end(ext2fs_generic_bitmap bitmap,
|
||||
errcode_t neq,
|
||||
__u64 end, __u64 *oend);
|
||||
extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 arg);
|
||||
extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 arg);
|
||||
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
|
||||
__u64 arg);
|
||||
extern errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, unsigned int num,
|
||||
void *in);
|
||||
extern errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bitmap,
|
||||
__u64 start, unsigned int num,
|
||||
void *out);
|
||||
extern void ext2fs_warn_bitmap32(ext2fs_generic_bitmap bitmap,const char *func);
|
||||
|
||||
extern int ext2fs_mem_is_zero(const char *mem, size_t len);
|
||||
|
||||
extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
|
||||
struct ext2_inode *inode,
|
||||
blk64_t offset);
|
||||
|
||||
/* atexit support */
|
||||
typedef void (*ext2_exit_fn)(void *);
|
||||
errcode_t ext2fs_add_exit_fn(ext2_exit_fn fn, void *data);
|
||||
errcode_t ext2fs_remove_exit_fn(ext2_exit_fn fn, void *data);
|
||||
|
||||
#define EXT2FS_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2*!!(cond)]))
|
||||
127
include/e2fsprogs/ext2fs/ext3_extents.h
Executable file
127
include/e2fsprogs/ext2fs/ext3_extents.h
Executable file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2004 Cluster File Systems, Inc, info@clusterfs.com
|
||||
* Written by Alex Tomas <alex@clusterfs.com>
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_EXT3_EXTENTS
|
||||
#define _LINUX_EXT3_EXTENTS
|
||||
|
||||
/*
|
||||
* ext3_inode has i_block array (total 60 bytes)
|
||||
* first 4 bytes are used to store:
|
||||
* - tree depth (0 mean there is no tree yet. all extents in the inode)
|
||||
* - number of alive extents in the inode
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is extent tail on-disk structure.
|
||||
* All other extent structures are 12 bytes long. It turns out that
|
||||
* block_size % 12 >= 4 for at least all powers of 2 greater than 512, which
|
||||
* covers all valid ext4 block sizes. Therefore, this tail structure can be
|
||||
* crammed into the end of the block without having to rebalance the tree.
|
||||
*/
|
||||
struct ext3_extent_tail {
|
||||
__le32 et_checksum; /* crc32c(uuid+inum+extent_block) */
|
||||
};
|
||||
|
||||
/*
|
||||
* this is extent on-disk structure
|
||||
* it's used at the bottom of the tree
|
||||
*/
|
||||
struct ext3_extent {
|
||||
__le32 ee_block; /* first logical block extent covers */
|
||||
__le16 ee_len; /* number of blocks covered by extent */
|
||||
__le16 ee_start_hi; /* high 16 bits of physical block */
|
||||
__le32 ee_start; /* low 32 bigs of physical block */
|
||||
};
|
||||
|
||||
/*
|
||||
* this is index on-disk structure
|
||||
* it's used at all the levels, but the bottom
|
||||
*/
|
||||
struct ext3_extent_idx {
|
||||
__le32 ei_block; /* index covers logical blocks from 'block' */
|
||||
__le32 ei_leaf; /* pointer to the physical block of the next *
|
||||
* level. leaf or next index could bet here */
|
||||
__le16 ei_leaf_hi; /* high 16 bits of physical block */
|
||||
__le16 ei_unused;
|
||||
};
|
||||
|
||||
/*
|
||||
* each block (leaves and indexes), even inode-stored has header
|
||||
*/
|
||||
struct ext3_extent_header {
|
||||
__le16 eh_magic; /* probably will support different formats */
|
||||
__le16 eh_entries; /* number of valid entries */
|
||||
__le16 eh_max; /* capacity of store in entries */
|
||||
__le16 eh_depth; /* has tree real underlying blocks? */
|
||||
__le32 eh_generation; /* generation of the tree */
|
||||
};
|
||||
|
||||
#define EXT3_EXT_MAGIC 0xf30a
|
||||
|
||||
/*
|
||||
* array of ext3_ext_path contains path to some extent
|
||||
* creation/lookup routines use it for traversal/splitting/etc
|
||||
* truncate uses it to simulate recursive walking
|
||||
*/
|
||||
struct ext3_ext_path {
|
||||
__u32 p_block;
|
||||
__u16 p_depth;
|
||||
struct ext3_extent *p_ext;
|
||||
struct ext3_extent_idx *p_idx;
|
||||
struct ext3_extent_header *p_hdr;
|
||||
struct buffer_head *p_bh;
|
||||
};
|
||||
|
||||
/*
|
||||
* EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
|
||||
* initialized extent. This is 2^15 and not (2^16 - 1), since we use the
|
||||
* MSB of ee_len field in the extent datastructure to signify if this
|
||||
* particular extent is an initialized extent or an uninitialized (i.e.
|
||||
* preallocated).
|
||||
* EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
|
||||
* uninitialized extent.
|
||||
* If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
|
||||
* uninitialized one. In other words, if MSB of ee_len is set, it is an
|
||||
* uninitialized extent with only one special scenario when ee_len = 0x8000.
|
||||
* In this case we can not have an uninitialized extent of zero length and
|
||||
* thus we make it as a special case of initialized extent with 0x8000 length.
|
||||
* This way we get better extent-to-group alignment for initialized extents.
|
||||
* Hence, the maximum number of blocks we can have in an *initialized*
|
||||
* extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
|
||||
*/
|
||||
#define EXT_INIT_MAX_LEN (1UL << 15)
|
||||
#define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1)
|
||||
#define EXT_MAX_EXTENT_LBLK (((__u64) 1 << 32) - 1)
|
||||
#define EXT_MAX_EXTENT_PBLK (((__u64) 1 << 48) - 1)
|
||||
|
||||
#define EXT_FIRST_EXTENT(__hdr__) \
|
||||
((struct ext3_extent *) (((char *) (__hdr__)) + \
|
||||
sizeof(struct ext3_extent_header)))
|
||||
#define EXT_FIRST_INDEX(__hdr__) \
|
||||
((struct ext3_extent_idx *) (((char *) (__hdr__)) + \
|
||||
sizeof(struct ext3_extent_header)))
|
||||
#define EXT_HAS_FREE_INDEX(__path__) \
|
||||
(ext2fs_le16_to_cpu((__path__)->p_hdr->eh_entries) < \
|
||||
ext2fs_le16_to_cpu((__path__)->p_hdr->eh_max))
|
||||
#define EXT_LAST_EXTENT(__hdr__) \
|
||||
(EXT_FIRST_EXTENT((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
|
||||
#define EXT_LAST_INDEX(__hdr__) \
|
||||
(EXT_FIRST_INDEX((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
|
||||
#define EXT_MAX_EXTENT(__hdr__) \
|
||||
(EXT_FIRST_EXTENT((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
|
||||
#define EXT_MAX_INDEX(__hdr__) \
|
||||
(EXT_FIRST_INDEX((__hdr__)) + \
|
||||
ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
|
||||
|
||||
#endif /* _LINUX_EXT3_EXTENTS */
|
||||
|
||||
62
include/e2fsprogs/ext2fs/ext4_acl.h
Executable file
62
include/e2fsprogs/ext2fs/ext4_acl.h
Executable file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Ext4's on-disk acl format. From linux/fs/ext4/acl.h
|
||||
*/
|
||||
|
||||
#define EXT4_ACL_VERSION 0x0001
|
||||
|
||||
/* 23.2.5 acl_tag_t values */
|
||||
|
||||
#define ACL_UNDEFINED_TAG (0x00)
|
||||
#define ACL_USER_OBJ (0x01)
|
||||
#define ACL_USER (0x02)
|
||||
#define ACL_GROUP_OBJ (0x04)
|
||||
#define ACL_GROUP (0x08)
|
||||
#define ACL_MASK (0x10)
|
||||
#define ACL_OTHER (0x20)
|
||||
|
||||
/* 23.3.6 acl_type_t values */
|
||||
|
||||
#define ACL_TYPE_ACCESS (0x8000)
|
||||
#define ACL_TYPE_DEFAULT (0x4000)
|
||||
|
||||
/* 23.2.7 ACL qualifier constants */
|
||||
|
||||
#define ACL_UNDEFINED_ID ((id_t)-1)
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
__le32 e_id;
|
||||
} ext4_acl_entry;
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
} ext4_acl_entry_short;
|
||||
|
||||
typedef struct {
|
||||
__le32 a_version;
|
||||
} ext4_acl_header;
|
||||
|
||||
|
||||
/* Supported ACL a_version fields */
|
||||
#define POSIX_ACL_XATTR_VERSION 0x0002
|
||||
|
||||
typedef struct {
|
||||
__le16 e_tag;
|
||||
__le16 e_perm;
|
||||
__le32 e_id;
|
||||
} posix_acl_xattr_entry;
|
||||
|
||||
typedef struct {
|
||||
__le32 a_version;
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
posix_acl_xattr_entry a_entries[0];
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} posix_acl_xattr_header;
|
||||
|
||||
190
include/e2fsprogs/ext2fs/fast_commit.h
Executable file
190
include/e2fsprogs/ext2fs/fast_commit.h
Executable file
@@ -0,0 +1,190 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#ifndef __FAST_COMMIT_H__
|
||||
#define __FAST_COMMIT_H__
|
||||
|
||||
#include "jfs_compat.h"
|
||||
|
||||
/*
|
||||
* Note this file is present in e2fsprogs/lib/ext2fs/fast_commit.h and
|
||||
* linux/fs/ext4/fast_commit.h. These file should always be byte identical.
|
||||
*/
|
||||
|
||||
/* Fast commit tags */
|
||||
#define EXT4_FC_TAG_ADD_RANGE 0x0001
|
||||
#define EXT4_FC_TAG_DEL_RANGE 0x0002
|
||||
#define EXT4_FC_TAG_CREAT 0x0003
|
||||
#define EXT4_FC_TAG_LINK 0x0004
|
||||
#define EXT4_FC_TAG_UNLINK 0x0005
|
||||
#define EXT4_FC_TAG_INODE 0x0006
|
||||
#define EXT4_FC_TAG_PAD 0x0007
|
||||
#define EXT4_FC_TAG_TAIL 0x0008
|
||||
#define EXT4_FC_TAG_HEAD 0x0009
|
||||
|
||||
#define EXT4_FC_SUPPORTED_FEATURES 0x0
|
||||
|
||||
/* On disk fast commit tlv value structures */
|
||||
|
||||
/* Fast commit on disk tag length structure */
|
||||
struct ext4_fc_tl {
|
||||
__le16 fc_tag;
|
||||
__le16 fc_len;
|
||||
};
|
||||
|
||||
/* Value structure for tag EXT4_FC_TAG_HEAD. */
|
||||
struct ext4_fc_head {
|
||||
__le32 fc_features;
|
||||
__le32 fc_tid;
|
||||
};
|
||||
|
||||
/* Value structure for EXT4_FC_TAG_ADD_RANGE. */
|
||||
struct ext4_fc_add_range {
|
||||
__le32 fc_ino;
|
||||
__u8 fc_ex[12];
|
||||
};
|
||||
|
||||
/* Value structure for tag EXT4_FC_TAG_DEL_RANGE. */
|
||||
struct ext4_fc_del_range {
|
||||
__le32 fc_ino;
|
||||
__le32 fc_lblk;
|
||||
__le32 fc_len;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the value structure for tags EXT4_FC_TAG_CREAT, EXT4_FC_TAG_LINK
|
||||
* and EXT4_FC_TAG_UNLINK.
|
||||
*/
|
||||
struct ext4_fc_dentry_info {
|
||||
__le32 fc_parent_ino;
|
||||
__le32 fc_ino;
|
||||
__u8 fc_dname[0];
|
||||
};
|
||||
|
||||
/* Value structure for EXT4_FC_TAG_INODE and EXT4_FC_TAG_INODE_PARTIAL. */
|
||||
struct ext4_fc_inode {
|
||||
__le32 fc_ino;
|
||||
__u8 fc_raw_inode[0];
|
||||
};
|
||||
|
||||
/* Value structure for tag EXT4_FC_TAG_TAIL. */
|
||||
struct ext4_fc_tail {
|
||||
__le32 fc_tid;
|
||||
__le32 fc_crc;
|
||||
};
|
||||
|
||||
/*
|
||||
* Fast commit reason codes
|
||||
*/
|
||||
enum {
|
||||
/*
|
||||
* Commit status codes:
|
||||
*/
|
||||
EXT4_FC_REASON_OK = 0,
|
||||
EXT4_FC_REASON_INELIGIBLE,
|
||||
EXT4_FC_REASON_ALREADY_COMMITTED,
|
||||
EXT4_FC_REASON_FC_START_FAILED,
|
||||
EXT4_FC_REASON_FC_FAILED,
|
||||
|
||||
/*
|
||||
* Fast commit ineligiblity reasons:
|
||||
*/
|
||||
EXT4_FC_REASON_XATTR = 0,
|
||||
EXT4_FC_REASON_CROSS_RENAME,
|
||||
EXT4_FC_REASON_JOURNAL_FLAG_CHANGE,
|
||||
EXT4_FC_REASON_NOMEM,
|
||||
EXT4_FC_REASON_SWAP_BOOT,
|
||||
EXT4_FC_REASON_RESIZE,
|
||||
EXT4_FC_REASON_RENAME_DIR,
|
||||
EXT4_FC_REASON_FALLOC_RANGE,
|
||||
EXT4_FC_REASON_INODE_JOURNAL_DATA,
|
||||
EXT4_FC_COMMIT_FAILED,
|
||||
EXT4_FC_REASON_MAX
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/*
|
||||
* In memory list of dentry updates that are performed on the file
|
||||
* system used by fast commit code.
|
||||
*/
|
||||
struct ext4_fc_dentry_update {
|
||||
int fcd_op; /* Type of update create / unlink / link */
|
||||
int fcd_parent; /* Parent inode number */
|
||||
int fcd_ino; /* Inode number */
|
||||
struct qstr fcd_name; /* Dirent name */
|
||||
unsigned char fcd_iname[DNAME_INLINE_LEN]; /* Dirent name string */
|
||||
struct list_head fcd_list;
|
||||
};
|
||||
|
||||
struct ext4_fc_stats {
|
||||
unsigned int fc_ineligible_reason_count[EXT4_FC_REASON_MAX];
|
||||
unsigned long fc_num_commits;
|
||||
unsigned long fc_ineligible_commits;
|
||||
unsigned long fc_numblks;
|
||||
};
|
||||
|
||||
#define EXT4_FC_REPLAY_REALLOC_INCREMENT 4
|
||||
|
||||
/*
|
||||
* Physical block regions added to different inodes due to fast commit
|
||||
* recovery. These are set during the SCAN phase. During the replay phase,
|
||||
* our allocator excludes these from its allocation. This ensures that
|
||||
* we don't accidentally allocating a block that is going to be used by
|
||||
* another inode.
|
||||
*/
|
||||
struct ext4_fc_alloc_region {
|
||||
ext4_lblk_t lblk;
|
||||
ext4_fsblk_t pblk;
|
||||
int ino, len;
|
||||
};
|
||||
|
||||
/*
|
||||
* Fast commit replay state.
|
||||
*/
|
||||
struct ext4_fc_replay_state {
|
||||
int fc_replay_num_tags;
|
||||
int fc_replay_expected_off;
|
||||
int fc_current_pass;
|
||||
int fc_cur_tag;
|
||||
int fc_crc;
|
||||
struct ext4_fc_alloc_region *fc_regions;
|
||||
int fc_regions_size, fc_regions_used, fc_regions_valid;
|
||||
int *fc_modified_inodes;
|
||||
int fc_modified_inodes_used, fc_modified_inodes_size;
|
||||
};
|
||||
|
||||
#define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1)
|
||||
#endif
|
||||
|
||||
static inline const char *tag2str(__u16 tag)
|
||||
{
|
||||
switch (tag) {
|
||||
case EXT4_FC_TAG_LINK:
|
||||
return "ADD_ENTRY";
|
||||
case EXT4_FC_TAG_UNLINK:
|
||||
return "DEL_ENTRY";
|
||||
case EXT4_FC_TAG_ADD_RANGE:
|
||||
return "ADD_RANGE";
|
||||
case EXT4_FC_TAG_CREAT:
|
||||
return "CREAT_DENTRY";
|
||||
case EXT4_FC_TAG_DEL_RANGE:
|
||||
return "DEL_RANGE";
|
||||
case EXT4_FC_TAG_INODE:
|
||||
return "INODE";
|
||||
case EXT4_FC_TAG_PAD:
|
||||
return "PAD";
|
||||
case EXT4_FC_TAG_TAIL:
|
||||
return "TAIL";
|
||||
case EXT4_FC_TAG_HEAD:
|
||||
return "HEAD";
|
||||
default:
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
/* Get length of a particular tlv */
|
||||
static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl)
|
||||
{
|
||||
return le16_to_cpu(tl->fc_len);
|
||||
}
|
||||
|
||||
#endif /* __FAST_COMMIT_H__ */
|
||||
93
include/e2fsprogs/ext2fs/fiemap.h
Executable file
93
include/e2fsprogs/ext2fs/fiemap.h
Executable file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* FS_IOC_FIEMAP ioctl infrastructure.
|
||||
*
|
||||
* Some portions copyright (C) 2007 Cluster File Systems, Inc
|
||||
*
|
||||
* Authors: Mark Fasheh <mfasheh@suse.com>
|
||||
* Kalpak Shah <kalpak.shah@sun.com>
|
||||
* Andreas Dilger <adilger@sun.com>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_FIEMAP_H
|
||||
#define _LINUX_FIEMAP_H
|
||||
|
||||
struct fiemap_extent {
|
||||
__u64 fe_logical; /* logical offset in bytes for the start of
|
||||
* the extent from the beginning of the file */
|
||||
__u64 fe_physical; /* physical offset in bytes for the start
|
||||
* of the extent from the beginning of the disk */
|
||||
__u64 fe_length; /* length in bytes for this extent */
|
||||
__u64 fe_reserved64[2];
|
||||
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
|
||||
__u32 fe_reserved[3];
|
||||
};
|
||||
|
||||
struct fiemap {
|
||||
__u64 fm_start; /* logical offset (inclusive) at
|
||||
* which to start mapping (in) */
|
||||
__u64 fm_length; /* logical length of mapping which
|
||||
* userspace wants (in) */
|
||||
__u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */
|
||||
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
|
||||
__u32 fm_extent_count; /* size of fm_extents array (in) */
|
||||
__u32 fm_reserved;
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
|
||||
#if __GNUC_PREREQ (4, 8)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__linux__) && !defined(FS_IOC_FIEMAP)
|
||||
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(FS_IOC_GETSTATE)
|
||||
#define EXT4_IOC_GETSTATE _IOW('f', 41, __u32)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(EXT4_IOC_GET_ES_CACHE)
|
||||
#define EXT4_IOC_GET_ES_CACHE _IOWR('f', 42, struct fiemap)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(EXT4_STATE_FLAG_EXT_PRECACHED)
|
||||
#define EXT4_STATE_FLAG_EXT_PRECACHED 0x00000001
|
||||
#endif
|
||||
|
||||
#define FIEMAP_MAX_OFFSET (~0ULL)
|
||||
|
||||
#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
|
||||
#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
|
||||
#define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */
|
||||
|
||||
#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
|
||||
|
||||
#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
|
||||
#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
|
||||
#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
|
||||
* Sets EXTENT_UNKNOWN. */
|
||||
#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read
|
||||
* while fs is unmounted */
|
||||
#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs.
|
||||
* Sets EXTENT_NO_BYPASS. */
|
||||
#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be
|
||||
* block aligned. */
|
||||
#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata.
|
||||
* Sets EXTENT_NOT_ALIGNED.*/
|
||||
#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block.
|
||||
* Sets EXTENT_NOT_ALIGNED.*/
|
||||
#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
|
||||
* no data (i.e. zero). */
|
||||
#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
|
||||
* support extents. Result
|
||||
* merged for efficiency. */
|
||||
#define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other
|
||||
* files. */
|
||||
|
||||
#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 /* Entry in extent status
|
||||
cache for a hole*/
|
||||
|
||||
#endif /* _LINUX_FIEMAP_H */
|
||||
42
include/e2fsprogs/ext2fs/hashmap.h
Executable file
42
include/e2fsprogs/ext2fs/hashmap.h
Executable file
@@ -0,0 +1,42 @@
|
||||
#ifndef HASHMAP_H
|
||||
# define HASHMAP_H
|
||||
|
||||
# include <stdlib.h>
|
||||
# include <stdint.h>
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
#define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
#define __GNUC_PREREQ(maj, min) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct ext2fs_hashmap;
|
||||
|
||||
struct ext2fs_hashmap_entry {
|
||||
void *data;
|
||||
const void *key;
|
||||
size_t key_len;
|
||||
struct ext2fs_hashmap_entry *next;
|
||||
struct ext2fs_hashmap_entry *list_next;
|
||||
struct ext2fs_hashmap_entry *list_prev;
|
||||
};
|
||||
|
||||
struct ext2fs_hashmap *ext2fs_hashmap_create(
|
||||
uint32_t(*hash_fct)(const void*, size_t),
|
||||
void(*free_fct)(void*), size_t size);
|
||||
int ext2fs_hashmap_add(struct ext2fs_hashmap *h,
|
||||
void *data, const void *key,size_t key_len);
|
||||
void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key,
|
||||
size_t key_len);
|
||||
void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h,
|
||||
struct ext2fs_hashmap_entry **it);
|
||||
void ext2fs_hashmap_del(struct ext2fs_hashmap *h,
|
||||
struct ext2fs_hashmap_entry *e);
|
||||
void ext2fs_hashmap_free(struct ext2fs_hashmap *h);
|
||||
|
||||
uint32_t ext2fs_djb2_hash(const void *str, size_t size);
|
||||
|
||||
#endif /* !HASHMAP_H */
|
||||
114
include/e2fsprogs/ext2fs/irel.h
Executable file
114
include/e2fsprogs/ext2fs/irel.h
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* irel.h
|
||||
*
|
||||
* Copyright (C) 1996, 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Library
|
||||
* General Public License, version 2.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
struct ext2_inode_reference {
|
||||
blk64_t block;
|
||||
__u16 offset;
|
||||
};
|
||||
|
||||
struct ext2_inode_relocate_entry {
|
||||
ext2_ino_t new;
|
||||
ext2_ino_t orig;
|
||||
__u16 flags;
|
||||
__u16 max_refs;
|
||||
};
|
||||
|
||||
typedef struct ext2_inode_relocation_table *ext2_irel;
|
||||
|
||||
struct ext2_inode_relocation_table {
|
||||
__u32 magic;
|
||||
char *name;
|
||||
ext2_ino_t current;
|
||||
void *priv_data;
|
||||
|
||||
/*
|
||||
* Add an inode relocation entry.
|
||||
*/
|
||||
errcode_t (*put)(ext2_irel irel, ext2_ino_t old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
/*
|
||||
* Get an inode relocation entry.
|
||||
*/
|
||||
errcode_t (*get)(ext2_irel irel, ext2_ino_t old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Get an inode relocation entry by its original inode number
|
||||
*/
|
||||
errcode_t (*get_by_orig)(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Initialize for iterating over the inode relocation entries.
|
||||
*/
|
||||
errcode_t (*start_iter)(ext2_irel irel);
|
||||
|
||||
/*
|
||||
* The iterator function for the inode relocation entries.
|
||||
* Returns an inode number of 0 when out of entries.
|
||||
*/
|
||||
errcode_t (*next)(ext2_irel irel, ext2_ino_t *old,
|
||||
struct ext2_inode_relocate_entry *ent);
|
||||
|
||||
/*
|
||||
* Add an inode reference (i.e., note the fact that a
|
||||
* particular block/offset contains a reference to an inode)
|
||||
*/
|
||||
errcode_t (*add_ref)(ext2_irel irel, ext2_ino_t ino,
|
||||
struct ext2_inode_reference *ref);
|
||||
|
||||
/*
|
||||
* Initialize for iterating over the inode references for a
|
||||
* particular inode.
|
||||
*/
|
||||
errcode_t (*start_iter_ref)(ext2_irel irel, ext2_ino_t ino);
|
||||
|
||||
/*
|
||||
* The iterator function for the inode references for an
|
||||
* inode. The references for only one inode can be iterator
|
||||
* over at a time, as the iterator state is stored in ext2_irel.
|
||||
*/
|
||||
errcode_t (*next_ref)(ext2_irel irel,
|
||||
struct ext2_inode_reference *ref);
|
||||
|
||||
/*
|
||||
* Move the inode relocation table from one inode number to
|
||||
* another. Note that the inode references also must move.
|
||||
*/
|
||||
errcode_t (*move)(ext2_irel irel, ext2_ino_t old, ext2_ino_t new);
|
||||
|
||||
/*
|
||||
* Remove an inode relocation entry, along with all of the
|
||||
* inode references.
|
||||
*/
|
||||
errcode_t (*delete)(ext2_irel irel, ext2_ino_t old);
|
||||
|
||||
/*
|
||||
* Free the inode relocation table.
|
||||
*/
|
||||
errcode_t (*free)(ext2_irel irel);
|
||||
};
|
||||
|
||||
errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode,
|
||||
ext2_irel *irel);
|
||||
|
||||
#define ext2fs_irel_put(irel, old, ent) ((irel)->put((irel), old, ent))
|
||||
#define ext2fs_irel_get(irel, old, ent) ((irel)->get((irel), old, ent))
|
||||
#define ext2fs_irel_get_by_orig(irel, orig, old, ent) \
|
||||
((irel)->get_by_orig((irel), orig, old, ent))
|
||||
#define ext2fs_irel_start_iter(irel) ((irel)->start_iter((irel)))
|
||||
#define ext2fs_irel_next(irel, old, ent) ((irel)->next((irel), old, ent))
|
||||
#define ext2fs_irel_add_ref(irel, ino, ref) ((irel)->add_ref((irel), ino, ref))
|
||||
#define ext2fs_irel_start_iter_ref(irel, ino) ((irel)->start_iter_ref((irel), ino))
|
||||
#define ext2fs_irel_next_ref(irel, ref) ((irel)->next_ref((irel), ref))
|
||||
#define ext2fs_irel_move(irel, old, new) ((irel)->move((irel), old, new))
|
||||
#define ext2fs_irel_delete(irel, old) ((irel)->delete((irel), old))
|
||||
#define ext2fs_irel_free(irel) ((irel)->free((irel)))
|
||||
113
include/e2fsprogs/ext2fs/jfs_compat.h
Executable file
113
include/e2fsprogs/ext2fs/jfs_compat.h
Executable file
@@ -0,0 +1,113 @@
|
||||
|
||||
#ifndef _JFS_COMPAT_H
|
||||
#define _JFS_COMPAT_H
|
||||
|
||||
#include "kernel-list.h"
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <arpa/inet.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define printk printf
|
||||
#define KERN_ERR ""
|
||||
#define KERN_DEBUG ""
|
||||
|
||||
#define REQ_OP_READ 0
|
||||
#define REQ_OP_WRITE 1
|
||||
|
||||
#define cpu_to_le16(x) ext2fs_cpu_to_le16(x)
|
||||
#define cpu_to_be16(x) ext2fs_cpu_to_be16(x)
|
||||
#define cpu_to_le32(x) ext2fs_cpu_to_le32(x)
|
||||
#define cpu_to_be32(x) ext2fs_cpu_to_be32(x)
|
||||
#define cpu_to_le64(x) ext2fs_cpu_to_le64(x)
|
||||
#define cpu_to_be64(x) ext2fs_cpu_to_be64(x)
|
||||
|
||||
#define le16_to_cpu(x) ext2fs_le16_to_cpu(x)
|
||||
#define be16_to_cpu(x) ext2fs_be16_to_cpu(x)
|
||||
#define le32_to_cpu(x) ext2fs_le32_to_cpu(x)
|
||||
#define be32_to_cpu(x) ext2fs_be32_to_cpu(x)
|
||||
#define le64_to_cpu(x) ext2fs_le64_to_cpu(x)
|
||||
#define be64_to_cpu(x) ext2fs_be64_to_cpu(x)
|
||||
|
||||
typedef unsigned int tid_t;
|
||||
typedef struct journal_s journal_t;
|
||||
typedef struct kdev_s *kdev_t;
|
||||
|
||||
struct buffer_head;
|
||||
struct inode;
|
||||
|
||||
typedef unsigned int gfp_t;
|
||||
#define GFP_KERNEL 0
|
||||
#define GFP_NOFS 0
|
||||
#define __GFP_NOFAIL 0
|
||||
#define JBD2_TAG_SIZE32 JBD_TAG_SIZE32
|
||||
#define JBD2_BARRIER 0
|
||||
typedef __u64 u64;
|
||||
#define put_bh(x) brelse(x)
|
||||
|
||||
#define crc32_be(x, y, z) ext2fs_crc32_be((x), (y), (z))
|
||||
#define spin_lock_init(x)
|
||||
#define spin_lock(x)
|
||||
#define spin_unlock(x)
|
||||
#define SLAB_HWCACHE_ALIGN 0
|
||||
#define SLAB_TEMPORARY 0
|
||||
#define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\
|
||||
sizeof(struct __struct), __alignof__(struct __struct),\
|
||||
(__flags), NULL)
|
||||
|
||||
#define blkdev_issue_flush(kdev) sync_blockdev(kdev)
|
||||
#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
|
||||
#define pr_emerg(fmt)
|
||||
#define pr_err(...)
|
||||
|
||||
enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
|
||||
|
||||
#define JBD2_FC_REPLAY_STOP 0
|
||||
#define JBD2_FC_REPLAY_CONTINUE 1
|
||||
|
||||
struct journal_s
|
||||
{
|
||||
unsigned long j_flags;
|
||||
int j_errno;
|
||||
struct buffer_head * j_sb_buffer;
|
||||
struct journal_superblock_s *j_superblock;
|
||||
int j_format_version;
|
||||
unsigned long j_head;
|
||||
unsigned long j_tail;
|
||||
unsigned long j_fc_first;
|
||||
unsigned long j_fc_off;
|
||||
unsigned long j_fc_last;
|
||||
unsigned long j_free;
|
||||
unsigned long j_first, j_last;
|
||||
kdev_t j_dev;
|
||||
kdev_t j_fs_dev;
|
||||
int j_blocksize;
|
||||
unsigned int j_blk_offset;
|
||||
unsigned int j_total_len;
|
||||
struct inode * j_inode;
|
||||
tid_t j_tail_sequence;
|
||||
tid_t j_transaction_sequence;
|
||||
__u8 j_uuid[16];
|
||||
struct jbd2_revoke_table_s *j_revoke;
|
||||
struct jbd2_revoke_table_s *j_revoke_table[2];
|
||||
tid_t j_failed_commit;
|
||||
__u32 j_csum_seed;
|
||||
int (*j_fc_replay_callback)(struct journal_s *journal,
|
||||
struct buffer_head *bh,
|
||||
enum passtype pass, int off,
|
||||
tid_t expected_tid);
|
||||
|
||||
};
|
||||
|
||||
#define is_journal_abort(x) 0
|
||||
|
||||
#define BUFFER_TRACE(bh, info) do {} while (0)
|
||||
|
||||
/* Need this so we can compile with configure --enable-gcc-wall */
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
#endif /* _JFS_COMPAT_H */
|
||||
456
include/e2fsprogs/ext2fs/kernel-jbd.h
Executable file
456
include/e2fsprogs/ext2fs/kernel-jbd.h
Executable file
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* linux/include/linux/jbd.h
|
||||
*
|
||||
* Written by Stephen C. Tweedie <sct@redhat.com>
|
||||
*
|
||||
* Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
|
||||
*
|
||||
* This file is part of the Linux kernel and is made available under
|
||||
* the terms of the GNU General Public License, version 2, or at your
|
||||
* option, any later version, incorporated herein by reference.
|
||||
*
|
||||
* Definitions for transaction data structures for the buffer cache
|
||||
* filesystem journaling support.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_JBD_H
|
||||
#define _LINUX_JBD_H
|
||||
|
||||
#include "jfs_compat.h"
|
||||
#define JFS_DEBUG
|
||||
#define jfs_debug jbd_debug
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __FUNCTION__ ""
|
||||
#endif
|
||||
|
||||
#define journal_oom_retry 0
|
||||
|
||||
#ifdef CONFIG_JBD_DEBUG
|
||||
/*
|
||||
* Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
|
||||
* consistency checks. By default we don't do this unless
|
||||
* CONFIG_JBD_DEBUG is on.
|
||||
*/
|
||||
#define JBD_EXPENSIVE_CHECKING
|
||||
extern int journal_enable_debug;
|
||||
#else
|
||||
#define journal_enable_debug (-1)
|
||||
#endif /* !CONFIG_JBD_DEBUG */
|
||||
|
||||
#ifdef __STDC__
|
||||
#define jbd_debug(n, f, a...) \
|
||||
do { \
|
||||
if ((n) <= journal_enable_debug) { \
|
||||
printk (KERN_DEBUG "(%s, %d): %s: ", \
|
||||
__FILE__, __LINE__, __FUNCTION__); \
|
||||
printk (f, ## a); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define jbd_debug(x) /* AIX doesn't do STDC */
|
||||
#endif /* !__STDC__ */
|
||||
|
||||
extern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry);
|
||||
#define jbd_kmalloc(size, flags) \
|
||||
__jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
|
||||
#define jbd_rep_kmalloc(size, flags) \
|
||||
__jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
|
||||
|
||||
#define JBD2_MIN_JOURNAL_BLOCKS 1024
|
||||
#define JBD2_DEFAULT_FAST_COMMIT_BLOCKS 256
|
||||
|
||||
/*
|
||||
* Internal structures used by the logging mechanism:
|
||||
*/
|
||||
|
||||
#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
|
||||
|
||||
/*
|
||||
* On-disk structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Descriptor block types:
|
||||
*/
|
||||
|
||||
#define JBD2_DESCRIPTOR_BLOCK 1
|
||||
#define JBD2_COMMIT_BLOCK 2
|
||||
#define JBD2_SUPERBLOCK_V1 3
|
||||
#define JBD2_SUPERBLOCK_V2 4
|
||||
#define JBD2_REVOKE_BLOCK 5
|
||||
#define JBD2_FC_BLOCK 6
|
||||
|
||||
/*
|
||||
* Standard header for all descriptor blocks:
|
||||
*/
|
||||
typedef struct journal_header_s
|
||||
{
|
||||
__be32 h_magic;
|
||||
__be32 h_blocktype;
|
||||
__be32 h_sequence;
|
||||
} journal_header_t;
|
||||
|
||||
/*
|
||||
* Checksum types.
|
||||
*/
|
||||
#define JBD2_CRC32_CHKSUM 1
|
||||
#define JBD2_MD5_CHKSUM 2
|
||||
#define JBD2_SHA1_CHKSUM 3
|
||||
#define JBD2_CRC32C_CHKSUM 4
|
||||
|
||||
#define JBD2_CRC32_CHKSUM_SIZE 4
|
||||
|
||||
#define JBD2_CHECKSUM_BYTES (32 / sizeof(__u32))
|
||||
/*
|
||||
* Commit block header for storing transactional checksums:
|
||||
*
|
||||
* NOTE: If FEATURE_COMPAT_CHECKSUM (checksum v1) is set, the h_chksum*
|
||||
* fields are used to store a checksum of the descriptor and data blocks.
|
||||
*
|
||||
* If FEATURE_INCOMPAT_CSUM_V2 (checksum v2) is set, then the h_chksum
|
||||
* field is used to store crc32c(uuid+commit_block). Each journal metadata
|
||||
* block gets its own checksum, and data block checksums are stored in
|
||||
* journal_block_tag (in the descriptor). The other h_chksum* fields are
|
||||
* not used.
|
||||
*
|
||||
* If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
|
||||
* journal_block_tag3_t to store a full 32-bit checksum. Everything else
|
||||
* is the same as v2.
|
||||
*
|
||||
* Checksum v1, v2, and v3 are mutually exclusive features.
|
||||
*/
|
||||
struct commit_header {
|
||||
__be32 h_magic;
|
||||
__be32 h_blocktype;
|
||||
__be32 h_sequence;
|
||||
unsigned char h_chksum_type;
|
||||
unsigned char h_chksum_size;
|
||||
unsigned char h_padding[2];
|
||||
__be32 h_chksum[JBD2_CHECKSUM_BYTES];
|
||||
__be64 h_commit_sec;
|
||||
__be32 h_commit_nsec;
|
||||
};
|
||||
|
||||
/*
|
||||
* The block tag: used to describe a single buffer in the journal
|
||||
*/
|
||||
typedef struct journal_block_tag3_s
|
||||
{
|
||||
__be32 t_blocknr; /* The on-disk block number */
|
||||
__be32 t_flags; /* See below */
|
||||
__be32 t_blocknr_high; /* most-significant high 32bits. */
|
||||
__be32 t_checksum; /* crc32c(uuid+seq+block) */
|
||||
} journal_block_tag3_t;
|
||||
|
||||
typedef struct journal_block_tag_s
|
||||
{
|
||||
__be32 t_blocknr; /* The on-disk block number */
|
||||
__be16 t_checksum; /* truncated crc32c(uuid+seq+block) */
|
||||
__be16 t_flags; /* See below */
|
||||
__be32 t_blocknr_high; /* most-significant high 32bits. */
|
||||
} journal_block_tag_t;
|
||||
|
||||
/* Tail of descriptor or revoke block, for checksumming */
|
||||
struct jbd2_journal_block_tail {
|
||||
__be32 t_checksum;
|
||||
};
|
||||
|
||||
/*
|
||||
* The revoke descriptor: used on disk to describe a series of blocks to
|
||||
* be revoked from the log
|
||||
*/
|
||||
typedef struct journal_revoke_header_s
|
||||
{
|
||||
journal_header_t r_header;
|
||||
__be32 r_count; /* Count of bytes used in the block */
|
||||
} jbd2_journal_revoke_header_t;
|
||||
|
||||
/* Definitions for the journal tag flags word: */
|
||||
#define JBD2_FLAG_ESCAPE 1 /* on-disk block is escaped */
|
||||
#define JBD2_FLAG_SAME_UUID 2 /* block has same uuid as previous */
|
||||
#define JBD2_FLAG_DELETED 4 /* block deleted by this transaction */
|
||||
#define JBD2_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
|
||||
|
||||
|
||||
#define UUID_SIZE 16
|
||||
#define JBD2_USERS_MAX 48
|
||||
#define JBD2_USERS_SIZE (UUID_SIZE * JBD2_USERS_MAX)
|
||||
/*
|
||||
* The journal superblock. All fields are in big-endian byte order.
|
||||
*/
|
||||
typedef struct journal_superblock_s
|
||||
{
|
||||
/* 0x0000 */
|
||||
journal_header_t s_header;
|
||||
|
||||
/* 0x000C */
|
||||
/* Static information describing the journal */
|
||||
__be32 s_blocksize; /* journal device blocksize */
|
||||
__be32 s_maxlen; /* total blocks in journal file */
|
||||
__be32 s_first; /* first block of log information */
|
||||
|
||||
/* 0x0018 */
|
||||
/* Dynamic information describing the current state of the log */
|
||||
__be32 s_sequence; /* first commit ID expected in log */
|
||||
__be32 s_start; /* blocknr of start of log */
|
||||
|
||||
/* 0x0020 */
|
||||
/* Error value, as set by journal_abort(). */
|
||||
__s32 s_errno;
|
||||
|
||||
/* 0x0024 */
|
||||
/* Remaining fields are only valid in a version-2 superblock */
|
||||
__be32 s_feature_compat; /* compatible feature set */
|
||||
__be32 s_feature_incompat; /* incompatible feature set */
|
||||
__be32 s_feature_ro_compat; /* readonly-compatible feature set */
|
||||
/* 0x0030 */
|
||||
__u8 s_uuid[16]; /* 128-bit uuid for journal */
|
||||
|
||||
/* 0x0040 */
|
||||
__be32 s_nr_users; /* Nr of filesystems sharing log */
|
||||
|
||||
__be32 s_dynsuper; /* Blocknr of dynamic superblock copy*/
|
||||
|
||||
/* 0x0048 */
|
||||
__be32 s_max_transaction; /* Limit of journal blocks per trans.*/
|
||||
__be32 s_max_trans_data; /* Limit of data blocks per trans. */
|
||||
|
||||
/* 0x0050 */
|
||||
__u8 s_checksum_type; /* checksum type */
|
||||
__u8 s_padding2[3];
|
||||
/* 0x0054 */
|
||||
__be32 s_num_fc_blks; /* Number of fast commit blocks */
|
||||
/* 0x0058 */
|
||||
__be32 s_padding[41];
|
||||
__be32 s_checksum; /* crc32c(superblock) */
|
||||
|
||||
/* 0x0100 */
|
||||
__u8 s_users[JBD2_USERS_SIZE]; /* ids of all fs'es sharing the log */
|
||||
|
||||
/* 0x0400 */
|
||||
} journal_superblock_t;
|
||||
|
||||
#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_compat & ext2fs_cpu_to_be32((mask))))
|
||||
#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_ro_compat & ext2fs_cpu_to_be32((mask))))
|
||||
#define JBD2_HAS_INCOMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_incompat & ext2fs_cpu_to_be32((mask))))
|
||||
|
||||
#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
|
||||
#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
|
||||
#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
|
||||
#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
|
||||
#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
|
||||
#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020
|
||||
|
||||
/* Features known to this kernel version: */
|
||||
#define JBD2_KNOWN_COMPAT_FEATURES 0
|
||||
#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
|
||||
#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE|\
|
||||
JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT| \
|
||||
JBD2_FEATURE_INCOMPAT_64BIT|\
|
||||
JBD2_FEATURE_INCOMPAT_CSUM_V2| \
|
||||
JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
|
||||
JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
|
||||
|
||||
#ifdef NO_INLINE_FUNCS
|
||||
extern size_t journal_tag_bytes(journal_t *journal);
|
||||
extern int jbd2_journal_has_csum_v2or3(journal_t *journal);
|
||||
extern int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb);
|
||||
extern int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused));
|
||||
extern int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused));
|
||||
#endif
|
||||
|
||||
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||
#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ extern inline
|
||||
#else
|
||||
#define _INLINE_ inline
|
||||
#endif
|
||||
#else /* !E2FSCK_INCLUDE_INLINE FUNCS */
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define _INLINE_ inline
|
||||
#else /* not C99 */
|
||||
#ifdef __GNUC__
|
||||
#define _INLINE_ extern __inline__
|
||||
#else /* For Watcom C */
|
||||
#define _INLINE_ extern inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
#endif /* INCLUDE_INLINE_FUNCS */
|
||||
|
||||
/* journal feature predicate functions */
|
||||
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_compat & \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_compat |= \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
|
||||
} \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_compat &= \
|
||||
~ext2fs_cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_ro_compat & \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_ro_compat |= \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
|
||||
} \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_ro_compat &= \
|
||||
~ext2fs_cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j); \
|
||||
_INLINE_ int jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_incompat & \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_incompat |= \
|
||||
ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
|
||||
} \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j); \
|
||||
_INLINE_ void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_incompat &= \
|
||||
~ext2fs_cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#else
|
||||
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
|
||||
extern int jbd2_has_feature_##name(journal_t *j); \
|
||||
extern void jbd2_set_feature_##name(journal_t *j); \
|
||||
extern void jbd2_clear_feature_##name(journal_t *j);
|
||||
|
||||
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
|
||||
extern int jbd2_has_feature_##name(journal_t *j); \
|
||||
extern void jbd2_set_feature_##name(journal_t *j); \
|
||||
extern void jbd2_clear_feature_##name(journal_t *j);
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
|
||||
extern int jbd2_has_feature_##name(journal_t *j); \
|
||||
extern void jbd2_set_feature_##name(journal_t *j); \
|
||||
extern void jbd2_clear_feature_##name(journal_t *j);
|
||||
|
||||
#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */
|
||||
|
||||
JBD2_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
|
||||
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
|
||||
|
||||
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
|
||||
/*
|
||||
* helper functions to deal with 32 or 64bit block numbers.
|
||||
*/
|
||||
_INLINE_ size_t journal_tag_bytes(journal_t *journal)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (jbd2_has_feature_csum3(journal))
|
||||
return sizeof(journal_block_tag3_t);
|
||||
|
||||
sz = sizeof(journal_block_tag_t);
|
||||
|
||||
if (jbd2_has_feature_csum2(journal))
|
||||
sz += sizeof(__u16);
|
||||
|
||||
if (jbd2_has_feature_64bit(journal))
|
||||
return sz;
|
||||
|
||||
return sz - sizeof(__u32);
|
||||
}
|
||||
|
||||
_INLINE_ int jbd2_journal_has_csum_v2or3(journal_t *journal)
|
||||
{
|
||||
if (jbd2_has_feature_csum2(journal) || jbd2_has_feature_csum3(journal))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_INLINE_ int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb)
|
||||
{
|
||||
int num_fc_blocks = be32_to_cpu(jsb->s_num_fc_blks);
|
||||
|
||||
return num_fc_blocks ? num_fc_blocks : JBD2_DEFAULT_FAST_COMMIT_BLOCKS;
|
||||
}
|
||||
|
||||
/* Comparison functions for transaction IDs: perform comparisons using
|
||||
* modulo arithmetic so that they work over sequence number wraps. */
|
||||
|
||||
_INLINE_ int tid_gt(tid_t x, tid_t y)
|
||||
{
|
||||
int difference = (x - y);
|
||||
return (difference > 0);
|
||||
}
|
||||
|
||||
_INLINE_ int tid_geq(tid_t x, tid_t y)
|
||||
{
|
||||
int difference = (x - y);
|
||||
return (difference >= 0);
|
||||
}
|
||||
#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */
|
||||
|
||||
#undef _INLINE_
|
||||
|
||||
extern int journal_blocks_per_page(struct inode *inode);
|
||||
|
||||
/*
|
||||
* Definitions which augment the buffer_head layer
|
||||
*/
|
||||
|
||||
/* journaling buffer types */
|
||||
#define BJ_None 0 /* Not journaled */
|
||||
#define BJ_SyncData 1 /* Normal data: flush before commit */
|
||||
#define BJ_AsyncData 2 /* writepage data: wait on it before commit */
|
||||
#define BJ_Metadata 3 /* Normal journaled metadata */
|
||||
#define BJ_Forget 4 /* Buffer superseded by this transaction */
|
||||
#define BJ_IO 5 /* Buffer is for temporary IO use */
|
||||
#define BJ_Shadow 6 /* Buffer contents being shadowed to the log */
|
||||
#define BJ_LogCtl 7 /* Buffer contains log descriptors */
|
||||
#define BJ_Reserved 8 /* Buffer is reserved for access by journal */
|
||||
#define BJ_Types 9
|
||||
|
||||
extern int jbd_blocks_per_page(struct inode *inode);
|
||||
|
||||
#endif /* _LINUX_JBD_H */
|
||||
111
include/e2fsprogs/ext2fs/kernel-list.h
Executable file
111
include/e2fsprogs/ext2fs/kernel-list.h
Executable file
@@ -0,0 +1,111 @@
|
||||
#ifndef _LINUX_LIST_H
|
||||
#define _LINUX_LIST_H
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
#if (!defined(__GNUC__) && !defined(__WATCOMC__))
|
||||
#define __inline__
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static __inline__ void __list_add(struct list_head * new,
|
||||
struct list_head * prev,
|
||||
struct list_head * next)
|
||||
{
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new entry after the specified head..
|
||||
*/
|
||||
static __inline__ void list_add(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head, head->next);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new entry at the tail
|
||||
*/
|
||||
static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static __inline__ void __list_del(struct list_head * prev,
|
||||
struct list_head * next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
static __inline__ void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
}
|
||||
|
||||
static __inline__ int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Splice in "list" into "head"
|
||||
*/
|
||||
static __inline__ void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
|
||||
if (first != list) {
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
}
|
||||
|
||||
#define list_entry(ptr, type, member) \
|
||||
container_of(ptr, type, member)
|
||||
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
#endif
|
||||
114
include/e2fsprogs/ext2fs/qcow2.h
Executable file
114
include/e2fsprogs/ext2fs/qcow2.h
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* qcow2.h --- structures and function prototypes for qcow2.c to generate
|
||||
* qcow2 formatted disk images. This format is used originally by QEMU
|
||||
* for virtual machines, and stores the filesystem data on disk in a
|
||||
* packed format to avoid creating sparse image files that need lots of
|
||||
* seeking to read and write.
|
||||
*
|
||||
* The qcow2 format supports zlib compression, but that is not yet
|
||||
* implemented.
|
||||
*
|
||||
* It is possible to directly mount a qcow2 image using qemu-nbd:
|
||||
*
|
||||
* [root]# modprobe nbd max_part=63
|
||||
* [root]# qemu-nbd -c /dev/nbd0 image.img
|
||||
* [root]# mount /dev/nbd0p1 /mnt/qemu
|
||||
*
|
||||
* Format details at http://people.gnome.org/~markmc/qcow-image-format.html
|
||||
*
|
||||
* Copyright (C) 2010 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
/* Number of l2 tables in memory before writeback */
|
||||
#define L2_CACHE_PREALLOC 512
|
||||
|
||||
|
||||
#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
|
||||
#define QCOW_VERSION 2
|
||||
#define QCOW_OFLAG_COPIED (1ULL << 63)
|
||||
#define QCOW_OFLAG_COMPRESSED (1ULL << 62)
|
||||
|
||||
#define QCOW_COMPRESSED 1
|
||||
#define QCOW_ENCRYPTED 2
|
||||
#define QCOW_CORRUPTED 3
|
||||
|
||||
struct ext2_qcow2_hdr {
|
||||
__u32 magic;
|
||||
__u32 version;
|
||||
|
||||
__u64 backing_file_offset;
|
||||
__u32 backing_file_size;
|
||||
|
||||
__u32 cluster_bits;
|
||||
__u64 size;
|
||||
__u32 crypt_method;
|
||||
|
||||
__u32 l1_size;
|
||||
__u64 l1_table_offset;
|
||||
|
||||
__u64 refcount_table_offset;
|
||||
__u32 refcount_table_clusters;
|
||||
|
||||
__u32 nb_snapshots;
|
||||
__u64 snapshots_offset;
|
||||
};
|
||||
|
||||
typedef struct ext2_qcow2_l2_table L2_CACHE_HEAD;
|
||||
|
||||
struct ext2_qcow2_l2_table {
|
||||
__u32 l1_index;
|
||||
__u64 offset;
|
||||
__u64 *data;
|
||||
L2_CACHE_HEAD *next;
|
||||
};
|
||||
|
||||
struct ext2_qcow2_l2_cache {
|
||||
L2_CACHE_HEAD *used_head;
|
||||
L2_CACHE_HEAD *used_tail;
|
||||
L2_CACHE_HEAD *free_head;
|
||||
__u32 free;
|
||||
__u32 count;
|
||||
__u64 next_offset;
|
||||
};
|
||||
|
||||
struct ext2_qcow2_refcount {
|
||||
__u64 *refcount_table;
|
||||
__u64 refcount_table_offset;
|
||||
__u64 refcount_block_offset;
|
||||
|
||||
__u32 refcount_table_clusters;
|
||||
__u32 refcount_table_index;
|
||||
__u32 refcount_block_index;
|
||||
|
||||
__u16 *refcount_block;
|
||||
};
|
||||
|
||||
struct ext2_qcow2_image {
|
||||
int fd;
|
||||
struct ext2_qcow2_hdr *hdr;
|
||||
struct ext2_qcow2_l2_cache *l2_cache;
|
||||
struct ext2_qcow2_refcount refcount;
|
||||
__u32 cluster_size;
|
||||
__u32 cluster_bits;
|
||||
__u32 l1_size;
|
||||
__u32 l2_size;
|
||||
|
||||
__u64 *l1_table;
|
||||
__u64 l2_offset;
|
||||
__u64 l1_offset;
|
||||
__u64 image_size;
|
||||
};
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/* qcow2.c */
|
||||
|
||||
/* Functions for converting qcow2 image into raw image */
|
||||
struct ext2_qcow2_hdr *qcow2_read_header(int);
|
||||
int qcow2_write_raw_image(int, int, struct ext2_qcow2_hdr *);
|
||||
|
||||
183
include/e2fsprogs/ext2fs/rbtree.h
Executable file
183
include/e2fsprogs/ext2fs/rbtree.h
Executable file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
Red Black Trees
|
||||
(C) 1999 Andrea Arcangeli <andrea@suse.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
linux/include/linux/rbtree.h
|
||||
|
||||
To use rbtrees you'll have to implement your own insert and search cores.
|
||||
This will avoid us to use callbacks and to drop dramatically performances.
|
||||
I know it's not the cleaner way, but in C (not in C++) to get
|
||||
performances and genericity...
|
||||
|
||||
Some example of insert and search follows here. The search is a plain
|
||||
normal search over an ordered tree. The insert instead must be implemented
|
||||
in two steps: First, the code must insert the element in order as a red leaf
|
||||
in the tree, and then the support library function rb_insert_color() must
|
||||
be called. Such function will do the not trivial work to rebalance the
|
||||
rbtree, if necessary.
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
static inline struct page * rb_search_page_cache(struct inode * inode,
|
||||
unsigned long offset)
|
||||
{
|
||||
struct rb_node * n = inode->i_rb_page_cache.rb_node;
|
||||
struct page * page;
|
||||
|
||||
while (n)
|
||||
{
|
||||
page = rb_entry(n, struct page, rb_page_cache);
|
||||
|
||||
if (offset < page->offset)
|
||||
n = n->rb_left;
|
||||
else if (offset > page->offset)
|
||||
n = n->rb_right;
|
||||
else
|
||||
return page;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct page * __rb_insert_page_cache(struct inode * inode,
|
||||
unsigned long offset,
|
||||
struct rb_node * node)
|
||||
{
|
||||
struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
|
||||
struct rb_node * parent = NULL;
|
||||
struct page * page;
|
||||
|
||||
while (*p)
|
||||
{
|
||||
parent = *p;
|
||||
page = rb_entry(parent, struct page, rb_page_cache);
|
||||
|
||||
if (offset < page->offset)
|
||||
p = &(*p)->rb_left;
|
||||
else if (offset > page->offset)
|
||||
p = &(*p)->rb_right;
|
||||
else
|
||||
return page;
|
||||
}
|
||||
|
||||
rb_link_node(node, parent, p);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct page * rb_insert_page_cache(struct inode * inode,
|
||||
unsigned long offset,
|
||||
struct rb_node * node)
|
||||
{
|
||||
struct page * ret;
|
||||
if ((ret = __rb_insert_page_cache(inode, offset, node)))
|
||||
goto out;
|
||||
rb_insert_color(node, &inode->i_rb_page_cache);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RBTREE_H
|
||||
#define _LINUX_RBTREE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "compiler.h"
|
||||
|
||||
#if __GNUC_PREREQ (4, 6)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
struct rb_node
|
||||
{
|
||||
uintptr_t rb_parent_color;
|
||||
#define RB_RED 0
|
||||
#define RB_BLACK 1
|
||||
struct rb_node *rb_right;
|
||||
struct rb_node *rb_left;
|
||||
} __attribute__((aligned(sizeof(long))));
|
||||
/* The alignment might seem pointless, but allegedly CRIS needs it */
|
||||
|
||||
struct rb_root
|
||||
{
|
||||
struct rb_node *rb_node;
|
||||
};
|
||||
|
||||
|
||||
#define ext2fs_rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
|
||||
#define ext2fs_rb_color(r) ((r)->rb_parent_color & 1)
|
||||
#define ext2fs_rb_is_red(r) (!ext2fs_rb_color(r))
|
||||
#define ext2fs_rb_is_black(r) ext2fs_rb_color(r)
|
||||
#define ext2fs_rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
|
||||
#define ext2fs_rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
|
||||
|
||||
static inline void ext2fs_rb_set_parent(struct rb_node *rb, struct rb_node *p)
|
||||
{
|
||||
rb->rb_parent_color = (rb->rb_parent_color & 3) | (uintptr_t)p;
|
||||
}
|
||||
static inline void ext2fs_rb_set_color(struct rb_node *rb, int color)
|
||||
{
|
||||
rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
|
||||
}
|
||||
|
||||
#define RB_ROOT (struct rb_root) { NULL, }
|
||||
#define ext2fs_rb_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
|
||||
static inline int ext2fs_rb_empty_root(struct rb_root *root)
|
||||
{
|
||||
return root->rb_node == NULL;
|
||||
}
|
||||
|
||||
static inline int ext2fs_rb_empty_node(struct rb_node *node)
|
||||
{
|
||||
return ext2fs_rb_parent(node) == node;
|
||||
}
|
||||
|
||||
static inline void ext2fs_rb_clear_node(struct rb_node *node)
|
||||
{
|
||||
ext2fs_rb_set_parent(node, node);
|
||||
}
|
||||
|
||||
extern void ext2fs_rb_insert_color(struct rb_node *, struct rb_root *);
|
||||
extern void ext2fs_rb_erase(struct rb_node *, struct rb_root *);
|
||||
|
||||
/* Find logical next and previous nodes in a tree */
|
||||
extern struct rb_node *ext2fs_rb_next(struct rb_node *);
|
||||
extern struct rb_node *ext2fs_rb_prev(struct rb_node *);
|
||||
extern struct rb_node *ext2fs_rb_first(const struct rb_root *);
|
||||
extern struct rb_node *ext2fs_rb_last(const struct rb_root *);
|
||||
|
||||
/* Fast replacement of a single node without remove/rebalance/add/rebalance */
|
||||
extern void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new,
|
||||
struct rb_root *root);
|
||||
|
||||
static inline void ext2fs_rb_link_node(struct rb_node * node,
|
||||
struct rb_node * parent,
|
||||
struct rb_node ** rb_link)
|
||||
{
|
||||
node->rb_parent_color = (uintptr_t)parent;
|
||||
node->rb_left = node->rb_right = NULL;
|
||||
|
||||
*rb_link = node;
|
||||
}
|
||||
|
||||
#if __GNUC_PREREQ (4, 6)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_RBTREE_H */
|
||||
215
include/e2fsprogs/ext2fs/tdb.h
Executable file
215
include/e2fsprogs/ext2fs/tdb.h
Executable file
@@ -0,0 +1,215 @@
|
||||
#ifndef __TDB_H__
|
||||
#define __TDB_H__
|
||||
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
trivial database library
|
||||
|
||||
Copyright (C) Andrew Tridgell 1999-2004
|
||||
|
||||
** NOTE! The following LGPL license applies to the tdb
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* flags to tdb_store() */
|
||||
#define TDB_REPLACE 1
|
||||
#define TDB_INSERT 2
|
||||
#define TDB_MODIFY 3
|
||||
|
||||
/* flags for tdb_open() */
|
||||
#define TDB_DEFAULT 0 /* just a readability place holder */
|
||||
#define TDB_CLEAR_IF_FIRST 1
|
||||
#define TDB_INTERNAL 2 /* don't store on disk */
|
||||
#define TDB_NOLOCK 4 /* don't do any locking */
|
||||
#define TDB_NOMMAP 8 /* don't use mmap */
|
||||
#define TDB_CONVERT 16 /* convert endian (internal use) */
|
||||
#define TDB_BIGENDIAN 32 /* header is big-endian (internal use) */
|
||||
#define TDB_NOSYNC 64 /* don't use synchronous transactions */
|
||||
#define TDB_SEQNUM 128 /* maintain a sequence number */
|
||||
|
||||
#define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
|
||||
|
||||
/* error codes */
|
||||
enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK,
|
||||
TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
|
||||
TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
|
||||
|
||||
/* debugging uses one of the following levels */
|
||||
enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR,
|
||||
TDB_DEBUG_WARNING, TDB_DEBUG_TRACE};
|
||||
|
||||
typedef struct TDB_DATA {
|
||||
unsigned char *dptr;
|
||||
size_t dsize;
|
||||
} TDB_DATA;
|
||||
|
||||
#ifndef PRINTF_ATTRIBUTE
|
||||
#if (__GNUC__ >= 3)
|
||||
/** Use gcc attribute to check printf fns. a1 is the 1-based index of
|
||||
* the parameter containing the format, and a2 the index of the first
|
||||
* argument. Note that some gcc 2.x versions don't handle this
|
||||
* properly **/
|
||||
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
|
||||
#else
|
||||
#define PRINTF_ATTRIBUTE(a1, a2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ext2fs tdb renames */
|
||||
#define tdb_open ext2fs_tdb_open
|
||||
#define tdb_open_ex ext2fs_tdb_open_ex
|
||||
#define tdb_set_max_dead ext2fs_tdb_set_max_dead
|
||||
#define tdb_reopen ext2fs_tdb_reopen
|
||||
#define tdb_reopen_all ext2fs_tdb_reopen_all
|
||||
#define tdb_set_logging_function ext2fs_tdb_set_logging_function
|
||||
#define tdb_error ext2fs_tdb_error
|
||||
#define tdb_errorstr ext2fs_tdb_errorstr
|
||||
#define tdb_fetch ext2fs_tdb_fetch
|
||||
#define tdb_parse_record ext2fs_tdb_parse_record
|
||||
#define tdb_delete ext2fs_tdb_delete
|
||||
#define tdb_store ext2fs_tdb_store
|
||||
#define tdb_append ext2fs_tdb_append
|
||||
#define tdb_close ext2fs_tdb_close
|
||||
#define tdb_firstkey ext2fs_tdb_firstkey
|
||||
#define tdb_nextkey ext2fs_tdb_nextkey
|
||||
#define tdb_traverse ext2fs_tdb_traverse
|
||||
#define tdb_traverse_read ext2fs_tdb_traverse_read
|
||||
#define tdb_exists ext2fs_tdb_exists
|
||||
#define tdb_lockall ext2fs_tdb_lockall
|
||||
#define tdb_unlockall ext2fs_tdb_unlockall
|
||||
#define tdb_lockall_read ext2fs_tdb_lockall_read
|
||||
#define tdb_unlockall_read ext2fs_tdb_unlockall_read
|
||||
#define tdb_name ext2fs_tdb_name
|
||||
#define tdb_fd ext2fs_tdb_fd
|
||||
#define tdb_log_fn ext2fs_tdb_log_fn
|
||||
#define tdb_get_logging_private ext2fs_tdb_get_logging_private
|
||||
#define tdb_transaction_start ext2fs_tdb_transaction_start
|
||||
#define tdb_transaction_commit ext2fs_tdb_transaction_commit
|
||||
#define tdb_transaction_cancel ext2fs_tdb_transaction_cancel
|
||||
#define tdb_transaction_recover ext2fs_tdb_transaction_recover
|
||||
#define tdb_get_seqnum ext2fs_tdb_get_seqnum
|
||||
#define tdb_hash_size ext2fs_tdb_hash_size
|
||||
#define tdb_map_size ext2fs_tdb_map_size
|
||||
#define tdb_get_flags ext2fs_tdb_get_flags
|
||||
#define tdb_chainlock ext2fs_tdb_chainlock
|
||||
#define tdb_chainunlock ext2fs_tdb_chainunlock
|
||||
#define tdb_chainlock_read ext2fs_tdb_chainlock_read
|
||||
#define tdb_chainunlock_read ext2fs_tdb_chainunlock_read
|
||||
#define tdb_dump_all ext2fs_tdb_dump_all
|
||||
#define tdb_printfreelist ext2fs_tdb_printfreelist
|
||||
#define tdb_validate_freelist ext2fs_tdb_validate_freelist
|
||||
#define tdb_chainlock_mark ext2fs_tdb_chainlock_mark
|
||||
#define tdb_chainlock_nonblock ext2fs_tdb_chainlock_nonblock
|
||||
#define tdb_chainlock_unmark ext2fs_tdb_chainlock_unmark
|
||||
#define tdb_enable_seqnum ext2fs_tdb_enable_seqnum
|
||||
#define tdb_increment_seqnum_nonblock ext2fs_tdb_increment_seqnum_nonblock
|
||||
#define tdb_lock_nonblock ext2fs_tdb_lock_nonblock
|
||||
#define tdb_lockall_mark ext2fs_tdb_lockall_mark
|
||||
#define tdb_lockall_nonblock ext2fs_tdb_lockall_nonblock
|
||||
#define tdb_lockall_read_nonblock ext2fs_tdb_lockall_read_nonblock
|
||||
#define tdb_lockall_unmark ext2fs_tdb_lockall_unmark
|
||||
#define tdb_flush ext2fs_tdb_flush
|
||||
|
||||
/* this is the context structure that is returned from a db open */
|
||||
typedef struct tdb_context TDB_CONTEXT;
|
||||
|
||||
typedef int (*tdb_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void *);
|
||||
typedef void (*tdb_log_func)(struct tdb_context *, enum tdb_debug_level, const char *, ...) PRINTF_ATTRIBUTE(3, 4);
|
||||
typedef unsigned int (*tdb_hash_func)(TDB_DATA *key);
|
||||
|
||||
struct tdb_logging_context {
|
||||
tdb_log_func log_fn;
|
||||
void *log_private;
|
||||
};
|
||||
|
||||
struct tdb_context *tdb_open(const char *name, int hash_size, int tdb_flags,
|
||||
int open_flags, mode_t mode);
|
||||
struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
|
||||
int open_flags, mode_t mode,
|
||||
const struct tdb_logging_context *log_ctx,
|
||||
tdb_hash_func hash_fn);
|
||||
void tdb_set_max_dead(struct tdb_context *tdb, int max_dead);
|
||||
|
||||
int tdb_reopen(struct tdb_context *tdb);
|
||||
int tdb_reopen_all(int parent_longlived);
|
||||
void tdb_set_logging_function(struct tdb_context *tdb, const struct tdb_logging_context *log_ctx);
|
||||
enum TDB_ERROR tdb_error(struct tdb_context *tdb);
|
||||
const char *tdb_errorstr(struct tdb_context *tdb);
|
||||
TDB_DATA tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key,
|
||||
int (*parser)(TDB_DATA key, TDB_DATA data,
|
||||
void *private_data),
|
||||
void *private_data);
|
||||
int tdb_delete(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
|
||||
int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
|
||||
int tdb_close(struct tdb_context *tdb);
|
||||
TDB_DATA tdb_firstkey(struct tdb_context *tdb);
|
||||
TDB_DATA tdb_nextkey(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *);
|
||||
int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *);
|
||||
int tdb_exists(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_lockall(struct tdb_context *tdb);
|
||||
int tdb_lockall_nonblock(struct tdb_context *tdb);
|
||||
int tdb_unlockall(struct tdb_context *tdb);
|
||||
int tdb_lockall_read(struct tdb_context *tdb);
|
||||
int tdb_lockall_read_nonblock(struct tdb_context *tdb);
|
||||
int tdb_unlockall_read(struct tdb_context *tdb);
|
||||
int tdb_lockall_mark(struct tdb_context *tdb);
|
||||
int tdb_lockall_unmark(struct tdb_context *tdb);
|
||||
const char *tdb_name(struct tdb_context *tdb);
|
||||
int tdb_fd(struct tdb_context *tdb);
|
||||
tdb_log_func tdb_log_fn(struct tdb_context *tdb);
|
||||
void *tdb_get_logging_private(struct tdb_context *tdb);
|
||||
int tdb_transaction_start(struct tdb_context *tdb);
|
||||
int tdb_transaction_commit(struct tdb_context *tdb);
|
||||
int tdb_transaction_cancel(struct tdb_context *tdb);
|
||||
int tdb_transaction_recover(struct tdb_context *tdb);
|
||||
int tdb_get_seqnum(struct tdb_context *tdb);
|
||||
int tdb_hash_size(struct tdb_context *tdb);
|
||||
size_t tdb_map_size(struct tdb_context *tdb);
|
||||
int tdb_get_flags(struct tdb_context *tdb);
|
||||
void tdb_enable_seqnum(struct tdb_context *tdb);
|
||||
void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
|
||||
int tdb_flush(struct tdb_context *tdb);
|
||||
|
||||
/* Low level locking functions: use with care */
|
||||
int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key);
|
||||
int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);
|
||||
|
||||
/* Debug functions. Not used in production. */
|
||||
void tdb_dump_all(struct tdb_context *tdb);
|
||||
int tdb_printfreelist(struct tdb_context *tdb);
|
||||
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* tdb.h */
|
||||
4109
include/e2fsprogs/ext2fs/utf8data.h
Executable file
4109
include/e2fsprogs/ext2fs/utf8data.h
Executable file
File diff suppressed because it is too large
Load Diff
120
include/e2fsprogs/ext2fs/utf8n.h
Executable file
120
include/e2fsprogs/ext2fs/utf8n.h
Executable file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2014 SGI.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* This code is copied from the linux kernel. We have a userspace
|
||||
* version here to such that hashes will match that implementation.
|
||||
*/
|
||||
|
||||
#ifndef UTF8NORM_H
|
||||
#define UTF8NORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Encoding a unicode version number as a single unsigned int. */
|
||||
#define UNICODE_MAJ_SHIFT (16)
|
||||
#define UNICODE_MIN_SHIFT (8)
|
||||
|
||||
#define UNICODE_AGE(MAJ, MIN, REV) \
|
||||
(((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \
|
||||
((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \
|
||||
((unsigned int)(REV)))
|
||||
|
||||
/* Highest unicode version supported by the data tables. */
|
||||
extern int utf8version_is_supported(uint8_t maj, uint8_t min, uint8_t rev);
|
||||
extern int utf8version_latest(void);
|
||||
|
||||
/*
|
||||
* Look for the correct const struct utf8data for a unicode version.
|
||||
* Returns NULL if the version requested is too new.
|
||||
*
|
||||
* Two normalization forms are supported: nfdi and nfdicf.
|
||||
*
|
||||
* nfdi:
|
||||
* - Apply unicode normalization form NFD.
|
||||
* - Remove any Default_Ignorable_Code_Point.
|
||||
*
|
||||
* nfdicf:
|
||||
* - Apply unicode normalization form NFD.
|
||||
* - Remove any Default_Ignorable_Code_Point.
|
||||
* - Apply a full casefold (C + F).
|
||||
*/
|
||||
extern const struct utf8data *utf8nfdi(unsigned int maxage);
|
||||
extern const struct utf8data *utf8nfdicf(unsigned int maxage);
|
||||
|
||||
/*
|
||||
* Determine the maximum age of any unicode character in the string.
|
||||
* Returns 0 if only unassigned code points are present.
|
||||
* Returns -1 if the input is not valid UTF-8.
|
||||
*/
|
||||
extern int utf8agemax(const struct utf8data *data, const char *s);
|
||||
extern int utf8nagemax(const struct utf8data *data, const char *s, size_t len);
|
||||
|
||||
/*
|
||||
* Determine the minimum age of any unicode character in the string.
|
||||
* Returns 0 if any unassigned code points are present.
|
||||
* Returns -1 if the input is not valid UTF-8.
|
||||
*/
|
||||
extern int utf8agemin(const struct utf8data *data, const char *s);
|
||||
extern int utf8nagemin(const struct utf8data *data, const char *s, size_t len);
|
||||
|
||||
/*
|
||||
* Determine the length of the normalized from of the string,
|
||||
* excluding any terminating NULL byte.
|
||||
* Returns 0 if only ignorable code points are present.
|
||||
* Returns -1 if the input is not valid UTF-8.
|
||||
*/
|
||||
extern ssize_t utf8len(const struct utf8data *data, const char *s);
|
||||
extern ssize_t utf8nlen(const struct utf8data *data, const char *s, size_t len);
|
||||
|
||||
/* Needed in struct utf8cursor below. */
|
||||
#define UTF8HANGULLEAF (12)
|
||||
|
||||
/*
|
||||
* Cursor structure used by the normalizer.
|
||||
*/
|
||||
struct utf8cursor {
|
||||
const struct utf8data *data;
|
||||
const char *s;
|
||||
const char *p;
|
||||
const char *ss;
|
||||
const char *sp;
|
||||
unsigned int len;
|
||||
unsigned int slen;
|
||||
short int ccc;
|
||||
short int nccc;
|
||||
unsigned char hangul[UTF8HANGULLEAF];
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize a utf8cursor to normalize a string.
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
extern int utf8cursor(struct utf8cursor *u8c, const struct utf8data *data,
|
||||
const char *s);
|
||||
extern int utf8ncursor(struct utf8cursor *u8c, const struct utf8data *data,
|
||||
const char *s, size_t len);
|
||||
|
||||
/*
|
||||
* Get the next byte in the normalization.
|
||||
* Returns a value > 0 && < 256 on success.
|
||||
* Returns 0 when the end of the normalization is reached.
|
||||
* Returns -1 if the string being normalized is not valid UTF-8.
|
||||
*/
|
||||
extern int utf8byte(struct utf8cursor *u8c);
|
||||
|
||||
#endif /* UTF8NORM_H */
|
||||
166
include/e2fsprogs/magic.h
Executable file
166
include/e2fsprogs/magic.h
Executable file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice immediately at the beginning of the file, without modification,
|
||||
* this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _MAGIC_H
|
||||
#define _MAGIC_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAGIC_NONE 0x0000000 /* No flags */
|
||||
#define MAGIC_DEBUG 0x0000001 /* Turn on debugging */
|
||||
#define MAGIC_SYMLINK 0x0000002 /* Follow symlinks */
|
||||
#define MAGIC_COMPRESS 0x0000004 /* Check inside compressed files */
|
||||
#define MAGIC_DEVICES 0x0000008 /* Look at the contents of devices */
|
||||
#define MAGIC_MIME_TYPE 0x0000010 /* Return the MIME type */
|
||||
#define MAGIC_CONTINUE 0x0000020 /* Return all matches */
|
||||
#define MAGIC_CHECK 0x0000040 /* Print warnings to stderr */
|
||||
#define MAGIC_PRESERVE_ATIME 0x0000080 /* Restore access time on exit */
|
||||
#define MAGIC_RAW 0x0000100 /* Don't convert unprintable chars */
|
||||
#define MAGIC_ERROR 0x0000200 /* Handle ENOENT etc as real errors */
|
||||
#define MAGIC_MIME_ENCODING 0x0000400 /* Return the MIME encoding */
|
||||
#define MAGIC_MIME (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)
|
||||
#define MAGIC_APPLE 0x0000800 /* Return the Apple creator/type */
|
||||
#define MAGIC_EXTENSION 0x1000000 /* Return a /-separated list of
|
||||
* extensions */
|
||||
#define MAGIC_COMPRESS_TRANSP 0x2000000 /* Check inside compressed files
|
||||
* but not report compression */
|
||||
#define MAGIC_NO_COMPRESS_FORK 0x4000000 /* Don't allow decompression that
|
||||
* needs to fork */
|
||||
#define MAGIC_NODESC (MAGIC_EXTENSION|MAGIC_MIME|MAGIC_APPLE)
|
||||
|
||||
#define MAGIC_NO_CHECK_COMPRESS 0x0001000 /* Don't check for compressed files */
|
||||
#define MAGIC_NO_CHECK_TAR 0x0002000 /* Don't check for tar files */
|
||||
#define MAGIC_NO_CHECK_SOFT 0x0004000 /* Don't check magic entries */
|
||||
#define MAGIC_NO_CHECK_APPTYPE 0x0008000 /* Don't check application type */
|
||||
#define MAGIC_NO_CHECK_ELF 0x0010000 /* Don't check for elf details */
|
||||
#define MAGIC_NO_CHECK_TEXT 0x0020000 /* Don't check for text files */
|
||||
#define MAGIC_NO_CHECK_CDF 0x0040000 /* Don't check for cdf files */
|
||||
#define MAGIC_NO_CHECK_CSV 0x0080000 /* Don't check for CSV files */
|
||||
#define MAGIC_NO_CHECK_TOKENS 0x0100000 /* Don't check tokens */
|
||||
#define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */
|
||||
#define MAGIC_NO_CHECK_JSON 0x0400000 /* Don't check for JSON files */
|
||||
#define MAGIC_NO_CHECK_SIMH 0x0800000 /* Don't check for SIMH tape files */
|
||||
|
||||
/* No built-in tests; only consult the magic file */
|
||||
#define MAGIC_NO_CHECK_BUILTIN ( \
|
||||
MAGIC_NO_CHECK_COMPRESS | \
|
||||
MAGIC_NO_CHECK_TAR | \
|
||||
/* MAGIC_NO_CHECK_SOFT | */ \
|
||||
MAGIC_NO_CHECK_APPTYPE | \
|
||||
MAGIC_NO_CHECK_ELF | \
|
||||
MAGIC_NO_CHECK_TEXT | \
|
||||
MAGIC_NO_CHECK_CSV | \
|
||||
MAGIC_NO_CHECK_CDF | \
|
||||
MAGIC_NO_CHECK_TOKENS | \
|
||||
MAGIC_NO_CHECK_ENCODING | \
|
||||
MAGIC_NO_CHECK_JSON | \
|
||||
MAGIC_NO_CHECK_SIMH | \
|
||||
0 \
|
||||
)
|
||||
|
||||
#define MAGIC_SNPRINTB "\177\020\
|
||||
b\0debug\0\
|
||||
b\1symlink\0\
|
||||
b\2compress\0\
|
||||
b\3devices\0\
|
||||
b\4mime_type\0\
|
||||
b\5continue\0\
|
||||
b\6check\0\
|
||||
b\7preserve_atime\0\
|
||||
b\10raw\0\
|
||||
b\11error\0\
|
||||
b\12mime_encoding\0\
|
||||
b\13apple\0\
|
||||
b\14no_check_compress\0\
|
||||
b\15no_check_tar\0\
|
||||
b\16no_check_soft\0\
|
||||
b\17no_check_sapptype\0\
|
||||
b\20no_check_elf\0\
|
||||
b\21no_check_text\0\
|
||||
b\22no_check_cdf\0\
|
||||
b\23no_check_csv\0\
|
||||
b\24no_check_tokens\0\
|
||||
b\25no_check_encoding\0\
|
||||
b\26no_check_json\0\
|
||||
b\27no_check_simh\0\
|
||||
b\30extension\0\
|
||||
b\31transp_compression\0\
|
||||
"
|
||||
|
||||
/* Defined for backwards compatibility (renamed) */
|
||||
#define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT
|
||||
|
||||
/* Defined for backwards compatibility; do nothing */
|
||||
#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
|
||||
#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
|
||||
|
||||
#define MAGIC_VERSION 545 /* This implementation */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct magic_set *magic_t;
|
||||
magic_t magic_open(int);
|
||||
void magic_close(magic_t);
|
||||
|
||||
const char *magic_getpath(const char *, int);
|
||||
const char *magic_file(magic_t, const char *);
|
||||
const char *magic_descriptor(magic_t, int);
|
||||
const char *magic_buffer(magic_t, const void *, size_t);
|
||||
|
||||
const char *magic_error(magic_t);
|
||||
int magic_getflags(magic_t);
|
||||
int magic_setflags(magic_t, int);
|
||||
|
||||
int magic_version(void);
|
||||
int magic_load(magic_t, const char *);
|
||||
int magic_load_buffers(magic_t, void **, size_t *, size_t);
|
||||
|
||||
int magic_compile(magic_t, const char *);
|
||||
int magic_check(magic_t, const char *);
|
||||
int magic_list(magic_t, const char *);
|
||||
int magic_errno(magic_t);
|
||||
|
||||
#define MAGIC_PARAM_INDIR_MAX 0
|
||||
#define MAGIC_PARAM_NAME_MAX 1
|
||||
#define MAGIC_PARAM_ELF_PHNUM_MAX 2
|
||||
#define MAGIC_PARAM_ELF_SHNUM_MAX 3
|
||||
#define MAGIC_PARAM_ELF_NOTES_MAX 4
|
||||
#define MAGIC_PARAM_REGEX_MAX 5
|
||||
#define MAGIC_PARAM_BYTES_MAX 6
|
||||
#define MAGIC_PARAM_ENCODING_MAX 7
|
||||
#define MAGIC_PARAM_ELF_SHSIZE_MAX 8
|
||||
|
||||
int magic_setparam(magic_t, int, const void *);
|
||||
int magic_getparam(magic_t, int, void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _MAGIC_H */
|
||||
57
include/e2fsprogs/misc/create_inode.h
Executable file
57
include/e2fsprogs/misc/create_inode.h
Executable file
@@ -0,0 +1,57 @@
|
||||
#ifndef _CREATE_INODE_H
|
||||
#define _CREATE_INODE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "et/com_err.h"
|
||||
#include "e2p/e2p.h"
|
||||
#include "ext2fs/ext2fs.h"
|
||||
|
||||
struct hdlink_s
|
||||
{
|
||||
dev_t src_dev;
|
||||
ino_t src_ino;
|
||||
ext2_ino_t dst_ino;
|
||||
};
|
||||
|
||||
struct hdlinks_s
|
||||
{
|
||||
int count;
|
||||
int size;
|
||||
struct hdlink_s *hdl;
|
||||
};
|
||||
|
||||
#define HDLINK_CNT (4)
|
||||
|
||||
struct fs_ops_callbacks {
|
||||
errcode_t (* create_new_inode)(ext2_filsys fs, const char *target_path,
|
||||
const char *name, ext2_ino_t parent_ino, ext2_ino_t root,
|
||||
mode_t mode);
|
||||
errcode_t (* end_create_new_inode)(ext2_filsys fs,
|
||||
const char *target_path, const char *name,
|
||||
ext2_ino_t parent_ino, ext2_ino_t root, mode_t mode);
|
||||
};
|
||||
|
||||
extern int no_copy_xattrs; /* this should eventually be a flag
|
||||
passed to populate_fs3() */
|
||||
|
||||
/* For populating the filesystem */
|
||||
extern errcode_t populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
|
||||
const char *source_dir, ext2_ino_t root);
|
||||
extern errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino,
|
||||
const char *source_dir, ext2_ino_t root,
|
||||
struct fs_ops_callbacks *fs_callbacks);
|
||||
extern errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd,
|
||||
const char *name, unsigned int st_mode,
|
||||
unsigned int st_rdev);
|
||||
extern errcode_t do_symlink_internal(ext2_filsys fs, ext2_ino_t cwd,
|
||||
const char *name, char *target,
|
||||
ext2_ino_t root);
|
||||
extern errcode_t do_mkdir_internal(ext2_filsys fs, ext2_ino_t cwd,
|
||||
const char *name, ext2_ino_t root);
|
||||
extern errcode_t do_write_internal(ext2_filsys fs, ext2_ino_t cwd,
|
||||
const char *src, const char *dest,
|
||||
ext2_ino_t root);
|
||||
|
||||
#endif /* _CREATE_INODE_H */
|
||||
30
include/e2fsprogs/misc/mke2fs.h
Executable file
30
include/e2fsprogs/misc/mke2fs.h
Executable file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* mke2fs.h
|
||||
*
|
||||
* Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
* 2003, 2004, 2005 by Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
/* mke2fs.c */
|
||||
extern const char * program_name;
|
||||
extern int quiet;
|
||||
extern int verbose;
|
||||
extern int zero_hugefile;
|
||||
extern char **fs_types;
|
||||
|
||||
extern char *get_string_from_profile(char **types, const char *opt,
|
||||
const char *def_val);
|
||||
extern int get_int_from_profile(char **types, const char *opt, int def_val);
|
||||
extern int get_bool_from_profile(char **types, const char *opt, int def_val);
|
||||
extern int int_log10(unsigned long long arg);
|
||||
|
||||
/* mk_hugefiles.c */
|
||||
extern errcode_t mk_hugefiles(ext2_filsys fs, const char *device_name);
|
||||
|
||||
|
||||
|
||||
29
include/e2fsprogs/misc/util.h
Executable file
29
include/e2fsprogs/misc/util.h
Executable file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* util.h --- header file defining prototypes for helper functions
|
||||
* used by tune2fs and mke2fs
|
||||
*
|
||||
* Copyright 2000 by Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
extern int journal_size;
|
||||
extern int journal_fc_size;
|
||||
extern int journal_flags;
|
||||
extern char *journal_device;
|
||||
extern char *journal_location_string;
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
extern int strcasecmp (char *s1, char *s2);
|
||||
#endif
|
||||
extern char *get_progname(char *argv_zero);
|
||||
extern void proceed_question(int delay);
|
||||
extern void parse_journal_opts(const char *opts);
|
||||
extern void check_mount(const char *device, int force, const char *type);
|
||||
extern void figure_journal_size(struct ext2fs_journal_params *jparams,
|
||||
int requested_j_size, int requested_fc_size, ext2_filsys fs);
|
||||
extern void print_check_message(int, unsigned int);
|
||||
extern void dump_mmp_msg(struct mmp_struct *mmp, const char *msg);
|
||||
43
include/e2fsprogs/support/argv_parse.h
Executable file
43
include/e2fsprogs/support/argv_parse.h
Executable file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* argv_parse.h --- header file for the argv parser.
|
||||
*
|
||||
* This file defines the interface for the functions argv_parse() and
|
||||
* argv_free().
|
||||
*
|
||||
***********************************************************************
|
||||
* int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv)
|
||||
*
|
||||
* This function takes as its first argument a string which it will
|
||||
* parse into an argv argument vector, with each white-space separated
|
||||
* word placed into its own slot in the argv. This function handles
|
||||
* double quotes and backslashes so that the parsed words can contain
|
||||
* special characters. The count of the number words found in the
|
||||
* parsed string, as well as the argument vector, are returned into
|
||||
* ret_argc and ret_argv, respectively.
|
||||
***********************************************************************
|
||||
* extern void argv_free(char **argv);
|
||||
*
|
||||
* This function frees the argument vector created by argv_parse().
|
||||
***********************************************************************
|
||||
*
|
||||
* Copyright 1999 by Theodore Ts'o.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose with or without fee is hereby granted, provided that
|
||||
* the above copyright notice and this permission notice appear in all
|
||||
* copies. THE SOFTWARE IS PROVIDED "AS IS" AND THEODORE TS'O (THE
|
||||
* AUTHOR) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (Isn't
|
||||
* it sick that the U.S. culture of lawsuit-happy lawyers requires
|
||||
* this kind of disclaimer?)
|
||||
*
|
||||
* Version 1.1, modified 2/27/1999
|
||||
*/
|
||||
|
||||
extern int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv);
|
||||
extern void argv_free(char **argv);
|
||||
36
include/e2fsprogs/support/common.h
Executable file
36
include/e2fsprogs/support/common.h
Executable file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
*
|
||||
* Various things common for all utilities
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __QUOTA_COMMON_H__
|
||||
#define __QUOTA_COMMON_H__
|
||||
|
||||
#if EXT2_FLAT_INCLUDES
|
||||
#include "e2_types.h"
|
||||
#else
|
||||
#include <ext2fs/ext2_types.h>
|
||||
#endif /* EXT2_FLAT_INCLUDES */
|
||||
|
||||
/* #define DEBUG_QUOTA 1 */
|
||||
|
||||
#ifndef __attribute__
|
||||
# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define log_err(format, arg ...) \
|
||||
fprintf(stderr, "[ERROR] %s:%d:%s: " format "\n", \
|
||||
__FILE__, __LINE__, __func__, ## arg)
|
||||
|
||||
#ifdef DEBUG_QUOTA
|
||||
# define log_debug(format, arg ...) \
|
||||
fprintf(stderr, "[DEBUG] %s:%d:%s: " format "\n", \
|
||||
__FILE__, __LINE__, __func__, ## arg)
|
||||
#else
|
||||
# define log_debug(...)
|
||||
#endif
|
||||
|
||||
#endif /* __QUOTA_COMMON_H__ */
|
||||
6
include/e2fsprogs/support/cstring.h
Executable file
6
include/e2fsprogs/support/cstring.h
Executable file
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* cstring.h -- header file for C string parse/print utilities
|
||||
*/
|
||||
|
||||
extern int parse_c_string(char *str);
|
||||
extern void print_c_string(FILE *f, const char *cp, int len);
|
||||
19
include/e2fsprogs/support/devname.h
Executable file
19
include/e2fsprogs/support/devname.h
Executable file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* devname.c --- Figure out if a pathname is ext* or something else.
|
||||
*
|
||||
* Copyright (C) 2022 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef DEVNAME_H_
|
||||
#define DEVNAME_H_
|
||||
|
||||
#include "blkid/blkid.h"
|
||||
|
||||
char *get_devname(blkid_cache cache, const char *token, const char *value);
|
||||
|
||||
#endif /* DEVNAME_H_ */
|
||||
147
include/e2fsprogs/support/dict.h
Executable file
147
include/e2fsprogs/support/dict.h
Executable file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Dictionary Abstract Data Type
|
||||
* Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
|
||||
*
|
||||
* Free Software License:
|
||||
*
|
||||
* All rights are reserved by the author, with the following exceptions:
|
||||
* Permission is granted to freely reproduce and distribute this software,
|
||||
* possibly in exchange for a fee, provided that this copyright notice appears
|
||||
* intact. Permission is also granted to adapt this software to produce
|
||||
* derivative works, as long as the modified versions carry this copyright
|
||||
* notice and additional notices stating that the work has been modified.
|
||||
* This source code may be translated into executable form and incorporated
|
||||
* into proprietary software; there is no requirement for such software to
|
||||
* contain a copyright notice related to this source.
|
||||
*
|
||||
* $Id: dict.h,v 1.22.2.6 2000/11/13 01:36:44 kaz Exp $
|
||||
* $Name: kazlib_1_20 $
|
||||
* The work has been modified.
|
||||
*/
|
||||
|
||||
#ifndef DICT_H
|
||||
#define DICT_H
|
||||
|
||||
#include <limits.h>
|
||||
#ifdef KAZLIB_SIDEEFFECT_DEBUG
|
||||
#include "sfx.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Blurb for inclusion into C++ translation units
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned long dictcount_t;
|
||||
#define DICTCOUNT_T_MAX ULONG_MAX
|
||||
|
||||
/*
|
||||
* The dictionary is implemented as a red-black tree
|
||||
*/
|
||||
|
||||
typedef enum { dnode_red, dnode_black } dnode_color_t;
|
||||
|
||||
typedef struct dnode_t {
|
||||
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
|
||||
struct dnode_t *dict_left;
|
||||
struct dnode_t *dict_right;
|
||||
struct dnode_t *dict_parent;
|
||||
dnode_color_t dict_color;
|
||||
const void *dict_key;
|
||||
void *dict_data;
|
||||
#else
|
||||
int dict_dummy;
|
||||
#endif
|
||||
} dnode_t;
|
||||
|
||||
typedef int (*dict_comp_t)(const void *, const void *, const void *);
|
||||
typedef dnode_t *(*dnode_alloc_t)(void *);
|
||||
typedef void (*dnode_free_t)(dnode_t *, void *);
|
||||
|
||||
typedef struct dict_t {
|
||||
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
|
||||
dnode_t dict_nilnode;
|
||||
dictcount_t dict_nodecount;
|
||||
dictcount_t dict_maxcount;
|
||||
dict_comp_t dict_compare;
|
||||
dnode_alloc_t dict_allocnode;
|
||||
dnode_free_t dict_freenode;
|
||||
void *dict_context;
|
||||
const void *cmp_ctx;
|
||||
int dict_dupes;
|
||||
#else
|
||||
int dict_dummmy;
|
||||
#endif
|
||||
} dict_t;
|
||||
|
||||
typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *);
|
||||
|
||||
typedef struct dict_load_t {
|
||||
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
|
||||
dict_t *dict_dictptr;
|
||||
dnode_t dict_nilnode;
|
||||
#else
|
||||
int dict_dummmy;
|
||||
#endif
|
||||
} dict_load_t;
|
||||
|
||||
extern dict_t *dict_create(dictcount_t, dict_comp_t);
|
||||
extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *);
|
||||
extern void dict_set_cmp_context(dict_t *, const void *);
|
||||
extern void dict_destroy(dict_t *);
|
||||
extern void dict_free_nodes(dict_t *);
|
||||
extern void dict_free(dict_t *);
|
||||
extern dict_t *dict_init(dict_t *, dictcount_t, dict_comp_t);
|
||||
extern void dict_init_like(dict_t *, const dict_t *);
|
||||
extern int dict_verify(dict_t *);
|
||||
extern int dict_similar(const dict_t *, const dict_t *);
|
||||
extern dnode_t *dict_lookup(dict_t *, const void *);
|
||||
extern dnode_t *dict_lower_bound(dict_t *, const void *);
|
||||
extern dnode_t *dict_upper_bound(dict_t *, const void *);
|
||||
extern void dict_insert(dict_t *, dnode_t *, const void *);
|
||||
extern dnode_t *dict_delete(dict_t *, dnode_t *);
|
||||
extern int dict_alloc_insert(dict_t *, const void *, void *);
|
||||
extern void dict_delete_free(dict_t *, dnode_t *);
|
||||
extern dnode_t *dict_first(dict_t *);
|
||||
extern dnode_t *dict_last(dict_t *);
|
||||
extern dnode_t *dict_next(dict_t *, dnode_t *);
|
||||
extern dnode_t *dict_prev(dict_t *, dnode_t *);
|
||||
extern dictcount_t dict_count(dict_t *);
|
||||
extern int dict_isempty(dict_t *);
|
||||
extern int dict_isfull(dict_t *);
|
||||
extern int dict_contains(dict_t *, dnode_t *);
|
||||
extern void dict_allow_dupes(dict_t *);
|
||||
extern int dnode_is_in_a_dict(dnode_t *);
|
||||
extern dnode_t *dnode_create(void *);
|
||||
extern dnode_t *dnode_init(dnode_t *, void *);
|
||||
extern void dnode_destroy(dnode_t *);
|
||||
extern void *dnode_get(dnode_t *);
|
||||
extern const void *dnode_getkey(dnode_t *);
|
||||
extern void dnode_put(dnode_t *, void *);
|
||||
extern void dict_process(dict_t *, void *, dnode_process_t);
|
||||
extern void dict_load_begin(dict_load_t *, dict_t *);
|
||||
extern void dict_load_next(dict_load_t *, dnode_t *, const void *);
|
||||
extern void dict_load_end(dict_load_t *);
|
||||
extern void dict_merge(dict_t *, dict_t *);
|
||||
|
||||
#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
|
||||
#ifdef KAZLIB_SIDEEFFECT_DEBUG
|
||||
#define dict_isfull(D) (SFX_CHECK(D)->dict_nodecount == (D)->dict_maxcount)
|
||||
#else
|
||||
#define dict_isfull(D) ((D)->dict_nodecount == (D)->dict_maxcount)
|
||||
#endif
|
||||
#define dict_count(D) ((D)->dict_nodecount)
|
||||
#define dict_isempty(D) ((D)->dict_nodecount == 0)
|
||||
#define dnode_get(N) ((N)->dict_data)
|
||||
#define dnode_getkey(N) ((N)->dict_key)
|
||||
#define dnode_put(N, X) ((N)->dict_data = (X))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
31
include/e2fsprogs/support/dqblk_v2.h
Executable file
31
include/e2fsprogs/support/dqblk_v2.h
Executable file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Header file for disk format of new quotafile format
|
||||
*
|
||||
* Jan Kara <jack@suse.cz> - sponsored by SuSE CR
|
||||
*/
|
||||
|
||||
#ifndef __QUOTA_DQBLK_V2_H__
|
||||
#define __QUOTA_DQBLK_V2_H__
|
||||
|
||||
#include "quotaio_tree.h"
|
||||
|
||||
/* Structure for format specific information */
|
||||
struct v2_mem_dqinfo {
|
||||
struct qtree_mem_dqinfo dqi_qtree;
|
||||
unsigned int dqi_flags; /* Flags set in quotafile */
|
||||
unsigned int dqi_used_entries; /* Number of entries in file -
|
||||
updated by scan_dquots */
|
||||
unsigned int dqi_data_blocks; /* Number of data blocks in file -
|
||||
updated by scan_dquots */
|
||||
};
|
||||
|
||||
struct v2_mem_dqblk {
|
||||
long long dqb_off; /* Offset of dquot in file */
|
||||
};
|
||||
|
||||
struct quotafile_ops; /* Will be defined later in quotaio.h */
|
||||
|
||||
/* Operations above this format */
|
||||
extern struct quotafile_ops quotafile_ops_2;
|
||||
|
||||
#endif /* __QUOTA_DQBLK_V2_H__ */
|
||||
21
include/e2fsprogs/support/nls-enable.h
Executable file
21
include/e2fsprogs/support/nls-enable.h
Executable file
@@ -0,0 +1,21 @@
|
||||
#if defined(ENABLE_NLS) && !defined(DEBUGFS)
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
#define _(a) (gettext (a))
|
||||
#ifdef gettext_noop
|
||||
#define N_(a) gettext_noop (a)
|
||||
#else
|
||||
#define N_(a) (a)
|
||||
#endif
|
||||
#define P_(singular, plural, n) (ngettext (singular, plural, n))
|
||||
#ifndef NLS_CAT_NAME
|
||||
#define NLS_CAT_NAME "e2fsprogs"
|
||||
#endif
|
||||
#ifndef LOCALEDIR
|
||||
#define LOCALEDIR "/usr/share/locale"
|
||||
#endif
|
||||
#else
|
||||
#define _(a) (a)
|
||||
#define N_(a) a
|
||||
#define P_(singular, plural, n) ((n) == 1 ? (singular) : (plural))
|
||||
#endif
|
||||
29
include/e2fsprogs/support/plausible.h
Executable file
29
include/e2fsprogs/support/plausible.h
Executable file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* plausible.h --- header file defining prototypes for helper functions
|
||||
* used by tune2fs and mke2fs
|
||||
*
|
||||
* Copyright 2014 by Oracle, Inc.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef PLAUSIBLE_H_
|
||||
#define PLAUSIBLE_H_
|
||||
|
||||
/*
|
||||
* Flags for check_plausibility()
|
||||
*/
|
||||
#define CHECK_BLOCK_DEV 0x0001
|
||||
#define CREATE_FILE 0x0002
|
||||
#define CHECK_FS_EXIST 0x0004
|
||||
#define VERBOSE_CREATE 0x0008
|
||||
#define NO_SIZE 0x0010
|
||||
#define QUIET_CHECK 0x0020
|
||||
|
||||
extern int check_plausibility(const char *device, int flags,
|
||||
int *ret_is_dev);
|
||||
|
||||
#endif /* PLAUSIBLE_H_ */
|
||||
5
include/e2fsprogs/support/print_fs_flags.h
Executable file
5
include/e2fsprogs/support/print_fs_flags.h
Executable file
@@ -0,0 +1,5 @@
|
||||
/*
|
||||
* print_flags.h -- header file for printing the fs flags
|
||||
*/
|
||||
|
||||
void print_fs_flags(FILE * f, unsigned long flags);
|
||||
49
include/e2fsprogs/support/prof_err.h
Executable file
49
include/e2fsprogs/support/prof_err.h
Executable file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* prof_err.h:
|
||||
* This file is automatically generated; please do not edit it.
|
||||
*/
|
||||
|
||||
#include <et/com_err.h>
|
||||
|
||||
#define PROF_VERSION (-1429577728L)
|
||||
#define PROF_MAGIC_NODE (-1429577727L)
|
||||
#define PROF_NO_SECTION (-1429577726L)
|
||||
#define PROF_NO_RELATION (-1429577725L)
|
||||
#define PROF_ADD_NOT_SECTION (-1429577724L)
|
||||
#define PROF_SECTION_WITH_VALUE (-1429577723L)
|
||||
#define PROF_BAD_LINK_LIST (-1429577722L)
|
||||
#define PROF_BAD_GROUP_LVL (-1429577721L)
|
||||
#define PROF_BAD_PARENT_PTR (-1429577720L)
|
||||
#define PROF_MAGIC_ITERATOR (-1429577719L)
|
||||
#define PROF_SET_SECTION_VALUE (-1429577718L)
|
||||
#define PROF_EINVAL (-1429577717L)
|
||||
#define PROF_READ_ONLY (-1429577716L)
|
||||
#define PROF_SECTION_NOTOP (-1429577715L)
|
||||
#define PROF_SECTION_SYNTAX (-1429577714L)
|
||||
#define PROF_RELATION_SYNTAX (-1429577713L)
|
||||
#define PROF_EXTRA_CBRACE (-1429577712L)
|
||||
#define PROF_MISSING_OBRACE (-1429577711L)
|
||||
#define PROF_MAGIC_PROFILE (-1429577710L)
|
||||
#define PROF_MAGIC_SECTION (-1429577709L)
|
||||
#define PROF_TOPSECTION_ITER_NOSUPP (-1429577708L)
|
||||
#define PROF_INVALID_SECTION (-1429577707L)
|
||||
#define PROF_END_OF_SECTIONS (-1429577706L)
|
||||
#define PROF_BAD_NAMESET (-1429577705L)
|
||||
#define PROF_NO_PROFILE (-1429577704L)
|
||||
#define PROF_MAGIC_FILE (-1429577703L)
|
||||
#define PROF_FAIL_OPEN (-1429577702L)
|
||||
#define PROF_EXISTS (-1429577701L)
|
||||
#define PROF_BAD_BOOLEAN (-1429577700L)
|
||||
#define PROF_BAD_INTEGER (-1429577699L)
|
||||
#define PROF_MAGIC_FILE_DATA (-1429577698L)
|
||||
extern const struct error_table et_prof_error_table;
|
||||
extern void initialize_prof_error_table(void);
|
||||
|
||||
/* For compatibility with Heimdal */
|
||||
extern void initialize_prof_error_table_r(struct et_list **list);
|
||||
|
||||
#define ERROR_TABLE_BASE_prof (-1429577728L)
|
||||
|
||||
/* for compatibility with older versions... */
|
||||
#define init_prof_err_tbl initialize_prof_error_table
|
||||
#define prof_err_base ERROR_TABLE_BASE_prof
|
||||
107
include/e2fsprogs/support/profile.h
Executable file
107
include/e2fsprogs/support/profile.h
Executable file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* profile.h
|
||||
*
|
||||
* Copyright (C) 2005 by Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*
|
||||
* Copyright (C) 1985-2005 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Export of this software from the United States of America may require
|
||||
* a specific license from the United States Government. It is the
|
||||
* responsibility of any person or organization contemplating export to
|
||||
* obtain such a license before exporting.
|
||||
*
|
||||
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
||||
* distribute this software and its documentation for any purpose and
|
||||
* without fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright notice and
|
||||
* this permission notice appear in supporting documentation, and that
|
||||
* the name of M.I.T. not be used in advertising or publicity pertaining
|
||||
* to distribution of the software without specific, written prior
|
||||
* permission. Furthermore if you modify this software you must label
|
||||
* your software as modified software and not distribute it in such a
|
||||
* fashion that it might be confused with the original MIT software.
|
||||
* M.I.T. makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _PROFILE_H
|
||||
#define _PROFILE_H
|
||||
|
||||
typedef struct _profile_t *profile_t;
|
||||
|
||||
typedef void (*profile_syntax_err_cb_t)(const char *file, long err,
|
||||
int line_num);
|
||||
|
||||
/*
|
||||
* Used by the profile iterator in prof_get.c
|
||||
*/
|
||||
#define PROFILE_ITER_LIST_SECTION 0x0001
|
||||
#define PROFILE_ITER_SECTIONS_ONLY 0x0002
|
||||
#define PROFILE_ITER_RELATIONS_ONLY 0x0004
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
long profile_init
|
||||
(const char * const *files, profile_t *ret_profile);
|
||||
|
||||
void profile_release
|
||||
(profile_t profile);
|
||||
|
||||
long profile_set_default
|
||||
(profile_t profile, const char *def_string);
|
||||
|
||||
long profile_get_string
|
||||
(profile_t profile, const char *name, const char *subname,
|
||||
const char *subsubname, const char *def_val,
|
||||
char **ret_string);
|
||||
long profile_get_integer
|
||||
(profile_t profile, const char *name, const char *subname,
|
||||
const char *subsubname, int def_val,
|
||||
int *ret_default);
|
||||
|
||||
long profile_get_uint
|
||||
(profile_t profile, const char *name, const char *subname,
|
||||
const char *subsubname, unsigned int def_val,
|
||||
unsigned int *ret_int);
|
||||
|
||||
long profile_get_double
|
||||
(profile_t profile, const char *name, const char *subname,
|
||||
const char *subsubname, double def_val,
|
||||
double *ret_float);
|
||||
|
||||
long profile_get_boolean
|
||||
(profile_t profile, const char *name, const char *subname,
|
||||
const char *subsubname, int def_val,
|
||||
int *ret_default);
|
||||
|
||||
long profile_iterator_create
|
||||
(profile_t profile, const char *const *names,
|
||||
int flags, void **ret_iter);
|
||||
|
||||
void profile_iterator_free
|
||||
(void **iter_p);
|
||||
|
||||
long profile_iterator
|
||||
(void **iter_p, char **ret_name, char **ret_value);
|
||||
|
||||
profile_syntax_err_cb_t profile_set_syntax_err_cb(profile_syntax_err_cb_t hook);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _KRB5_H */
|
||||
28
include/e2fsprogs/support/profile_helpers.h
Executable file
28
include/e2fsprogs/support/profile_helpers.h
Executable file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* profile_helpers.h -- Function prototypes for profile helper functions
|
||||
*
|
||||
* Copyright (C) 2006 by Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
long profile_get_values
|
||||
(profile_t profile, const char *const *names, char ***ret_values);
|
||||
|
||||
void profile_free_list
|
||||
(char **list);
|
||||
|
||||
long profile_get_relation_names
|
||||
(profile_t profile, const char **names, char ***ret_names);
|
||||
|
||||
long profile_get_subsection_names
|
||||
(profile_t profile, const char **names, char ***ret_names);
|
||||
|
||||
void profile_release_string (char *str);
|
||||
|
||||
long profile_init_path
|
||||
(const char * filelist, profile_t *ret_profile);
|
||||
|
||||
268
include/e2fsprogs/support/quotaio.h
Executable file
268
include/e2fsprogs/support/quotaio.h
Executable file
@@ -0,0 +1,268 @@
|
||||
/** quotaio.h
|
||||
*
|
||||
* Interface to the quota library.
|
||||
*
|
||||
* The quota library provides interface for creating and updating the quota
|
||||
* files and the ext4 superblock fields. It supports the new VFS_V1 quota
|
||||
* format. The quota library also provides support for keeping track of quotas
|
||||
* in memory.
|
||||
* The typical way to use the quota library is as follows:
|
||||
* {
|
||||
* quota_ctx_t qctx;
|
||||
*
|
||||
* quota_init_context(&qctx, fs, QUOTA_ALL_BIT);
|
||||
* {
|
||||
* quota_compute_usage(qctx);
|
||||
* AND/OR
|
||||
* quota_data_add/quota_data_sub/quota_data_inodes();
|
||||
* }
|
||||
* quota_write_inode(qctx, USRQUOTA);
|
||||
* quota_write_inode(qctx, GRPQUOTA);
|
||||
* quota_release_context(&qctx);
|
||||
* }
|
||||
*
|
||||
* This initial version does not support reading the quota files. This support
|
||||
* will be added in near future.
|
||||
*
|
||||
* Aditya Kali <adityakali@google.com>
|
||||
* Header of IO operations for quota utilities
|
||||
*
|
||||
* Jan Kara <jack@suse.cz>
|
||||
*/
|
||||
|
||||
#ifndef GUARD_QUOTAIO_H
|
||||
#define GUARD_QUOTAIO_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "ext2fs/ext2_fs.h"
|
||||
#include "ext2fs/ext2fs.h"
|
||||
#include "dqblk_v2.h"
|
||||
|
||||
typedef int64_t qsize_t; /* Type in which we store size limitations */
|
||||
|
||||
enum quota_type {
|
||||
USRQUOTA = 0,
|
||||
GRPQUOTA = 1,
|
||||
PRJQUOTA = 2,
|
||||
MAXQUOTAS = 3,
|
||||
};
|
||||
|
||||
#if MAXQUOTAS > 32
|
||||
#error "cannot have more than 32 quota types to fit in qtype_bits"
|
||||
#endif
|
||||
|
||||
#define QUOTA_USR_BIT (1 << USRQUOTA)
|
||||
#define QUOTA_GRP_BIT (1 << GRPQUOTA)
|
||||
#define QUOTA_PRJ_BIT (1 << PRJQUOTA)
|
||||
#define QUOTA_ALL_BIT (QUOTA_USR_BIT | QUOTA_GRP_BIT | QUOTA_PRJ_BIT)
|
||||
|
||||
typedef struct quota_ctx *quota_ctx_t;
|
||||
struct dict_t;
|
||||
|
||||
struct quota_ctx {
|
||||
ext2_filsys fs;
|
||||
struct dict_t *quota_dict[MAXQUOTAS];
|
||||
struct quota_handle *quota_file[MAXQUOTAS];
|
||||
};
|
||||
|
||||
/*
|
||||
* Definitions of magics and versions of current quota files
|
||||
*/
|
||||
#define INITQMAGICS {\
|
||||
0xd9c01f11, /* USRQUOTA */\
|
||||
0xd9c01927, /* GRPQUOTA */\
|
||||
0xd9c03f14 /* PRJQUOTA */\
|
||||
}
|
||||
|
||||
/* Size of blocks in which are counted size limits in generic utility parts */
|
||||
#define QUOTABLOCK_BITS 10
|
||||
#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
|
||||
#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
|
||||
|
||||
/* Quota format type IDs */
|
||||
#define QFMT_VFS_OLD 1
|
||||
#define QFMT_VFS_V0 2
|
||||
#define QFMT_VFS_V1 4
|
||||
|
||||
/*
|
||||
* The following constants define the default amount of time given a user
|
||||
* before the soft limits are treated as hard limits (usually resulting
|
||||
* in an allocation failure). The timer is started when the user crosses
|
||||
* their soft limit, it is reset when they go below their soft limit.
|
||||
*/
|
||||
#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
|
||||
#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
|
||||
|
||||
#define IOFL_INFODIRTY 0x01 /* Did info change? */
|
||||
|
||||
struct quotafile_ops;
|
||||
|
||||
/* Generic information about quotafile */
|
||||
struct util_dqinfo {
|
||||
time_t dqi_bgrace; /* Block grace time for given quotafile */
|
||||
time_t dqi_igrace; /* Inode grace time for given quotafile */
|
||||
union {
|
||||
struct v2_mem_dqinfo v2_mdqi;
|
||||
} u; /* Format specific info about quotafile */
|
||||
};
|
||||
|
||||
struct quota_file {
|
||||
ext2_filsys fs;
|
||||
ext2_ino_t ino;
|
||||
ext2_file_t e2_file;
|
||||
};
|
||||
|
||||
/* Structure for one opened quota file */
|
||||
struct quota_handle {
|
||||
enum quota_type qh_type; /* Type of quotafile */
|
||||
int qh_fmt; /* Quotafile format */
|
||||
int qh_file_flags;
|
||||
int qh_io_flags; /* IO flags for file */
|
||||
struct quota_file qh_qf;
|
||||
unsigned int (*e2fs_read)(struct quota_file *qf, ext2_loff_t offset,
|
||||
void *buf, unsigned int size);
|
||||
unsigned int (*e2fs_write)(struct quota_file *qf, ext2_loff_t offset,
|
||||
void *buf, unsigned int size);
|
||||
struct quotafile_ops *qh_ops; /* Operations on quotafile */
|
||||
struct util_dqinfo qh_info; /* Generic quotafile info */
|
||||
};
|
||||
|
||||
/* Utility quota block */
|
||||
struct util_dqblk {
|
||||
qsize_t dqb_ihardlimit;
|
||||
qsize_t dqb_isoftlimit;
|
||||
qsize_t dqb_curinodes;
|
||||
qsize_t dqb_bhardlimit;
|
||||
qsize_t dqb_bsoftlimit;
|
||||
qsize_t dqb_curspace;
|
||||
time_t dqb_btime;
|
||||
time_t dqb_itime;
|
||||
union {
|
||||
struct v2_mem_dqblk v2_mdqb;
|
||||
} u; /* Format specific dquot information */
|
||||
};
|
||||
|
||||
/* Structure for one loaded quota */
|
||||
struct dquot {
|
||||
struct dquot *dq_next; /* Pointer to next dquot in the list */
|
||||
qid_t dq_id; /* ID dquot belongs to */
|
||||
int dq_flags; /* Some flags for utils */
|
||||
struct quota_handle *dq_h; /* Handle of quotafile for this dquot */
|
||||
struct util_dqblk dq_dqb; /* Parsed data of dquot */
|
||||
};
|
||||
|
||||
#define DQF_SEEN 0x0001
|
||||
|
||||
/* Structure of quotafile operations */
|
||||
struct quotafile_ops {
|
||||
/* Check whether quotafile is in our format */
|
||||
int (*check_file) (struct quota_handle *h, int type, int fmt);
|
||||
/* Open quotafile */
|
||||
int (*init_io) (struct quota_handle *h);
|
||||
/* Create new quotafile */
|
||||
int (*new_io) (struct quota_handle *h);
|
||||
/* Write all changes and close quotafile */
|
||||
int (*end_io) (struct quota_handle *h);
|
||||
/* Write info about quotafile */
|
||||
int (*write_info) (struct quota_handle *h);
|
||||
/* Read dquot into memory */
|
||||
struct dquot *(*read_dquot) (struct quota_handle *h, qid_t id);
|
||||
/* Write given dquot to disk */
|
||||
int (*commit_dquot) (struct dquot *dquot);
|
||||
/* Scan quotafile and call callback on every structure */
|
||||
int (*scan_dquots) (struct quota_handle *h,
|
||||
int (*process_dquot) (struct dquot *dquot,
|
||||
void *data),
|
||||
void *data);
|
||||
/* Function to print format specific file information */
|
||||
int (*report) (struct quota_handle *h, int verbose);
|
||||
};
|
||||
|
||||
/* This might go into a special header file but that sounds a bit silly... */
|
||||
extern struct quotafile_ops quotafile_ops_meta;
|
||||
|
||||
/* Open existing quotafile of given type (and verify its format) on given
|
||||
* filesystem. */
|
||||
errcode_t quota_file_open(quota_ctx_t qctx, struct quota_handle *h,
|
||||
ext2_ino_t qf_ino, enum quota_type type,
|
||||
int fmt, int flags);
|
||||
|
||||
|
||||
/* Create new quotafile of specified format on given filesystem */
|
||||
errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs,
|
||||
enum quota_type qtype, int fmt);
|
||||
|
||||
/* Close quotafile */
|
||||
errcode_t quota_file_close(quota_ctx_t qctx, struct quota_handle *h);
|
||||
|
||||
/* Get empty quota structure */
|
||||
struct dquot *get_empty_dquot(void);
|
||||
|
||||
errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino);
|
||||
|
||||
const char *quota_type2name(enum quota_type qtype);
|
||||
ext2_ino_t quota_type2inum(enum quota_type qtype, struct ext2_super_block *);
|
||||
|
||||
void update_grace_times(struct dquot *q);
|
||||
|
||||
/* size for the buffer returned by quota_get_qf_name(); must be greater
|
||||
than maxlen of extensions[] and fmtnames[] (plus 2) found in quotaio.c */
|
||||
#define QUOTA_NAME_LEN 16
|
||||
|
||||
const char *quota_get_qf_name(enum quota_type, int fmt, char *buf);
|
||||
|
||||
/* In mkquota.c */
|
||||
errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs,
|
||||
unsigned int qtype_bits);
|
||||
void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode_large *inode,
|
||||
ext2_ino_t ino, int adjust);
|
||||
void quota_data_add(quota_ctx_t qctx, struct ext2_inode_large *inode,
|
||||
ext2_ino_t ino, qsize_t space);
|
||||
void quota_data_sub(quota_ctx_t qctx, struct ext2_inode_large *inode,
|
||||
ext2_ino_t ino, qsize_t space);
|
||||
errcode_t quota_write_inode(quota_ctx_t qctx, enum quota_type qtype);
|
||||
/* Flags for quota_read_all_dquots() */
|
||||
#define QREAD_USAGE 0x01
|
||||
#define QREAD_LIMITS 0x02
|
||||
errcode_t quota_read_all_dquots(quota_ctx_t qctx, ext2_ino_t qf_ino,
|
||||
enum quota_type type, unsigned int flags);
|
||||
errcode_t quota_compute_usage(quota_ctx_t qctx);
|
||||
void quota_release_context(quota_ctx_t *qctx);
|
||||
errcode_t quota_remove_inode(ext2_filsys fs, enum quota_type qtype);
|
||||
int quota_file_exists(ext2_filsys fs, enum quota_type qtype);
|
||||
void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, enum quota_type qtype);
|
||||
errcode_t quota_compare_and_update(quota_ctx_t qctx, enum quota_type qtype,
|
||||
int *usage_inconsistent);
|
||||
int parse_quota_opts(const char *opts, int (*func)(char *));
|
||||
|
||||
/* parse_qtype.c */
|
||||
int parse_quota_types(const char *in_str, unsigned int *qtype_bits,
|
||||
char **err_token);
|
||||
|
||||
/*
|
||||
* Return pointer to reserved inode field in superblock for given quota type.
|
||||
*
|
||||
* This allows the caller to get or set the quota inode by type without the
|
||||
* need for the quota array to be contiguous in the superblock.
|
||||
*/
|
||||
static inline ext2_ino_t *quota_sb_inump(struct ext2_super_block *sb,
|
||||
enum quota_type qtype)
|
||||
{
|
||||
switch (qtype) {
|
||||
case USRQUOTA:
|
||||
return &sb->s_usr_quota_inum;
|
||||
case GRPQUOTA:
|
||||
return &sb->s_grp_quota_inum;
|
||||
case PRJQUOTA:
|
||||
return &sb->s_prj_quota_inum;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* GUARD_QUOTAIO_H */
|
||||
64
include/e2fsprogs/support/quotaio_tree.h
Executable file
64
include/e2fsprogs/support/quotaio_tree.h
Executable file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Definitions of structures for vfsv0 quota format
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_QUOTA_TREE_H
|
||||
#define _LINUX_QUOTA_TREE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef __u32 qid_t; /* Type in which we store ids in memory */
|
||||
|
||||
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
|
||||
#define QT_TREEDEPTH 4 /* Depth of quota tree */
|
||||
#define QT_BLKSIZE_BITS 10
|
||||
#define QT_BLKSIZE (1 << QT_BLKSIZE_BITS) /* Size of block with quota
|
||||
* structures */
|
||||
|
||||
/*
|
||||
* Structure of header of block with quota structures. It is padded to 16 bytes
|
||||
* so there will be space for exactly 21 quota-entries in a block
|
||||
*/
|
||||
struct qt_disk_dqdbheader {
|
||||
__le32 dqdh_next_free; /* Number of next block with free
|
||||
* entry */
|
||||
__le32 dqdh_prev_free; /* Number of previous block with free
|
||||
* entry */
|
||||
__le16 dqdh_entries; /* Number of valid entries in block */
|
||||
__le16 dqdh_pad1;
|
||||
__le32 dqdh_pad2;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct dquot;
|
||||
struct quota_handle;
|
||||
|
||||
/* Operations */
|
||||
struct qtree_fmt_operations {
|
||||
/* Convert given entry from in memory format to disk one */
|
||||
void (*mem2disk_dqblk)(void *disk, struct dquot *dquot);
|
||||
/* Convert given entry from disk format to in memory one */
|
||||
void (*disk2mem_dqblk)(struct dquot *dquot, void *disk);
|
||||
/* Is this structure for given id? */
|
||||
int (*is_id)(void *disk, struct dquot *dquot);
|
||||
};
|
||||
|
||||
/* In-memory copy of version specific information */
|
||||
struct qtree_mem_dqinfo {
|
||||
unsigned int dqi_blocks; /* # of blocks in quota file */
|
||||
unsigned int dqi_free_blk; /* First block in list of free blocks */
|
||||
unsigned int dqi_free_entry; /* First block with free entry */
|
||||
unsigned int dqi_entry_size; /* Size of quota entry in quota file */
|
||||
struct qtree_fmt_operations *dqi_ops; /* Operations for entry
|
||||
* manipulation */
|
||||
};
|
||||
|
||||
void qtree_write_dquot(struct dquot *dquot);
|
||||
struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id);
|
||||
void qtree_delete_dquot(struct dquot *dquot);
|
||||
int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
|
||||
int qtree_scan_dquots(struct quota_handle *h,
|
||||
int (*process_dquot) (struct dquot *, void *), void *data);
|
||||
|
||||
int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info);
|
||||
|
||||
#endif /* _LINUX_QUOTAIO_TREE_H */
|
||||
69
include/e2fsprogs/support/quotaio_v2.h
Executable file
69
include/e2fsprogs/support/quotaio_v2.h
Executable file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* Header file for disk format of new quotafile format
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GUARD_QUOTAIO_V2_H
|
||||
#define GUARD_QUOTAIO_V2_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "quotaio.h"
|
||||
|
||||
/* Offset of info header in file */
|
||||
#define V2_DQINFOOFF sizeof(struct v2_disk_dqheader)
|
||||
/* Supported version of quota-tree format */
|
||||
#define V2_VERSION_R1 1
|
||||
#define V2_VERSION_R0 0
|
||||
|
||||
struct v2_disk_dqheader {
|
||||
__le32 dqh_magic; /* Magic number identifying file */
|
||||
__le32 dqh_version; /* File version */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Flags for version specific files */
|
||||
#define V2_DQF_MASK 0x0000 /* Mask for all valid ondisk flags */
|
||||
|
||||
/* Header with type and version specific information */
|
||||
struct v2_disk_dqinfo {
|
||||
__le32 dqi_bgrace; /* Time before block soft limit becomes
|
||||
* hard limit */
|
||||
__le32 dqi_igrace; /* Time before inode soft limit becomes
|
||||
* hard limit */
|
||||
__le32 dqi_flags; /* Flags for quotafile (DQF_*) */
|
||||
__le32 dqi_blocks; /* Number of blocks in file */
|
||||
__le32 dqi_free_blk; /* Number of first free block in the list */
|
||||
__le32 dqi_free_entry; /* Number of block with at least one
|
||||
* free entry */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct v2r0_disk_dqblk {
|
||||
__le32 dqb_id; /* id this quota applies to */
|
||||
__le32 dqb_ihardlimit; /* absolute limit on allocated inodes */
|
||||
__le32 dqb_isoftlimit; /* preferred inode limit */
|
||||
__le32 dqb_curinodes; /* current # allocated inodes */
|
||||
__le32 dqb_bhardlimit; /* absolute limit on disk space
|
||||
* (in QUOTABLOCK_SIZE) */
|
||||
__le32 dqb_bsoftlimit; /* preferred limit on disk space
|
||||
* (in QUOTABLOCK_SIZE) */
|
||||
__le64 dqb_curspace; /* current space occupied (in bytes) */
|
||||
__le64 dqb_btime; /* time limit for excessive disk use */
|
||||
__le64 dqb_itime; /* time limit for excessive inode use */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct v2r1_disk_dqblk {
|
||||
__le32 dqb_id; /* id this quota applies to */
|
||||
__le32 dqb_pad;
|
||||
__le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
|
||||
__le64 dqb_isoftlimit; /* preferred inode limit */
|
||||
__le64 dqb_curinodes; /* current # allocated inodes */
|
||||
__le64 dqb_bhardlimit; /* absolute limit on disk space
|
||||
* (in QUOTABLOCK_SIZE) */
|
||||
__le64 dqb_bsoftlimit; /* preferred limit on disk space
|
||||
* (in QUOTABLOCK_SIZE) */
|
||||
__le64 dqb_curspace; /* current space occupied (in bytes) */
|
||||
__le64 dqb_btime; /* time limit for excessive disk use */
|
||||
__le64 dqb_itime; /* time limit for excessive inode use */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#endif
|
||||
325
include/e2fsprogs/support/sort_r.h
Executable file
325
include/e2fsprogs/support/sort_r.h
Executable file
@@ -0,0 +1,325 @@
|
||||
/* Isaac Turner 29 April 2014 Public Domain */
|
||||
#ifndef SORT_R_H_
|
||||
#define SORT_R_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
|
||||
sort_r function to be exported.
|
||||
|
||||
Parameters:
|
||||
base is the array to be sorted
|
||||
nel is the number of elements in the array
|
||||
width is the size in bytes of each element of the array
|
||||
compar is the comparison function
|
||||
arg is a pointer to be passed to the comparison function
|
||||
|
||||
void sort_r(void *base, size_t nel, size_t width,
|
||||
int (*compar)(const void *_a, const void *_b, void *_arg),
|
||||
void *arg);
|
||||
|
||||
*/
|
||||
|
||||
#define _SORT_R_INLINE inline
|
||||
|
||||
#if (defined HAVE_GNU_QSORT_R)
|
||||
# define _SORT_R_GNU
|
||||
#elif (defined HAVE_BSD_QSORT_R)
|
||||
# define _SORT_R_BSD
|
||||
#elif (defined __gnu_hurd__ || defined __GNU__ || \
|
||||
defined __MINGW32__ || defined __GLIBC__)
|
||||
# define _SORT_R_GNU
|
||||
#elif (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || \
|
||||
defined __FreeBSD__ || defined __DragonFly__)
|
||||
# define _SORT_R_BSD
|
||||
#elif (defined _WIN32 || defined _WIN64 || defined __WINDOWS__)
|
||||
# define _SORT_R_WINDOWS
|
||||
# undef _SORT_R_INLINE
|
||||
# define _SORT_R_INLINE __inline
|
||||
#else
|
||||
/* Using our own recursive quicksort sort_r_simple() */
|
||||
#endif
|
||||
|
||||
#if (defined NESTED_QSORT && NESTED_QSORT == 0)
|
||||
# undef NESTED_QSORT
|
||||
#endif
|
||||
|
||||
#define SORT_R_SWAP(a,b,tmp) ((tmp) = (a), (a) = (b), (b) = (tmp))
|
||||
|
||||
/* swap a and b */
|
||||
/* a and b must not be equal! */
|
||||
static _SORT_R_INLINE void sort_r_swap(char *__restrict a, char *__restrict b,
|
||||
size_t w)
|
||||
{
|
||||
char tmp, *end = a+w;
|
||||
for(; a < end; a++, b++) { SORT_R_SWAP(*a, *b, tmp); }
|
||||
}
|
||||
|
||||
/* swap a, b iff a>b */
|
||||
/* a and b must not be equal! */
|
||||
/* __restrict is same as restrict but better support on old machines */
|
||||
static _SORT_R_INLINE int sort_r_cmpswap(char *__restrict a,
|
||||
char *__restrict b, size_t w,
|
||||
int (*compar)(const void *_a,
|
||||
const void *_b,
|
||||
void *_arg),
|
||||
void *arg)
|
||||
{
|
||||
if(compar(a, b, arg) > 0) {
|
||||
sort_r_swap(a, b, w);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Swap consecutive blocks of bytes of size na and nb starting at memory addr ptr,
|
||||
with the smallest swap so that the blocks are in the opposite order. Blocks may
|
||||
be internally re-ordered e.g.
|
||||
|
||||
12345ab -> ab34512
|
||||
123abc -> abc123
|
||||
12abcde -> deabc12
|
||||
*/
|
||||
static _SORT_R_INLINE void sort_r_swap_blocks(char *ptr, size_t na, size_t nb)
|
||||
{
|
||||
if(na > 0 && nb > 0) {
|
||||
if(na > nb) { sort_r_swap(ptr, ptr+na, nb); }
|
||||
else { sort_r_swap(ptr, ptr+nb, na); }
|
||||
}
|
||||
}
|
||||
|
||||
/* Implement recursive quicksort ourselves */
|
||||
/* Note: quicksort is not stable, equivalent values may be swapped */
|
||||
static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w,
|
||||
int (*compar)(const void *_a,
|
||||
const void *_b,
|
||||
void *_arg),
|
||||
void *arg)
|
||||
{
|
||||
char *b = (char *)base, *end = b + nel*w;
|
||||
|
||||
/* for(size_t i=0; i<nel; i++) {printf("%4i", *(int*)(b + i*sizeof(int)));}
|
||||
printf("\n"); */
|
||||
|
||||
if(nel < 10) {
|
||||
/* Insertion sort for arbitrarily small inputs */
|
||||
char *pi, *pj;
|
||||
for(pi = b+w; pi < end; pi += w) {
|
||||
for(pj = pi; pj > b && sort_r_cmpswap(pj-w,pj,w,compar,arg); pj -= w) {}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* nel > 6; Quicksort */
|
||||
|
||||
int cmp;
|
||||
char *pl, *ple, *pr, *pre, *pivot;
|
||||
char *last = b+w*(nel-1), *tmp;
|
||||
|
||||
/*
|
||||
Use median of second, middle and second-last items as pivot.
|
||||
First and last may have been swapped with pivot and therefore be extreme
|
||||
*/
|
||||
char *l[3];
|
||||
l[0] = b + w;
|
||||
l[1] = b+w*(nel/2);
|
||||
l[2] = last - w;
|
||||
|
||||
/* printf("pivots: %i, %i, %i\n", *(int*)l[0], *(int*)l[1], *(int*)l[2]); */
|
||||
|
||||
if(compar(l[0],l[1],arg) > 0) { SORT_R_SWAP(l[0], l[1], tmp); }
|
||||
if(compar(l[1],l[2],arg) > 0) {
|
||||
SORT_R_SWAP(l[1], l[2], tmp);
|
||||
if(compar(l[0],l[1],arg) > 0) { SORT_R_SWAP(l[0], l[1], tmp); }
|
||||
}
|
||||
|
||||
/* swap mid value (l[1]), and last element to put pivot as last element */
|
||||
if(l[1] != last) { sort_r_swap(l[1], last, w); }
|
||||
|
||||
/*
|
||||
pl is the next item on the left to be compared to the pivot
|
||||
pr is the last item on the right that was compared to the pivot
|
||||
ple is the left position to put the next item that equals the pivot
|
||||
ple is the last right position where we put an item that equals the pivot
|
||||
|
||||
v- end (beyond the array)
|
||||
EEEEEELLLLLLLLuuuuuuuuGGGGGGGEEEEEEEE.
|
||||
^- b ^- ple ^- pl ^- pr ^- pre ^- last (where the pivot is)
|
||||
|
||||
Pivot comparison key:
|
||||
E = equal, L = less than, u = unknown, G = greater than, E = equal
|
||||
*/
|
||||
pivot = last;
|
||||
ple = pl = b;
|
||||
pre = pr = last;
|
||||
|
||||
/*
|
||||
Strategy:
|
||||
Loop into the list from the left and right at the same time to find:
|
||||
- an item on the left that is greater than the pivot
|
||||
- an item on the right that is less than the pivot
|
||||
Once found, they are swapped and the loop continues.
|
||||
Meanwhile items that are equal to the pivot are moved to the edges of the
|
||||
array.
|
||||
*/
|
||||
while(pl < pr) {
|
||||
/* Move left hand items which are equal to the pivot to the far left.
|
||||
break when we find an item that is greater than the pivot */
|
||||
for(; pl < pr; pl += w) {
|
||||
cmp = compar(pl, pivot, arg);
|
||||
if(cmp > 0) { break; }
|
||||
else if(cmp == 0) {
|
||||
if(ple < pl) { sort_r_swap(ple, pl, w); }
|
||||
ple += w;
|
||||
}
|
||||
}
|
||||
/* break if last batch of left hand items were equal to pivot */
|
||||
if(pl >= pr) { break; }
|
||||
/* Move right hand items which are equal to the pivot to the far right.
|
||||
break when we find an item that is less than the pivot */
|
||||
for(; pl < pr; ) {
|
||||
pr -= w; /* Move right pointer onto an unprocessed item */
|
||||
cmp = compar(pr, pivot, arg);
|
||||
if(cmp == 0) {
|
||||
pre -= w;
|
||||
if(pr < pre) { sort_r_swap(pr, pre, w); }
|
||||
}
|
||||
else if(cmp < 0) {
|
||||
if(pl < pr) { sort_r_swap(pl, pr, w); }
|
||||
pl += w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pl = pr; /* pr may have gone below pl */
|
||||
|
||||
/*
|
||||
Now we need to go from: EEELLLGGGGEEEE
|
||||
to: LLLEEEEEEEGGGG
|
||||
|
||||
Pivot comparison key:
|
||||
E = equal, L = less than, u = unknown, G = greater than, E = equal
|
||||
*/
|
||||
sort_r_swap_blocks(b, ple-b, pl-ple);
|
||||
sort_r_swap_blocks(pr, pre-pr, end-pre);
|
||||
|
||||
/*for(size_t i=0; i<nel; i++) {printf("%4i", *(int*)(b + i*sizeof(int)));}
|
||||
printf("\n");*/
|
||||
|
||||
sort_r_simple(b, (pl-ple)/w, w, compar, arg);
|
||||
sort_r_simple(end-(pre-pr), (pre-pr)/w, w, compar, arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined NESTED_QSORT
|
||||
|
||||
static _SORT_R_INLINE void sort_r(void *base, size_t nel, size_t width,
|
||||
int (*compar)(const void *_a,
|
||||
const void *_b,
|
||||
void *aarg),
|
||||
void *arg)
|
||||
{
|
||||
int nested_cmp(const void *a, const void *b)
|
||||
{
|
||||
return compar(a, b, arg);
|
||||
}
|
||||
|
||||
qsort(base, nel, width, nested_cmp);
|
||||
}
|
||||
|
||||
#else /* !NESTED_QSORT */
|
||||
|
||||
/* Declare structs and functions */
|
||||
|
||||
#if defined _SORT_R_BSD
|
||||
|
||||
/* Ensure qsort_r is defined */
|
||||
extern void qsort_r(void *base, size_t nel, size_t width, void *thunk,
|
||||
int (*compar)(void *_thunk,
|
||||
const void *_a, const void *_b));
|
||||
|
||||
#endif
|
||||
|
||||
#if defined _SORT_R_BSD || defined _SORT_R_WINDOWS
|
||||
|
||||
/* BSD (qsort_r), Windows (qsort_s) require argument swap */
|
||||
|
||||
struct sort_r_data
|
||||
{
|
||||
void *arg;
|
||||
int (*compar)(const void *_a, const void *_b, void *_arg);
|
||||
};
|
||||
|
||||
static _SORT_R_INLINE int sort_r_arg_swap(void *s,
|
||||
const void *a, const void *b)
|
||||
{
|
||||
struct sort_r_data *ss = (struct sort_r_data*)s;
|
||||
return (ss->compar)(a, b, ss->arg);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined _SORT_R_GNU
|
||||
|
||||
typedef int(* __compar_d_fn_t)(const void *, const void *, void *);
|
||||
extern void qsort_r(void *base, size_t nel, size_t width,
|
||||
__compar_d_fn_t __compar, void *arg)
|
||||
__attribute__((nonnull (1, 4)));
|
||||
|
||||
#endif
|
||||
|
||||
/* implementation */
|
||||
|
||||
static _SORT_R_INLINE void sort_r(void *base, size_t nel, size_t width,
|
||||
int (*compar)(const void *_a,
|
||||
const void *_b, void *_arg),
|
||||
void *arg)
|
||||
{
|
||||
#if defined _SORT_R_GNU
|
||||
|
||||
#if defined __GLIBC__ && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 8))
|
||||
|
||||
/* no qsort_r in glibc before 2.8, need to use nested qsort */
|
||||
sort_r_simple(base, nel, width, compar, arg);
|
||||
|
||||
#else
|
||||
|
||||
qsort_r(base, nel, width, compar, arg);
|
||||
|
||||
#endif
|
||||
|
||||
#elif defined _SORT_R_BSD
|
||||
|
||||
struct sort_r_data tmp;
|
||||
tmp.arg = arg;
|
||||
tmp.compar = compar;
|
||||
qsort_r(base, nel, width, &tmp, sort_r_arg_swap);
|
||||
|
||||
#elif defined _SORT_R_WINDOWS
|
||||
|
||||
struct sort_r_data tmp;
|
||||
tmp.arg = arg;
|
||||
tmp.compar = compar;
|
||||
qsort_s(base, nel, width, sort_r_arg_swap, &tmp);
|
||||
|
||||
#else
|
||||
|
||||
/* Fall back to our own quicksort implementation */
|
||||
sort_r_simple(base, nel, width, compar, arg);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !NESTED_QSORT */
|
||||
|
||||
#undef _SORT_R_INLINE
|
||||
#undef _SORT_R_WINDOWS
|
||||
#undef _SORT_R_GNU
|
||||
#undef _SORT_R_BSD
|
||||
|
||||
#endif /* SORT_R_H_ */
|
||||
103
include/e2fsprogs/uuid/uuid.h
Executable file
103
include/e2fsprogs/uuid/uuid.h
Executable file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Public include file for the UUID library
|
||||
*
|
||||
* Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, and the entire permission notice in its entirety,
|
||||
* including the disclaimer of warranties.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
|
||||
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _UUID_UUID_H
|
||||
#define _UUID_UUID_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
typedef unsigned char uuid_t[16];
|
||||
|
||||
/* UUID Variant definitions */
|
||||
#define UUID_VARIANT_NCS 0
|
||||
#define UUID_VARIANT_DCE 1
|
||||
#define UUID_VARIANT_MICROSOFT 2
|
||||
#define UUID_VARIANT_OTHER 3
|
||||
|
||||
/* UUID Type definitions */
|
||||
#define UUID_TYPE_DCE_TIME 1
|
||||
#define UUID_TYPE_DCE_RANDOM 4
|
||||
|
||||
/* Allow UUID constants to be defined */
|
||||
#ifdef __GNUC__
|
||||
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
|
||||
static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
|
||||
#else
|
||||
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
|
||||
static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* clear.c */
|
||||
void uuid_clear(uuid_t uu);
|
||||
|
||||
/* compare.c */
|
||||
int uuid_compare(const uuid_t uu1, const uuid_t uu2);
|
||||
|
||||
/* copy.c */
|
||||
void uuid_copy(uuid_t dst, const uuid_t src);
|
||||
|
||||
/* gen_uuid.c */
|
||||
void uuid_generate(uuid_t out);
|
||||
void uuid_generate_random(uuid_t out);
|
||||
void uuid_generate_time(uuid_t out);
|
||||
|
||||
/* isnull.c */
|
||||
int uuid_is_null(const uuid_t uu);
|
||||
|
||||
/* parse.c */
|
||||
int uuid_parse(const char *in, uuid_t uu);
|
||||
|
||||
/* unparse.c */
|
||||
void uuid_unparse(const uuid_t uu, char *out);
|
||||
void uuid_unparse_lower(const uuid_t uu, char *out);
|
||||
void uuid_unparse_upper(const uuid_t uu, char *out);
|
||||
|
||||
/* uuid_time.c */
|
||||
time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
|
||||
int uuid_type(const uuid_t uu);
|
||||
int uuid_variant(const uuid_t uu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UUID_UUID_H */
|
||||
71
include/e2fsprogs/uuid/uuidP.h
Executable file
71
include/e2fsprogs/uuid/uuidP.h
Executable file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* uuid.h -- private header file for uuids
|
||||
*
|
||||
* Copyright (C) 1996, 1997 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, and the entire permission notice in its entirety,
|
||||
* including the disclaimer of warranties.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
|
||||
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#include <uuid/uuid_types.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
/*
|
||||
* Offset between 15-Oct-1582 and 1-Jan-70
|
||||
*/
|
||||
#define TIME_OFFSET_HIGH 0x01B21DD2
|
||||
#define TIME_OFFSET_LOW 0x13814000
|
||||
|
||||
struct uuid {
|
||||
uint32_t time_low;
|
||||
uint16_t time_mid;
|
||||
uint16_t time_hi_and_version;
|
||||
uint16_t clock_seq;
|
||||
uint8_t node[6];
|
||||
};
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
#define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
#define __GNUC_PREREQ(maj, min) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* prototypes
|
||||
*/
|
||||
void uuid_pack(const struct uuid *uu, uuid_t ptr);
|
||||
void uuid_unpack(const uuid_t in, struct uuid *uu);
|
||||
45
include/e2fsprogs/uuid/uuid_types.h
Executable file
45
include/e2fsprogs/uuid/uuid_types.h
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* If linux/types.h is already been included, assume it has defined
|
||||
* everything we need. (cross fingers) Other header files may have
|
||||
* also defined the types that we need.
|
||||
*/
|
||||
#if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
|
||||
!defined(_EXT2_TYPES_H) && !defined(_UUID_TYPES_H))
|
||||
#define _UUID_TYPES_H
|
||||
|
||||
typedef unsigned char __u8;
|
||||
typedef __signed__ char __s8;
|
||||
typedef unsigned short __u16;
|
||||
typedef __signed__ short __s16;
|
||||
typedef unsigned int __u32;
|
||||
typedef __signed__ int __s32;
|
||||
typedef unsigned long long __u64;
|
||||
typedef __signed__ long long __s64;
|
||||
#endif
|
||||
|
||||
#include <stdint.h> //uintptr_t
|
||||
|
||||
/* endian checking stuff */
|
||||
#ifndef EXT2_ENDIAN_H_
|
||||
#define EXT2_ENDIAN_H_
|
||||
|
||||
#ifdef __CHECKER__
|
||||
#ifndef __bitwise
|
||||
#define __bitwise __attribute__((bitwise))
|
||||
#endif
|
||||
#define __force __attribute__((force))
|
||||
#else
|
||||
#ifndef __bitwise
|
||||
#define __bitwise
|
||||
#endif
|
||||
#define __force
|
||||
#endif
|
||||
|
||||
typedef __u16 __bitwise __le16;
|
||||
typedef __u32 __bitwise __le32;
|
||||
typedef __u64 __bitwise __le64;
|
||||
typedef __u16 __bitwise __be16;
|
||||
typedef __u32 __bitwise __be32;
|
||||
typedef __u64 __bitwise __be64;
|
||||
|
||||
#endif /* EXT2_ENDIAN_H_ */
|
||||
54
include/e2fsprogs/uuid/uuidd.h
Executable file
54
include/e2fsprogs/uuid/uuidd.h
Executable file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Definitions used by the uuidd daemon
|
||||
*
|
||||
* Copyright (C) 2007 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, and the entire permission notice in its entirety,
|
||||
* including the disclaimer of warranties.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
|
||||
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _UUID_UUIDD_H
|
||||
#define _UUID_UUIDD_H
|
||||
|
||||
#define UUIDD_DIR "/var/lib/libuuid"
|
||||
#define UUIDD_SOCKET_PATH UUIDD_DIR "/request"
|
||||
#define UUIDD_PIDFILE_PATH UUIDD_DIR "/uuidd.pid"
|
||||
#define UUIDD_PATH "/usr/sbin/uuidd"
|
||||
|
||||
#define UUIDD_OP_GETPID 0
|
||||
#define UUIDD_OP_GET_MAXOP 1
|
||||
#define UUIDD_OP_TIME_UUID 2
|
||||
#define UUIDD_OP_RANDOM_UUID 3
|
||||
#define UUIDD_OP_BULK_TIME_UUID 4
|
||||
#define UUIDD_OP_BULK_RANDOM_UUID 5
|
||||
#define UUIDD_MAX_OP UUIDD_OP_BULK_RANDOM_UUID
|
||||
|
||||
extern void uuid__generate_time(uuid_t out, int *num);
|
||||
extern void uuid__generate_random(uuid_t out, int *num);
|
||||
|
||||
#endif /* _UUID_UUID_H */
|
||||
13
include/e2fsprogs/version.h
Executable file
13
include/e2fsprogs/version.h
Executable file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* version.h --- controls the version number printed by the e2fs
|
||||
* programs.
|
||||
*
|
||||
* Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
* 2004, 2005, 2006, 2007, 2008, 2009, 2010 by Theodore Ts'o. This
|
||||
* file may be redistributed under the GNU Public License v2.
|
||||
*/
|
||||
|
||||
#define E2FSPROGS_VERSION "1.46.6 [pmt-static]"
|
||||
#define E2FSPROGS_VERSION_PRIVATE "1.46.6"
|
||||
#define EXT2FS_LIB_VERSION_PRIVATE "android-static-369-g8ed4b2673"
|
||||
#define E2FSPROGS_DATE "1-Feb-2023"
|
||||
Reference in New Issue
Block a user