From 0d6bbb0497016d23e1e480a47b2e0823918de021 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 27 Mar 2012 14:32:48 +0200 Subject: hush: remove unused member struct command::is_stopped function old new delta builtin_umask 133 132 -1 checkjobs 551 544 -7 builtin_fg_bg 291 267 -24 Signed-off-by: Denys Vlasenko --- shell/hush.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 7a34f59ae..180ae4a62 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -524,7 +524,6 @@ typedef enum redir_type { struct command { pid_t pid; /* 0 if exited */ int assignment_cnt; /* how many argv[i] are assignments? */ - smallint is_stopped; /* is the command currently running? */ smallint cmd_type; /* CMD_xxx */ #define CMD_NORMAL 0 #define CMD_SUBSHELL 1 @@ -6767,7 +6766,6 @@ static int checkjobs(struct pipe *fg_pipe) } fg_pipe->cmds[i].cmd_exitcode = ex; } else { - fg_pipe->cmds[i].is_stopped = 1; fg_pipe->stopped_cmds++; } debug_printf_jobs("fg_pipe: alive_cmds %d stopped_cmds %d\n", @@ -6828,7 +6826,6 @@ static int checkjobs(struct pipe *fg_pipe) } } else { /* child stopped */ - pi->cmds[i].is_stopped = 1; pi->stopped_cmds++; } #endif @@ -8596,7 +8593,6 @@ static int FAST_FUNC builtin_fg_bg(char **argv) debug_printf_jobs("reviving %d procs, pgrp %d\n", pi->num_cmds, pi->pgrp); for (i = 0; i < pi->num_cmds; i++) { debug_printf_jobs("reviving pid %d\n", pi->cmds[i].pid); - pi->cmds[i].is_stopped = 0; } pi->stopped_cmds = 0; -- cgit v1.2.3-55-g6feb From b1b70969e06658555d07d5cab40fb8a70c251e1b Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 30 Mar 2012 19:14:27 +0200 Subject: bloat-o-meter: handle huge (hex) sizes. dynamic symbols with size >99999 are printed in hex. see print_vma(psym->st_size, DEC_5) Signed-off-by: Bernhard Reutner-Fischer --- scripts/bloat-o-meter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 0d3ff7f5e..d095b27b5 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter @@ -57,7 +57,7 @@ def getsizes(file): # if typ in ["SECTION", "FILES"]: continue # skip sections and files if "." in name: name = "static." + name.split(".")[0] value = int(value, 16) - size = int(size) + size = int(size, 16) if size.startswith('0x') else int(size) if vis != "DEFAULT" and bind != "GLOBAL": # see if it is an alias alias[(value, size)] = {"name" : name} else: -- cgit v1.2.3-55-g6feb From 25dbb0743e58fc91ecb7ff5c793c5519eec45494 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 30 Mar 2012 19:50:39 +0200 Subject: bloat-o-meter: Remove unused code The regex matching is way slower, so remove it since it was disabled anyway. Signed-off-by: Bernhard Reutner-Fischer --- scripts/bloat-o-meter | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index d095b27b5..6db2a5e58 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter @@ -39,22 +39,13 @@ if f1 is None or f2 is None: sym_args = " ".join(sys.argv[3 + flag_timing + dashes:]) def getsizes(file): sym, alias, lut = {}, {}, {} - #dynsym_filter = re.compile("^\d+:\s+[\dA-Fa-f]+\s+\d+\s+\w+\s+\w+\s+\w+\s+\w+\s+\w+$") for l in os.popen("readelf -W -s %s %s" % (sym_args, file)).readlines(): - if True: - l = l.strip() - if not (len(l) and l[0].isdigit() and len(l.split()) == 8): - continue - num, value, size, typ, bind, vis, ndx, name = l.split() - if ndx == "UND": continue # skip undefined - if typ in ["SECTION", "FILES"]: continue # skip sections and files - #else: - # l = l.strip() - # match = dynsym_filter.match(l) - # if not match: continue - # x, value, size, typ, bind, x, ndx, name = l.split() - # if ndx == "UND": continue # skip undefined - # if typ in ["SECTION", "FILES"]: continue # skip sections and files + l = l.strip() + if not (len(l) and l[0].isdigit() and len(l.split()) == 8): + continue + num, value, size, typ, bind, vis, ndx, name = l.split() + if ndx == "UND": continue # skip undefined + if typ in ["SECTION", "FILES"]: continue # skip sections and files if "." in name: name = "static." + name.split(".")[0] value = int(value, 16) size = int(size, 16) if size.startswith('0x') else int(size) -- cgit v1.2.3-55-g6feb From 1c12b67705a4a2d5854d5e62fcbd2b241852ffe9 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll Date: Sun, 1 Apr 2012 16:23:23 +0200 Subject: lsof: new applet text data bss dec hex filename 221 0 0 221 dd lsof.o Signed-off-by: Sven Oliver Moll Signed-off-by: souf Signed-off-by: Tito Ragusa Signed-off-by: Denys Vlasenko --- procps/lsof.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 procps/lsof.c diff --git a/procps/lsof.c b/procps/lsof.c new file mode 100644 index 000000000..7e0ffa4e5 --- /dev/null +++ b/procps/lsof.c @@ -0,0 +1,76 @@ +/* vi: set sw=4 ts=4: */ +/* + * Mini lsof implementation for busybox + * + * Copyright (C) 2012 by Sven Oliver 'SvOlli' Moll + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ + +//config:config LSOF +//config: bool "lsof" +//config: default y +//config: help +//config: Show open files in the format of: +//config: PID /path/to/executable /path/to/opened/file + +//applet:IF_LSOF(APPLET(lsof, BB_DIR_USR_BIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_LSOF) += lsof.o + +//usage:#define lsof_trivial_usage +//usage: "" +//usage:#define lsof_full_usage "\n\n" +//usage: "Show all open files" + +#include "libbb.h" + +/* + * Examples of "standard" lsof output: + * + * COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME + * init 1 root cwd DIR 8,5 4096 2 / + * init 1 root rtd DIR 8,5 4096 2 / + * init 1 root txt REG 8,5 872400 63408 /app/busybox-1.19.2/busybox + * rpc.portm 1064 root mem REG 8,5 43494 47451 /app/glibc-2.11/lib/libnss_files-2.11.so + * rpc.portm 1064 root 3u IPv4 2178 UDP *:111 + * rpc.portm 1064 root 4u IPv4 1244 TCP *:111 (LISTEN) + * runsvdir 1116 root 0r CHR 1,3 1214 /dev/null + * runsvdir 1116 root 1w CHR 1,3 1214 /dev/null + * runsvdir 1116 root 2w CHR 1,3 1214 /dev/null + * runsvdir 1116 root 3r DIR 8,6 1560 58359 /.local/var/service + * gpm 1128 root 4u unix 0xffff88007c09ccc0 1302 /dev/gpmctl + */ + +int lsof_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int lsof_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) +{ + procps_status_t *proc = NULL; + + while ((proc = procps_scan(proc, PSSCAN_PID|PSSCAN_EXE)) != NULL) { + char name[sizeof("/proc/%u/fd/0123456789") + sizeof(int)*3]; + unsigned baseofs; + DIR *d_fd; + char *fdlink; + struct dirent *entry; + + if (getpid() == proc->pid) + continue; + + baseofs = sprintf(name, "/proc/%u/fd/", proc->pid); + d_fd = opendir(name); + if (d_fd) { + while ((entry = readdir(d_fd)) != NULL) { + if (entry->d_type == DT_LNK) { + safe_strncpy(name + baseofs, entry->d_name, 10); + fdlink = xmalloc_readlink(name); + printf("%d\t%s\t%s\n", proc->pid, proc->exe, fdlink); + free(fdlink); + } + } + closedir(d_fd); + } + } + + return EXIT_SUCCESS; +} -- cgit v1.2.3-55-g6feb From 3e3a8d50b3d9190c7b06787cb7639b53644e66c7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 1 Apr 2012 16:31:04 +0200 Subject: ntpd: fix build failure if !NTPD_SERVER. Closes 4994 Signed-off-by: Denys Vlasenko --- networking/ntpd.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/networking/ntpd.c b/networking/ntpd.c index 4d939458c..603801ec6 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -276,6 +276,9 @@ struct globals { llist_t *ntp_peers; #if ENABLE_FEATURE_NTPD_SERVER int listen_fd; +# define G_listen_fd (G.listen_fd) +#else +# define G_listen_fd (-1) #endif unsigned verbose; unsigned peer_cnt; @@ -1815,10 +1818,10 @@ recv_and_process_client_pkt(void /*int fd*/) uint8_t query_status; l_fixedpt_t query_xmttime; - to = get_sock_lsa(G.listen_fd); + to = get_sock_lsa(G_listen_fd); from = xzalloc(to->len); - size = recv_from_to(G.listen_fd, &msg, sizeof(msg), MSG_DONTWAIT, from, &to->u.sa, to->len); + size = recv_from_to(G_listen_fd, &msg, sizeof(msg), MSG_DONTWAIT, from, &to->u.sa, to->len); if (size != NTP_MSGSIZE_NOAUTH && size != NTP_MSGSIZE) { char *addr; if (size < 0) { @@ -1861,7 +1864,7 @@ recv_and_process_client_pkt(void /*int fd*/) /* We reply from the local address packet was sent to, * this makes to/from look swapped here: */ - do_sendto(G.listen_fd, + do_sendto(G_listen_fd, /*from:*/ &to->u.sa, /*to:*/ from, /*addrlen:*/ to->len, &msg, size); @@ -2000,11 +2003,11 @@ static NOINLINE void ntp_init(char **argv) logmode = LOGMODE_NONE; } #if ENABLE_FEATURE_NTPD_SERVER - G.listen_fd = -1; + G_listen_fd = -1; if (opts & OPT_l) { - G.listen_fd = create_and_bind_dgram_or_die(NULL, 123); - socket_want_pktinfo(G.listen_fd); - setsockopt(G.listen_fd, IPPROTO_IP, IP_TOS, &const_IPTOS_LOWDELAY, sizeof(const_IPTOS_LOWDELAY)); + G_listen_fd = create_and_bind_dgram_or_die(NULL, 123); + socket_want_pktinfo(G_listen_fd); + setsockopt(G_listen_fd, IPPROTO_IP, IP_TOS, &const_IPTOS_LOWDELAY, sizeof(const_IPTOS_LOWDELAY)); } #endif /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */ @@ -2078,8 +2081,8 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) i = 0; #if ENABLE_FEATURE_NTPD_SERVER - if (G.listen_fd != -1) { - pfd[0].fd = G.listen_fd; + if (G_listen_fd != -1) { + pfd[0].fd = G_listen_fd; pfd[0].events = POLLIN; i++; } @@ -2125,7 +2128,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) /* Here we may block */ VERB2 { - if (i > (ENABLE_FEATURE_NTPD_SERVER && G.listen_fd != -1)) { + if (i > (ENABLE_FEATURE_NTPD_SERVER && G_listen_fd != -1)) { /* We wait for at least one reply. * Poll for it, without wasting time for message. * Since replies often come under 1 second, this also -- cgit v1.2.3-55-g6feb From 1d9e99b399e72763045a2428e04b32278538ccc7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 1 Apr 2012 16:52:21 +0200 Subject: hostname: make -i not emit extra trailing space Signed-off-by: Denys Vlasenko --- networking/hostname.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/hostname.c b/networking/hostname.c index 5f663908c..d2516b5fb 100644 --- a/networking/hostname.c +++ b/networking/hostname.c @@ -153,7 +153,7 @@ int hostname_main(int argc UNUSED_PARAM, char **argv) if (hp->h_length == sizeof(struct in_addr)) { struct in_addr **h_addr_list = (struct in_addr **)hp->h_addr_list; while (*h_addr_list) { - printf("%s ", inet_ntoa(**h_addr_list)); + printf(h_addr_list[1] ? "%s " : "%s", inet_ntoa(**h_addr_list)); h_addr_list++; } bb_putchar('\n'); -- cgit v1.2.3-55-g6feb From 7a4269329fa05411b477b540beebf18af90e9b42 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Tue, 3 Apr 2012 08:09:28 +0200 Subject: httpd: emit correct content length on range requests past the end. Closes 4952 Signed-off-by: Rob Walker Signed-off-by: Denys Vlasenko --- networking/httpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/httpd.c b/networking/httpd.c index f233cb0ba..fb6ecbf70 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1594,7 +1594,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) } range_len = MAXINT(off_t); if (range_start >= 0) { - if (!range_end) { + if (!range_end || range_end > file_size - 1) { range_end = file_size - 1; } if (range_end < range_start -- cgit v1.2.3-55-g6feb From 14850308e902594785e6789a4f28677103ca2096 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Apr 2012 08:16:05 +0200 Subject: killall5: don't do STOP/CONT dance if the signal we send is SIGSTOP or SIGCONT function old new delta kill_main 913 942 +29 Signed-off-by: Denys Vlasenko --- procps/kill.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/procps/kill.c b/procps/kill.c index b267a7aaf..cd189bcd6 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -163,7 +163,8 @@ int kill_main(int argc, char **argv) /* Find out our session id */ sid = getsid(pid); /* Stop all processes */ - kill(-1, SIGSTOP); + if (signo != SIGSTOP && signo != SIGCONT) + kill(-1, SIGSTOP); /* Signal all processes except those in our session */ while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID)) != NULL) { int i; @@ -203,7 +204,8 @@ int kill_main(int argc, char **argv) } resume: /* And let them continue */ - kill(-1, SIGCONT); + if (signo != SIGSTOP && signo != SIGCONT) + kill(-1, SIGCONT); return ret; } -- cgit v1.2.3-55-g6feb From caf5768154301697430f0a3718838967d0f55f95 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 12 Apr 2012 14:01:10 +0200 Subject: work around linux/ext2_fs.h breakage See https://bugzilla.kernel.org/show_bug.cgi?id=42986 Signed-off-by: Denys Vlasenko --- e2fsprogs/tune2fs.c | 6 ++++++ util-linux/mkfs_ext2.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 020bdaa33..8da7432d9 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c @@ -8,6 +8,12 @@ */ #include "libbb.h" #include +/* + * Work around linux/ext2_fs.h breakage. + * See https://bugzilla.kernel.org/show_bug.cgi?id=42986. + */ +typedef mode_t bb__umode_t; +#define umode_t bb__umode_t #include // storage helpers diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 6cbbe0e07..759bb0a7a 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -48,6 +48,12 @@ #include "libbb.h" #include +/* + * Work around linux/ext2_fs.h breakage. + * See https://bugzilla.kernel.org/show_bug.cgi?id=42986. + */ +typedef mode_t bb__umode_t; +#define umode_t bb__umode_t #include #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0 -- cgit v1.2.3-55-g6feb From 0b2b0f31a38d77ebfb2a6416011562687ef58191 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 13 Apr 2012 16:39:18 +0200 Subject: Create and use our own copy of linux/ext2_fs.h Signed-off-by: Denys Vlasenko --- e2fsprogs/tune2fs.c | 8 +- include/bb_linux_ext2_fs.h | 547 +++++++++++++++++++++++++++++++++++++++++++++ util-linux/mkfs_ext2.c | 8 +- 3 files changed, 549 insertions(+), 14 deletions(-) create mode 100644 include/bb_linux_ext2_fs.h diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 8da7432d9..841d58a9c 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c @@ -8,13 +8,7 @@ */ #include "libbb.h" #include -/* - * Work around linux/ext2_fs.h breakage. - * See https://bugzilla.kernel.org/show_bug.cgi?id=42986. - */ -typedef mode_t bb__umode_t; -#define umode_t bb__umode_t -#include +#include "bb_linux_ext2_fs.h" // storage helpers char BUG_wrong_field_size(void); diff --git a/include/bb_linux_ext2_fs.h b/include/bb_linux_ext2_fs.h new file mode 100644 index 000000000..fdc470bc2 --- /dev/null +++ b/include/bb_linux_ext2_fs.h @@ -0,0 +1,547 @@ +/* + * Work around linux/ext2_fs.h breakage. + * linux/ext2_fs.h might be removed from future kernel header distribution. + * See https://bugzilla.kernel.org/show_bug.cgi?id=42986 + * + * Licensed under GPLv2, see file LICENSE in this source tree. + */ +#ifndef BB_LINUX_EXT2_FS_H +#define BB_LINUX_EXT2_FS_H + +/* + * From linux/magic.h + */ + +#define EXT2_SUPER_MAGIC 0xEF53 +#define EXT3_SUPER_MAGIC 0xEF53 +#define EXT4_SUPER_MAGIC 0xEF53 + +/* + * From linux/ext2_fs.h, with minor changes. + */ + +/* + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/include/linux/minix_fs.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* + * The second extended filesystem constants/structures + */ + +/* + * Define EXT2_RESERVATION to reserve data blocks for expanding files + */ +#define EXT2_DEFAULT_RESERVE_BLOCKS 8 +/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ +#define EXT2_MAX_RESERVE_BLOCKS 1027 +#define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0 + +/* + * Special inode numbers + */ +#define EXT2_BAD_INO 1 /* Bad blocks inode */ +#define EXT2_ROOT_INO 2 /* Root inode */ +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ + +/* First non-reserved inode for old ext2 filesystems */ +#define EXT2_GOOD_OLD_FIRST_INO 11 + +/* Assume that user mode programs are passing in an ext2fs superblock, not + * a kernel struct super_block. This will allow us to call the feature-test + * macros from user land. */ +#define EXT2_SB(sb) (sb) + +/* + * Maximal count of links to a file + */ +#define EXT2_LINK_MAX 32000 + +/* + * Macro-instructions used to manage several block sizes + */ +#define EXT2_MIN_BLOCK_SIZE 1024 +#define EXT2_MAX_BLOCK_SIZE 4096 +#define EXT2_MIN_BLOCK_LOG_SIZE 10 +# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (uint32_t)) +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) +#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ + EXT2_GOOD_OLD_INODE_SIZE : \ + (s)->s_inode_size) +#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ + EXT2_GOOD_OLD_FIRST_INO : \ + (s)->s_first_ino) + +/* + * Macro-instructions used to manage fragments + */ +#define EXT2_MIN_FRAG_SIZE 1024 +#define EXT2_MAX_FRAG_SIZE 4096 +#define EXT2_MIN_FRAG_LOG_SIZE 10 +# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) + +/* + * Structure of a blocks group descriptor + */ +struct ext2_group_desc +{ + uint32_t bg_block_bitmap; /* Blocks bitmap block */ + uint32_t bg_inode_bitmap; /* Inodes bitmap block */ + uint32_t bg_inode_table; /* Inodes table block */ + uint16_t bg_free_blocks_count; /* Free blocks count */ + uint16_t bg_free_inodes_count; /* Free inodes count */ + uint16_t bg_used_dirs_count; /* Directories count */ + uint16_t bg_pad; + uint32_t bg_reserved[3]; +}; + +/* + * Macro-instructions used to manage group descriptors + */ +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) +# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) + +/* + * Constants relative to the data blocks + */ +#define EXT2_NDIR_BLOCKS 12 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) + +/* + * Inode flags (GETFLAGS/SETFLAGS) + */ +#define EXT2_SECRM_FL FS_SECRM_FL /* Secure deletion */ +#define EXT2_UNRM_FL FS_UNRM_FL /* Undelete */ +#define EXT2_COMPR_FL FS_COMPR_FL /* Compress file */ +#define EXT2_SYNC_FL FS_SYNC_FL /* Synchronous updates */ +#define EXT2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */ +#define EXT2_APPEND_FL FS_APPEND_FL /* writes to file may only append */ +#define EXT2_NODUMP_FL FS_NODUMP_FL /* do not dump file */ +#define EXT2_NOATIME_FL FS_NOATIME_FL /* do not update atime */ +/* Reserved for compression usage... */ +#define EXT2_DIRTY_FL FS_DIRTY_FL +#define EXT2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */ +#define EXT2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */ +#define EXT2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */ +/* End compression flags --- maybe not all used */ +#define EXT2_BTREE_FL FS_BTREE_FL /* btree format dir */ +#define EXT2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */ +#define EXT2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */ +#define EXT2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */ +#define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */ +#define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */ +#define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/ +#define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */ + +#define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */ +#define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */ + +/* Flags that should be inherited by new inodes from their parent. */ +#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\ + EXT2_SYNC_FL | EXT2_IMMUTABLE_FL | EXT2_APPEND_FL |\ + EXT2_NODUMP_FL | EXT2_NOATIME_FL | EXT2_COMPRBLK_FL|\ + EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\ + EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL) + +/* Flags that are appropriate for regular files (all but dir-specific ones). */ +#define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL)) + +/* Flags that are appropriate for non-directories/regular files. */ +#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL) + +/* Mask out flags that are inappropriate for the given type of inode. */ +static inline uint32_t ext2_mask_flags(mode_t mode, uint32_t flags) +{ + if (S_ISDIR(mode)) + return flags; + else if (S_ISREG(mode)) + return flags & EXT2_REG_FLMASK; + else + return flags & EXT2_OTHER_FLMASK; +} + +/* + * ioctl commands + */ +#define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS +#define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS +#define EXT2_IOC_GETVERSION FS_IOC_GETVERSION +#define EXT2_IOC_SETVERSION FS_IOC_SETVERSION +#define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) +#define EXT2_IOC_SETRSVSZ _IOW('f', 6, long) + +/* + * ioctl commands in 32 bit emulation + */ +#define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS +#define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS +#define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION +#define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION + +/* + * Structure of an inode on the disk + */ +struct ext2_inode { + uint16_t i_mode; /* File mode */ + uint16_t i_uid; /* Low 16 bits of Owner Uid */ + uint32_t i_size; /* Size in bytes */ + uint32_t i_atime; /* Access time */ + uint32_t i_ctime; /* Creation time */ + uint32_t i_mtime; /* Modification time */ + uint32_t i_dtime; /* Deletion Time */ + uint16_t i_gid; /* Low 16 bits of Group Id */ + uint16_t i_links_count; /* Links count */ + uint32_t i_blocks; /* Blocks count */ + uint32_t i_flags; /* File flags */ + union { + struct { + uint32_t l_i_reserved1; + } linux1; + struct { + uint32_t h_i_translator; + } hurd1; + struct { + uint32_t m_i_reserved1; + } masix1; + } osd1; /* OS dependent 1 */ + uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + uint32_t i_generation; /* File version (for NFS) */ + uint32_t i_file_acl; /* File ACL */ + uint32_t i_dir_acl; /* Directory ACL */ + uint32_t i_faddr; /* Fragment address */ + union { + struct { + uint8_t l_i_frag; /* Fragment number */ + uint8_t l_i_fsize; /* Fragment size */ + uint16_t i_pad1; + uint16_t l_i_uid_high; /* these 2 fields */ + uint16_t l_i_gid_high; /* were reserved2[0] */ + uint32_t l_i_reserved2; + } linux2; + struct { + uint8_t h_i_frag; /* Fragment number */ + uint8_t h_i_fsize; /* Fragment size */ + uint16_t h_i_mode_high; + uint16_t h_i_uid_high; + uint16_t h_i_gid_high; + uint32_t h_i_author; + } hurd2; + struct { + uint8_t m_i_frag; /* Fragment number */ + uint8_t m_i_fsize; /* Fragment size */ + uint16_t m_pad1; + uint32_t m_i_reserved2[2]; + } masix2; + } osd2; /* OS dependent 2 */ +}; + +#define i_size_high i_dir_acl + +#if defined(__KERNEL__) || defined(__linux__) +#define i_reserved1 osd1.linux1.l_i_reserved1 +#define i_frag osd2.linux2.l_i_frag +#define i_fsize osd2.linux2.l_i_fsize +#define i_uid_low i_uid +#define i_gid_low i_gid +#define i_uid_high osd2.linux2.l_i_uid_high +#define i_gid_high osd2.linux2.l_i_gid_high +#define i_reserved2 osd2.linux2.l_i_reserved2 +#endif + +#ifdef __hurd__ +#define i_translator osd1.hurd1.h_i_translator +#define i_frag osd2.hurd2.h_i_frag +#define i_fsize osd2.hurd2.h_i_fsize +#define i_uid_high osd2.hurd2.h_i_uid_high +#define i_gid_high osd2.hurd2.h_i_gid_high +#define i_author osd2.hurd2.h_i_author +#endif + +#ifdef __masix__ +#define i_reserved1 osd1.masix1.m_i_reserved1 +#define i_frag osd2.masix2.m_i_frag +#define i_fsize osd2.masix2.m_i_fsize +#define i_reserved2 osd2.masix2.m_i_reserved2 +#endif + +/* + * File system states + */ +#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ +#define EXT2_ERROR_FS 0x0002 /* Errors detected */ + +/* + * Mount flags + */ +#define EXT2_MOUNT_CHECK 0x000001 /* Do mount-time checks */ +#define EXT2_MOUNT_OLDALLOC 0x000002 /* Don't use the new Orlov allocator */ +#define EXT2_MOUNT_GRPID 0x000004 /* Create files with directory's group */ +#define EXT2_MOUNT_DEBUG 0x000008 /* Some debugging messages */ +#define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */ +#define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */ +#define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */ +#define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */ +#define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */ +#define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */ +#define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */ +#define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */ +#define EXT2_MOUNT_XIP 0x010000 /* Execute in place */ +#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */ +#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */ +#define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */ + + +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt +#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ + EXT2_MOUNT_##opt) +/* + * Maximal mount counts between two filesystem checks + */ +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ + +/* + * Behaviour when detecting errors + */ +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ +#define EXT2_ERRORS_PANIC 3 /* Panic */ +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE + +/* + * Structure of the super block + */ +struct ext2_super_block { + uint32_t s_inodes_count; /* Inodes count */ + uint32_t s_blocks_count; /* Blocks count */ + uint32_t s_r_blocks_count; /* Reserved blocks count */ + uint32_t s_free_blocks_count; /* Free blocks count */ + uint32_t s_free_inodes_count; /* Free inodes count */ + uint32_t s_first_data_block; /* First Data Block */ + uint32_t s_log_block_size; /* Block size */ + uint32_t s_log_frag_size; /* Fragment size */ + uint32_t s_blocks_per_group; /* # Blocks per group */ + uint32_t s_frags_per_group; /* # Fragments per group */ + uint32_t s_inodes_per_group; /* # Inodes per group */ + uint32_t s_mtime; /* Mount time */ + uint32_t s_wtime; /* Write time */ + uint16_t s_mnt_count; /* Mount count */ + uint16_t s_max_mnt_count; /* Maximal mount count */ + uint16_t s_magic; /* Magic signature */ + uint16_t s_state; /* File system state */ + uint16_t s_errors; /* Behaviour when detecting errors */ + uint16_t s_minor_rev_level; /* minor revision level */ + uint32_t s_lastcheck; /* time of last check */ + uint32_t s_checkinterval; /* max. time between checks */ + uint32_t s_creator_os; /* OS */ + uint32_t s_rev_level; /* Revision level */ + uint16_t s_def_resuid; /* Default uid for reserved blocks */ + uint16_t s_def_resgid; /* Default gid for reserved blocks */ + /* + * These fields are for EXT2_DYNAMIC_REV superblocks only. + * + * Note: the difference between the compatible feature set and + * the incompatible feature set is that if there is a bit set + * in the incompatible feature set that the kernel doesn't + * know about, it should refuse to mount the filesystem. + * + * e2fsck's requirements are more strict; if it doesn't know + * about a feature in either the compatible or incompatible + * feature set, it must abort and not try to meddle with + * things it doesn't understand... + */ + uint32_t s_first_ino; /* First non-reserved inode */ + uint16_t s_inode_size; /* size of inode structure */ + uint16_t s_block_group_nr; /* block group # of this superblock */ + uint32_t s_feature_compat; /* compatible feature set */ + uint32_t s_feature_incompat; /* incompatible feature set */ + uint32_t s_feature_ro_compat; /* readonly-compatible feature set */ + uint8_t s_uuid[16]; /* 128-bit uuid for volume */ + char s_volume_name[16]; /* volume name */ + char s_last_mounted[64]; /* directory where last mounted */ + uint32_t s_algorithm_usage_bitmap; /* For compression */ + /* + * Performance hints. Directory preallocation should only + * happen if the EXT2_COMPAT_PREALLOC flag is on. + */ + uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ + uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ + uint16_t s_padding1; + /* + * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. + */ + uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ + uint32_t s_journal_inum; /* inode number of journal file */ + uint32_t s_journal_dev; /* device number of journal file */ + uint32_t s_last_orphan; /* start of list of inodes to delete */ + uint32_t s_hash_seed[4]; /* HTREE hash seed */ + uint8_t s_def_hash_version; /* Default hash version to use */ + uint8_t s_reserved_char_pad; + uint16_t s_reserved_word_pad; + uint32_t s_default_mount_opts; + uint32_t s_first_meta_bg; /* First metablock block group */ + uint32_t s_reserved[190]; /* Padding to the end of the block */ +}; + +/* + * Codes for operating systems + */ +#define EXT2_OS_LINUX 0 +#define EXT2_OS_HURD 1 +#define EXT2_OS_MASIX 2 +#define EXT2_OS_FREEBSD 3 +#define EXT2_OS_LITES 4 + +/* + * Revision levels + */ +#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ +#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ + +#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV +#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV + +#define EXT2_GOOD_OLD_INODE_SIZE 128 + +/* + * Feature set definitions + */ + +#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) ) +#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) ) +#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) ) +#define EXT2_SET_COMPAT_FEATURE(sb,mask) \ + EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask) +#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \ + EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask) +#define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \ + EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask) +#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \ + EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask) +#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ + EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask) +#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ + EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask) + +#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 +#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 +#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 +#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 +#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 +#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 +#define EXT2_FEATURE_COMPAT_ANY 0xffffffff + +#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 EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff + +#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 +#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 EXT2_FEATURE_INCOMPAT_ANY 0xffffffff + +#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR +#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \ + EXT2_FEATURE_INCOMPAT_META_BG) +#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_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP +#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP + +/* + * Default values for user and/or group using reserved blocks + */ +#define EXT2_DEF_RESUID 0 +#define EXT2_DEF_RESGID 0 + +/* + * Default mount options + */ +#define EXT2_DEFM_DEBUG 0x0001 +#define EXT2_DEFM_BSDGROUPS 0x0002 +#define EXT2_DEFM_XATTR_USER 0x0004 +#define EXT2_DEFM_ACL 0x0008 +#define EXT2_DEFM_UID16 0x0010 + /* Not used by ext2, but reserved for use by ext3 */ +#define EXT3_DEFM_JMODE 0x0060 +#define EXT3_DEFM_JMODE_DATA 0x0020 +#define EXT3_DEFM_JMODE_ORDERED 0x0040 +#define EXT3_DEFM_JMODE_WBACK 0x0060 + +/* + * Structure of a directory entry + */ +#define EXT2_NAME_LEN 255 + +struct ext2_dir_entry { + uint32_t inode; /* Inode number */ + uint16_t rec_len; /* Directory entry length */ + uint16_t name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * The new version of the directory entry. Since EXT2 structures are + * stored in intel byte order, and the name_len field could never be + * bigger than 255 chars, it's safe to reclaim the extra byte for the + * file_type field. + */ +struct ext2_dir_entry_2 { + uint32_t inode; /* Inode number */ + uint16_t rec_len; /* Directory entry length */ + uint8_t name_len; /* Name length */ + uint8_t file_type; + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * Ext2 directory file types. Only the low 3 bits are used. The + * other bits are reserved for now. + */ +enum { + EXT2_FT_UNKNOWN = 0, + EXT2_FT_REG_FILE = 1, + EXT2_FT_DIR = 2, + EXT2_FT_CHRDEV = 3, + EXT2_FT_BLKDEV = 4, + EXT2_FT_FIFO = 5, + EXT2_FT_SOCK = 6, + EXT2_FT_SYMLINK = 7, + EXT2_FT_MAX +}; + +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ + ~EXT2_DIR_ROUND) +#define EXT2_MAX_REC_LEN ((1<<16)-1) + +#endif diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 759bb0a7a..2d9d72000 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -48,13 +48,7 @@ #include "libbb.h" #include -/* - * Work around linux/ext2_fs.h breakage. - * See https://bugzilla.kernel.org/show_bug.cgi?id=42986. - */ -typedef mode_t bb__umode_t; -#define umode_t bb__umode_t -#include +#include "bb_linux_ext2_fs.h" #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0 #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1 -- cgit v1.2.3-55-g6feb From ee0d4cd8cb64a4ef7f10a89c7d51145d44cc6d49 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 12:28:13 +0200 Subject: Tweak INSTALL text Signed-off-by: Denys Vlasenko --- INSTALL | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index f93e5fb25..750cfc45b 100644 --- a/INSTALL +++ b/INSTALL @@ -47,8 +47,11 @@ the only commands busybox can find are the built-in ones. Note that the standalone shell requires CONFIG_BUSYBOX_EXEC_PATH to be set appropriately, depending on whether or not /proc/self/exe is -available or not. If you do not have /proc, then point that config option +available. If you do not have /proc, then point that config option to the location of your busybox binary, usually /bin/busybox. +Another solution is to patch the kernel (see +examples/linux-*_proc_self_exe.patch) to make exec("/proc/self/exe") +always work. Configuring Busybox: ==================== -- cgit v1.2.3-55-g6feb From 86a03bee1d3d6990c03bf500836b19ec8a1c1f12 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 13:07:28 +0200 Subject: umount: make -d always active, add -D to suppress it Signed-off-by: Denys Vlasenko --- util-linux/umount.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/util-linux/umount.c b/util-linux/umount.c index 5b716c688..4c2e8821e 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -22,7 +22,7 @@ //usage: "\n -l Lazy umount (detach filesystem)" //usage: "\n -f Force umount (i.e., unreachable NFS server)" //usage: IF_FEATURE_MOUNT_LOOP( -//usage: "\n -d Free loop device if it has been used" +//usage: "\n -D Don't free loop device even if it has been used" //usage: ) //usage: //usage:#define umount_example_usage @@ -44,14 +44,22 @@ static struct mntent *getmntent_r(FILE* stream, struct mntent* result, } #endif -/* ignored: -v -d -t -i */ -#define OPTION_STRING "fldnra" "vdt:i" +/* Ignored: -v -t -i + * bbox always acts as if -d is present. + * -D can be used to suppress it (bbox extension). + * Rationale: + * (1) util-linux's umount does it if "loop=..." is seen in /etc/mtab: + * thus, on many systems, bare umount _does_ drop loop devices. + * (2) many users request this feature. + */ +#define OPTION_STRING "fldDnra" "vt:i" #define OPT_FORCE (1 << 0) // Same as MNT_FORCE #define OPT_LAZY (1 << 1) // Same as MNT_DETACH -#define OPT_FREELOOP (1 << 2) -#define OPT_NO_MTAB (1 << 3) -#define OPT_REMOUNT (1 << 4) -#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? (1 << 5) : 0) +//#define OPT_FREE_LOOP (1 << 2) // -d is assumed always present +#define OPT_DONT_FREE_LOOP (1 << 3) +#define OPT_NO_MTAB (1 << 4) +#define OPT_REMOUNT (1 << 5) +#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? (1 << 6) : 0) int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int umount_main(int argc UNUSED_PARAM, char **argv) @@ -165,7 +173,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv) } else { // De-allocate the loop device. This ioctl should be ignored on // any non-loop block devices. - if (ENABLE_FEATURE_MOUNT_LOOP && (opt & OPT_FREELOOP) && m) + if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONT_FREE_LOOP) && m) del_loop(m->device); if (ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m) erase_mtab(m->dir); -- cgit v1.2.3-55-g6feb From 176bc344751dfc41e87976182381ae0560c94f22 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 15:06:55 +0200 Subject: Drop include/bb_linux_ext2_fs.h, use existing e2fsprogs/e2fs_defs.h Signed-off-by: Denys Vlasenko --- e2fsprogs/e2fs_defs.h | 561 ---------------------------- e2fsprogs/e2fs_lib.h | 2 +- e2fsprogs/old_e2fsprogs/e2fsck.c | 6 +- e2fsprogs/old_e2fsprogs/e2p/feature.c | 2 +- e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h | 2 +- e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h | 2 +- e2fsprogs/old_e2fsprogs/ext2fs/initialize.c | 2 +- e2fsprogs/old_e2fsprogs/mke2fs.c | 8 +- e2fsprogs/tune2fs.c | 2 +- include/bb_e2fs_defs.h | 561 ++++++++++++++++++++++++++++ include/bb_linux_ext2_fs.h | 547 --------------------------- util-linux/mkfs_ext2.c | 2 +- 12 files changed, 575 insertions(+), 1122 deletions(-) delete mode 100644 e2fsprogs/e2fs_defs.h create mode 100644 include/bb_e2fs_defs.h delete mode 100644 include/bb_linux_ext2_fs.h diff --git a/e2fsprogs/e2fs_defs.h b/e2fsprogs/e2fs_defs.h deleted file mode 100644 index 379640eb8..000000000 --- a/e2fsprogs/e2fs_defs.h +++ /dev/null @@ -1,561 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * linux/include/linux/ext2_fs.h - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -#ifndef LINUX_EXT2_FS_H -#define LINUX_EXT2_FS_H 1 - -/* - * Special inode numbers - */ -#define EXT2_BAD_INO 1 /* Bad blocks inode */ -#define EXT2_ROOT_INO 2 /* Root inode */ -#define EXT2_ACL_IDX_INO 3 /* ACL inode */ -#define EXT2_ACL_DATA_INO 4 /* ACL inode */ -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ -#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ -#define EXT2_JOURNAL_INO 8 /* Journal inode */ - -/* First non-reserved inode for old ext2 filesystems */ -#define EXT2_GOOD_OLD_FIRST_INO 11 - -/* - * The second extended file system magic number - */ -#define EXT2_SUPER_MAGIC 0xEF53 - -/* Assume that user mode programs are passing in an ext2fs superblock, not - * a kernel struct super_block. This will allow us to call the feature-test - * macros from user land. */ -#define EXT2_SB(sb) (sb) - -/* - * Maximal count of links to a file - */ -#define EXT2_LINK_MAX 32000 - -/* - * Macro-instructions used to manage several block sizes - */ -#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */ -#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */ -#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE) -#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE) -#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) -#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) -#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) -#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) -#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t)) - -/* - * Macro-instructions used to manage fragments - */ -#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE -#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE -#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE -#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) -#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) - -/* - * ACL structures - */ -struct ext2_acl_header { /* Header of Access Control Lists */ - uint32_t aclh_size; - uint32_t aclh_file_count; - uint32_t aclh_acle_count; - uint32_t aclh_first_acle; -}; - -struct ext2_acl_entry { /* Access Control List Entry */ - uint32_t acle_size; - uint16_t acle_perms; /* Access permissions */ - uint16_t acle_type; /* Type of entry */ - uint16_t acle_tag; /* User or group identity */ - uint16_t acle_pad1; - uint32_t acle_next; /* Pointer on next entry for the */ - /* same inode or on next free entry */ -}; - -/* - * Structure of a blocks group descriptor - */ -struct ext2_group_desc { - uint32_t bg_block_bitmap; /* Blocks bitmap block */ - uint32_t bg_inode_bitmap; /* Inodes bitmap block */ - uint32_t bg_inode_table; /* Inodes table block */ - uint16_t bg_free_blocks_count; /* Free blocks count */ - uint16_t bg_free_inodes_count; /* Free inodes count */ - uint16_t bg_used_dirs_count; /* Directories count */ - uint16_t bg_pad; - uint32_t bg_reserved[3]; -}; - -/* - * Data structures used by the directory indexing feature - * - * Note: all of the multibyte integer fields are little endian. - */ - -/* - * Note: dx_root_info is laid out so that if it should somehow get - * overlaid by a dirent the two low bits of the hash version will be - * zero. Therefore, the hash version mod 4 should never be 0. - * Sincerely, the paranoia department. - */ -struct ext2_dx_root_info { - uint32_t reserved_zero; - uint8_t hash_version; /* 0 now, 1 at release */ - uint8_t info_length; /* 8 */ - uint8_t indirect_levels; - uint8_t unused_flags; -}; - -#define EXT2_HASH_LEGACY 0 -#define EXT2_HASH_HALF_MD4 1 -#define EXT2_HASH_TEA 2 - -#define EXT2_HASH_FLAG_INCOMPAT 0x1 - -struct ext2_dx_entry { - uint32_t hash; - uint32_t block; -}; - -struct ext2_dx_countlimit { - uint16_t limit; - uint16_t count; -}; - - -/* - * Macro-instructions used to manage group descriptors - */ -#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) -#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) -#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s)) -/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */ -#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8) -#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s)) -#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) - -/* - * Constants relative to the data blocks - */ -#define EXT2_NDIR_BLOCKS 12 -#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS -#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) -#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) -#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) - -/* - * Inode flags - */ -#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ -#define EXT2_UNRM_FL 0x00000002 /* Undelete */ -#define EXT2_COMPR_FL 0x00000004 /* Compress file */ -#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ -#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ -#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ -#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ -#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ -/* Reserved for compression usage... */ -#define EXT2_DIRTY_FL 0x00000100 -#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ -#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ -#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ -/* End compression flags --- maybe not all used */ -#define EXT2_BTREE_FL 0x00001000 /* btree format dir */ -#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ -#define EXT2_IMAGIC_FL 0x00002000 -#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ -#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ -#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */ -#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ -#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */ -#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ - -#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ -#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */ - -/* - * ioctl commands - */ -#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) -#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) -#define EXT2_IOC_GETVERSION _IOR('v', 1, long) -#define EXT2_IOC_SETVERSION _IOW('v', 2, long) - -/* - * Structure of an inode on the disk - */ -struct ext2_inode { - uint16_t i_mode; /* File mode */ - uint16_t i_uid; /* Low 16 bits of Owner Uid */ - uint32_t i_size; /* Size in bytes */ - uint32_t i_atime; /* Access time */ - uint32_t i_ctime; /* Creation time */ - uint32_t i_mtime; /* Modification time */ - uint32_t i_dtime; /* Deletion Time */ - uint16_t i_gid; /* Low 16 bits of Group Id */ - uint16_t i_links_count; /* Links count */ - uint32_t i_blocks; /* Blocks count */ - uint32_t i_flags; /* File flags */ - union { - struct { - uint32_t l_i_reserved1; - } linux1; - struct { - uint32_t h_i_translator; - } hurd1; - struct { - uint32_t m_i_reserved1; - } masix1; - } osd1; /* OS dependent 1 */ - uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - uint32_t i_generation; /* File version (for NFS) */ - uint32_t i_file_acl; /* File ACL */ - uint32_t i_dir_acl; /* Directory ACL */ - uint32_t i_faddr; /* Fragment address */ - union { - struct { - uint8_t l_i_frag; /* Fragment number */ - uint8_t l_i_fsize; /* Fragment size */ - uint16_t i_pad1; - uint16_t l_i_uid_high; /* these 2 fields */ - uint16_t l_i_gid_high; /* were reserved2[0] */ - uint32_t l_i_reserved2; - } linux2; - struct { - uint8_t h_i_frag; /* Fragment number */ - uint8_t h_i_fsize; /* Fragment size */ - uint16_t h_i_mode_high; - uint16_t h_i_uid_high; - uint16_t h_i_gid_high; - uint32_t h_i_author; - } hurd2; - struct { - uint8_t m_i_frag; /* Fragment number */ - uint8_t m_i_fsize; /* Fragment size */ - uint16_t m_pad1; - uint32_t m_i_reserved2[2]; - } masix2; - } osd2; /* OS dependent 2 */ -}; - -/* - * Permanent part of an large inode on the disk - */ -struct ext2_inode_large { - uint16_t i_mode; /* File mode */ - uint16_t i_uid; /* Low 16 bits of Owner Uid */ - uint32_t i_size; /* Size in bytes */ - uint32_t i_atime; /* Access time */ - uint32_t i_ctime; /* Creation time */ - uint32_t i_mtime; /* Modification time */ - uint32_t i_dtime; /* Deletion Time */ - uint16_t i_gid; /* Low 16 bits of Group Id */ - uint16_t i_links_count; /* Links count */ - uint32_t i_blocks; /* Blocks count */ - uint32_t i_flags; /* File flags */ - union { - struct { - uint32_t l_i_reserved1; - } linux1; - struct { - uint32_t h_i_translator; - } hurd1; - struct { - uint32_t m_i_reserved1; - } masix1; - } osd1; /* OS dependent 1 */ - uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - uint32_t i_generation; /* File version (for NFS) */ - uint32_t i_file_acl; /* File ACL */ - uint32_t i_dir_acl; /* Directory ACL */ - uint32_t i_faddr; /* Fragment address */ - union { - struct { - uint8_t l_i_frag; /* Fragment number */ - uint8_t l_i_fsize; /* Fragment size */ - uint16_t i_pad1; - uint16_t l_i_uid_high; /* these 2 fields */ - uint16_t l_i_gid_high; /* were reserved2[0] */ - uint32_t l_i_reserved2; - } linux2; - struct { - uint8_t h_i_frag; /* Fragment number */ - uint8_t h_i_fsize; /* Fragment size */ - uint16_t h_i_mode_high; - uint16_t h_i_uid_high; - uint16_t h_i_gid_high; - uint32_t h_i_author; - } hurd2; - struct { - uint8_t m_i_frag; /* Fragment number */ - uint8_t m_i_fsize; /* Fragment size */ - uint16_t m_pad1; - uint32_t m_i_reserved2[2]; - } masix2; - } osd2; /* OS dependent 2 */ - uint16_t i_extra_isize; - uint16_t i_pad1; -}; - -#define i_size_high i_dir_acl - -/* - * File system states - */ -#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ -#define EXT2_ERROR_FS 0x0002 /* Errors detected */ - -/* - * Mount flags - */ -#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ -#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ -#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ -#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ -#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ -#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ -#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ -#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ - -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt -#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ - EXT2_MOUNT_##opt) -/* - * Maximal mount counts between two filesystem checks - */ -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ - -/* - * Behaviour when detecting errors - */ -#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ -#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ -#define EXT2_ERRORS_PANIC 3 /* Panic */ -#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE - -/* - * Structure of the super block - */ -struct ext2_super_block { - uint32_t s_inodes_count; /* Inodes count */ - uint32_t s_blocks_count; /* Blocks count */ - uint32_t s_r_blocks_count; /* Reserved blocks count */ - uint32_t s_free_blocks_count; /* Free blocks count */ - uint32_t s_free_inodes_count; /* Free inodes count */ - uint32_t s_first_data_block; /* First Data Block */ - uint32_t s_log_block_size; /* Block size */ - int32_t s_log_frag_size; /* Fragment size */ - uint32_t s_blocks_per_group; /* # Blocks per group */ - uint32_t s_frags_per_group; /* # Fragments per group */ - uint32_t s_inodes_per_group; /* # Inodes per group */ - uint32_t s_mtime; /* Mount time */ - uint32_t s_wtime; /* Write time */ - uint16_t s_mnt_count; /* Mount count */ - int16_t s_max_mnt_count; /* Maximal mount count */ - uint16_t s_magic; /* Magic signature */ - uint16_t s_state; /* File system state */ - uint16_t s_errors; /* Behaviour when detecting errors */ - uint16_t s_minor_rev_level; /* minor revision level */ - uint32_t s_lastcheck; /* time of last check */ - uint32_t s_checkinterval; /* max. time between checks */ - uint32_t s_creator_os; /* OS */ - uint32_t s_rev_level; /* Revision level */ - uint16_t s_def_resuid; /* Default uid for reserved blocks */ - uint16_t s_def_resgid; /* Default gid for reserved blocks */ - /* - * These fields are for EXT2_DYNAMIC_REV superblocks only. - * - * Note: the difference between the compatible feature set and - * the incompatible feature set is that if there is a bit set - * in the incompatible feature set that the kernel doesn't - * know about, it should refuse to mount the filesystem. - * - * e2fsck's requirements are more strict; if it doesn't know - * about a feature in either the compatible or incompatible - * feature set, it must abort and not try to meddle with - * things it doesn't understand... - */ - uint32_t s_first_ino; /* First non-reserved inode */ - uint16_t s_inode_size; /* size of inode structure */ - uint16_t s_block_group_nr; /* block group # of this superblock */ - uint32_t s_feature_compat; /* compatible feature set */ - uint32_t s_feature_incompat; /* incompatible feature set */ - uint32_t s_feature_ro_compat; /* readonly-compatible feature set */ - uint8_t s_uuid[16]; /* 128-bit uuid for volume */ - char s_volume_name[16]; /* volume name */ - char s_last_mounted[64]; /* directory where last mounted */ - uint32_t s_algorithm_usage_bitmap; /* For compression */ - /* - * Performance hints. Directory preallocation should only - * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. - */ - uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ - uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ - uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */ - /* - * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. - */ - uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ - uint32_t s_journal_inum; /* inode number of journal file */ - uint32_t s_journal_dev; /* device number of journal file */ - uint32_t s_last_orphan; /* start of list of inodes to delete */ - uint32_t s_hash_seed[4]; /* HTREE hash seed */ - uint8_t s_def_hash_version; /* Default hash version to use */ - uint8_t s_jnl_backup_type; /* Default type of journal backup */ - uint16_t s_reserved_word_pad; - uint32_t s_default_mount_opts; - uint32_t s_first_meta_bg; /* First metablock group */ - uint32_t s_mkfs_time; /* When the filesystem was created */ - uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */ - uint32_t s_reserved[172]; /* Padding to the end of the block */ -}; - -/* - * Codes for operating systems - */ -#define EXT2_OS_LINUX 0 -#define EXT2_OS_HURD 1 -#define EXT2_OS_MASIX 2 -#define EXT2_OS_FREEBSD 3 -#define EXT2_OS_LITES 4 - -/* - * Revision levels - */ -#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ -#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ - -#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV -#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV - -#define EXT2_GOOD_OLD_INODE_SIZE 128 - -/* - * Journal inode backup types - */ -#define EXT3_JNL_BACKUP_BLOCKS 1 - -/* - * Feature set definitions - */ - -#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_compat & (mask) ) -#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_ro_compat & (mask) ) -#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_incompat & (mask) ) - -#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 -#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 -#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 -#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 -#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 - -#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 -#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 -/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */ - -#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 -#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 -#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ -#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ -#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 -#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040 - - -#define EXT2_FEATURE_COMPAT_SUPP 0 -#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE) -#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ - EXT2_FEATURE_RO_COMPAT_BTREE_DIR) - -/* - * Default values for user and/or group using reserved blocks - */ -#define EXT2_DEF_RESUID 0 -#define EXT2_DEF_RESGID 0 - -/* - * Default mount options - */ -#define EXT2_DEFM_DEBUG 0x0001 -#define EXT2_DEFM_BSDGROUPS 0x0002 -#define EXT2_DEFM_XATTR_USER 0x0004 -#define EXT2_DEFM_ACL 0x0008 -#define EXT2_DEFM_UID16 0x0010 -#define EXT3_DEFM_JMODE 0x0060 -#define EXT3_DEFM_JMODE_DATA 0x0020 -#define EXT3_DEFM_JMODE_ORDERED 0x0040 -#define EXT3_DEFM_JMODE_WBACK 0x0060 - -/* - * Structure of a directory entry - */ -#define EXT2_NAME_LEN 255 - -struct ext2_dir_entry { - uint32_t inode; /* Inode number */ - uint16_t rec_len; /* Directory entry length */ - uint16_t name_len; /* Name length */ - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * The new version of the directory entry. Since EXT2 structures are - * stored in intel byte order, and the name_len field could never be - * bigger than 255 chars, it's safe to reclaim the extra byte for the - * file_type field. - */ -struct ext2_dir_entry_2 { - uint32_t inode; /* Inode number */ - uint16_t rec_len; /* Directory entry length */ - uint8_t name_len; /* Name length */ - uint8_t file_type; - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * Ext2 directory file types. Only the low 3 bits are used. The - * other bits are reserved for now. - */ -#define EXT2_FT_UNKNOWN 0 -#define EXT2_FT_REG_FILE 1 -#define EXT2_FT_DIR 2 -#define EXT2_FT_CHRDEV 3 -#define EXT2_FT_BLKDEV 4 -#define EXT2_FT_FIFO 5 -#define EXT2_FT_SOCK 6 -#define EXT2_FT_SYMLINK 7 - -#define EXT2_FT_MAX 8 - -/* - * EXT2_DIR_PAD defines the directory entries boundaries - * - * NOTE: It must be a multiple of 4 - */ -#define EXT2_DIR_PAD 4 -#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) -#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ - ~EXT2_DIR_ROUND) - -#endif diff --git a/e2fsprogs/e2fs_lib.h b/e2fsprogs/e2fs_lib.h index 3905ee71d..f2ae56f43 100644 --- a/e2fsprogs/e2fs_lib.h +++ b/e2fsprogs/e2fs_lib.h @@ -7,7 +7,7 @@ */ /* Constants and structures */ -#include "e2fs_defs.h" +#include "bb_e2fs_defs.h" PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index 8fffa7f20..373e8ce91 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c @@ -11577,7 +11577,7 @@ static void check_resize_inode(e2fsck_t ctx) * s_reserved_gdt_blocks must be zero. */ if (!(fs->super->s_feature_compat & - EXT2_FEATURE_COMPAT_RESIZE_INODE)) { + EXT2_FEATURE_COMPAT_RESIZE_INO)) { if (fs->super->s_reserved_gdt_blocks) { pctx.num = fs->super->s_reserved_gdt_blocks; if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS, @@ -11593,7 +11593,7 @@ static void check_resize_inode(e2fsck_t ctx) retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); if (retval) { if (fs->super->s_feature_compat & - EXT2_FEATURE_COMPAT_RESIZE_INODE) + EXT2_FEATURE_COMPAT_RESIZE_INO) ctx->flags |= E2F_FLAG_RESIZE_INODE; return; } @@ -11603,7 +11603,7 @@ static void check_resize_inode(e2fsck_t ctx) * the resize inode is cleared; then we're done. */ if (!(fs->super->s_feature_compat & - EXT2_FEATURE_COMPAT_RESIZE_INODE)) { + EXT2_FEATURE_COMPAT_RESIZE_INO)) { for (i=0; i < EXT2_N_BLOCKS; i++) { if (inode.i_block[i]) break; diff --git a/e2fsprogs/old_e2fsprogs/e2p/feature.c b/e2fsprogs/old_e2fsprogs/e2p/feature.c index b45754f97..2102ed8e7 100644 --- a/e2fsprogs/old_e2fsprogs/e2p/feature.c +++ b/e2fsprogs/old_e2fsprogs/e2p/feature.c @@ -34,7 +34,7 @@ static const struct feature feature_list[] = { "ext_attr" }, { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX, "dir_index" }, - { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE, + { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INO, "resize_inode" }, { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER, "sparse_super" }, diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h index 6f4f70862..80ea2cbdd 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h +++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h @@ -475,7 +475,7 @@ struct ext2_super_block { #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 -#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 +#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h index 9f772016f..39fb11620 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h +++ b/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h @@ -383,7 +383,7 @@ typedef struct ext2_icount *ext2_icount_t; #define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\ EXT2_FEATURE_COMPAT_IMAGIC_INODES|\ EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ - EXT2_FEATURE_COMPAT_RESIZE_INODE|\ + EXT2_FEATURE_COMPAT_RESIZE_INO|\ EXT2_FEATURE_COMPAT_DIR_INDEX|\ EXT2_FEATURE_COMPAT_EXT_ATTR) diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c index ef1d34379..da2d15137 100644 --- a/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c +++ b/e2fsprogs/old_e2fsprogs/ext2fs/initialize.c @@ -284,7 +284,7 @@ retry: /* * check the number of reserved group descriptor table blocks */ - if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) + if (super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) rsv_gdt = calc_reserved_gdt_blocks(fs); else rsv_gdt = 0; diff --git a/e2fsprogs/old_e2fsprogs/mke2fs.c b/e2fsprogs/old_e2fsprogs/mke2fs.c index 7555650a2..35d717a55 100644 --- a/e2fsprogs/old_e2fsprogs/mke2fs.c +++ b/e2fsprogs/old_e2fsprogs/mke2fs.c @@ -757,7 +757,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param, if (rsv_gdb > 0) { sb_param->s_feature_compat |= - EXT2_FEATURE_COMPAT_RESIZE_INODE; + EXT2_FEATURE_COMPAT_RESIZE_INO; sb_param->s_reserved_gdt_blocks = rsv_gdb; } @@ -778,7 +778,7 @@ static void parse_extended_opts(struct ext2_super_block *sb_param, static __u32 ok_features[3] = { EXT3_FEATURE_COMPAT_HAS_JOURNAL | - EXT2_FEATURE_COMPAT_RESIZE_INODE | + EXT2_FEATURE_COMPAT_RESIZE_INO | EXT2_FEATURE_COMPAT_DIR_INDEX, /* Compat */ EXT2_FEATURE_INCOMPAT_FILETYPE| /* Incompat */ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV| @@ -1123,7 +1123,7 @@ static int PRS(int argc, char **argv) /* Since sparse_super is the default, we would only have a problem * here if it was explicitly disabled. */ - if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) && + if ((param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INO) && !(param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) { bb_error_msg_and_die("reserved online resize blocks not supported " "on non-sparse filesystem"); @@ -1312,7 +1312,7 @@ int mke2fs_main (int argc, char **argv) reserve_inodes(fs); create_bad_block_inode(fs, bb_list); if (fs->super->s_feature_compat & - EXT2_FEATURE_COMPAT_RESIZE_INODE) { + EXT2_FEATURE_COMPAT_RESIZE_INO) { retval = ext2fs_create_resize_inode(fs); mke2fs_error_msg_and_die(retval, "reserve blocks for online resize"); } diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 841d58a9c..46a745ee4 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c @@ -8,7 +8,7 @@ */ #include "libbb.h" #include -#include "bb_linux_ext2_fs.h" +#include "bb_e2fs_defs.h" // storage helpers char BUG_wrong_field_size(void); diff --git a/include/bb_e2fs_defs.h b/include/bb_e2fs_defs.h new file mode 100644 index 000000000..7974497ca --- /dev/null +++ b/include/bb_e2fs_defs.h @@ -0,0 +1,561 @@ +/* vi: set sw=4 ts=4: */ +/* + * linux/include/linux/ext2_fs.h + * + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#ifndef LINUX_EXT2_FS_H +#define LINUX_EXT2_FS_H 1 + +/* + * Special inode numbers + */ +#define EXT2_BAD_INO 1 /* Bad blocks inode */ +#define EXT2_ROOT_INO 2 /* Root inode */ +#define EXT2_ACL_IDX_INO 3 /* ACL inode */ +#define EXT2_ACL_DATA_INO 4 /* ACL inode */ +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ +#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ +#define EXT2_JOURNAL_INO 8 /* Journal inode */ + +/* First non-reserved inode for old ext2 filesystems */ +#define EXT2_GOOD_OLD_FIRST_INO 11 + +/* + * The second extended file system magic number + */ +#define EXT2_SUPER_MAGIC 0xEF53 + +/* Assume that user mode programs are passing in an ext2fs superblock, not + * a kernel struct super_block. This will allow us to call the feature-test + * macros from user land. */ +#define EXT2_SB(sb) (sb) + +/* + * Maximal count of links to a file + */ +#define EXT2_LINK_MAX 32000 + +/* + * Macro-instructions used to manage several block sizes + */ +#define EXT2_MIN_BLOCK_LOG_SIZE 10 /* 1024 */ +#define EXT2_MAX_BLOCK_LOG_SIZE 16 /* 65536 */ +#define EXT2_MIN_BLOCK_SIZE (1 << EXT2_MIN_BLOCK_LOG_SIZE) +#define EXT2_MAX_BLOCK_SIZE (1 << EXT2_MAX_BLOCK_LOG_SIZE) +#define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) +#define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) +#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ + EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) +#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ + EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(uint32_t)) + +/* + * Macro-instructions used to manage fragments + */ +#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE +#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE +#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE +#define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) +#define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) + +/* + * ACL structures + */ +struct ext2_acl_header { /* Header of Access Control Lists */ + uint32_t aclh_size; + uint32_t aclh_file_count; + uint32_t aclh_acle_count; + uint32_t aclh_first_acle; +}; + +struct ext2_acl_entry { /* Access Control List Entry */ + uint32_t acle_size; + uint16_t acle_perms; /* Access permissions */ + uint16_t acle_type; /* Type of entry */ + uint16_t acle_tag; /* User or group identity */ + uint16_t acle_pad1; + uint32_t acle_next; /* Pointer on next entry for the */ + /* same inode or on next free entry */ +}; + +/* + * Structure of a blocks group descriptor + */ +struct ext2_group_desc { + uint32_t bg_block_bitmap; /* Blocks bitmap block */ + uint32_t bg_inode_bitmap; /* Inodes bitmap block */ + uint32_t bg_inode_table; /* Inodes table block */ + uint16_t bg_free_blocks_count; /* Free blocks count */ + uint16_t bg_free_inodes_count; /* Free inodes count */ + uint16_t bg_used_dirs_count; /* Directories count */ + uint16_t bg_pad; + uint32_t bg_reserved[3]; +}; + +/* + * Data structures used by the directory indexing feature + * + * Note: all of the multibyte integer fields are little endian. + */ + +/* + * Note: dx_root_info is laid out so that if it should somehow get + * overlaid by a dirent the two low bits of the hash version will be + * zero. Therefore, the hash version mod 4 should never be 0. + * Sincerely, the paranoia department. + */ +struct ext2_dx_root_info { + uint32_t reserved_zero; + uint8_t hash_version; /* 0 now, 1 at release */ + uint8_t info_length; /* 8 */ + uint8_t indirect_levels; + uint8_t unused_flags; +}; + +#define EXT2_HASH_LEGACY 0 +#define EXT2_HASH_HALF_MD4 1 +#define EXT2_HASH_TEA 2 + +#define EXT2_HASH_FLAG_INCOMPAT 0x1 + +struct ext2_dx_entry { + uint32_t hash; + uint32_t block; +}; + +struct ext2_dx_countlimit { + uint16_t limit; + uint16_t count; +}; + + +/* + * Macro-instructions used to manage group descriptors + */ +#define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) +#define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) +#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s)) +/* limits imposed by 16-bit value gd_free_{blocks,inode}_count */ +#define EXT2_MAX_BLOCKS_PER_GROUP(s) ((1 << 16) - 8) +#define EXT2_MAX_INODES_PER_GROUP(s) ((1 << 16) - EXT2_INODES_PER_BLOCK(s)) +#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) + +/* + * Constants relative to the data blocks + */ +#define EXT2_NDIR_BLOCKS 12 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) + +/* + * Inode flags + */ +#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ +#define EXT2_UNRM_FL 0x00000002 /* Undelete */ +#define EXT2_COMPR_FL 0x00000004 /* Compress file */ +#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ +#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ +#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ +#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ +#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ +/* Reserved for compression usage... */ +#define EXT2_DIRTY_FL 0x00000100 +#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ +#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ +#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ +/* End compression flags --- maybe not all used */ +#define EXT2_BTREE_FL 0x00001000 /* btree format dir */ +#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ +#define EXT2_IMAGIC_FL 0x00002000 +#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ +#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ +#define EXT2_DIRSYNC_FL 0x00010000 /* Synchronous directory modifications */ +#define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ +#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */ +#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ + +#define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ +#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */ + +/* + * ioctl commands + */ +#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) +#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) +#define EXT2_IOC_GETVERSION _IOR('v', 1, long) +#define EXT2_IOC_SETVERSION _IOW('v', 2, long) + +/* + * Structure of an inode on the disk + */ +struct ext2_inode { + uint16_t i_mode; /* File mode */ + uint16_t i_uid; /* Low 16 bits of Owner Uid */ + uint32_t i_size; /* Size in bytes */ + uint32_t i_atime; /* Access time */ + uint32_t i_ctime; /* Creation time */ + uint32_t i_mtime; /* Modification time */ + uint32_t i_dtime; /* Deletion Time */ + uint16_t i_gid; /* Low 16 bits of Group Id */ + uint16_t i_links_count; /* Links count */ + uint32_t i_blocks; /* Blocks count */ + uint32_t i_flags; /* File flags */ + union { + struct { + uint32_t l_i_reserved1; + } linux1; + struct { + uint32_t h_i_translator; + } hurd1; + struct { + uint32_t m_i_reserved1; + } masix1; + } osd1; /* OS dependent 1 */ + uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + uint32_t i_generation; /* File version (for NFS) */ + uint32_t i_file_acl; /* File ACL */ + uint32_t i_dir_acl; /* Directory ACL */ + uint32_t i_faddr; /* Fragment address */ + union { + struct { + uint8_t l_i_frag; /* Fragment number */ + uint8_t l_i_fsize; /* Fragment size */ + uint16_t i_pad1; + uint16_t l_i_uid_high; /* these 2 fields */ + uint16_t l_i_gid_high; /* were reserved2[0] */ + uint32_t l_i_reserved2; + } linux2; + struct { + uint8_t h_i_frag; /* Fragment number */ + uint8_t h_i_fsize; /* Fragment size */ + uint16_t h_i_mode_high; + uint16_t h_i_uid_high; + uint16_t h_i_gid_high; + uint32_t h_i_author; + } hurd2; + struct { + uint8_t m_i_frag; /* Fragment number */ + uint8_t m_i_fsize; /* Fragment size */ + uint16_t m_pad1; + uint32_t m_i_reserved2[2]; + } masix2; + } osd2; /* OS dependent 2 */ +}; + +/* + * Permanent part of an large inode on the disk + */ +struct ext2_inode_large { + uint16_t i_mode; /* File mode */ + uint16_t i_uid; /* Low 16 bits of Owner Uid */ + uint32_t i_size; /* Size in bytes */ + uint32_t i_atime; /* Access time */ + uint32_t i_ctime; /* Creation time */ + uint32_t i_mtime; /* Modification time */ + uint32_t i_dtime; /* Deletion Time */ + uint16_t i_gid; /* Low 16 bits of Group Id */ + uint16_t i_links_count; /* Links count */ + uint32_t i_blocks; /* Blocks count */ + uint32_t i_flags; /* File flags */ + union { + struct { + uint32_t l_i_reserved1; + } linux1; + struct { + uint32_t h_i_translator; + } hurd1; + struct { + uint32_t m_i_reserved1; + } masix1; + } osd1; /* OS dependent 1 */ + uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + uint32_t i_generation; /* File version (for NFS) */ + uint32_t i_file_acl; /* File ACL */ + uint32_t i_dir_acl; /* Directory ACL */ + uint32_t i_faddr; /* Fragment address */ + union { + struct { + uint8_t l_i_frag; /* Fragment number */ + uint8_t l_i_fsize; /* Fragment size */ + uint16_t i_pad1; + uint16_t l_i_uid_high; /* these 2 fields */ + uint16_t l_i_gid_high; /* were reserved2[0] */ + uint32_t l_i_reserved2; + } linux2; + struct { + uint8_t h_i_frag; /* Fragment number */ + uint8_t h_i_fsize; /* Fragment size */ + uint16_t h_i_mode_high; + uint16_t h_i_uid_high; + uint16_t h_i_gid_high; + uint32_t h_i_author; + } hurd2; + struct { + uint8_t m_i_frag; /* Fragment number */ + uint8_t m_i_fsize; /* Fragment size */ + uint16_t m_pad1; + uint32_t m_i_reserved2[2]; + } masix2; + } osd2; /* OS dependent 2 */ + uint16_t i_extra_isize; + uint16_t i_pad1; +}; + +#define i_size_high i_dir_acl + +/* + * File system states + */ +#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ +#define EXT2_ERROR_FS 0x0002 /* Errors detected */ + +/* + * Mount flags + */ +#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ +#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ +#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ +#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ +#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ +#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ +#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ +#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ + +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt +#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ + EXT2_MOUNT_##opt) +/* + * Maximal mount counts between two filesystem checks + */ +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ + +/* + * Behaviour when detecting errors + */ +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ +#define EXT2_ERRORS_PANIC 3 /* Panic */ +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE + +/* + * Structure of the super block + */ +struct ext2_super_block { + uint32_t s_inodes_count; /* Inodes count */ + uint32_t s_blocks_count; /* Blocks count */ + uint32_t s_r_blocks_count; /* Reserved blocks count */ + uint32_t s_free_blocks_count; /* Free blocks count */ + uint32_t s_free_inodes_count; /* Free inodes count */ + uint32_t s_first_data_block; /* First Data Block */ + uint32_t s_log_block_size; /* Block size */ + int32_t s_log_frag_size; /* Fragment size */ + uint32_t s_blocks_per_group; /* # Blocks per group */ + uint32_t s_frags_per_group; /* # Fragments per group */ + uint32_t s_inodes_per_group; /* # Inodes per group */ + uint32_t s_mtime; /* Mount time */ + uint32_t s_wtime; /* Write time */ + uint16_t s_mnt_count; /* Mount count */ + int16_t s_max_mnt_count; /* Maximal mount count */ + uint16_t s_magic; /* Magic signature */ + uint16_t s_state; /* File system state */ + uint16_t s_errors; /* Behaviour when detecting errors */ + uint16_t s_minor_rev_level; /* minor revision level */ + uint32_t s_lastcheck; /* time of last check */ + uint32_t s_checkinterval; /* max. time between checks */ + uint32_t s_creator_os; /* OS */ + uint32_t s_rev_level; /* Revision level */ + uint16_t s_def_resuid; /* Default uid for reserved blocks */ + uint16_t s_def_resgid; /* Default gid for reserved blocks */ + /* + * These fields are for EXT2_DYNAMIC_REV superblocks only. + * + * Note: the difference between the compatible feature set and + * the incompatible feature set is that if there is a bit set + * in the incompatible feature set that the kernel doesn't + * know about, it should refuse to mount the filesystem. + * + * e2fsck's requirements are more strict; if it doesn't know + * about a feature in either the compatible or incompatible + * feature set, it must abort and not try to meddle with + * things it doesn't understand... + */ + uint32_t s_first_ino; /* First non-reserved inode */ + uint16_t s_inode_size; /* size of inode structure */ + uint16_t s_block_group_nr; /* block group # of this superblock */ + uint32_t s_feature_compat; /* compatible feature set */ + uint32_t s_feature_incompat; /* incompatible feature set */ + uint32_t s_feature_ro_compat; /* readonly-compatible feature set */ + uint8_t s_uuid[16]; /* 128-bit uuid for volume */ + char s_volume_name[16]; /* volume name */ + char s_last_mounted[64]; /* directory where last mounted */ + uint32_t s_algorithm_usage_bitmap; /* For compression */ + /* + * Performance hints. Directory preallocation should only + * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. + */ + uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ + uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ + uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */ + /* + * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. + */ + uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ + uint32_t s_journal_inum; /* inode number of journal file */ + uint32_t s_journal_dev; /* device number of journal file */ + uint32_t s_last_orphan; /* start of list of inodes to delete */ + uint32_t s_hash_seed[4]; /* HTREE hash seed */ + uint8_t s_def_hash_version; /* Default hash version to use */ + uint8_t s_jnl_backup_type; /* Default type of journal backup */ + uint16_t s_reserved_word_pad; + uint32_t s_default_mount_opts; + uint32_t s_first_meta_bg; /* First metablock group */ + uint32_t s_mkfs_time; /* When the filesystem was created */ + uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */ + uint32_t s_reserved[172]; /* Padding to the end of the block */ +}; + +/* + * Codes for operating systems + */ +#define EXT2_OS_LINUX 0 +#define EXT2_OS_HURD 1 +#define EXT2_OS_MASIX 2 +#define EXT2_OS_FREEBSD 3 +#define EXT2_OS_LITES 4 + +/* + * Revision levels + */ +#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ +#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ + +#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV +#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV + +#define EXT2_GOOD_OLD_INODE_SIZE 128 + +/* + * Journal inode backup types + */ +#define EXT3_JNL_BACKUP_BLOCKS 1 + +/* + * Feature set definitions + */ + +#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_feature_compat & (mask) ) +#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_feature_ro_compat & (mask) ) +#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_feature_incompat & (mask) ) + +#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 +#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 +#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 +#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 +#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 +#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 + +#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 +#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 +/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */ + +#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 +#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 +#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ +#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ +#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 +#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040 + + +#define EXT2_FEATURE_COMPAT_SUPP 0 +#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE) +#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ + EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ + EXT2_FEATURE_RO_COMPAT_BTREE_DIR) + +/* + * Default values for user and/or group using reserved blocks + */ +#define EXT2_DEF_RESUID 0 +#define EXT2_DEF_RESGID 0 + +/* + * Default mount options + */ +#define EXT2_DEFM_DEBUG 0x0001 +#define EXT2_DEFM_BSDGROUPS 0x0002 +#define EXT2_DEFM_XATTR_USER 0x0004 +#define EXT2_DEFM_ACL 0x0008 +#define EXT2_DEFM_UID16 0x0010 +#define EXT3_DEFM_JMODE 0x0060 +#define EXT3_DEFM_JMODE_DATA 0x0020 +#define EXT3_DEFM_JMODE_ORDERED 0x0040 +#define EXT3_DEFM_JMODE_WBACK 0x0060 + +/* + * Structure of a directory entry + */ +#define EXT2_NAME_LEN 255 + +struct ext2_dir_entry { + uint32_t inode; /* Inode number */ + uint16_t rec_len; /* Directory entry length */ + uint16_t name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * The new version of the directory entry. Since EXT2 structures are + * stored in intel byte order, and the name_len field could never be + * bigger than 255 chars, it's safe to reclaim the extra byte for the + * file_type field. + */ +struct ext2_dir_entry_2 { + uint32_t inode; /* Inode number */ + uint16_t rec_len; /* Directory entry length */ + uint8_t name_len; /* Name length */ + uint8_t file_type; + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * Ext2 directory file types. Only the low 3 bits are used. The + * other bits are reserved for now. + */ +#define EXT2_FT_UNKNOWN 0 +#define EXT2_FT_REG_FILE 1 +#define EXT2_FT_DIR 2 +#define EXT2_FT_CHRDEV 3 +#define EXT2_FT_BLKDEV 4 +#define EXT2_FT_FIFO 5 +#define EXT2_FT_SOCK 6 +#define EXT2_FT_SYMLINK 7 + +#define EXT2_FT_MAX 8 + +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ + ~EXT2_DIR_ROUND) + +#endif diff --git a/include/bb_linux_ext2_fs.h b/include/bb_linux_ext2_fs.h deleted file mode 100644 index fdc470bc2..000000000 --- a/include/bb_linux_ext2_fs.h +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Work around linux/ext2_fs.h breakage. - * linux/ext2_fs.h might be removed from future kernel header distribution. - * See https://bugzilla.kernel.org/show_bug.cgi?id=42986 - * - * Licensed under GPLv2, see file LICENSE in this source tree. - */ -#ifndef BB_LINUX_EXT2_FS_H -#define BB_LINUX_EXT2_FS_H - -/* - * From linux/magic.h - */ - -#define EXT2_SUPER_MAGIC 0xEF53 -#define EXT3_SUPER_MAGIC 0xEF53 -#define EXT4_SUPER_MAGIC 0xEF53 - -/* - * From linux/ext2_fs.h, with minor changes. - */ - -/* - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/include/linux/minix_fs.h - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -/* - * The second extended filesystem constants/structures - */ - -/* - * Define EXT2_RESERVATION to reserve data blocks for expanding files - */ -#define EXT2_DEFAULT_RESERVE_BLOCKS 8 -/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ -#define EXT2_MAX_RESERVE_BLOCKS 1027 -#define EXT2_RESERVE_WINDOW_NOT_ALLOCATED 0 - -/* - * Special inode numbers - */ -#define EXT2_BAD_INO 1 /* Bad blocks inode */ -#define EXT2_ROOT_INO 2 /* Root inode */ -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ - -/* First non-reserved inode for old ext2 filesystems */ -#define EXT2_GOOD_OLD_FIRST_INO 11 - -/* Assume that user mode programs are passing in an ext2fs superblock, not - * a kernel struct super_block. This will allow us to call the feature-test - * macros from user land. */ -#define EXT2_SB(sb) (sb) - -/* - * Maximal count of links to a file - */ -#define EXT2_LINK_MAX 32000 - -/* - * Macro-instructions used to manage several block sizes - */ -#define EXT2_MIN_BLOCK_SIZE 1024 -#define EXT2_MAX_BLOCK_SIZE 4096 -#define EXT2_MIN_BLOCK_LOG_SIZE 10 -# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) -#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (uint32_t)) -# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) -#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_INODE_SIZE : \ - (s)->s_inode_size) -#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_FIRST_INO : \ - (s)->s_first_ino) - -/* - * Macro-instructions used to manage fragments - */ -#define EXT2_MIN_FRAG_SIZE 1024 -#define EXT2_MAX_FRAG_SIZE 4096 -#define EXT2_MIN_FRAG_LOG_SIZE 10 -# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) - -/* - * Structure of a blocks group descriptor - */ -struct ext2_group_desc -{ - uint32_t bg_block_bitmap; /* Blocks bitmap block */ - uint32_t bg_inode_bitmap; /* Inodes bitmap block */ - uint32_t bg_inode_table; /* Inodes table block */ - uint16_t bg_free_blocks_count; /* Free blocks count */ - uint16_t bg_free_inodes_count; /* Free inodes count */ - uint16_t bg_used_dirs_count; /* Directories count */ - uint16_t bg_pad; - uint32_t bg_reserved[3]; -}; - -/* - * Macro-instructions used to manage group descriptors - */ -# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) -# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) -# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) - -/* - * Constants relative to the data blocks - */ -#define EXT2_NDIR_BLOCKS 12 -#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS -#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) -#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) -#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) - -/* - * Inode flags (GETFLAGS/SETFLAGS) - */ -#define EXT2_SECRM_FL FS_SECRM_FL /* Secure deletion */ -#define EXT2_UNRM_FL FS_UNRM_FL /* Undelete */ -#define EXT2_COMPR_FL FS_COMPR_FL /* Compress file */ -#define EXT2_SYNC_FL FS_SYNC_FL /* Synchronous updates */ -#define EXT2_IMMUTABLE_FL FS_IMMUTABLE_FL /* Immutable file */ -#define EXT2_APPEND_FL FS_APPEND_FL /* writes to file may only append */ -#define EXT2_NODUMP_FL FS_NODUMP_FL /* do not dump file */ -#define EXT2_NOATIME_FL FS_NOATIME_FL /* do not update atime */ -/* Reserved for compression usage... */ -#define EXT2_DIRTY_FL FS_DIRTY_FL -#define EXT2_COMPRBLK_FL FS_COMPRBLK_FL /* One or more compressed clusters */ -#define EXT2_NOCOMP_FL FS_NOCOMP_FL /* Don't compress */ -#define EXT2_ECOMPR_FL FS_ECOMPR_FL /* Compression error */ -/* End compression flags --- maybe not all used */ -#define EXT2_BTREE_FL FS_BTREE_FL /* btree format dir */ -#define EXT2_INDEX_FL FS_INDEX_FL /* hash-indexed directory */ -#define EXT2_IMAGIC_FL FS_IMAGIC_FL /* AFS directory */ -#define EXT2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL /* Reserved for ext3 */ -#define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */ -#define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */ -#define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/ -#define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */ - -#define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */ -#define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */ - -/* Flags that should be inherited by new inodes from their parent. */ -#define EXT2_FL_INHERITED (EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_COMPR_FL |\ - EXT2_SYNC_FL | EXT2_IMMUTABLE_FL | EXT2_APPEND_FL |\ - EXT2_NODUMP_FL | EXT2_NOATIME_FL | EXT2_COMPRBLK_FL|\ - EXT2_NOCOMP_FL | EXT2_JOURNAL_DATA_FL |\ - EXT2_NOTAIL_FL | EXT2_DIRSYNC_FL) - -/* Flags that are appropriate for regular files (all but dir-specific ones). */ -#define EXT2_REG_FLMASK (~(EXT2_DIRSYNC_FL | EXT2_TOPDIR_FL)) - -/* Flags that are appropriate for non-directories/regular files. */ -#define EXT2_OTHER_FLMASK (EXT2_NODUMP_FL | EXT2_NOATIME_FL) - -/* Mask out flags that are inappropriate for the given type of inode. */ -static inline uint32_t ext2_mask_flags(mode_t mode, uint32_t flags) -{ - if (S_ISDIR(mode)) - return flags; - else if (S_ISREG(mode)) - return flags & EXT2_REG_FLMASK; - else - return flags & EXT2_OTHER_FLMASK; -} - -/* - * ioctl commands - */ -#define EXT2_IOC_GETFLAGS FS_IOC_GETFLAGS -#define EXT2_IOC_SETFLAGS FS_IOC_SETFLAGS -#define EXT2_IOC_GETVERSION FS_IOC_GETVERSION -#define EXT2_IOC_SETVERSION FS_IOC_SETVERSION -#define EXT2_IOC_GETRSVSZ _IOR('f', 5, long) -#define EXT2_IOC_SETRSVSZ _IOW('f', 6, long) - -/* - * ioctl commands in 32 bit emulation - */ -#define EXT2_IOC32_GETFLAGS FS_IOC32_GETFLAGS -#define EXT2_IOC32_SETFLAGS FS_IOC32_SETFLAGS -#define EXT2_IOC32_GETVERSION FS_IOC32_GETVERSION -#define EXT2_IOC32_SETVERSION FS_IOC32_SETVERSION - -/* - * Structure of an inode on the disk - */ -struct ext2_inode { - uint16_t i_mode; /* File mode */ - uint16_t i_uid; /* Low 16 bits of Owner Uid */ - uint32_t i_size; /* Size in bytes */ - uint32_t i_atime; /* Access time */ - uint32_t i_ctime; /* Creation time */ - uint32_t i_mtime; /* Modification time */ - uint32_t i_dtime; /* Deletion Time */ - uint16_t i_gid; /* Low 16 bits of Group Id */ - uint16_t i_links_count; /* Links count */ - uint32_t i_blocks; /* Blocks count */ - uint32_t i_flags; /* File flags */ - union { - struct { - uint32_t l_i_reserved1; - } linux1; - struct { - uint32_t h_i_translator; - } hurd1; - struct { - uint32_t m_i_reserved1; - } masix1; - } osd1; /* OS dependent 1 */ - uint32_t i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - uint32_t i_generation; /* File version (for NFS) */ - uint32_t i_file_acl; /* File ACL */ - uint32_t i_dir_acl; /* Directory ACL */ - uint32_t i_faddr; /* Fragment address */ - union { - struct { - uint8_t l_i_frag; /* Fragment number */ - uint8_t l_i_fsize; /* Fragment size */ - uint16_t i_pad1; - uint16_t l_i_uid_high; /* these 2 fields */ - uint16_t l_i_gid_high; /* were reserved2[0] */ - uint32_t l_i_reserved2; - } linux2; - struct { - uint8_t h_i_frag; /* Fragment number */ - uint8_t h_i_fsize; /* Fragment size */ - uint16_t h_i_mode_high; - uint16_t h_i_uid_high; - uint16_t h_i_gid_high; - uint32_t h_i_author; - } hurd2; - struct { - uint8_t m_i_frag; /* Fragment number */ - uint8_t m_i_fsize; /* Fragment size */ - uint16_t m_pad1; - uint32_t m_i_reserved2[2]; - } masix2; - } osd2; /* OS dependent 2 */ -}; - -#define i_size_high i_dir_acl - -#if defined(__KERNEL__) || defined(__linux__) -#define i_reserved1 osd1.linux1.l_i_reserved1 -#define i_frag osd2.linux2.l_i_frag -#define i_fsize osd2.linux2.l_i_fsize -#define i_uid_low i_uid -#define i_gid_low i_gid -#define i_uid_high osd2.linux2.l_i_uid_high -#define i_gid_high osd2.linux2.l_i_gid_high -#define i_reserved2 osd2.linux2.l_i_reserved2 -#endif - -#ifdef __hurd__ -#define i_translator osd1.hurd1.h_i_translator -#define i_frag osd2.hurd2.h_i_frag -#define i_fsize osd2.hurd2.h_i_fsize -#define i_uid_high osd2.hurd2.h_i_uid_high -#define i_gid_high osd2.hurd2.h_i_gid_high -#define i_author osd2.hurd2.h_i_author -#endif - -#ifdef __masix__ -#define i_reserved1 osd1.masix1.m_i_reserved1 -#define i_frag osd2.masix2.m_i_frag -#define i_fsize osd2.masix2.m_i_fsize -#define i_reserved2 osd2.masix2.m_i_reserved2 -#endif - -/* - * File system states - */ -#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ -#define EXT2_ERROR_FS 0x0002 /* Errors detected */ - -/* - * Mount flags - */ -#define EXT2_MOUNT_CHECK 0x000001 /* Do mount-time checks */ -#define EXT2_MOUNT_OLDALLOC 0x000002 /* Don't use the new Orlov allocator */ -#define EXT2_MOUNT_GRPID 0x000004 /* Create files with directory's group */ -#define EXT2_MOUNT_DEBUG 0x000008 /* Some debugging messages */ -#define EXT2_MOUNT_ERRORS_CONT 0x000010 /* Continue on errors */ -#define EXT2_MOUNT_ERRORS_RO 0x000020 /* Remount fs ro on errors */ -#define EXT2_MOUNT_ERRORS_PANIC 0x000040 /* Panic on errors */ -#define EXT2_MOUNT_MINIX_DF 0x000080 /* Mimics the Minix statfs */ -#define EXT2_MOUNT_NOBH 0x000100 /* No buffer_heads */ -#define EXT2_MOUNT_NO_UID32 0x000200 /* Disable 32-bit UIDs */ -#define EXT2_MOUNT_XATTR_USER 0x004000 /* Extended user attributes */ -#define EXT2_MOUNT_POSIX_ACL 0x008000 /* POSIX Access Control Lists */ -#define EXT2_MOUNT_XIP 0x010000 /* Execute in place */ -#define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */ -#define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */ -#define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */ - - -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt -#define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & \ - EXT2_MOUNT_##opt) -/* - * Maximal mount counts between two filesystem checks - */ -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ - -/* - * Behaviour when detecting errors - */ -#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ -#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ -#define EXT2_ERRORS_PANIC 3 /* Panic */ -#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE - -/* - * Structure of the super block - */ -struct ext2_super_block { - uint32_t s_inodes_count; /* Inodes count */ - uint32_t s_blocks_count; /* Blocks count */ - uint32_t s_r_blocks_count; /* Reserved blocks count */ - uint32_t s_free_blocks_count; /* Free blocks count */ - uint32_t s_free_inodes_count; /* Free inodes count */ - uint32_t s_first_data_block; /* First Data Block */ - uint32_t s_log_block_size; /* Block size */ - uint32_t s_log_frag_size; /* Fragment size */ - uint32_t s_blocks_per_group; /* # Blocks per group */ - uint32_t s_frags_per_group; /* # Fragments per group */ - uint32_t s_inodes_per_group; /* # Inodes per group */ - uint32_t s_mtime; /* Mount time */ - uint32_t s_wtime; /* Write time */ - uint16_t s_mnt_count; /* Mount count */ - uint16_t s_max_mnt_count; /* Maximal mount count */ - uint16_t s_magic; /* Magic signature */ - uint16_t s_state; /* File system state */ - uint16_t s_errors; /* Behaviour when detecting errors */ - uint16_t s_minor_rev_level; /* minor revision level */ - uint32_t s_lastcheck; /* time of last check */ - uint32_t s_checkinterval; /* max. time between checks */ - uint32_t s_creator_os; /* OS */ - uint32_t s_rev_level; /* Revision level */ - uint16_t s_def_resuid; /* Default uid for reserved blocks */ - uint16_t s_def_resgid; /* Default gid for reserved blocks */ - /* - * These fields are for EXT2_DYNAMIC_REV superblocks only. - * - * Note: the difference between the compatible feature set and - * the incompatible feature set is that if there is a bit set - * in the incompatible feature set that the kernel doesn't - * know about, it should refuse to mount the filesystem. - * - * e2fsck's requirements are more strict; if it doesn't know - * about a feature in either the compatible or incompatible - * feature set, it must abort and not try to meddle with - * things it doesn't understand... - */ - uint32_t s_first_ino; /* First non-reserved inode */ - uint16_t s_inode_size; /* size of inode structure */ - uint16_t s_block_group_nr; /* block group # of this superblock */ - uint32_t s_feature_compat; /* compatible feature set */ - uint32_t s_feature_incompat; /* incompatible feature set */ - uint32_t s_feature_ro_compat; /* readonly-compatible feature set */ - uint8_t s_uuid[16]; /* 128-bit uuid for volume */ - char s_volume_name[16]; /* volume name */ - char s_last_mounted[64]; /* directory where last mounted */ - uint32_t s_algorithm_usage_bitmap; /* For compression */ - /* - * Performance hints. Directory preallocation should only - * happen if the EXT2_COMPAT_PREALLOC flag is on. - */ - uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ - uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ - uint16_t s_padding1; - /* - * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. - */ - uint8_t s_journal_uuid[16]; /* uuid of journal superblock */ - uint32_t s_journal_inum; /* inode number of journal file */ - uint32_t s_journal_dev; /* device number of journal file */ - uint32_t s_last_orphan; /* start of list of inodes to delete */ - uint32_t s_hash_seed[4]; /* HTREE hash seed */ - uint8_t s_def_hash_version; /* Default hash version to use */ - uint8_t s_reserved_char_pad; - uint16_t s_reserved_word_pad; - uint32_t s_default_mount_opts; - uint32_t s_first_meta_bg; /* First metablock block group */ - uint32_t s_reserved[190]; /* Padding to the end of the block */ -}; - -/* - * Codes for operating systems - */ -#define EXT2_OS_LINUX 0 -#define EXT2_OS_HURD 1 -#define EXT2_OS_MASIX 2 -#define EXT2_OS_FREEBSD 3 -#define EXT2_OS_LITES 4 - -/* - * Revision levels - */ -#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ -#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ - -#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV -#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV - -#define EXT2_GOOD_OLD_INODE_SIZE 128 - -/* - * Feature set definitions - */ - -#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) ) -#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) ) -#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) ) -#define EXT2_SET_COMPAT_FEATURE(sb,mask) \ - EXT2_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask) -#define EXT2_SET_RO_COMPAT_FEATURE(sb,mask) \ - EXT2_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask) -#define EXT2_SET_INCOMPAT_FEATURE(sb,mask) \ - EXT2_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask) -#define EXT2_CLEAR_COMPAT_FEATURE(sb,mask) \ - EXT2_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask) -#define EXT2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ - EXT2_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask) -#define EXT2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ - EXT2_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask) - -#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 -#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 -#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 -#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010 -#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 -#define EXT2_FEATURE_COMPAT_ANY 0xffffffff - -#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 EXT2_FEATURE_RO_COMPAT_ANY 0xffffffff - -#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 -#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 EXT2_FEATURE_INCOMPAT_ANY 0xffffffff - -#define EXT2_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR -#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \ - EXT2_FEATURE_INCOMPAT_META_BG) -#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_RO_COMPAT_UNSUPPORTED ~EXT2_FEATURE_RO_COMPAT_SUPP -#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED ~EXT2_FEATURE_INCOMPAT_SUPP - -/* - * Default values for user and/or group using reserved blocks - */ -#define EXT2_DEF_RESUID 0 -#define EXT2_DEF_RESGID 0 - -/* - * Default mount options - */ -#define EXT2_DEFM_DEBUG 0x0001 -#define EXT2_DEFM_BSDGROUPS 0x0002 -#define EXT2_DEFM_XATTR_USER 0x0004 -#define EXT2_DEFM_ACL 0x0008 -#define EXT2_DEFM_UID16 0x0010 - /* Not used by ext2, but reserved for use by ext3 */ -#define EXT3_DEFM_JMODE 0x0060 -#define EXT3_DEFM_JMODE_DATA 0x0020 -#define EXT3_DEFM_JMODE_ORDERED 0x0040 -#define EXT3_DEFM_JMODE_WBACK 0x0060 - -/* - * Structure of a directory entry - */ -#define EXT2_NAME_LEN 255 - -struct ext2_dir_entry { - uint32_t inode; /* Inode number */ - uint16_t rec_len; /* Directory entry length */ - uint16_t name_len; /* Name length */ - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * The new version of the directory entry. Since EXT2 structures are - * stored in intel byte order, and the name_len field could never be - * bigger than 255 chars, it's safe to reclaim the extra byte for the - * file_type field. - */ -struct ext2_dir_entry_2 { - uint32_t inode; /* Inode number */ - uint16_t rec_len; /* Directory entry length */ - uint8_t name_len; /* Name length */ - uint8_t file_type; - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * Ext2 directory file types. Only the low 3 bits are used. The - * other bits are reserved for now. - */ -enum { - EXT2_FT_UNKNOWN = 0, - EXT2_FT_REG_FILE = 1, - EXT2_FT_DIR = 2, - EXT2_FT_CHRDEV = 3, - EXT2_FT_BLKDEV = 4, - EXT2_FT_FIFO = 5, - EXT2_FT_SOCK = 6, - EXT2_FT_SYMLINK = 7, - EXT2_FT_MAX -}; - -/* - * EXT2_DIR_PAD defines the directory entries boundaries - * - * NOTE: It must be a multiple of 4 - */ -#define EXT2_DIR_PAD 4 -#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) -#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ - ~EXT2_DIR_ROUND) -#define EXT2_MAX_REC_LEN ((1<<16)-1) - -#endif diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 2d9d72000..69b25c946 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -48,7 +48,7 @@ #include "libbb.h" #include -#include "bb_linux_ext2_fs.h" +#include "bb_e2fs_defs.h" #define ENABLE_FEATURE_MKFS_EXT2_RESERVED_GDT 0 #define ENABLE_FEATURE_MKFS_EXT2_DIR_INDEX 1 -- cgit v1.2.3-55-g6feb From 75e1e7b3d538fa1a2396cd36122e0be702931345 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 16:00:20 +0200 Subject: mktemp: add support for -u zlib-1.2.6 Makefile uses "mktemp -u". function old new delta ___path_search - 266 +266 mktemp_main 165 250 +85 tempnam - 79 +79 packed_usage 29189 29176 -13 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 1/1 up/down: 430/-13) Total: 417 bytes Signed-off-by: Denys Vlasenko --- debianutils/mktemp.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c index 007cb1c5b..dbe430955 100644 --- a/debianutils/mktemp.c +++ b/debianutils/mktemp.c @@ -41,6 +41,7 @@ ////usage: "\n -q Fail silently on errors" - we ignore this opt //usage: "\n -t Prepend base directory name to TEMPLATE" //usage: "\n -p DIR Use DIR as a base directory (implies -t)" +//usage: "\n -u Do not create anything; print a name" //usage: "\n" //usage: "\nBase directory is: -p DIR, else $TMPDIR, else /tmp" //usage: @@ -63,6 +64,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv) OPT_q = 1 << 1, OPT_t = 1 << 2, OPT_p = 1 << 3, + OPT_u = 1 << 4, }; path = getenv("TMPDIR"); @@ -71,7 +73,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv) /* -q is ignored */ opt_complementary = "?1"; /* 1 argument max */ - opts = getopt32(argv, "dqtp:", &path); + opts = getopt32(argv, "dqtp:u", &path); chp = argv[optind]; if (!chp) { @@ -81,6 +83,22 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv) chp = xstrdup("tmp.XXXXXX"); opts |= OPT_t; } + + if (opts & OPT_u) { + /* Remove (up to) 6 X's */ + unsigned len = strlen(chp); + int cnt = len > 6 ? 6 : len; + while (--cnt >= 0 && chp[--len] == 'X') + chp[len] = '\0'; + + chp = tempnam(opts & (OPT_t|OPT_p) ? path : "./", chp); + if (!chp) + return EXIT_FAILURE; + if (!(opts & (OPT_t|OPT_p))) + chp += 2; + goto ret; + } + if (opts & (OPT_t|OPT_p)) chp = concat_path_file(path, chp); @@ -91,8 +109,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv) if (mkstemp(chp) < 0) return EXIT_FAILURE; } - + ret: puts(chp); - return EXIT_SUCCESS; } -- cgit v1.2.3-55-g6feb From 53772869bc4ecfe68ac8d53c50a6057e7872df06 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 16:11:25 +0200 Subject: who,less: tweaked help text function old new delta packed_usage 29176 29173 -3 Signed-off-by: Denys Vlasenko --- coreutils/who.c | 1 + miscutils/less.c | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/coreutils/who.c b/coreutils/who.c index c6c925264..597a4d581 100644 --- a/coreutils/who.c +++ b/coreutils/who.c @@ -48,6 +48,7 @@ //usage:#define who_full_usage "\n\n" //usage: "Show who is logged on\n" //usage: "\n -a Show all" +//usage: "\n -a Print column headers" #include "libbb.h" diff --git a/miscutils/less.c b/miscutils/less.c index 045fd2db3..f0187bf8a 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -42,14 +42,11 @@ //config: brackets, facilitating programming. //config: //config:config FEATURE_LESS_FLAGS -//config: bool "Enable extra flags" +//config: bool "Enable -m/-M" //config: default y //config: depends on LESS //config: help -//config: The extra flags provided do the following: -//config: -//config: The -M flag enables a more sophisticated status line. -//config: The -m flag enables a simpler status line with a percentage. +//config: The -M/-m flag enables a more sophisticated status line. //config: //config:config FEATURE_LESS_MARKS //config: bool "Enable marks" @@ -101,15 +98,17 @@ //config: Enables "-N" command. //usage:#define less_trivial_usage -//usage: "[-EMNmh~I?] [FILE]..." +//usage: "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~I?] [FILE]..." //usage:#define less_full_usage "\n\n" //usage: "View FILE (or stdin) one screenful at a time\n" //usage: "\n -E Quit once the end of a file is reached" +//usage: IF_FEATURE_LESS_FLAGS( //usage: "\n -M,-m Display status line with line numbers" //usage: "\n and percentage through the file" +//usage: ) //usage: "\n -N Prefix line number to each line" //usage: "\n -I Ignore case in all searches" -//usage: "\n -~ Suppress ~s displayed past the end of the file" +//usage: "\n -~ Suppress ~s displayed past EOF" #include /* sched_yield() */ -- cgit v1.2.3-55-g6feb From 6500d123d01af895d2b8eae1a36e553a1f75e211 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 17:10:31 +0200 Subject: udhcp: make arpping code resistant to time jumps Signed-off-by: Denys Vlasenko --- networking/udhcp/arpping.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index ff6347847..b43e52e96 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c @@ -118,8 +118,13 @@ int FAST_FUNC arpping(uint32_t test_nip, break; } } - timeout_ms -= (unsigned)monotonic_ms() - prevTime; - } while (timeout_ms > 0); + timeout_ms -= (unsigned)monotonic_ms() - prevTime + 1; + + /* We used to check "timeout_ms > 0", but + * this is more under/overflow-resistant + * (people did see overflows here when system time jumps): + */ + } while ((unsigned)timeout_ms <= 2000); ret: close(s); -- cgit v1.2.3-55-g6feb From d778e6c6f81b0b1c74602c5c6ddf8d1b235146de Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 17 Apr 2012 19:25:13 +0200 Subject: hwclock: fix wrong comparison of time value (when it will overlow int) Signed-off-by: Denys Vlasenko --- util-linux/hwclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 6b4e29bfa..379eeb253 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -43,7 +43,7 @@ static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc) while (1) { rtc_read_tm(&tm_time, fd); gettimeofday(sys_tv, NULL); - if (before != tm_time.tm_sec) + if (before != (int)tm_time.tm_sec) break; } } -- cgit v1.2.3-55-g6feb From b110e1fecb4398524e857d772c5cc635615b0ac4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 18 Apr 2012 14:38:15 +0200 Subject: who: fix typo in help text Signed-off-by: Denys Vlasenko --- coreutils/who.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreutils/who.c b/coreutils/who.c index 597a4d581..f955ce6d3 100644 --- a/coreutils/who.c +++ b/coreutils/who.c @@ -48,7 +48,7 @@ //usage:#define who_full_usage "\n\n" //usage: "Show who is logged on\n" //usage: "\n -a Show all" -//usage: "\n -a Print column headers" +//usage: "\n -H Print column headers" #include "libbb.h" -- cgit v1.2.3-55-g6feb From 8cab66730aa59c121eb98b20f4ae7ddda1c3ecf6 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 20 Apr 2012 14:48:00 +0200 Subject: fix build breakage found by randconfig Signed-off-by: Denys Vlasenko --- archival/libarchive/Kbuild.src | 1 + libbb/Kbuild.src | 1 + networking/httpd.c | 4 +++- networking/udhcp/d6_common.h | 4 ++++ networking/udhcp/d6_dhcpc.c | 2 +- scripts/randomtest.loop | 12 +++++++++--- shell/hush.c | 2 ++ 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/archival/libarchive/Kbuild.src b/archival/libarchive/Kbuild.src index 39c18f264..7ae013e84 100644 --- a/archival/libarchive/Kbuild.src +++ b/archival/libarchive/Kbuild.src @@ -53,6 +53,7 @@ lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o lib-$(CONFIG_UNZIP) += decompress_gunzip.o lib-$(CONFIG_LZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o +lib-$(CONFIG_MODINFO) += open_transformer.o lib-$(CONFIG_FEATURE_SEAMLESS_Z) += open_transformer.o decompress_uncompress.o lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_gunzip.o lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 335b34128..61eec26f7 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -170,6 +170,7 @@ lib-$(CONFIG_PING) += inet_cksum.o lib-$(CONFIG_TRACEROUTE) += inet_cksum.o lib-$(CONFIG_TRACEROUTE6) += inet_cksum.o lib-$(CONFIG_UDHCPC) += inet_cksum.o +lib-$(CONFIG_UDHCPC6) += inet_cksum.o lib-$(CONFIG_UDHCPD) += inet_cksum.o # We shouldn't build xregcomp.c if we don't need it - this ensures we don't diff --git a/networking/httpd.c b/networking/httpd.c index fb6ecbf70..12218a0a3 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1676,7 +1676,7 @@ static int checkPermIP(void) #if ENABLE_FEATURE_HTTPD_BASIC_AUTH -# if ENABLE_FEATURE_HTTPD_AUTH_MD5 && ENABLE_PAM +# if ENABLE_PAM struct pam_userinfo { const char *name; const char *pw; @@ -1842,7 +1842,9 @@ static int check_user_passwd(const char *path, char *user_and_passwd) if (passwd[0] == '$' && isdigit(passwd[1])) { char *encrypted; +# if !ENABLE_PAM check_encrypted: +# endif /* encrypt pwd from peer and check match with local one */ encrypted = pw_encrypt( /* pwd (from peer): */ colon_after_user + 1, diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h index 4dd7e621e..eb211ea0f 100644 --- a/networking/udhcp/d6_common.h +++ b/networking/udhcp/d6_common.h @@ -115,7 +115,11 @@ int FAST_FUNC d6_send_kernel_packet( struct in6_addr *dst_ipv6, int dest_port ); +#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2 void FAST_FUNC d6_dump_packet(struct d6_packet *packet); +#else +# define d6_dump_packet(packet) ((void)0) +#endif POP_SAVED_FUNCTION_VISIBILITY diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 23e6862dc..a792a9dca 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c @@ -19,7 +19,7 @@ //applet:IF_UDHCPC6(APPLET(udhcpc6, BB_DIR_USR_BIN, BB_SUID_DROP)) -//kbuild:lib-$(CONFIG_UDHCPC6) += d6_dhcpc.o d6_packet.o d6_socket.o common.o +//kbuild:lib-$(CONFIG_UDHCPC6) += d6_dhcpc.o d6_packet.o d6_socket.o common.o socket.o signalpipe.o #include diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop index 2c8a9bd35..758a8e862 100755 --- a/scripts/randomtest.loop +++ b/scripts/randomtest.loop @@ -1,5 +1,7 @@ #!/bin/sh +run_testsuite=true + test -d "$1" || { echo "'$1' is not a directory"; exit 1; } test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; } @@ -21,7 +23,9 @@ while sleep 1; do echo "Failed build in: failed.$dir" exit 1 # you may comment this out... let fail++ - else + continue + fi + if $run_testsuite; then ( cd -- "$dir/testsuite" || exit 1 echo "Running testsuite in $dir..." @@ -29,10 +33,12 @@ while sleep 1; do ) if test $? != 0; then echo "Failed runtest in $dir" - exit 1 + exit 1 # you may comment this out... + let fail++ + continue fi tail -n10 -- "$dir/testsuite/runtest.log" - rm -rf -- "$dir" fi + rm -rf -- "$dir" let cnt++ done diff --git a/shell/hush.c b/shell/hush.c index 180ae4a62..51d38d3ae 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -324,6 +324,8 @@ typedef void (*hush_sighandler_t)(int); # define ENABLE_FEATURE_EDITING 0 # undef ENABLE_FEATURE_EDITING_FANCY_PROMPT # define ENABLE_FEATURE_EDITING_FANCY_PROMPT 0 +# undef ENABLE_FEATURE_EDITING_SAVE_ON_EXIT +# define ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 0 #endif /* Do we support ANY keywords? */ -- cgit v1.2.3-55-g6feb From 56443cdbdd23f7691df833d45f8c3468e07115bb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 20 Apr 2012 15:07:22 +0200 Subject: whitespace fixes Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 2 +- util-linux/mount.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 460e27fed..db8416712 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -2517,7 +2517,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman switch (ic) { //case KEYCODE_LEFT: - bash doesn't do this case 'b': - ctrl_left(); + ctrl_left(); break; //case KEYCODE_RIGHT: - bash doesn't do this case 'f': diff --git a/util-linux/mount.c b/util-linux/mount.c index 807e89747..f1da30fac 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -1337,7 +1337,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) "udp\0" "lock\0" "rdirplus\0" - "acl\0"; + "acl\0"; int val = 1; if (!strncmp(opt, "no", 2)) { val = 0; @@ -1388,7 +1388,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) nordirplus = !val; break; case 12: // acl - noacl = !val; + noacl = !val; break; default: bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt); @@ -1404,7 +1404,7 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) | (nocto ? NFS_MOUNT_NOCTO : 0) | (noac ? NFS_MOUNT_NOAC : 0) | (nordirplus ? NFS_MOUNT_NORDIRPLUS : 0) - | (noacl ? NFS_MOUNT_NOACL : 0); + | (noacl ? NFS_MOUNT_NOACL : 0); if (nfs_mount_version >= 2) data.flags |= (tcp ? NFS_MOUNT_TCP : 0); if (nfs_mount_version >= 3) -- cgit v1.2.3-55-g6feb From 6dca17261065eabe6102a7e7facf9ebb717315e5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 20 Apr 2012 18:24:09 +0200 Subject: fix build breakage with gcc 4.2.1 Signed-off-by: Denys Vlasenko --- Makefile.flags | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.flags b/Makefile.flags index f745c2fdf..c43c8dca8 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -105,7 +105,10 @@ export SYSROOT=$(CONFIG_SYSROOT) endif # Android has no separate crypt library -CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' | $(CC) $(CFLAGS) -lcrypt -o /dev/null -xc - >/dev/null 2>&1 && echo "y") +# gcc-4.2.1 fails if we try to feed C source on stdin: +# echo 'int main(void){return 0;}' | $(CC) $(CFLAGS) -lcrypt -o /dev/null -xc - +# fall back to using a temp file: +CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >crypttest.c; $(CC) $(CFLAGS) -lcrypt -o /dev/null crypttest.c >/dev/null 2>&1 && echo "y"; rm crypttest.c) ifeq ($(CRYPT_AVAILABLE),y) LDLIBS += m crypt else -- cgit v1.2.3-55-g6feb From df9196d824ea9bca7590edade631362e89b5c6ce Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 20 Apr 2012 18:59:14 +0200 Subject: Fix another build failure found with randconfig Signed-off-by: Denys Vlasenko --- archival/libarchive/Kbuild.src | 1 + 1 file changed, 1 insertion(+) diff --git a/archival/libarchive/Kbuild.src b/archival/libarchive/Kbuild.src index 7ae013e84..959221789 100644 --- a/archival/libarchive/Kbuild.src +++ b/archival/libarchive/Kbuild.src @@ -54,6 +54,7 @@ lib-$(CONFIG_UNZIP) += decompress_gunzip.o lib-$(CONFIG_LZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o lib-$(CONFIG_MODINFO) += open_transformer.o +lib-$(CONFIG_INSMOD) += open_transformer.o lib-$(CONFIG_FEATURE_SEAMLESS_Z) += open_transformer.o decompress_uncompress.o lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_gunzip.o lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o -- cgit v1.2.3-55-g6feb From c9665631d37daeb90084a28b3f339ce5296677a9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 21 Apr 2012 14:35:32 +0200 Subject: mdev: fix mode of creatred node if config file support is not configured Signed-off-by: Denys Vlasenko --- util-linux/mdev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 67de52d06..0a34122b4 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -164,7 +164,10 @@ struct globals { struct rule cur_rule; } FIX_ALIASING; #define G (*(struct globals*)&bb_common_bufsiz1) -#define INIT_G() do { } while (0) +#define INIT_G() do { \ + IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.maj = -1;) \ + IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.mode = 0660;) \ +} while (0) /* Prevent infinite loops in /sys symlinks */ @@ -477,9 +480,8 @@ static void make_device(char *path, int delete) } } /* else: it's final implicit "match-all" rule */ -#endif - rule_matches: +#endif dbg("rule matched"); /* Build alias name */ -- cgit v1.2.3-55-g6feb From d2266d43bfe3cd9a40deb50dfe80ab679d2def0c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 22 Apr 2012 03:37:01 +0200 Subject: udhcpc: fix improper size calculation for OPTION_STRING_HOST Signed-off-by: Denys Vlasenko --- networking/udhcp/dhcpc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 2f2016cd5..ddb328dd5 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -101,6 +101,7 @@ static const uint8_t len_of_option_as_string[] = { [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "), [OPTION_6RD ] = sizeof("32 128 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 255.255.255.255 "), [OPTION_STRING ] = 1, + [OPTION_STRING_HOST ] = 1, #if ENABLE_FEATURE_UDHCP_RFC3397 [OPTION_DNS_STRING ] = 1, /* unused */ /* Hmmm, this severely overestimates size if SIP_SERVERS option -- cgit v1.2.3-55-g6feb From f5234398ef3010b68468cafe3e2ea89b2bb08a17 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 22 Apr 2012 03:38:31 +0200 Subject: Bump version to 1.20.0 Signed-off-by: Denys Vlasenko --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 35d2e1e00..d5beb0459 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1 PATCHLEVEL = 20 SUBLEVEL = 0 -EXTRAVERSION = .git +EXTRAVERSION = NAME = Unnamed # *DOCUMENTATION* -- cgit v1.2.3-55-g6feb