diff options
author | Theodore Ts'o <tytso@mit.edu> | 2021-01-23 01:05:43 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2021-01-23 01:05:43 -0500 |
commit | 45fa214d623e4e4a8844535a7e80dece63f121c8 (patch) | |
tree | 3e2b805aff30afa886d0a73e8c9f6de196ac27b7 | |
parent | 26cb9f7db66feef485c377ed10ae1ec2d2003c5a (diff) | |
parent | b3f288ed9fbb1b12c67fd00860f286a800427125 (diff) | |
download | e2fsprogs-45fa214d623e4e4a8844535a7e80dece63f121c8.tar.gz |
Merge branch 'maint' into next
-rw-r--r-- | debugfs/util.c | 6 | ||||
-rw-r--r-- | e2fsck/unix.c | 2 | ||||
-rw-r--r-- | lib/ext2fs/compiler.h | 22 | ||||
-rw-r--r-- | lib/ext2fs/kernel-list.h | 4 | ||||
-rw-r--r-- | lib/ext2fs/mmp.c | 12 | ||||
-rw-r--r-- | lib/ext2fs/rbtree.h | 12 | ||||
-rw-r--r-- | lib/ext2fs/sparse_io.c | 4 | ||||
-rw-r--r-- | lib/ext2fs/unix_io.c | 2 | ||||
-rw-r--r-- | misc/Makefile.in | 2 | ||||
-rw-r--r-- | misc/e2fuzz.c | 3 | ||||
-rw-r--r-- | misc/mke2fs.8.in | 10 | ||||
-rw-r--r-- | misc/mke2fs.c | 4 | ||||
-rw-r--r-- | misc/tune2fs.c | 6 |
13 files changed, 54 insertions, 35 deletions
diff --git a/debugfs/util.c b/debugfs/util.c index da3a7ef76..fb05e897b 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -545,10 +545,8 @@ errcode_t read_list(char *str, blk64_t **list, size_t *len) goto err; } l = realloc(lst, sizeof(blk64_t) * (ln + y - x + 1)); - if (l == NULL) { - retval = ENOMEM; - goto err; - } + if (l == NULL) + return ENOMEM; lst = l; for (; x <= y; x++) lst[ln++] = x; diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 84224c14f..4fe5fe4cb 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1699,7 +1699,7 @@ failure: * or informational messages to the user. */ if (ctx->device_name == 0 && sb->s_volume_name[0]) - ctx->device_name = string_copy(ctx, sb->s_volume_name, + ctx->device_name = string_copy(ctx, (char *) sb->s_volume_name, sizeof(sb->s_volume_name)); if (ctx->device_name == 0) diff --git a/lib/ext2fs/compiler.h b/lib/ext2fs/compiler.h new file mode 100644 index 000000000..9aa9b4ec6 --- /dev/null +++ b/lib/ext2fs/compiler.h @@ -0,0 +1,22 @@ +#ifndef _EXT2FS_COMPILER_H +#define _EXT2FS_COMPILER_H + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +#undef offsetof +#if __has_builtin(__builtin_offsetof) +#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) +#elif defined(__compiler_offsetof) +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + +#endif /* _EXT2FS_COMPILER_H */ diff --git a/lib/ext2fs/kernel-list.h b/lib/ext2fs/kernel-list.h index 01f4f6b95..dd7b8e07d 100644 --- a/lib/ext2fs/kernel-list.h +++ b/lib/ext2fs/kernel-list.h @@ -1,6 +1,8 @@ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H +#include "compiler.h" + /* * Simple doubly linked list implementation. * @@ -101,7 +103,7 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea } #define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + container_of(ptr, type, member) #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c index e96a22732..c21ae272f 100644 --- a/lib/ext2fs/mmp.c +++ b/lib/ext2fs/mmp.c @@ -172,9 +172,11 @@ unsigned ext2fs_mmp_new_seq(void) #ifdef CONFIG_MMP unsigned new_seq; struct timeval tv; + unsigned long pid = getpid(); gettimeofday(&tv, 0); - srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); + pid = (pid >> 16) | ((pid & 0xFFFF) << 16); + srand(pid ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); gettimeofday(&tv, 0); /* Crank the random number generator a few times */ @@ -210,11 +212,11 @@ static errcode_t ext2fs_mmp_reset(ext2_filsys fs) mmp_s->mmp_seq = EXT4_MMP_SEQ_CLEAN; mmp_s->mmp_time = 0; #ifdef HAVE_GETHOSTNAME - gethostname(mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename)); + gethostname((char *) mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename)); #else mmp_s->mmp_nodename[0] = '\0'; #endif - strncpy(mmp_s->mmp_bdevname, fs->device_name, + strncpy((char *) mmp_s->mmp_bdevname, fs->device_name, sizeof(mmp_s->mmp_bdevname)); mmp_s->mmp_check_interval = fs->super->s_mmp_update_interval; @@ -352,11 +354,11 @@ clean_seq: mmp_s->mmp_seq = seq = ext2fs_mmp_new_seq(); #ifdef HAVE_GETHOSTNAME - gethostname(mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename)); + gethostname((char *) mmp_s->mmp_nodename, sizeof(mmp_s->mmp_nodename)); #else strcpy(mmp_s->mmp_nodename, "unknown host"); #endif - strncpy(mmp_s->mmp_bdevname, fs->device_name, + strncpy((char *) mmp_s->mmp_bdevname, fs->device_name, sizeof(mmp_s->mmp_bdevname)); retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_buf); diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h index 9e8067799..dfeeb2342 100644 --- a/lib/ext2fs/rbtree.h +++ b/lib/ext2fs/rbtree.h @@ -96,17 +96,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, #include <stdlib.h> #include <stdint.h> - -#undef offsetof -#ifdef __compiler_offsetof -#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) -#else -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - -#define container_of(ptr, type, member) ({ \ - const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#include "compiler.h" struct rb_node { diff --git a/lib/ext2fs/sparse_io.c b/lib/ext2fs/sparse_io.c index 5e0e2cd9a..f287e76d8 100644 --- a/lib/ext2fs/sparse_io.c +++ b/lib/ext2fs/sparse_io.c @@ -138,7 +138,7 @@ static errcode_t io_manager_configure(struct sparse_io_params *params, retval = io_manager_import_sparse(params, sm, io); if (retval) { if (!params->block_size || !params->blocks_count) { - retval = -EINVAL; + retval = EINVAL; goto err_params; } sm->block_size = params->block_size; @@ -229,7 +229,7 @@ static errcode_t read_sparse_argv(const char *name, bool is_fd, if (ret < 1) { free(sparse_params->file); - return -EINVAL; + return EINVAL; } return 0; } diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 2df53e51c..73f5667ec 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -822,7 +822,7 @@ static errcode_t unixfd_open(const char *str_fd, int flags, #if defined(HAVE_FCNTL) fd_flags = fcntl(fd, F_GETFD); if (fd_flags == -1) - return -EBADF; + return EBADF; flags = 0; if (fd_flags & O_RDWR) diff --git a/misc/Makefile.in b/misc/Makefile.in index 26b4fd90d..bde7539c2 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -249,7 +249,7 @@ e4defrag: $(E4DEFRAG_OBJS) $(DEPLIBS) e4crypt: $(E4CRYPT_OBJS) $(DEPLIBS) $(DEPSTATIC_LIBUUID) $(E) " LD $@" $(Q) $(CC) $(ALL_LDFLAGS) -o e4crypt $(E4CRYPT_OBJS) \ - $(LIBUUID) $(LIBS) + $(LIBUUID) $(LIBS) $(SYSLIBS) e4defrag.profiled: $(E4DEFRAG_OBJS) $(PROFILED_DEPLIBS) $(E) " LD $@" diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c index 1ace1df5a..0ceece9e6 100644 --- a/misc/e2fuzz.c +++ b/misc/e2fuzz.c @@ -173,7 +173,8 @@ static uint64_t rand_num(uint64_t min, uint64_t max) for (i = 0; i < sizeof(x); i++) px[i] = random(); - return min + (uint64_t)((double)(max - min) * (x / (UINT64_MAX + 1.0))); + return min + (uint64_t)((double)(max - min) * + (x / ((double) UINT64_MAX + 1.0))); } static int process_fs(const char *fsname) diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 2833b408e..00dcc906f 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -207,12 +207,14 @@ manual page for more details. .SH OPTIONS .TP .BI \-b " block-size" -Specify the size of blocks in bytes. Valid block-size values are 1024, -2048 and 4096 bytes per block. If omitted, -block-size is heuristically determined by the filesystem size and +Specify the size of blocks in bytes. Valid block-size values are powers of two +from 1024 up to 65536 (however note that the kernel is able to mount only +filesystems with block-size smaller or equal to the system page size - 4k on +x86 systems, upto 64k on ppc64 or aarch64 depending on kernel configuration). +If omitted, block-size is heuristically determined by the filesystem size and the expected usage of the filesystem (see the .B \-T -option). If +option). In most common cases, the default block size is 4k. If .I block-size is preceded by a negative sign ('-'), then .B mke2fs diff --git a/misc/mke2fs.c b/misc/mke2fs.c index d7ce7c9d6..995764274 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -3189,7 +3189,7 @@ int main (int argc, char *argv[]) if (volume_label) { memset(fs->super->s_volume_name, 0, sizeof(fs->super->s_volume_name)); - strncpy(fs->super->s_volume_name, volume_label, + strncpy((char *) fs->super->s_volume_name, volume_label, sizeof(fs->super->s_volume_name)); } @@ -3199,7 +3199,7 @@ int main (int argc, char *argv[]) if (mount_dir) { memset(fs->super->s_last_mounted, 0, sizeof(fs->super->s_last_mounted)); - strncpy(fs->super->s_last_mounted, mount_dir, + strncpy((char *) fs->super->s_last_mounted, mount_dir, sizeof(fs->super->s_last_mounted)); } diff --git a/misc/tune2fs.c b/misc/tune2fs.c index f3bfb0472..e660309f3 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -1670,6 +1670,8 @@ static int handle_quota_options(ext2_filsys fs) com_err(program_name, retval, _("while updating quota limits (%d)"), qtype); + quota_errout: + quota_release_context(&qctx); return 1; } } @@ -1678,7 +1680,7 @@ static int handle_quota_options(ext2_filsys fs) com_err(program_name, retval, _("while writing quota file (%d)"), qtype); - return 1; + goto quota_errout; } /* Enable Quota feature if one of quota enabled */ if (!ext2fs_has_feature_quota(fs->super)) { @@ -1696,7 +1698,7 @@ static int handle_quota_options(ext2_filsys fs) com_err(program_name, retval, _("while removing quota file (%d)"), qtype); - return 1; + goto quota_errout; } if (qtype == PRJQUOTA) { ext2fs_clear_feature_project(fs->super); |