summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/dev.c1
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/inode.c8
-rw-r--r--fs/btrfs/kernel-shared/btrfs_tree.h5
-rw-r--r--fs/btrfs/volumes.c3
-rw-r--r--fs/cbfs/cbfs.c2
-rw-r--r--fs/cramfs/cramfs.c2
-rw-r--r--fs/cramfs/uncompress.c2
-rw-r--r--fs/erofs/data.c2
-rw-r--r--fs/ext4/dev.c1
-rw-r--r--fs/ext4/ext4_common.c24
-rw-r--r--fs/ext4/ext4_common.h5
-rw-r--r--fs/ext4/ext4_journal.c1
-rw-r--r--fs/ext4/ext4_write.c15
-rw-r--r--fs/ext4/ext4fs.c1
-rw-r--r--fs/fat/fat.c1
-rw-r--r--fs/fat/fat_write.c1
-rw-r--r--fs/fs.c14
-rw-r--r--fs/fs_internal.c1
-rw-r--r--fs/jffs2/compr_lzo.c1
-rw-r--r--fs/jffs2/compr_rubin.c1
-rw-r--r--fs/jffs2/compr_zlib.c2
-rw-r--r--fs/jffs2/jffs2_1pass.c13
-rw-r--r--fs/jffs2/jffs2_private.h1
-rw-r--r--fs/jffs2/mergesort.c1
-rw-r--r--fs/jffs2/mini_inflate.c2
-rw-r--r--fs/sandbox/host_bootdev.c1
-rw-r--r--fs/sandbox/sandboxfs.c8
-rw-r--r--fs/semihostingfs.c2
-rw-r--r--fs/squashfs/sqfs.c110
-rw-r--r--fs/squashfs/sqfs_inode.c9
-rw-r--r--fs/ubifs/replay.c2
-rw-r--r--fs/ubifs/super.c11
-rw-r--r--fs/ubifs/ubifs-media.h2
-rw-r--r--fs/ubifs/ubifs.c95
-rw-r--r--fs/yaffs2/yaffs_attribs.c2
-rw-r--r--fs/yaffs2/yaffs_ecc.c1
-rw-r--r--fs/yaffs2/yaffs_flashif.h1
-rw-r--r--fs/yaffs2/yaffs_flashif2.h1
-rw-r--r--fs/yaffs2/yaffs_guts.c18
-rw-r--r--fs/yaffs2/yaffs_guts.h4
-rw-r--r--fs/yaffs2/yaffs_mtdif.c5
-rw-r--r--fs/yaffs2/yaffs_mtdif2.c3
-rw-r--r--fs/yaffs2/yaffs_nandif.c6
-rw-r--r--fs/yaffs2/yaffs_nandif.h2
-rw-r--r--fs/yaffs2/yaffs_osglue.h3
-rw-r--r--fs/yaffs2/yaffs_summary.c4
-rw-r--r--fs/yaffs2/yaffs_summary.h2
-rw-r--r--fs/yaffs2/yaffs_tagscompat.c1
-rw-r--r--fs/yaffs2/yaffs_uboot_glue.c11
-rw-r--r--fs/yaffs2/yaffs_verify.c1
-rw-r--r--fs/yaffs2/yaffs_yaffs2.c1
-rw-r--r--fs/yaffs2/yaffscfg.h4
-rw-r--r--fs/yaffs2/yaffsfs.c1
-rw-r--r--fs/yaffs2/yaffsfs.h10
-rw-r--r--fs/yaffs2/ydirectenv.h4
-rw-r--r--fs/yaffs2/yportenv.h9
-rw-r--r--fs/zfs/dev.c2
-rw-r--r--fs/zfs/zfs.c20
-rw-r--r--fs/zfs/zfs_fletcher.c1
-rw-r--r--fs/zfs/zfs_lzjb.c1
-rw-r--r--fs/zfs/zfs_sha256.c1
63 files changed, 238 insertions, 234 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 59439552a45..b7be09d5df8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -461,7 +461,6 @@ static inline u8 *btrfs_dev_extent_chunk_tree_uuid(struct btrfs_dev_extent *dev)
return (u8 *)((unsigned long)dev + ptr);
}
-
/* struct btrfs_extent_item */
BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 64);
BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, refs, 64);
diff --git a/fs/btrfs/dev.c b/fs/btrfs/dev.c
index cb3b9713a5f..e27a032c9f6 100644
--- a/fs/btrfs/dev.c
+++ b/fs/btrfs/dev.c
@@ -5,7 +5,6 @@
* 2017 Marek BehĂșn, CZ.NIC, kabel@kernel.org
*/
-#include <common.h>
#include <blk.h>
#include <compiler.h>
#include <fs_internal.h>
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 7eaa7e94960..34d9d535121 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0+
-#include <common.h>
#include <fs_internal.h>
#include <log.h>
#include <uuid.h>
@@ -70,7 +69,6 @@ static int check_tree_block(struct btrfs_fs_info *fs_info,
btrfs_header_fsid(),
BTRFS_FSID_SIZE);
-
if (fsid_match) {
ret = 0;
break;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4691612eda3..3998ffc2c81 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -640,7 +640,11 @@ static int read_and_truncate_page(struct btrfs_path *path,
extent_type = btrfs_file_extent_type(leaf, fi);
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
ret = btrfs_read_extent_inline(path, fi, buf);
- memcpy(dest, buf + page_off, min(page_len, ret));
+ if (ret < 0) {
+ free(buf);
+ return ret;
+ }
+ memcpy(dest, buf + page_off, min3(page_len, ret, len));
free(buf);
return len;
}
@@ -652,7 +656,7 @@ static int read_and_truncate_page(struct btrfs_path *path,
free(buf);
return ret;
}
- memcpy(dest, buf + page_off, page_len);
+ memcpy(dest, buf + page_off, min(page_len, len));
free(buf);
return len;
}
diff --git a/fs/btrfs/kernel-shared/btrfs_tree.h b/fs/btrfs/kernel-shared/btrfs_tree.h
index d8eff0b9122..f9dc005c50b 100644
--- a/fs/btrfs/kernel-shared/btrfs_tree.h
+++ b/fs/btrfs/kernel-shared/btrfs_tree.h
@@ -115,7 +115,6 @@
#define BTRFS_LAST_FREE_OBJECTID -256ULL
#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
-
/*
* The device items go into the chunk tree.
*
@@ -333,7 +332,6 @@
*/
#define BTRFS_STRING_ITEM_KEY 253
-
/* 32 bytes in various csum fields */
#define BTRFS_CSUM_SIZE 32
@@ -508,7 +506,6 @@ struct btrfs_free_space_header {
#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
-
/*
* Items in the extent tree are used to record the objectid of the
* owner of the block and the number of references.
@@ -523,7 +520,6 @@ struct btrfs_extent_item_v0 {
__le32 refs;
} __attribute__ ((__packed__));
-
#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
@@ -565,7 +561,6 @@ struct btrfs_extent_ref_v0 {
__le32 count;
} __attribute__ ((__packed__));
-
/* Dev extents record used space on individual devices.
*
* The owner field points back to the chunk allocation mapping tree that
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 7d4095d9ca8..5726981b19c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
#include <stdlib.h>
-#include <common.h>
+#include <errno.h>
#include <fs_internal.h>
#include "ctree.h"
#include "disk-io.h"
@@ -255,7 +255,6 @@ static int device_list_add(struct btrfs_super_block *disk_super,
}
}
-
if (found_transid > fs_devices->latest_trans) {
fs_devices->latest_devid = devid;
fs_devices->latest_trans = found_transid;
diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
index 714f4baafc9..ad5583233bb 100644
--- a/fs/cbfs/cbfs.c
+++ b/fs/cbfs/cbfs.c
@@ -3,10 +3,10 @@
* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
*/
-#include <common.h>
#include <cbfs.h>
#include <log.h>
#include <malloc.h>
+#include <linux/errno.h>
#include <asm/byteorder.h>
/* Offset of master header from the start of a coreboot ROM */
diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index abb2de34eb0..22148ff8fe2 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -24,7 +24,7 @@
* The actual compression is based on zlib, see the other files.
*/
-#include <common.h>
+#include <stdio.h>
#include <malloc.h>
#include <asm/byteorder.h>
#include <linux/stat.h>
diff --git a/fs/cramfs/uncompress.c b/fs/cramfs/uncompress.c
index 0d071b69f4c..2141edf22e4 100644
--- a/fs/cramfs/uncompress.c
+++ b/fs/cramfs/uncompress.c
@@ -20,7 +20,7 @@
* then is used by multiple filesystems.
*/
-#include <common.h>
+#include <stdio.h>
#include <cyclic.h>
#include <malloc.h>
#include <watchdog.h>
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index f4b21d7917a..95b609d8ea8 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -313,7 +313,7 @@ static int z_erofs_read_data(struct erofs_inode *inode, char *buffer,
}
if (!(map.m_flags & EROFS_MAP_MAPPED)) {
- memset(buffer + end - offset, 0, length);
+ memset(buffer + end - offset, 0, length - skip);
end = map.m_la;
continue;
}
diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c
index 168443de1ff..3fd8980b1d6 100644
--- a/fs/ext4/dev.c
+++ b/fs/ext4/dev.c
@@ -22,7 +22,6 @@
* fs/ext2/dev.c file in uboot.
*/
-#include <common.h>
#include <blk.h>
#include <config.h>
#include <fs_internal.h>
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 2ff0dca2495..76f7102456e 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -18,7 +18,6 @@
* ext4write : Based on generic ext4 protocol.
*/
-#include <common.h>
#include <blk.h>
#include <ext_common.h>
#include <ext4fs.h>
@@ -1206,7 +1205,6 @@ fail:
}
-
static void alloc_single_indirect_block(struct ext2_inode *file_inode,
unsigned int *total_remaining_blocks,
unsigned int *no_blks_reqd)
@@ -2183,13 +2181,18 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
struct ext2fs_node *diro = node;
int status;
loff_t actread;
+ size_t alloc_size;
if (!diro->inode_read) {
status = ext4fs_read_inode(diro->data, diro->ino, &diro->inode);
if (status == 0)
return NULL;
}
- symlink = zalloc(le32_to_cpu(diro->inode.size) + 1);
+
+ if (__builtin_add_overflow(le32_to_cpu(diro->inode.size), 1, &alloc_size))
+ return NULL;
+
+ symlink = zalloc(alloc_size);
if (!symlink)
return NULL;
@@ -2381,11 +2384,24 @@ int ext4fs_mount(void)
if (le16_to_cpu(data->sblock.magic) != EXT2_MAGIC)
goto fail_noerr;
-
if (le32_to_cpu(data->sblock.revision_level) == 0) {
fs->inodesz = 128;
fs->gdsize = 32;
} else {
+ int missing = __le32_to_cpu(data->sblock.feature_incompat) &
+ ~(EXT4_FEATURE_INCOMPAT_SUPP |
+ EXT4_FEATURE_INCOMPAT_SUPP_LAZY_RO);
+
+ if (missing) {
+ /*
+ * This code used to be relaxed about feature flags.
+ * We don't stop the mount to avoid breaking existing setups.
+ * But, incompatible features can cause serious read errors.
+ */
+ log_err("fs uses incompatible features: %08x, ignoring\n",
+ missing);
+ }
+
debug("EXT4 features COMPAT: %08x INCOMPAT: %08x RO_COMPAT: %08x\n",
__le32_to_cpu(data->sblock.feature_compatibility),
__le32_to_cpu(data->sblock.feature_incompat),
diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h
index 84500e990aa..346752092b0 100644
--- a/fs/ext4/ext4_common.h
+++ b/fs/ext4/ext4_common.h
@@ -24,6 +24,7 @@
#include <ext4fs.h>
#include <malloc.h>
#include <asm/cache.h>
+#include <linux/compat.h>
#include <linux/errno.h>
#if defined(CONFIG_EXT4_WRITE)
#include "ext4_journal.h"
@@ -43,9 +44,7 @@
static inline void *zalloc(size_t size)
{
- void *p = memalign(ARCH_DMA_MINALIGN, size);
- memset(p, 0, size);
- return p;
+ return kzalloc(size, 0);
}
int ext4fs_read_inode(struct ext2_data *data, int ino,
diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c
index e80f797c8dc..02c4ac2cb93 100644
--- a/fs/ext4/ext4_journal.c
+++ b/fs/ext4/ext4_journal.c
@@ -13,7 +13,6 @@
* Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
*/
-#include <common.h>
#include <blk.h>
#include <ext4fs.h>
#include <log.h>
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index d057f6b5a79..d109ed6e90d 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -20,8 +20,6 @@
* ext4write : Based on generic ext4 protocol.
*/
-
-#include <common.h>
#include <blk.h>
#include <log.h>
#include <malloc.h>
@@ -747,7 +745,6 @@ void ext4fs_deinit(void)
fs->inode_bmaps = NULL;
}
-
free(fs->gdtable);
fs->gdtable = NULL;
/*
@@ -869,6 +866,7 @@ int ext4fs_write(const char *fname, const char *buffer,
ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
bool store_link_in_inode = false;
memset(filename, 0x00, 256);
+ int missing_feat;
if (type != FILETYPE_REG && type != FILETYPE_SYMLINK)
return -1;
@@ -882,8 +880,15 @@ int ext4fs_write(const char *fname, const char *buffer,
return -1;
}
- if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
- printf("Unsupported feature metadata_csum found, not writing.\n");
+ missing_feat = le32_to_cpu(fs->sb->feature_incompat) & ~EXT4_FEATURE_INCOMPAT_SUPP;
+ if (missing_feat) {
+ log_err("Unsupported features found %08x, not writing.\n", missing_feat);
+ return -1;
+ }
+
+ missing_feat = le32_to_cpu(fs->sb->feature_ro_compat) & ~EXT4_FEATURE_RO_COMPAT_SUPP;
+ if (missing_feat) {
+ log_err("Unsupported RO compat features found %08x, not writing.\n", missing_feat);
return -1;
}
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 33e200ffa3c..da59cb008fc 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -20,7 +20,6 @@
* ext4write : Based on generic ext4 protocol.
*/
-#include <common.h>
#include <blk.h>
#include <ext_common.h>
#include <ext4fs.h>
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 2dd9d4e72dc..e2570e81676 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -10,7 +10,6 @@
#define LOG_CATEGORY LOGC_FS
-#include <common.h>
#include <blk.h>
#include <config.h>
#include <exports.h>
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index c8e0fbf1a3b..ea877ee9171 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -7,7 +7,6 @@
#define LOG_CATEGORY LOGC_FS
-#include <common.h>
#include <command.h>
#include <config.h>
#include <div64.h>
diff --git a/fs/fs.c b/fs/fs.c
index acf465bdd80..4bc28d1dffb 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -9,7 +9,6 @@
#include <config.h>
#include <display_options.h>
#include <errno.h>
-#include <common.h>
#include <env.h>
#include <lmb.h>
#include <log.h>
@@ -21,6 +20,7 @@
#include <fs.h>
#include <sandboxfs.h>
#include <semihostingfs.h>
+#include <time.h>
#include <ubifs_uboot.h>
#include <btrfs.h>
#include <asm/global_data.h>
@@ -224,7 +224,7 @@ static struct fstype_info fstypes[] = {
.exists = ext4fs_exists,
.size = ext4fs_size,
.read = ext4_read_file,
-#ifdef CONFIG_CMD_EXT4_WRITE
+#ifdef CONFIG_EXT4_WRITE
.write = ext4_write_file,
.ln = ext4fs_create_link,
#else
@@ -526,12 +526,11 @@ int fs_size(const char *filename, loff_t *size)
return ret;
}
-#ifdef CONFIG_LMB
+#if CONFIG_IS_ENABLED(LMB)
/* Check if a file may be read to the given address */
static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
loff_t len, struct fstype_info *info)
{
- struct lmb lmb;
int ret;
loff_t size;
loff_t read_len;
@@ -550,10 +549,9 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
if (len && len < read_len)
read_len = len;
- lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
- lmb_dump_all(&lmb);
+ lmb_dump_all();
- if (lmb_alloc_addr(&lmb, addr, read_len) == addr)
+ if (lmb_alloc_addr(addr, read_len) == addr)
return 0;
log_err("** Reading file would overwrite reserved memory **\n");
@@ -568,7 +566,7 @@ static int _fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
void *buf;
int ret;
-#ifdef CONFIG_LMB
+#if CONFIG_IS_ENABLED(LMB)
if (do_lmb_check) {
ret = fs_read_lmb_check(filename, addr, offset, len, info);
if (ret)
diff --git a/fs/fs_internal.c b/fs/fs_internal.c
index 111f91b355d..51c1719361b 100644
--- a/fs/fs_internal.c
+++ b/fs/fs_internal.c
@@ -7,7 +7,6 @@
#define LOG_CATEGORY LOGC_CORE
-#include <common.h>
#include <blk.h>
#include <compiler.h>
#include <log.h>
diff --git a/fs/jffs2/compr_lzo.c b/fs/jffs2/compr_lzo.c
index e648ec4fb2e..892766e12eb 100644
--- a/fs/jffs2/compr_lzo.c
+++ b/fs/jffs2/compr_lzo.c
@@ -65,7 +65,6 @@
*/
-
#include <config.h>
#include <linux/stddef.h>
#include <jffs2/jffs2.h>
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
index 9ff22177382..88b65845997 100644
--- a/fs/jffs2/compr_rubin.c
+++ b/fs/jffs2/compr_rubin.c
@@ -42,7 +42,6 @@
#include <jffs2/jffs2.h>
#include <jffs2/compr_rubin.h>
-
void rubin_do_decompress(unsigned char *bits, unsigned char *in,
unsigned char *page_out, __u32 destlen)
{
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c
index d306b6dc4cf..e1e3c15e75e 100644
--- a/fs/jffs2/compr_zlib.c
+++ b/fs/jffs2/compr_zlib.c
@@ -35,8 +35,6 @@
*
*/
-#include <common.h>
-#include <config.h>
#include <jffs2/jffs2.h>
#include <jffs2/mini_inflate.h>
diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index 49ba82ef959..b5f74d65017 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -110,8 +110,6 @@
* it should probably be dumped and replaced by something like jffs2reader!
*/
-
-#include <common.h>
#include <config.h>
#include <malloc.h>
#include <div64.h>
@@ -127,7 +125,6 @@
#include "jffs2_private.h"
-
#define NODE_CHUNK 1024 /* size of memory allocation chunk in b_nodes */
#define SPIN_BLKSIZE 18 /* spin after having scanned 1<<BLKSIZE bytes */
@@ -136,7 +133,6 @@
#undef DEBUG_FRAGMENTS /* print fragment list after scan */
#undef DEBUG /* enable debugging messages */
-
#ifdef DEBUG
# define DEBUGF(fmt,args...) printf(fmt ,##args)
#else
@@ -371,14 +367,12 @@ static void *get_node_mem_onenand(u32 off, void *ext_buf)
return ret;
}
-
static void put_fl_mem_onenand(void *buf)
{
free(buf);
}
#endif
-
#if defined(CONFIG_CMD_FLASH)
#include <flash.h>
@@ -415,7 +409,6 @@ static inline void *get_node_mem_nor(u32 off, void *ext_buf)
}
#endif
-
/*
* Generic jffs2 raw memory and node read routines.
*
@@ -516,7 +509,6 @@ struct mem_block {
struct b_node nodes[NODE_CHUNK];
};
-
static void
free_nodes(struct b_list *list)
{
@@ -1855,7 +1847,6 @@ jffs2_1pass_build_lists(struct part_info * part)
return 1;
}
-
static u32
jffs2_1pass_fill_info(struct b_lists * pL, struct b_jffs2_info * piL)
{
@@ -1884,7 +1875,6 @@ jffs2_1pass_fill_info(struct b_lists * pL, struct b_jffs2_info * piL)
return 0;
}
-
static struct b_lists *
jffs2_get_list(struct part_info * part, const char *who)
{
@@ -1900,7 +1890,6 @@ jffs2_get_list(struct part_info * part, const char *who)
return (struct b_lists *)part->jffs2_priv;
}
-
/* Print directory / file contents */
u32
jffs2_1pass_ls(struct part_info * part, const char *fname)
@@ -1917,7 +1906,6 @@ jffs2_1pass_ls(struct part_info * part, const char *fname)
return 0;
}
-
#if 0
putLabeledWord("found file at inode = ", inode);
putLabeledWord("read_inode returns = ", ret);
@@ -1926,7 +1914,6 @@ jffs2_1pass_ls(struct part_info * part, const char *fname)
return ret;
}
-
/* Load a file from flash into memory. fname can be a full path */
u32
jffs2_1pass_load(char *dest, struct part_info * part, const char *fname)
diff --git a/fs/jffs2/jffs2_private.h b/fs/jffs2/jffs2_private.h
index 65d19a76f97..9284ab5c2c1 100644
--- a/fs/jffs2/jffs2_private.h
+++ b/fs/jffs2/jffs2_private.h
@@ -3,7 +3,6 @@
#include <jffs2/jffs2.h>
-
struct b_node {
u32 offset;
struct b_node *next;
diff --git a/fs/jffs2/mergesort.c b/fs/jffs2/mergesort.c
index fca77aa6511..495937d792d 100644
--- a/fs/jffs2/mergesort.c
+++ b/fs/jffs2/mergesort.c
@@ -7,7 +7,6 @@
* http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
*/
-#include <common.h>
#include "jffs2_private.h"
int sort_list(struct b_list *list)
diff --git a/fs/jffs2/mini_inflate.c b/fs/jffs2/mini_inflate.c
index 3072eedd8c1..12ab180d2f0 100644
--- a/fs/jffs2/mini_inflate.c
+++ b/fs/jffs2/mini_inflate.c
@@ -336,11 +336,9 @@ static void decompress_fixed(struct bitstream *stream, unsigned char *dest)
cramfs_memset(distance->lengths, 5, 32);
distance->count[5] = 32;
-
fill_code_tables(lengths);
fill_code_tables(distance);
-
decompress_huffman(stream, dest);
}
diff --git a/fs/sandbox/host_bootdev.c b/fs/sandbox/host_bootdev.c
index 3ef53627608..3f74972a9f8 100644
--- a/fs/sandbox/host_bootdev.c
+++ b/fs/sandbox/host_bootdev.c
@@ -6,7 +6,6 @@
* Written by Simon Glass <sjg@chromium.org>
*/
-#include <common.h>
#include <bootdev.h>
#include <bootflow.h>
#include <bootmeth.h>
diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c
index 4ae41d5b4db..76f1a71f412 100644
--- a/fs/sandbox/sandboxfs.c
+++ b/fs/sandbox/sandboxfs.c
@@ -3,7 +3,7 @@
* Copyright (c) 2012, Google Inc.
*/
-#include <common.h>
+#include <stdio.h>
#include <fs.h>
#include <malloc.h>
#include <os.h>
@@ -28,7 +28,7 @@ int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer,
if (fd < 0)
return fd;
ret = os_lseek(fd, pos, OS_SEEK_SET);
- if (ret == -1) {
+ if (ret < 0) {
os_close(fd);
return ret;
}
@@ -65,14 +65,14 @@ int sandbox_fs_write_at(const char *filename, loff_t pos, void *buffer,
if (fd < 0)
return fd;
ret = os_lseek(fd, pos, OS_SEEK_SET);
- if (ret == -1) {
+ if (ret < 0) {
os_close(fd);
return ret;
}
size = os_write(fd, buffer, towrite);
os_close(fd);
- if (size == -1) {
+ if (size < 0) {
ret = -1;
} else {
ret = 0;
diff --git a/fs/semihostingfs.c b/fs/semihostingfs.c
index 3592338a686..77e39ca407e 100644
--- a/fs/semihostingfs.c
+++ b/fs/semihostingfs.c
@@ -4,7 +4,7 @@
* Copyright (c) 2012, Google Inc.
*/
-#include <common.h>
+#include <stdio.h>
#include <fs.h>
#include <malloc.h>
#include <os.h>
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 1430e671a5a..b9314019b1b 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -24,7 +24,12 @@
#include "sqfs_filesystem.h"
#include "sqfs_utils.h"
+#define MAX_SYMLINK_NEST 8
+
static struct squashfs_ctxt ctxt;
+static int symlinknest;
+
+static int sqfs_readdir_nest(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp);
static int sqfs_disk_read(__u32 block, __u32 nr_blocks, void *buf)
{
@@ -422,8 +427,10 @@ static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,
char *resolved, *target;
u32 sz;
- sz = get_unaligned_le32(&sym->symlink_size);
- target = malloc(sz + 1);
+ if (__builtin_add_overflow(get_unaligned_le32(&sym->symlink_size), 1, &sz))
+ return NULL;
+
+ target = malloc(sz);
if (!target)
return NULL;
@@ -431,9 +438,9 @@ static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,
* There is no trailling null byte in the symlink's target path, so a
* copy is made and a '\0' is added at its end.
*/
- target[sz] = '\0';
+ target[sz - 1] = '\0';
/* Get target name (relative path) */
- strncpy(target, sym->symlink, sz);
+ strncpy(target, sym->symlink, sz - 1);
/* Relative -> absolute path conversion */
resolved = sqfs_get_abs_path(base_path, target);
@@ -472,6 +479,8 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
/* Start by root inode */
table = sqfs_find_inode(dirs->inode_table, le32_to_cpu(sblk->inodes),
sblk->inodes, sblk->block_size);
+ if (!table)
+ return -EINVAL;
dir = (struct squashfs_dir_inode *)table;
ldir = (struct squashfs_ldir_inode *)table;
@@ -506,7 +515,7 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
goto out;
}
- while (!sqfs_readdir(dirsp, &dent)) {
+ while (!sqfs_readdir_nest(dirsp, &dent)) {
ret = strcmp(dent->name, token_list[j]);
if (!ret)
break;
@@ -527,10 +536,17 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
/* Get reference to inode in the inode table */
table = sqfs_find_inode(dirs->inode_table, new_inode_number,
sblk->inodes, sblk->block_size);
+ if (!table)
+ return -EINVAL;
dir = (struct squashfs_dir_inode *)table;
/* Check for symbolic link and inode type sanity */
if (get_unaligned_le16(&dir->inode_type) == SQFS_SYMLINK_TYPE) {
+ if (++symlinknest == MAX_SYMLINK_NEST) {
+ ret = -ELOOP;
+ goto out;
+ }
+
sym = (struct squashfs_symlink_inode *)table;
/* Get first j + 1 tokens */
path = sqfs_concat_tokens(token_list, j + 1);
@@ -551,8 +567,11 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
ret = -ENOMEM;
goto out;
}
- /* Concatenate remaining tokens and symlink's target */
- res = malloc(strlen(rem) + strlen(target) + 1);
+ /*
+ * Concatenate remaining tokens and symlink's target.
+ * Allocate enough space for rem, target, '/' and '\0'.
+ */
+ res = malloc(strlen(rem) + strlen(target) + 2);
if (!res) {
ret = -ENOMEM;
goto out;
@@ -878,7 +897,7 @@ out:
return metablks_count;
}
-int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
+static int sqfs_opendir_nest(const char *filename, struct fs_dir_stream **dirsp)
{
unsigned char *inode_table = NULL, *dir_table = NULL;
int j, token_count = 0, ret = 0, metablks_count;
@@ -973,8 +992,20 @@ out:
return ret;
}
+int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
+{
+ symlinknest = 0;
+ return sqfs_opendir_nest(filename, dirsp);
+}
+
int sqfs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp)
{
+ symlinknest = 0;
+ return sqfs_readdir_nest(fs_dirs, dentp);
+}
+
+static int sqfs_readdir_nest(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp)
+{
struct squashfs_super_block *sblk = ctxt.sblk;
struct squashfs_dir_stream *dirs;
struct squashfs_lreg_inode *lreg;
@@ -1023,6 +1054,8 @@ int sqfs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp)
i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;
ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
sblk->block_size);
+ if (!ipos)
+ return -SQFS_STOP_READDIR;
base = (struct squashfs_base_inode *)ipos;
@@ -1317,8 +1350,8 @@ static int sqfs_get_lregfile_info(struct squashfs_lreg_inode *lreg,
return datablk_count;
}
-int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
- loff_t *actread)
+static int sqfs_read_nest(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actread)
{
char *dir = NULL, *fragment_block, *datablock = NULL;
char *fragment = NULL, *file = NULL, *resolved, *data;
@@ -1348,11 +1381,11 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
}
/*
- * sqfs_opendir will uncompress inode and directory tables, and will
+ * sqfs_opendir_nest will uncompress inode and directory tables, and will
* return a pointer to the directory that contains the requested file.
*/
sqfs_split_path(&file, &dir, filename);
- ret = sqfs_opendir(dir, &dirsp);
+ ret = sqfs_opendir_nest(dir, &dirsp);
if (ret) {
goto out;
}
@@ -1360,7 +1393,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
dirs = (struct squashfs_dir_stream *)dirsp;
/* For now, only regular files are able to be loaded */
- while (!sqfs_readdir(dirsp, &dent)) {
+ while (!sqfs_readdir_nest(dirsp, &dent)) {
ret = strcmp(dent->name, file);
if (!ret)
break;
@@ -1379,6 +1412,10 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;
ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
sblk->block_size);
+ if (!ipos) {
+ ret = -EINVAL;
+ goto out;
+ }
base = (struct squashfs_base_inode *)ipos;
switch (get_unaligned_le16(&base->inode_type)) {
@@ -1409,9 +1446,14 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
break;
case SQFS_SYMLINK_TYPE:
case SQFS_LSYMLINK_TYPE:
+ if (++symlinknest == MAX_SYMLINK_NEST) {
+ ret = -ELOOP;
+ goto out;
+ }
+
symlink = (struct squashfs_symlink_inode *)ipos;
resolved = sqfs_resolve_symlink(symlink, filename);
- ret = sqfs_read(resolved, buf, offset, len, actread);
+ ret = sqfs_read_nest(resolved, buf, offset, len, actread);
free(resolved);
goto out;
case SQFS_BLKDEV_TYPE:
@@ -1582,7 +1624,14 @@ out:
return ret;
}
-int sqfs_size(const char *filename, loff_t *size)
+int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
+ loff_t *actread)
+{
+ symlinknest = 0;
+ return sqfs_read_nest(filename, buf, offset, len, actread);
+}
+
+static int sqfs_size_nest(const char *filename, loff_t *size)
{
struct squashfs_super_block *sblk = ctxt.sblk;
struct squashfs_symlink_inode *symlink;
@@ -1598,10 +1647,10 @@ int sqfs_size(const char *filename, loff_t *size)
sqfs_split_path(&file, &dir, filename);
/*
- * sqfs_opendir will uncompress inode and directory tables, and will
+ * sqfs_opendir_nest will uncompress inode and directory tables, and will
* return a pointer to the directory that contains the requested file.
*/
- ret = sqfs_opendir(dir, &dirsp);
+ ret = sqfs_opendir_nest(dir, &dirsp);
if (ret) {
ret = -EINVAL;
goto free_strings;
@@ -1609,7 +1658,7 @@ int sqfs_size(const char *filename, loff_t *size)
dirs = (struct squashfs_dir_stream *)dirsp;
- while (!sqfs_readdir(dirsp, &dent)) {
+ while (!sqfs_readdir_nest(dirsp, &dent)) {
ret = strcmp(dent->name, file);
if (!ret)
break;
@@ -1627,6 +1676,13 @@ int sqfs_size(const char *filename, loff_t *size)
i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;
ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
sblk->block_size);
+
+ if (!ipos) {
+ *size = 0;
+ ret = -EINVAL;
+ goto free_strings;
+ }
+
free(dirs->entry);
dirs->entry = NULL;
@@ -1642,6 +1698,11 @@ int sqfs_size(const char *filename, loff_t *size)
break;
case SQFS_SYMLINK_TYPE:
case SQFS_LSYMLINK_TYPE:
+ if (++symlinknest == MAX_SYMLINK_NEST) {
+ *size = 0;
+ return -ELOOP;
+ }
+
symlink = (struct squashfs_symlink_inode *)ipos;
resolved = sqfs_resolve_symlink(symlink, filename);
ret = sqfs_size(resolved, size);
@@ -1681,10 +1742,11 @@ int sqfs_exists(const char *filename)
sqfs_split_path(&file, &dir, filename);
/*
- * sqfs_opendir will uncompress inode and directory tables, and will
+ * sqfs_opendir_nest will uncompress inode and directory tables, and will
* return a pointer to the directory that contains the requested file.
*/
- ret = sqfs_opendir(dir, &dirsp);
+ symlinknest = 0;
+ ret = sqfs_opendir_nest(dir, &dirsp);
if (ret) {
ret = -EINVAL;
goto free_strings;
@@ -1692,7 +1754,7 @@ int sqfs_exists(const char *filename)
dirs = (struct squashfs_dir_stream *)dirsp;
- while (!sqfs_readdir(dirsp, &dent)) {
+ while (!sqfs_readdir_nest(dirsp, &dent)) {
ret = strcmp(dent->name, file);
if (!ret)
break;
@@ -1709,6 +1771,12 @@ free_strings:
return ret == 0;
}
+int sqfs_size(const char *filename, loff_t *size)
+{
+ symlinknest = 0;
+ return sqfs_size_nest(filename, size);
+}
+
void sqfs_close(void)
{
sqfs_decompressor_cleanup(&ctxt);
diff --git a/fs/squashfs/sqfs_inode.c b/fs/squashfs/sqfs_inode.c
index d25cfb53e75..bb3ccd37e33 100644
--- a/fs/squashfs/sqfs_inode.c
+++ b/fs/squashfs/sqfs_inode.c
@@ -78,11 +78,16 @@ int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
case SQFS_SYMLINK_TYPE:
case SQFS_LSYMLINK_TYPE: {
+ int size;
+
struct squashfs_symlink_inode *symlink =
(struct squashfs_symlink_inode *)inode;
- return sizeof(*symlink) +
- get_unaligned_le32(&symlink->symlink_size);
+ if (__builtin_add_overflow(sizeof(*symlink),
+ get_unaligned_le32(&symlink->symlink_size), &size))
+ return -EINVAL;
+
+ return size;
}
case SQFS_BLKDEV_TYPE:
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index aa7f281ef6b..b6e03b76d41 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -451,7 +451,7 @@ int ubifs_validate_entry(struct ubifs_info *c,
if (le32_to_cpu(dent->ch.len) != nlen + UBIFS_DENT_NODE_SZ + 1 ||
dent->type >= UBIFS_ITYPES_CNT ||
nlen > UBIFS_MAX_NLEN || dent->name[nlen] != 0 ||
- strnlen(dent->name, nlen) != nlen ||
+ (key_type == UBIFS_XENT_KEY && strnlen(dent->name, nlen) != nlen) ||
le64_to_cpu(dent->inum) > MAX_INUM) {
ubifs_err(c, "bad %s node", key_type == UBIFS_DENT_KEY ?
"directory entry" : "extended attribute entry");
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 3e7160352e6..7718081f093 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -29,7 +29,6 @@
#include <linux/writeback.h>
#else
-#include <common.h>
#include <malloc.h>
#include <memalign.h>
#include <linux/bitops.h>
@@ -1759,11 +1758,13 @@ void ubifs_umount(struct ubifs_info *c)
ubifs_debugging_exit(c);
#ifdef __UBOOT__
ubi_close_volume(c->ubi);
+ c->ubi = NULL;
mutex_unlock(&c->umount_mutex);
/* Finally free U-Boot's global copy of superblock */
if (ubifs_sb != NULL) {
- free(ubifs_sb->s_fs_info);
- free(ubifs_sb);
+ kfree(ubifs_sb->s_fs_info);
+ kfree(ubifs_sb);
+ ubifs_sb = NULL;
}
#endif
}
@@ -2062,6 +2063,7 @@ static void ubifs_put_super(struct super_block *sb)
#ifndef __UBOOT__
bdi_destroy(&c->bdi);
ubi_close_volume(c->ubi);
+ c->ubi = NULL;
mutex_unlock(&c->umount_mutex);
#endif
}
@@ -2322,6 +2324,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
goto out_umount;
}
#else
+ ubifs_iput(root);
sb->s_root = NULL;
#endif
@@ -2341,6 +2344,7 @@ out_bdi:
out_close:
#endif
ubi_close_volume(c->ubi);
+ c->ubi = NULL;
out:
return err;
}
@@ -2453,7 +2457,6 @@ retry:
EXPORT_SYMBOL(sget);
-
static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
const char *name, void *data)
{
diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h
index 2b5b26a01b0..299d80f928c 100644
--- a/fs/ubifs/ubifs-media.h
+++ b/fs/ubifs/ubifs-media.h
@@ -320,12 +320,14 @@ enum {
* UBIFS_COMPR_NONE: no compression
* UBIFS_COMPR_LZO: LZO compression
* UBIFS_COMPR_ZLIB: ZLIB compression
+ * UBIFS_COMPR_ZSTD: ZSTD compression
* UBIFS_COMPR_TYPES_CNT: count of supported compression types
*/
enum {
UBIFS_COMPR_NONE,
UBIFS_COMPR_LZO,
UBIFS_COMPR_ZLIB,
+ UBIFS_COMPR_ZSTD,
UBIFS_COMPR_TYPES_CNT,
};
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index a509584e5d7..398b076d783 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -11,7 +11,6 @@
* Adrian Hunter
*/
-#include <common.h>
#include <env.h>
#include <gzip.h>
#include <log.h>
@@ -27,6 +26,11 @@
#include <linux/err.h>
#include <linux/lzo.h>
+#if IS_ENABLED(CONFIG_ZSTD)
+#include <linux/zstd.h>
+#include <abuf.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
/* compress.c */
@@ -42,6 +46,25 @@ static int gzip_decompress(const unsigned char *in, size_t in_len,
(unsigned long *)out_len, 0, 0);
}
+#if IS_ENABLED(CONFIG_ZSTD)
+static int zstd_decompress_wrapper(const unsigned char *in, size_t in_len,
+ unsigned char *out, size_t *out_len)
+{
+ struct abuf abuf_in, abuf_out;
+ int ret;
+
+ abuf_init_set(&abuf_in, (void *)in, in_len);
+ abuf_init_set(&abuf_out, (void *)out, *out_len);
+
+ ret = zstd_decompress(&abuf_in, &abuf_out);
+ if (ret < 0)
+ return ret;
+
+ *out_len = ret;
+ return 0;
+}
+#endif
+
/* Fake description object for the "none" compressor */
static struct ubifs_compressor none_compr = {
.compr_type = UBIFS_COMPR_NONE,
@@ -71,9 +94,21 @@ static struct ubifs_compressor zlib_compr = {
.decompress = gzip_decompress,
};
-/* All UBIFS compressors */
-struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
+#if IS_ENABLED(CONFIG_ZSTD)
+static struct ubifs_compressor zstd_compr = {
+ .compr_type = UBIFS_COMPR_ZSTD,
+#ifndef __UBOOT__
+ .comp_mutex = &zstd_enc_mutex,
+ .decomp_mutex = &zstd_dec_mutex,
+#endif
+ .name = "zstd",
+ .capi_name = "zstd",
+ .decompress = zstd_decompress_wrapper,
+};
+#endif
+/* All UBIFS compressors */
+struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT] = {NULL};
#ifdef __UBOOT__
@@ -166,8 +201,14 @@ int ubifs_decompress(const struct ubifs_info *c, const void *in_buf,
compr = ubifs_compressors[compr_type];
+ if (unlikely(!compr)) {
+ ubifs_err(c, "compression type %d is not compiled in", compr_type);
+ return -EINVAL;
+ }
+
if (unlikely(!compr->capi_name)) {
- ubifs_err(c, "%s compression is not compiled in", compr->name);
+ ubifs_err(c, "%s compression is not compiled in",
+ compr->name ? compr->name : "unknown");
return -EINVAL;
}
@@ -232,6 +273,12 @@ int __init ubifs_compressors_init(void)
if (err)
return err;
+#if IS_ENABLED(CONFIG_ZSTD)
+ err = compr_init(&zstd_compr);
+ if (err)
+ return err;
+#endif
+
err = compr_init(&none_compr);
if (err)
return err;
@@ -272,9 +319,7 @@ static int filldir(struct ubifs_info *c, const char *name, int namlen,
}
ctime_r((time_t *)&inode->i_mtime, filetime);
printf("%9lld %24.24s ", inode->i_size, filetime);
-#ifndef __UBOOT__
ubifs_iput(inode);
-#endif
printf("%s\n", name);
@@ -510,6 +555,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
/* We have some sort of symlink recursion, bail out */
if (symlink_count++ > 8) {
+ ubifs_iput(inode);
printf("Symlink recursion, aborting\n");
return 0;
}
@@ -521,6 +567,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
* the leading slash */
next = name = link_name + 1;
root_inum = 1;
+ ubifs_iput(inode);
continue;
}
/* Relative to cur dir */
@@ -528,6 +575,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
link_name, next == NULL ? "" : next);
memcpy(symlinkpath, buf, sizeof(buf));
next = name = symlinkpath;
+ ubifs_iput(inode);
continue;
}
@@ -536,8 +584,10 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
*/
/* Found the node! */
- if (!next || *next == '\0')
+ if (!next || *next == '\0') {
+ ubifs_iput(inode);
return inum;
+ }
root_inum = inum;
name = next;
@@ -567,7 +617,6 @@ int ubifs_set_blk_dev(struct blk_desc *rbdd, struct disk_partition *info)
int ubifs_ls(const char *filename)
{
- struct ubifs_info *c = ubifs_sb->s_fs_info;
struct file *file;
struct dentry *dentry;
struct inode *dir;
@@ -575,7 +624,11 @@ int ubifs_ls(const char *filename)
unsigned long inum;
int ret = 0;
- c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
+ if (!ubifs_is_mounted()) {
+ debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
+ return -1;
+ }
+
inum = ubifs_findfile(ubifs_sb, (char *)filename);
if (!inum) {
ret = -1;
@@ -609,30 +662,33 @@ out_mem:
free(dir);
out:
- ubi_close_volume(c->ubi);
return ret;
}
int ubifs_exists(const char *filename)
{
- struct ubifs_info *c = ubifs_sb->s_fs_info;
unsigned long inum;
- c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
+ if (!ubifs_is_mounted()) {
+ debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
+ return -1;
+ }
+
inum = ubifs_findfile(ubifs_sb, (char *)filename);
- ubi_close_volume(c->ubi);
return inum != 0;
}
int ubifs_size(const char *filename, loff_t *size)
{
- struct ubifs_info *c = ubifs_sb->s_fs_info;
unsigned long inum;
struct inode *inode;
int err = 0;
- c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
+ if (!ubifs_is_mounted()) {
+ debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
+ return -1;
+ }
inum = ubifs_findfile(ubifs_sb, (char *)filename);
if (!inum) {
@@ -651,7 +707,6 @@ int ubifs_size(const char *filename, loff_t *size)
ubifs_iput(inode);
out:
- ubi_close_volume(c->ubi);
return err;
}
@@ -838,6 +893,11 @@ int ubifs_read(const char *filename, void *buf, loff_t offset,
int count;
int last_block_size = 0;
+ if (!ubifs_is_mounted()) {
+ debug("UBIFS not mounted, use ubifsmount to mount volume first!\n");
+ return -1;
+ }
+
*actread = 0;
if (offset & (PAGE_SIZE - 1)) {
@@ -846,7 +906,6 @@ int ubifs_read(const char *filename, void *buf, loff_t offset,
return -1;
}
- c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
/* ubifs_findfile will resolve symlinks, so we know that we get
* the real file here */
inum = ubifs_findfile(ubifs_sb, (char *)filename);
@@ -910,7 +969,6 @@ put_inode:
ubifs_iput(inode);
out:
- ubi_close_volume(c->ubi);
return err;
}
@@ -941,6 +999,5 @@ void uboot_ubifs_umount(void)
printf("Unmounting UBIFS volume %s!\n",
((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name);
ubifs_umount(ubifs_sb->s_fs_info);
- ubifs_sb = NULL;
}
}
diff --git a/fs/yaffs2/yaffs_attribs.c b/fs/yaffs2/yaffs_attribs.c
index 69664268e14..81927cb9437 100644
--- a/fs/yaffs2/yaffs_attribs.c
+++ b/fs/yaffs2/yaffs_attribs.c
@@ -13,7 +13,6 @@
#include "yaffs_attribs.h"
-
void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
{
obj->yst_uid = oh->yst_uid;
@@ -24,7 +23,6 @@ void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
obj->yst_rdev = oh->yst_rdev;
}
-
void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
{
#ifdef CONFIG_YAFFS_WINCE
diff --git a/fs/yaffs2/yaffs_ecc.c b/fs/yaffs2/yaffs_ecc.c
index 9294107c150..0860a3c7843 100644
--- a/fs/yaffs2/yaffs_ecc.c
+++ b/fs/yaffs2/yaffs_ecc.c
@@ -67,7 +67,6 @@ static const unsigned char column_parity_table[] = {
0x69, 0x3c, 0x30, 0x65, 0x0c, 0x59, 0x55, 0x00,
};
-
/* Calculate the ECC for a 256-byte block of data */
void yaffs_ecc_calc(const unsigned char *data, unsigned char *ecc)
{
diff --git a/fs/yaffs2/yaffs_flashif.h b/fs/yaffs2/yaffs_flashif.h
index e6e8979ee62..886901a0ff5 100644
--- a/fs/yaffs2/yaffs_flashif.h
+++ b/fs/yaffs2/yaffs_flashif.h
@@ -16,7 +16,6 @@
#ifndef __YAFFS_FLASH_H__
#define __YAFFS_FLASH_H__
-
#include "yaffs_guts.h"
int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber);
int yflash_WriteChunkToNAND(struct yaffs_dev *dev, int nand_chunk,
diff --git a/fs/yaffs2/yaffs_flashif2.h b/fs/yaffs2/yaffs_flashif2.h
index cfdbde9dc8f..c69862668b1 100644
--- a/fs/yaffs2/yaffs_flashif2.h
+++ b/fs/yaffs2/yaffs_flashif2.h
@@ -16,7 +16,6 @@
#ifndef __YAFFS_FLASH2_H__
#define __YAFFS_FLASH2_H__
-
#include "yaffs_guts.h"
int yflash2_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber);
int yflash2_WriteChunkToNAND(struct yaffs_dev *dev, int nand_chunk,
diff --git a/fs/yaffs2/yaffs_guts.c b/fs/yaffs2/yaffs_guts.c
index e13a73298b4..c20f2f8298f 100644
--- a/fs/yaffs2/yaffs_guts.c
+++ b/fs/yaffs2/yaffs_guts.c
@@ -41,8 +41,6 @@
static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk,
const u8 *buffer, int n_bytes, int use_reserve);
-
-
/* Function to calculate chunk and offset */
void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr,
@@ -355,7 +353,6 @@ static int yaffs_verify_chunk_written(struct yaffs_dev *dev,
return retval;
}
-
int yaffs_check_alloc_available(struct yaffs_dev *dev, int n_chunks)
{
int reserved_chunks;
@@ -1989,7 +1986,6 @@ static struct yaffs_obj *yaffs_create_fake_dir(struct yaffs_dev *dev,
}
-
static void yaffs_init_tnodes_and_objs(struct yaffs_dev *dev)
{
int i;
@@ -2233,8 +2229,6 @@ struct yaffs_obj *yaffs_link_obj(struct yaffs_obj *parent, const YCHAR * name,
}
-
-
/*---------------------- Block Management and Page Allocation -------------*/
static void yaffs_deinit_blocks(struct yaffs_dev *dev)
@@ -2292,7 +2286,6 @@ static int yaffs_init_blocks(struct yaffs_dev *dev)
if (!dev->chunk_bits)
goto alloc_error;
-
memset(dev->block_info, 0, n_blocks * sizeof(struct yaffs_block_info));
memset(dev->chunk_bits, 0, dev->chunk_bit_stride * n_blocks);
return YAFFS_OK;
@@ -2302,7 +2295,6 @@ alloc_error:
return YAFFS_FAIL;
}
-
void yaffs_block_became_dirty(struct yaffs_dev *dev, int block_no)
{
struct yaffs_block_info *bi = yaffs_get_block_info(dev, block_no);
@@ -3036,8 +3028,6 @@ static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk,
}
-
-
static int yaffs_do_xattrib_mod(struct yaffs_obj *obj, int set,
const YCHAR *name, const void *value, int size,
int flags)
@@ -3396,7 +3386,6 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
bi->has_shrink_hdr = 1;
}
-
return new_chunk_id;
}
@@ -3804,7 +3793,6 @@ int yaffs_flush_file(struct yaffs_obj *in, int update_time, int data_sync)
YAFFS_OK : YAFFS_FAIL;
}
-
/* yaffs_del_file deletes the whole file data
* and the inode associated with the file.
* It does not delete the links associated with the file.
@@ -4306,7 +4294,6 @@ static void yaffs_empty_l_n_f(struct yaffs_dev *dev)
yaffs_del_dir_contents(dev->lost_n_found);
}
-
struct yaffs_obj *yaffs_find_by_name(struct yaffs_obj *directory,
const YCHAR *name)
{
@@ -4465,13 +4452,12 @@ loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
int yaffs_get_obj_link_count(struct yaffs_obj *obj)
{
int count = 0;
- struct list_head *i;
if (!obj->unlinked)
count++; /* the object itself */
- list_for_each(i, &obj->hard_links)
- count++; /* add the hard links; */
+ /* add the hard links; */
+ count += list_count_nodes(&obj->hard_links);
return count;
}
diff --git a/fs/yaffs2/yaffs_guts.h b/fs/yaffs2/yaffs_guts.h
index e3558c5a6d0..f4e7f796bd1 100644
--- a/fs/yaffs2/yaffs_guts.h
+++ b/fs/yaffs2/yaffs_guts.h
@@ -64,8 +64,6 @@
#define YAFFS_MIN_YAFFS2_CHUNK_SIZE 1024
#define YAFFS_MIN_YAFFS2_SPARE_SIZE 32
-
-
#define YAFFS_ALLOCATION_NOBJECTS 100
#define YAFFS_ALLOCATION_NTNODES 100
#define YAFFS_ALLOCATION_NLINKS 100
@@ -155,7 +153,6 @@ union yaffs_tags_union {
u8 as_bytes[8];
};
-
/* Stuff used for extended tags in YAFFS2 */
enum yaffs_ecc_result {
@@ -969,5 +966,4 @@ void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize);
loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh);
loff_t yaffs_max_file_size(struct yaffs_dev *dev);
-
#endif
diff --git a/fs/yaffs2/yaffs_mtdif.c b/fs/yaffs2/yaffs_mtdif.c
index 50fed2d4b15..d4af0a329ee 100644
--- a/fs/yaffs2/yaffs_mtdif.c
+++ b/fs/yaffs2/yaffs_mtdif.c
@@ -12,11 +12,9 @@
*/
/* XXX U-BOOT XXX */
-#include <common.h>
#include "yportenv.h"
-
#include "yaffs_mtdif.h"
#include <linux/mtd/mtd.h>
@@ -24,7 +22,6 @@
#include <linux/time.h>
#include <linux/mtd/rawnand.h>
-
static inline void translate_spare2oob(const struct yaffs_spare *spare, u8 *oob)
{
oob[0] = spare->tb0;
@@ -58,7 +55,6 @@ static inline void translate_oob2spare(struct yaffs_spare *spare, u8 *oob)
nspare->eccres1 = nspare->eccres2 = 0; /* FIXME */
}
-
int nandmtd_WriteChunkToNAND(struct yaffs_dev *dev, int chunkInNAND,
const u8 *data, const struct yaffs_spare *spare)
{
@@ -149,7 +145,6 @@ int nandmtd_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
/* Todo finish off the ei if required */
-
retval = mtd_erase(mtd, &ei);
if (retval == 0)
diff --git a/fs/yaffs2/yaffs_mtdif2.c b/fs/yaffs2/yaffs_mtdif2.c
index 81a4d964f3e..f21f15bfbd8 100644
--- a/fs/yaffs2/yaffs_mtdif2.c
+++ b/fs/yaffs2/yaffs_mtdif2.c
@@ -14,7 +14,6 @@
/* mtd interface for YAFFS2 */
/* XXX U-BOOT XXX */
-#include <common.h>
#include <linux/bug.h>
#include <linux/errno.h>
@@ -33,7 +32,6 @@
#define yaffs_dev_to_mtd(dev) ((struct mtd_info *)((dev)->driver_context))
#define yaffs_dev_to_lc(dev) ((struct yaffs_linux_context *)((dev)->os_context))
-
/* NB For use with inband tags....
* We assume that the data buffer is of size total_bytes_per_chunk so
* that we can also use it to load the tags.
@@ -170,7 +168,6 @@ int nandmtd2_read_chunk_tags(struct yaffs_dev *dev, int nand_chunk,
return YAFFS_FAIL;
}
-
int nandmtd2_MarkNANDBlockBad(struct yaffs_dev *dev, int blockNo)
{
struct mtd_info *mtd = (struct mtd_info *)(dev->driver_context);
diff --git a/fs/yaffs2/yaffs_nandif.c b/fs/yaffs2/yaffs_nandif.c
index ee5a1720607..632f4275518 100644
--- a/fs/yaffs2/yaffs_nandif.c
+++ b/fs/yaffs2/yaffs_nandif.c
@@ -15,7 +15,6 @@
#include "yaffs_guts.h"
#include <malloc.h>
-
#include "yaffs_nandif.h"
#include "yaffs_packedtags2.h"
@@ -24,7 +23,6 @@
#include "yaffs_trace.h"
#include "yaffsfs.h"
-
/* NB For use with inband tags....
* We assume that the data buffer is of size totalBytersPerChunk so that
* we can also use it to load the tags.
@@ -44,7 +42,6 @@ int ynandif_WriteChunkWithTagsToNAND(struct yaffs_dev *dev, int nand_chunk,
"nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p",
nand_chunk, data, tags);
-
/* For yaffs2 writing there must be both data and tags.
* If we're using inband tags, then the tags are stuffed into
* the end of the data buffer.
@@ -152,7 +149,6 @@ int ynandif_EraseBlockInNAND(struct yaffs_dev *dev, int blockId)
}
-
static int ynandif_IsBlockOk(struct yaffs_dev *dev, int blockId)
{
struct ynandif_Geometry *geometry = (struct ynandif_Geometry *)(dev->driver_context);
@@ -186,7 +182,6 @@ int ynandif_QueryNANDBlock(struct yaffs_dev *dev, int blockId,
return YAFFS_OK;
}
-
int ynandif_InitialiseNAND(struct yaffs_dev *dev)
{
struct ynandif_Geometry *geometry = (struct ynandif_Geometry *)(dev->driver_context);
@@ -205,7 +200,6 @@ int ynandif_Deinitialise_flash_fn(struct yaffs_dev *dev)
return YAFFS_OK;
}
-
struct yaffs_dev *
yaffs_add_dev_from_geometry(const YCHAR *name,
const struct ynandif_Geometry *geometry)
diff --git a/fs/yaffs2/yaffs_nandif.h b/fs/yaffs2/yaffs_nandif.h
index e780f7f3b40..6454cea20a0 100644
--- a/fs/yaffs2/yaffs_nandif.h
+++ b/fs/yaffs2/yaffs_nandif.h
@@ -13,7 +13,6 @@
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-
#ifndef __YNANDIF_H__
#define __YNANDIF_H__
@@ -61,5 +60,4 @@ struct yaffs_dev *
yaffs_add_dev_from_geometry(const YCHAR *name,
const struct ynandif_Geometry *geometry);
-
#endif
diff --git a/fs/yaffs2/yaffs_osglue.h b/fs/yaffs2/yaffs_osglue.h
index f629a4b59e8..c2bb682c92f 100644
--- a/fs/yaffs2/yaffs_osglue.h
+++ b/fs/yaffs2/yaffs_osglue.h
@@ -18,11 +18,9 @@
* a direct interface.
*/
-
#ifndef __YAFFS_OSGLUE_H__
#define __YAFFS_OSGLUE_H__
-
#include "yportenv.h"
void yaffsfs_Lock(void);
@@ -37,5 +35,4 @@ void yaffsfs_free(void *ptr);
void yaffsfs_OSInitialisation(void);
-
#endif
diff --git a/fs/yaffs2/yaffs_summary.c b/fs/yaffs2/yaffs_summary.c
index 4f9449a8447..2efd73a0223 100644
--- a/fs/yaffs2/yaffs_summary.c
+++ b/fs/yaffs2/yaffs_summary.c
@@ -52,7 +52,6 @@ struct yaffs_summary_header {
unsigned sum; /* Just add up all the bytes in the tags */
};
-
static void yaffs_summary_clear(struct yaffs_dev *dev)
{
if (!dev->sum_tags)
@@ -61,7 +60,6 @@ static void yaffs_summary_clear(struct yaffs_dev *dev)
sizeof(struct yaffs_summary_tags));
}
-
void yaffs_summary_deinit(struct yaffs_dev *dev)
{
kfree(dev->sum_tags);
@@ -168,11 +166,9 @@ static int yaffs_summary_write(struct yaffs_dev *dev, int blk)
} while (result == YAFFS_OK && n_bytes > 0);
yaffs_release_temp_buffer(dev, buffer);
-
if (result == YAFFS_OK)
bi->has_summary = 1;
-
return result;
}
diff --git a/fs/yaffs2/yaffs_summary.h b/fs/yaffs2/yaffs_summary.h
index be141d07336..e2e027b9257 100644
--- a/fs/yaffs2/yaffs_summary.h
+++ b/fs/yaffs2/yaffs_summary.h
@@ -18,7 +18,6 @@
#include "yaffs_packedtags2.h"
-
int yaffs_summary_init(struct yaffs_dev *dev);
void yaffs_summary_deinit(struct yaffs_dev *dev);
@@ -33,5 +32,4 @@ int yaffs_summary_read(struct yaffs_dev *dev,
int blk);
void yaffs_summary_gc(struct yaffs_dev *dev, int blk);
-
#endif
diff --git a/fs/yaffs2/yaffs_tagscompat.c b/fs/yaffs2/yaffs_tagscompat.c
index 9ac5896da37..1a367fe6985 100644
--- a/fs/yaffs2/yaffs_tagscompat.c
+++ b/fs/yaffs2/yaffs_tagscompat.c
@@ -19,7 +19,6 @@
static void yaffs_handle_rd_data_error(struct yaffs_dev *dev, int nand_chunk);
-
/********** Tags ECC calculations *********/
void yaffs_calc_ecc(const u8 *data, struct yaffs_spare *spare)
diff --git a/fs/yaffs2/yaffs_uboot_glue.c b/fs/yaffs2/yaffs_uboot_glue.c
index 0a920561149..c52362b3eda 100644
--- a/fs/yaffs2/yaffs_uboot_glue.c
+++ b/fs/yaffs2/yaffs_uboot_glue.c
@@ -19,7 +19,6 @@
* This version now uses the ydevconfig mechanism to set up partitions.
*/
-#include <common.h>
#include <div64.h>
#include <malloc.h>
#include <linux/printk.h>
@@ -41,7 +40,6 @@
unsigned yaffs_trace_mask = 0x0; /* Disable logging */
static int yaffs_errno;
-
void yaffs_bug_fn(const char *fn, int n)
{
printf("yaffs bug at %s:%d\n", fn, n);
@@ -67,7 +65,6 @@ int yaffsfs_GetLastError(void)
return yaffs_errno;
}
-
int yaffsfs_GetError(void)
{
return yaffs_errno;
@@ -101,7 +98,6 @@ void yaffsfs_LocalInitialisation(void)
/* No locking used */
}
-
static const char *yaffs_file_type_str(struct yaffs_stat *stat)
{
switch (stat->st_mode & S_IFMT) {
@@ -306,7 +302,6 @@ void make_a_file(char *yaffsName, char bval, int sizeOfFile)
} while (sizeOfFile > 0);
-
yaffs_close(outh);
}
@@ -342,7 +337,6 @@ void cmd_yaffs_mount(char *mp)
yaffsfs_GetError(), yaffs_error_str());
}
-
void cmd_yaffs_umount(char *mp)
{
if (yaffs_unmount(mp) == -1)
@@ -355,13 +349,11 @@ void cmd_yaffs_write_file(char *yaffsName, char bval, int sizeOfFile)
make_a_file(yaffsName, bval, sizeOfFile);
}
-
void cmd_yaffs_read_file(char *fn)
{
read_a_file(fn);
}
-
void cmd_yaffs_mread_file(char *fn, char *addr)
{
int h;
@@ -382,7 +374,6 @@ void cmd_yaffs_mread_file(char *fn, char *addr)
yaffs_close(h);
}
-
void cmd_yaffs_mwrite_file(char *fn, char *addr, int size)
{
int outh;
@@ -396,7 +387,6 @@ void cmd_yaffs_mwrite_file(char *fn, char *addr, int size)
yaffs_close(outh);
}
-
void cmd_yaffs_ls(const char *mountpt, int longlist)
{
int i;
@@ -430,7 +420,6 @@ void cmd_yaffs_ls(const char *mountpt, int longlist)
yaffs_closedir(d);
}
-
void cmd_yaffs_mkdir(const char *dir)
{
int retval = yaffs_mkdir(dir, 0);
diff --git a/fs/yaffs2/yaffs_verify.c b/fs/yaffs2/yaffs_verify.c
index 3fef28bdcb0..f10fe03bc42 100644
--- a/fs/yaffs2/yaffs_verify.c
+++ b/fs/yaffs2/yaffs_verify.c
@@ -240,7 +240,6 @@ void yaffs_verify_file(struct yaffs_obj *obj)
dev = obj->my_dev;
obj_id = obj->obj_id;
-
/* Check file size is consistent with tnode depth */
yaffs_addr_to_chunk(dev, obj->variant.file_variant.file_size,
&last_chunk, &offset_in_chunk);
diff --git a/fs/yaffs2/yaffs_yaffs2.c b/fs/yaffs2/yaffs_yaffs2.c
index 14d497eb99b..627a701a45b 100644
--- a/fs/yaffs2/yaffs_yaffs2.c
+++ b/fs/yaffs2/yaffs_yaffs2.c
@@ -592,7 +592,6 @@ static int yaffs2_rd_checkpt_objs(struct yaffs_dev *dev)
int done = 0;
LIST_HEAD(hard_list);
-
while (ok && !done) {
ok = (yaffs2_checkpt_rd(dev, &cp, sizeof(cp)) == sizeof(cp));
if (cp.struct_type != sizeof(cp)) {
diff --git a/fs/yaffs2/yaffscfg.h b/fs/yaffs2/yaffscfg.h
index 718504eeac5..4f723d6480c 100644
--- a/fs/yaffs2/yaffscfg.h
+++ b/fs/yaffs2/yaffscfg.h
@@ -18,21 +18,17 @@
* a direct interface.
*/
-
#ifndef __YAFFSCFG_H__
#define __YAFFSCFG_H__
-
#include "yportenv.h"
#define YAFFSFS_N_HANDLES 100
#define YAFFSFS_N_DSC 20
-
struct yaffsfs_DeviceConfiguration {
const YCHAR *prefix;
struct yaffs_dev *dev;
};
-
#endif
diff --git a/fs/yaffs2/yaffsfs.c b/fs/yaffs2/yaffsfs.c
index d615f02d3fc..c4909af9fc5 100644
--- a/fs/yaffs2/yaffsfs.c
+++ b/fs/yaffs2/yaffsfs.c
@@ -82,7 +82,6 @@ struct yaffsfs_Handle {
short int useCount;
};
-
struct yaffsfs_DirSearchContxt {
struct yaffs_dirent de; /* directory entry */
YCHAR name[NAME_MAX + 1]; /* name of directory being searched */
diff --git a/fs/yaffs2/yaffsfs.h b/fs/yaffs2/yaffsfs.h
index f2c7666625c..e14f41c63ee 100644
--- a/fs/yaffs2/yaffsfs.h
+++ b/fs/yaffs2/yaffsfs.h
@@ -18,21 +18,18 @@
* a direct interface.
*/
-
#ifndef __YAFFSFS_H__
#define __YAFFSFS_H__
#include "yaffscfg.h"
#include "yportenv.h"
-
#ifndef NAME_MAX
#define NAME_MAX 256
#endif
#define YAFFS_MAX_FILE_SIZE (0x800000000LL - 1)
-
struct yaffs_dirent {
long d_ino; /* inode number */
off_t d_off; /* offset to this dirent */
@@ -44,8 +41,6 @@ struct yaffs_dirent {
typedef struct opaque_structure yaffs_DIR;
-
-
struct yaffs_stat {
int st_dev; /* device */
int st_ino; /* inode */
@@ -69,13 +64,11 @@ struct yaffs_stat {
#endif
};
-
struct yaffs_utimbuf {
unsigned long actime;
unsigned long modtime;
};
-
int yaffs_open(const YCHAR *path, int oflag, int mode) ;
int yaffs_close(int fd) ;
@@ -108,7 +101,6 @@ int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
int yaffs_utime(const YCHAR *path, const struct yaffs_utimbuf *buf);
int yaffs_futime(int fd, const struct yaffs_utimbuf *buf);
-
int yaffs_setxattr(const char *path, const char *name,
const void *data, int size, int flags);
int yaffs_lsetxattr(const char *path, const char *name,
@@ -131,7 +123,6 @@ int yaffs_listxattr(const char *path, char *list, int size);
int yaffs_llistxattr(const char *path, char *list, int size);
int yaffs_flistxattr(int fd, char *list, int size);
-
#ifdef CONFIG_YAFFS_WINCE
int yaffs_set_wince_times(int fd,
@@ -164,7 +155,6 @@ int yaffs_unmount(const YCHAR *path) ;
int yaffs_unmount2(const YCHAR *path, int force);
int yaffs_remount(const YCHAR *path, int force, int read_only);
-
int yaffs_sync(const YCHAR *path) ;
int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath);
diff --git a/fs/yaffs2/ydirectenv.h b/fs/yaffs2/ydirectenv.h
index 790f8512f74..14b13ce2bd4 100644
--- a/fs/yaffs2/ydirectenv.h
+++ b/fs/yaffs2/ydirectenv.h
@@ -27,8 +27,6 @@
void yaffs_bug_fn(const char *file_name, int line_no);
-
-
#define YCHAR char
#define YUCHAR unsigned char
#define _Y(x) x
@@ -45,7 +43,6 @@ void yaffs_bug_fn(const char *file_name, int line_no);
#define yaffs_strncmp(a, b, c) strncmp(a, b, c)
#endif
-
void yaffs_qsort(void *aa, size_t n, size_t es,
int (*cmp)(const void *, const void *));
@@ -62,7 +59,6 @@ void yaffs_qsort(void *aa, size_t n, size_t es,
printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
} while (0)
-
#define YAFFS_LOSTNFOUND_NAME "lost+found"
#define YAFFS_LOSTNFOUND_PREFIX "obj"
diff --git a/fs/yaffs2/yportenv.h b/fs/yaffs2/yportenv.h
index 081391a1d0f..b23042948db 100644
--- a/fs/yaffs2/yportenv.h
+++ b/fs/yaffs2/yportenv.h
@@ -13,7 +13,6 @@
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-
#ifndef __YPORTENV_H__
#define __YPORTENV_H__
@@ -27,11 +26,9 @@ typedef unsigned short u16;
typedef unsigned u32;
#endif
-
#ifdef CONFIG_YAFFS_PROVIDE_DEFS
/* File types */
-
#define DT_UNKNOWN 0
#define DT_FIFO 1
#define DT_CHR 2
@@ -42,7 +39,6 @@ typedef unsigned u32;
#define DT_SOCK 12
#define DT_WHT 14
-
/*
* Attribute flags.
* These are or-ed together to select what has been changed.
@@ -69,13 +65,10 @@ struct iattr {
#endif
-
-
#if defined CONFIG_YAFFS_WINCE
#include "ywinceenv.h"
-
#elif defined CONFIG_YAFFS_DIRECT
/* Direct interface */
@@ -215,7 +208,6 @@ struct iattr {
#define ELOOP 40
#endif
-
/* Mode flags */
#ifndef S_IFMT
@@ -258,7 +250,6 @@ struct iattr {
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-
#ifndef S_IREAD
#define S_IREAD 0000400
#endif
diff --git a/fs/zfs/dev.c b/fs/zfs/dev.c
index fcd9893b3ac..0eceafab2af 100644
--- a/fs/zfs/dev.c
+++ b/fs/zfs/dev.c
@@ -7,8 +7,6 @@
* Sysgo AG, <www.elinos.com>, Pavel Bartusek <pba@sysgo.com>
*/
-
-#include <common.h>
#include <config.h>
#include <fs_internal.h>
#include <zfs_common.h>
diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c
index 113b428a938..410a61aa611 100644
--- a/fs/zfs/zfs.c
+++ b/fs/zfs/zfs.c
@@ -10,7 +10,6 @@
* Copyright 2004 Sun Microsystems, Inc.
*/
-#include <common.h>
#include <log.h>
#include <malloc.h>
#include <linux/stat.h>
@@ -51,10 +50,8 @@ struct blk_desc *zfs_dev_desc;
#include <zfs/dsl_dir.h>
#include <zfs/dsl_dataset.h>
-
#define ZPOOL_PROP_BOOTFS "bootfs"
-
/*
* For nvlist manipulation. (from nvpair.h)
*/
@@ -67,7 +64,6 @@ struct blk_desc *zfs_dev_desc;
#define DATA_TYPE_NVLIST 19
#define DATA_TYPE_NVLIST_ARRAY 20
-
/*
* Macros to get fields in a bp or DVA.
*/
@@ -121,7 +117,6 @@ struct blk_desc *zfs_dev_desc;
((zap_leaf_chunk_t *)(l->l_hash + ZAP_LEAF_HASH_NUMENTRIES(bs)))[idx]
#define ZAP_LEAF_ENTRY(l, bs, idx) (&ZAP_LEAF_CHUNK(l, bs, idx).l_entry)
-
/*
* Decompression Entry - lzjb
*/
@@ -129,8 +124,6 @@ struct blk_desc *zfs_dev_desc;
#define NBBY 8
#endif
-
-
typedef int zfs_decomp_func_t(void *s_start, void *d_start,
uint32_t s_len, uint32_t d_len);
typedef struct decomp_entry {
@@ -177,9 +170,6 @@ struct zfs_data {
};
-
-
-
static int
zlib_decompress(void *s, void *d,
uint32_t slen, uint32_t dlen)
@@ -207,8 +197,6 @@ static decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = {
{"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */
};
-
-
static int zio_read_data(blkptr_t *bp, zfs_endian_t endian,
void *buf, struct zfs_data *data);
@@ -232,7 +220,6 @@ zfs_log2(uint64_t num)
return i;
}
-
/* Checksum Functions */
static void
zio_checksum_off(const void *buf __attribute__ ((unused)),
@@ -813,7 +800,6 @@ zap_leaf_array_get(zap_leaf_phys_t *l, zfs_endian_t endian, int blksft,
return ZFS_ERR_NONE;
}
-
/*
* Given a zap_leaf_phys_t, walk thru the zap leaf chunks to get the
* value for the property "name".
@@ -880,7 +866,6 @@ zap_leaf_lookup(zap_leaf_phys_t *l, zfs_endian_t endian,
return ZFS_ERR_FILE_NOT_FOUND;
}
-
/* Verify if this is a fat zap header block */
static int
zap_verify(zap_phys_t *zap)
@@ -1030,7 +1015,6 @@ fzap_iterate(dnode_end_t *zap_dnode, zap_phys_t *zap,
return 0;
}
-
/*
* Read in the data of a zap object and find the value for a matching
* property name.
@@ -1105,7 +1089,6 @@ zap_iterate(dnode_end_t *zap_dnode,
return 0;
}
-
/*
* Get the dnode of an object number from the metadnode of an object set.
*
@@ -1300,7 +1283,6 @@ dnode_get_path(dnode_end_t *mdn, const char *path_in, dnode_end_t *dn,
return err;
}
-
/*
* Given a MOS metadnode, get the metadnode of a given filesystem name (fsname),
* e.g. pool/rootfs, or a given object number (obj), e.g. the object number
@@ -1435,7 +1417,6 @@ dnode_get_fullpath(const char *fullpath, dnode_end_t *mdn,
fsname, snapname, filename);
}
-
err = get_filesystem_dnode(&(data->mos), fsname, dn, data);
if (err) {
@@ -2337,7 +2318,6 @@ zfs_ls(device_t device, const char *path,
return err;
}
-
zap_iterate(&dn, iterate_zap_fs, data);
err = dnode_get(&(data->mos), headobj, DMU_OT_DSL_DATASET, &dn, data);
diff --git a/fs/zfs/zfs_fletcher.c b/fs/zfs/zfs_fletcher.c
index 008a303ec79..b06c335626a 100644
--- a/fs/zfs/zfs_fletcher.c
+++ b/fs/zfs/zfs_fletcher.c
@@ -8,7 +8,6 @@
* Use is subject to license terms.
*/
-#include <common.h>
#include <malloc.h>
#include <linux/stat.h>
#include <linux/time.h>
diff --git a/fs/zfs/zfs_lzjb.c b/fs/zfs/zfs_lzjb.c
index b42d4980129..e79c5b4278f 100644
--- a/fs/zfs/zfs_lzjb.c
+++ b/fs/zfs/zfs_lzjb.c
@@ -8,7 +8,6 @@
* Use is subject to license terms.
*/
-#include <common.h>
#include <malloc.h>
#include <linux/stat.h>
#include <linux/time.h>
diff --git a/fs/zfs/zfs_sha256.c b/fs/zfs/zfs_sha256.c
index cb5b1c06834..602d75254ff 100644
--- a/fs/zfs/zfs_sha256.c
+++ b/fs/zfs/zfs_sha256.c
@@ -8,7 +8,6 @@
* Use is subject to license terms.
*/
-#include <common.h>
#include <malloc.h>
#include <linux/stat.h>
#include <linux/time.h>