2008-07-14 23:08:37 +07:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of UBIFS.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006-2008 Nokia Corporation.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
|
* the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
|
|
|
|
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*
|
|
|
|
|
* Authors: Artem Bityutskiy (Битюцкий Артём)
|
|
|
|
|
* Adrian Hunter
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file implements UBIFS superblock. The superblock is stored at the first
|
|
|
|
|
* LEB of the volume and is never changed by UBIFS. Only user-space tools may
|
|
|
|
|
* change it. The superblock node mostly contains geometry information.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ubifs.h"
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
|
#include <linux/slab.h>
|
2008-12-18 19:06:51 +07:00
|
|
|
|
#include <linux/math64.h>
|
2016-05-21 07:01:00 +07:00
|
|
|
|
#include <linux/uuid.h>
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Default journal size in logical eraseblocks as a percent of total
|
|
|
|
|
* flash size.
|
|
|
|
|
*/
|
|
|
|
|
#define DEFAULT_JNL_PERCENT 5
|
|
|
|
|
|
|
|
|
|
/* Default maximum journal size in bytes */
|
|
|
|
|
#define DEFAULT_MAX_JNL (32*1024*1024)
|
|
|
|
|
|
|
|
|
|
/* Default indexing tree fanout */
|
|
|
|
|
#define DEFAULT_FANOUT 8
|
|
|
|
|
|
|
|
|
|
/* Default number of data journal heads */
|
|
|
|
|
#define DEFAULT_JHEADS_CNT 1
|
|
|
|
|
|
|
|
|
|
/* Default positions of different LEBs in the main area */
|
|
|
|
|
#define DEFAULT_IDX_LEB 0
|
|
|
|
|
#define DEFAULT_DATA_LEB 1
|
|
|
|
|
#define DEFAULT_GC_LEB 2
|
|
|
|
|
|
|
|
|
|
/* Default number of LEB numbers in LPT's save table */
|
|
|
|
|
#define DEFAULT_LSAVE_CNT 256
|
|
|
|
|
|
|
|
|
|
/* Default reserved pool size as a percent of maximum free space */
|
|
|
|
|
#define DEFAULT_RP_PERCENT 5
|
|
|
|
|
|
|
|
|
|
/* The default maximum size of reserved pool in bytes */
|
|
|
|
|
#define DEFAULT_MAX_RP_SIZE (5*1024*1024)
|
|
|
|
|
|
|
|
|
|
/* Default time granularity in nanoseconds */
|
|
|
|
|
#define DEFAULT_TIME_GRAN 1000000000
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* create_default_filesystem - format empty UBI volume.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
*
|
|
|
|
|
* This function creates default empty file-system. Returns zero in case of
|
|
|
|
|
* success and a negative error code in case of failure.
|
|
|
|
|
*/
|
|
|
|
|
static int create_default_filesystem(struct ubifs_info *c)
|
|
|
|
|
{
|
|
|
|
|
struct ubifs_sb_node *sup;
|
|
|
|
|
struct ubifs_mst_node *mst;
|
|
|
|
|
struct ubifs_idx_node *idx;
|
|
|
|
|
struct ubifs_branch *br;
|
|
|
|
|
struct ubifs_ino_node *ino;
|
|
|
|
|
struct ubifs_cs_node *cs;
|
|
|
|
|
union ubifs_key key;
|
|
|
|
|
int err, tmp, jnl_lebs, log_lebs, max_buds, main_lebs, main_first;
|
|
|
|
|
int lpt_lebs, lpt_first, orph_lebs, big_lpt, ino_waste, sup_flags = 0;
|
|
|
|
|
int min_leb_cnt = UBIFS_MIN_LEB_CNT;
|
2008-12-18 19:06:51 +07:00
|
|
|
|
long long tmp64, main_bytes;
|
2008-10-25 00:52:57 +07:00
|
|
|
|
__le64 tmp_le64;
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
|
|
|
|
/* Some functions called from here depend on the @c->key_len filed */
|
|
|
|
|
c->key_len = UBIFS_SK_LEN;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* First of all, we have to calculate default file-system geometry -
|
|
|
|
|
* log size, journal size, etc.
|
|
|
|
|
*/
|
|
|
|
|
if (c->leb_cnt < 0x7FFFFFFF / DEFAULT_JNL_PERCENT)
|
|
|
|
|
/* We can first multiply then divide and have no overflow */
|
|
|
|
|
jnl_lebs = c->leb_cnt * DEFAULT_JNL_PERCENT / 100;
|
|
|
|
|
else
|
|
|
|
|
jnl_lebs = (c->leb_cnt / 100) * DEFAULT_JNL_PERCENT;
|
|
|
|
|
|
|
|
|
|
if (jnl_lebs < UBIFS_MIN_JNL_LEBS)
|
|
|
|
|
jnl_lebs = UBIFS_MIN_JNL_LEBS;
|
|
|
|
|
if (jnl_lebs * c->leb_size > DEFAULT_MAX_JNL)
|
|
|
|
|
jnl_lebs = DEFAULT_MAX_JNL / c->leb_size;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The log should be large enough to fit reference nodes for all bud
|
|
|
|
|
* LEBs. Because buds do not have to start from the beginning of LEBs
|
|
|
|
|
* (half of the LEB may contain committed data), the log should
|
|
|
|
|
* generally be larger, make it twice as large.
|
|
|
|
|
*/
|
|
|
|
|
tmp = 2 * (c->ref_node_alsz * jnl_lebs) + c->leb_size - 1;
|
|
|
|
|
log_lebs = tmp / c->leb_size;
|
|
|
|
|
/* Plus one LEB reserved for commit */
|
|
|
|
|
log_lebs += 1;
|
|
|
|
|
if (c->leb_cnt - min_leb_cnt > 8) {
|
|
|
|
|
/* And some extra space to allow writes while committing */
|
|
|
|
|
log_lebs += 1;
|
|
|
|
|
min_leb_cnt += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
max_buds = jnl_lebs - log_lebs;
|
|
|
|
|
if (max_buds < UBIFS_MIN_BUD_LEBS)
|
|
|
|
|
max_buds = UBIFS_MIN_BUD_LEBS;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Orphan nodes are stored in a separate area. One node can store a lot
|
|
|
|
|
* of orphan inode numbers, but when new orphan comes we just add a new
|
|
|
|
|
* orphan node. At some point the nodes are consolidated into one
|
|
|
|
|
* orphan node.
|
|
|
|
|
*/
|
|
|
|
|
orph_lebs = UBIFS_MIN_ORPH_LEBS;
|
|
|
|
|
if (c->leb_cnt - min_leb_cnt > 1)
|
|
|
|
|
/*
|
|
|
|
|
* For debugging purposes it is better to have at least 2
|
|
|
|
|
* orphan LEBs, because the orphan subsystem would need to do
|
|
|
|
|
* consolidations and would be stressed more.
|
|
|
|
|
*/
|
|
|
|
|
orph_lebs += 1;
|
|
|
|
|
|
|
|
|
|
main_lebs = c->leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS - log_lebs;
|
|
|
|
|
main_lebs -= orph_lebs;
|
|
|
|
|
|
|
|
|
|
lpt_first = UBIFS_LOG_LNUM + log_lebs;
|
|
|
|
|
c->lsave_cnt = DEFAULT_LSAVE_CNT;
|
|
|
|
|
c->max_leb_cnt = c->leb_cnt;
|
|
|
|
|
err = ubifs_create_dflt_lpt(c, &main_lebs, lpt_first, &lpt_lebs,
|
|
|
|
|
&big_lpt);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
dbg_gen("LEB Properties Tree created (LEBs %d-%d)", lpt_first,
|
|
|
|
|
lpt_first + lpt_lebs - 1);
|
|
|
|
|
|
|
|
|
|
main_first = c->leb_cnt - main_lebs;
|
|
|
|
|
|
|
|
|
|
/* Create default superblock */
|
|
|
|
|
tmp = ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size);
|
|
|
|
|
sup = kzalloc(tmp, GFP_KERNEL);
|
|
|
|
|
if (!sup)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
2008-12-18 19:06:51 +07:00
|
|
|
|
tmp64 = (long long)max_buds * c->leb_size;
|
2008-07-14 23:08:37 +07:00
|
|
|
|
if (big_lpt)
|
|
|
|
|
sup_flags |= UBIFS_FLG_BIGLPT;
|
2016-10-19 20:59:12 +07:00
|
|
|
|
sup_flags |= UBIFS_FLG_DOUBLE_HASH;
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
|
|
|
|
sup->ch.node_type = UBIFS_SB_NODE;
|
|
|
|
|
sup->key_hash = UBIFS_KEY_HASH_R5;
|
|
|
|
|
sup->flags = cpu_to_le32(sup_flags);
|
|
|
|
|
sup->min_io_size = cpu_to_le32(c->min_io_size);
|
|
|
|
|
sup->leb_size = cpu_to_le32(c->leb_size);
|
|
|
|
|
sup->leb_cnt = cpu_to_le32(c->leb_cnt);
|
|
|
|
|
sup->max_leb_cnt = cpu_to_le32(c->max_leb_cnt);
|
|
|
|
|
sup->max_bud_bytes = cpu_to_le64(tmp64);
|
|
|
|
|
sup->log_lebs = cpu_to_le32(log_lebs);
|
|
|
|
|
sup->lpt_lebs = cpu_to_le32(lpt_lebs);
|
|
|
|
|
sup->orph_lebs = cpu_to_le32(orph_lebs);
|
|
|
|
|
sup->jhead_cnt = cpu_to_le32(DEFAULT_JHEADS_CNT);
|
|
|
|
|
sup->fanout = cpu_to_le32(DEFAULT_FANOUT);
|
|
|
|
|
sup->lsave_cnt = cpu_to_le32(c->lsave_cnt);
|
|
|
|
|
sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION);
|
|
|
|
|
sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN);
|
2008-11-01 19:57:49 +07:00
|
|
|
|
if (c->mount_opts.override_compr)
|
|
|
|
|
sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
|
|
|
|
|
else
|
|
|
|
|
sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
|
|
|
|
generate_random_uuid(sup->uuid);
|
|
|
|
|
|
2008-12-18 19:06:51 +07:00
|
|
|
|
main_bytes = (long long)main_lebs * c->leb_size;
|
|
|
|
|
tmp64 = div_u64(main_bytes * DEFAULT_RP_PERCENT, 100);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
if (tmp64 > DEFAULT_MAX_RP_SIZE)
|
|
|
|
|
tmp64 = DEFAULT_MAX_RP_SIZE;
|
|
|
|
|
sup->rp_size = cpu_to_le64(tmp64);
|
2009-03-26 17:51:21 +07:00
|
|
|
|
sup->ro_compat_version = cpu_to_le32(UBIFS_RO_COMPAT_VERSION);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
2012-05-14 22:55:51 +07:00
|
|
|
|
err = ubifs_write_node(c, sup, UBIFS_SB_NODE_SZ, 0, 0);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
kfree(sup);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
dbg_gen("default superblock created at LEB 0:0");
|
|
|
|
|
|
|
|
|
|
/* Create default master node */
|
|
|
|
|
mst = kzalloc(c->mst_node_alsz, GFP_KERNEL);
|
|
|
|
|
if (!mst)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
mst->ch.node_type = UBIFS_MST_NODE;
|
|
|
|
|
mst->log_lnum = cpu_to_le32(UBIFS_LOG_LNUM);
|
|
|
|
|
mst->highest_inum = cpu_to_le64(UBIFS_FIRST_INO);
|
|
|
|
|
mst->cmt_no = 0;
|
|
|
|
|
mst->root_lnum = cpu_to_le32(main_first + DEFAULT_IDX_LEB);
|
|
|
|
|
mst->root_offs = 0;
|
|
|
|
|
tmp = ubifs_idx_node_sz(c, 1);
|
|
|
|
|
mst->root_len = cpu_to_le32(tmp);
|
|
|
|
|
mst->gc_lnum = cpu_to_le32(main_first + DEFAULT_GC_LEB);
|
|
|
|
|
mst->ihead_lnum = cpu_to_le32(main_first + DEFAULT_IDX_LEB);
|
|
|
|
|
mst->ihead_offs = cpu_to_le32(ALIGN(tmp, c->min_io_size));
|
|
|
|
|
mst->index_size = cpu_to_le64(ALIGN(tmp, 8));
|
|
|
|
|
mst->lpt_lnum = cpu_to_le32(c->lpt_lnum);
|
|
|
|
|
mst->lpt_offs = cpu_to_le32(c->lpt_offs);
|
|
|
|
|
mst->nhead_lnum = cpu_to_le32(c->nhead_lnum);
|
|
|
|
|
mst->nhead_offs = cpu_to_le32(c->nhead_offs);
|
|
|
|
|
mst->ltab_lnum = cpu_to_le32(c->ltab_lnum);
|
|
|
|
|
mst->ltab_offs = cpu_to_le32(c->ltab_offs);
|
|
|
|
|
mst->lsave_lnum = cpu_to_le32(c->lsave_lnum);
|
|
|
|
|
mst->lsave_offs = cpu_to_le32(c->lsave_offs);
|
|
|
|
|
mst->lscan_lnum = cpu_to_le32(main_first);
|
|
|
|
|
mst->empty_lebs = cpu_to_le32(main_lebs - 2);
|
|
|
|
|
mst->idx_lebs = cpu_to_le32(1);
|
|
|
|
|
mst->leb_cnt = cpu_to_le32(c->leb_cnt);
|
|
|
|
|
|
|
|
|
|
/* Calculate lprops statistics */
|
|
|
|
|
tmp64 = main_bytes;
|
|
|
|
|
tmp64 -= ALIGN(ubifs_idx_node_sz(c, 1), c->min_io_size);
|
|
|
|
|
tmp64 -= ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size);
|
|
|
|
|
mst->total_free = cpu_to_le64(tmp64);
|
|
|
|
|
|
|
|
|
|
tmp64 = ALIGN(ubifs_idx_node_sz(c, 1), c->min_io_size);
|
|
|
|
|
ino_waste = ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size) -
|
|
|
|
|
UBIFS_INO_NODE_SZ;
|
|
|
|
|
tmp64 += ino_waste;
|
|
|
|
|
tmp64 -= ALIGN(ubifs_idx_node_sz(c, 1), 8);
|
|
|
|
|
mst->total_dirty = cpu_to_le64(tmp64);
|
|
|
|
|
|
|
|
|
|
/* The indexing LEB does not contribute to dark space */
|
2011-08-26 17:38:39 +07:00
|
|
|
|
tmp64 = ((long long)(c->main_lebs - 1) * c->dark_wm);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
mst->total_dark = cpu_to_le64(tmp64);
|
|
|
|
|
|
|
|
|
|
mst->total_used = cpu_to_le64(UBIFS_INO_NODE_SZ);
|
|
|
|
|
|
2012-05-14 22:55:51 +07:00
|
|
|
|
err = ubifs_write_node(c, mst, UBIFS_MST_NODE_SZ, UBIFS_MST_LNUM, 0);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
if (err) {
|
|
|
|
|
kfree(mst);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2012-05-14 22:55:51 +07:00
|
|
|
|
err = ubifs_write_node(c, mst, UBIFS_MST_NODE_SZ, UBIFS_MST_LNUM + 1,
|
|
|
|
|
0);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
kfree(mst);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
dbg_gen("default master node created at LEB %d:0", UBIFS_MST_LNUM);
|
|
|
|
|
|
|
|
|
|
/* Create the root indexing node */
|
|
|
|
|
tmp = ubifs_idx_node_sz(c, 1);
|
|
|
|
|
idx = kzalloc(ALIGN(tmp, c->min_io_size), GFP_KERNEL);
|
|
|
|
|
if (!idx)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
c->key_fmt = UBIFS_SIMPLE_KEY_FMT;
|
|
|
|
|
c->key_hash = key_r5_hash;
|
|
|
|
|
|
|
|
|
|
idx->ch.node_type = UBIFS_IDX_NODE;
|
|
|
|
|
idx->child_cnt = cpu_to_le16(1);
|
|
|
|
|
ino_key_init(c, &key, UBIFS_ROOT_INO);
|
|
|
|
|
br = ubifs_idx_branch(c, idx, 0);
|
|
|
|
|
key_write_idx(c, &key, &br->key);
|
|
|
|
|
br->lnum = cpu_to_le32(main_first + DEFAULT_DATA_LEB);
|
|
|
|
|
br->len = cpu_to_le32(UBIFS_INO_NODE_SZ);
|
2012-05-14 22:55:51 +07:00
|
|
|
|
err = ubifs_write_node(c, idx, tmp, main_first + DEFAULT_IDX_LEB, 0);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
kfree(idx);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
dbg_gen("default root indexing node created LEB %d:0",
|
|
|
|
|
main_first + DEFAULT_IDX_LEB);
|
|
|
|
|
|
|
|
|
|
/* Create default root inode */
|
|
|
|
|
tmp = ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size);
|
|
|
|
|
ino = kzalloc(tmp, GFP_KERNEL);
|
|
|
|
|
if (!ino)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
ino_key_init_flash(c, &ino->key, UBIFS_ROOT_INO);
|
|
|
|
|
ino->ch.node_type = UBIFS_INO_NODE;
|
|
|
|
|
ino->creat_sqnum = cpu_to_le64(++c->max_sqnum);
|
|
|
|
|
ino->nlink = cpu_to_le32(2);
|
2008-10-25 00:52:57 +07:00
|
|
|
|
tmp_le64 = cpu_to_le64(CURRENT_TIME_SEC.tv_sec);
|
|
|
|
|
ino->atime_sec = tmp_le64;
|
|
|
|
|
ino->ctime_sec = tmp_le64;
|
|
|
|
|
ino->mtime_sec = tmp_le64;
|
2008-07-14 23:08:37 +07:00
|
|
|
|
ino->atime_nsec = 0;
|
|
|
|
|
ino->ctime_nsec = 0;
|
|
|
|
|
ino->mtime_nsec = 0;
|
|
|
|
|
ino->mode = cpu_to_le32(S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO);
|
|
|
|
|
ino->size = cpu_to_le64(UBIFS_INO_NODE_SZ);
|
|
|
|
|
|
|
|
|
|
/* Set compression enabled by default */
|
|
|
|
|
ino->flags = cpu_to_le32(UBIFS_COMPR_FL);
|
|
|
|
|
|
|
|
|
|
err = ubifs_write_node(c, ino, UBIFS_INO_NODE_SZ,
|
2012-05-14 22:55:51 +07:00
|
|
|
|
main_first + DEFAULT_DATA_LEB, 0);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
kfree(ino);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
dbg_gen("root inode created at LEB %d:0",
|
|
|
|
|
main_first + DEFAULT_DATA_LEB);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The first node in the log has to be the commit start node. This is
|
|
|
|
|
* always the case during normal file-system operation. Write a fake
|
|
|
|
|
* commit start node to the log.
|
|
|
|
|
*/
|
|
|
|
|
tmp = ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size);
|
|
|
|
|
cs = kzalloc(tmp, GFP_KERNEL);
|
|
|
|
|
if (!cs)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
cs->ch.node_type = UBIFS_CS_NODE;
|
2012-05-14 22:55:51 +07:00
|
|
|
|
err = ubifs_write_node(c, cs, UBIFS_CS_NODE_SZ, UBIFS_LOG_LNUM, 0);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
kfree(cs);
|
2014-06-11 09:38:45 +07:00
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_msg(c, "default file-system created");
|
2008-07-14 23:08:37 +07:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* validate_sb - validate superblock node.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @sup: superblock node
|
|
|
|
|
*
|
|
|
|
|
* This function validates superblock node @sup. Since most of data was read
|
|
|
|
|
* from the superblock and stored in @c, the function validates fields in @c
|
|
|
|
|
* instead. Returns zero in case of success and %-EINVAL in case of validation
|
|
|
|
|
* failure.
|
|
|
|
|
*/
|
|
|
|
|
static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup)
|
|
|
|
|
{
|
|
|
|
|
long long max_bytes;
|
|
|
|
|
int err = 1, min_leb_cnt;
|
|
|
|
|
|
|
|
|
|
if (!c->key_hash) {
|
|
|
|
|
err = 2;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sup->key_fmt != UBIFS_SIMPLE_KEY_FMT) {
|
|
|
|
|
err = 3;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (le32_to_cpu(sup->min_io_size) != c->min_io_size) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "min. I/O unit mismatch: %d in superblock, %d real",
|
2008-07-14 23:08:37 +07:00
|
|
|
|
le32_to_cpu(sup->min_io_size), c->min_io_size);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (le32_to_cpu(sup->leb_size) != c->leb_size) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "LEB size mismatch: %d in superblock, %d real",
|
2008-07-14 23:08:37 +07:00
|
|
|
|
le32_to_cpu(sup->leb_size), c->leb_size);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->log_lebs < UBIFS_MIN_LOG_LEBS ||
|
|
|
|
|
c->lpt_lebs < UBIFS_MIN_LPT_LEBS ||
|
|
|
|
|
c->orph_lebs < UBIFS_MIN_ORPH_LEBS ||
|
|
|
|
|
c->main_lebs < UBIFS_MIN_MAIN_LEBS) {
|
|
|
|
|
err = 4;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Calculate minimum allowed amount of main area LEBs. This is very
|
|
|
|
|
* similar to %UBIFS_MIN_LEB_CNT, but we take into account real what we
|
|
|
|
|
* have just read from the superblock.
|
|
|
|
|
*/
|
|
|
|
|
min_leb_cnt = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs;
|
|
|
|
|
min_leb_cnt += c->lpt_lebs + c->orph_lebs + c->jhead_cnt + 6;
|
|
|
|
|
|
|
|
|
|
if (c->leb_cnt < min_leb_cnt || c->leb_cnt > c->vi.size) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "bad LEB count: %d in superblock, %d on UBI volume, %d minimum required",
|
2012-08-27 17:34:09 +07:00
|
|
|
|
c->leb_cnt, c->vi.size, min_leb_cnt);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->max_leb_cnt < c->leb_cnt) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "max. LEB count %d less than LEB count %d",
|
2008-07-14 23:08:37 +07:00
|
|
|
|
c->max_leb_cnt, c->leb_cnt);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "too few main LEBs count %d, must be at least %d",
|
2012-03-07 21:29:45 +07:00
|
|
|
|
c->main_lebs, UBIFS_MIN_MAIN_LEBS);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-07 21:29:45 +07:00
|
|
|
|
max_bytes = (long long)c->leb_size * UBIFS_MIN_BUD_LEBS;
|
|
|
|
|
if (c->max_bud_bytes < max_bytes) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "too small journal (%lld bytes), must be at least %lld bytes",
|
2012-08-27 17:34:09 +07:00
|
|
|
|
c->max_bud_bytes, max_bytes);
|
2012-03-07 21:29:45 +07:00
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
max_bytes = (long long)c->leb_size * c->main_lebs;
|
|
|
|
|
if (c->max_bud_bytes > max_bytes) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "too large journal size (%lld bytes), only %lld bytes available in the main area",
|
2012-03-07 21:29:45 +07:00
|
|
|
|
c->max_bud_bytes, max_bytes);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->jhead_cnt < NONDATA_JHEADS_CNT + 1 ||
|
|
|
|
|
c->jhead_cnt > NONDATA_JHEADS_CNT + UBIFS_MAX_JHEADS) {
|
|
|
|
|
err = 9;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->fanout < UBIFS_MIN_FANOUT ||
|
|
|
|
|
ubifs_idx_node_sz(c, c->fanout) > c->leb_size) {
|
|
|
|
|
err = 10;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->lsave_cnt < 0 || (c->lsave_cnt > DEFAULT_LSAVE_CNT &&
|
|
|
|
|
c->lsave_cnt > c->max_leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS -
|
|
|
|
|
c->log_lebs - c->lpt_lebs - c->orph_lebs)) {
|
|
|
|
|
err = 11;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs + c->lpt_lebs +
|
|
|
|
|
c->orph_lebs + c->main_lebs != c->leb_cnt) {
|
|
|
|
|
err = 12;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-11 09:42:52 +07:00
|
|
|
|
if (c->default_compr >= UBIFS_COMPR_TYPES_CNT) {
|
2008-07-14 23:08:37 +07:00
|
|
|
|
err = 13;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->rp_size < 0 || max_bytes < c->rp_size) {
|
|
|
|
|
err = 14;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (le32_to_cpu(sup->time_gran) > 1000000000 ||
|
|
|
|
|
le32_to_cpu(sup->time_gran) < 1) {
|
|
|
|
|
err = 15;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 04:46:39 +07:00
|
|
|
|
if (!c->double_hash && c->fmt_version >= 5) {
|
|
|
|
|
err = 16;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->encrypted && c->fmt_version < 5) {
|
|
|
|
|
err = 17;
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-14 23:08:37 +07:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
failed:
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "bad superblock, error %d", err);
|
2012-05-16 23:15:56 +07:00
|
|
|
|
ubifs_dump_node(c, sup);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_read_sb_node - read superblock node.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
*
|
|
|
|
|
* This function returns a pointer to the superblock node or a negative error
|
2011-05-06 21:08:56 +07:00
|
|
|
|
* code. Note, the user of this function is responsible of kfree()'ing the
|
|
|
|
|
* returned superblock buffer.
|
2008-07-14 23:08:37 +07:00
|
|
|
|
*/
|
|
|
|
|
struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
|
|
|
|
|
{
|
|
|
|
|
struct ubifs_sb_node *sup;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS);
|
|
|
|
|
if (!sup)
|
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
|
|
err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ,
|
|
|
|
|
UBIFS_SB_LNUM, 0);
|
|
|
|
|
if (err) {
|
|
|
|
|
kfree(sup);
|
|
|
|
|
return ERR_PTR(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_write_sb_node - write superblock node.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @sup: superblock node read with 'ubifs_read_sb_node()'
|
|
|
|
|
*
|
|
|
|
|
* This function returns %0 on success and a negative error code on failure.
|
|
|
|
|
*/
|
|
|
|
|
int ubifs_write_sb_node(struct ubifs_info *c, struct ubifs_sb_node *sup)
|
|
|
|
|
{
|
|
|
|
|
int len = ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size);
|
|
|
|
|
|
|
|
|
|
ubifs_prepare_node(c, sup, UBIFS_SB_NODE_SZ, 1);
|
2012-05-14 22:55:51 +07:00
|
|
|
|
return ubifs_leb_change(c, UBIFS_SB_LNUM, sup, len);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_read_superblock - read superblock.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
*
|
|
|
|
|
* This function finds, reads and checks the superblock. If an empty UBI volume
|
|
|
|
|
* is being mounted, this function creates default superblock. Returns zero in
|
|
|
|
|
* case of success, and a negative error code in case of failure.
|
|
|
|
|
*/
|
|
|
|
|
int ubifs_read_superblock(struct ubifs_info *c)
|
|
|
|
|
{
|
|
|
|
|
int err, sup_flags;
|
|
|
|
|
struct ubifs_sb_node *sup;
|
|
|
|
|
|
|
|
|
|
if (c->empty) {
|
|
|
|
|
err = create_default_filesystem(c);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sup = ubifs_read_sb_node(c);
|
|
|
|
|
if (IS_ERR(sup))
|
|
|
|
|
return PTR_ERR(sup);
|
|
|
|
|
|
2009-03-26 17:51:21 +07:00
|
|
|
|
c->fmt_version = le32_to_cpu(sup->fmt_version);
|
|
|
|
|
c->ro_compat_version = le32_to_cpu(sup->ro_compat_version);
|
|
|
|
|
|
2008-07-14 23:08:37 +07:00
|
|
|
|
/*
|
|
|
|
|
* The software supports all previous versions but not future versions,
|
|
|
|
|
* due to the unavailability of time-travelling equipment.
|
|
|
|
|
*/
|
|
|
|
|
if (c->fmt_version > UBIFS_FORMAT_VERSION) {
|
2010-09-19 22:34:26 +07:00
|
|
|
|
ubifs_assert(!c->ro_media || c->ro_mount);
|
|
|
|
|
if (!c->ro_mount ||
|
2009-03-26 17:51:21 +07:00
|
|
|
|
c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d",
|
2012-08-27 17:34:09 +07:00
|
|
|
|
c->fmt_version, c->ro_compat_version,
|
|
|
|
|
UBIFS_FORMAT_VERSION,
|
2009-03-26 17:51:21 +07:00
|
|
|
|
UBIFS_RO_COMPAT_VERSION);
|
|
|
|
|
if (c->ro_compat_version <= UBIFS_RO_COMPAT_VERSION) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_msg(c, "only R/O mounting is possible");
|
2009-03-26 17:51:21 +07:00
|
|
|
|
err = -EROFS;
|
|
|
|
|
} else
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The FS is mounted R/O, and the media format is
|
|
|
|
|
* R/O-compatible with the UBIFS implementation, so we can
|
|
|
|
|
* mount.
|
|
|
|
|
*/
|
|
|
|
|
c->rw_incompat = 1;
|
2008-07-14 23:08:37 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c->fmt_version < 3) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "on-flash format version %d is not supported",
|
2008-07-14 23:08:37 +07:00
|
|
|
|
c->fmt_version);
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (sup->key_hash) {
|
|
|
|
|
case UBIFS_KEY_HASH_R5:
|
|
|
|
|
c->key_hash = key_r5_hash;
|
|
|
|
|
c->key_hash_type = UBIFS_KEY_HASH_R5;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case UBIFS_KEY_HASH_TEST:
|
|
|
|
|
c->key_hash = key_test_hash;
|
|
|
|
|
c->key_hash_type = UBIFS_KEY_HASH_TEST;
|
|
|
|
|
break;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
c->key_fmt = sup->key_fmt;
|
|
|
|
|
|
|
|
|
|
switch (c->key_fmt) {
|
|
|
|
|
case UBIFS_SIMPLE_KEY_FMT:
|
|
|
|
|
c->key_len = UBIFS_SK_LEN;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_err(c, "unsupported key format");
|
2008-07-14 23:08:37 +07:00
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c->leb_cnt = le32_to_cpu(sup->leb_cnt);
|
|
|
|
|
c->max_leb_cnt = le32_to_cpu(sup->max_leb_cnt);
|
|
|
|
|
c->max_bud_bytes = le64_to_cpu(sup->max_bud_bytes);
|
|
|
|
|
c->log_lebs = le32_to_cpu(sup->log_lebs);
|
|
|
|
|
c->lpt_lebs = le32_to_cpu(sup->lpt_lebs);
|
|
|
|
|
c->orph_lebs = le32_to_cpu(sup->orph_lebs);
|
|
|
|
|
c->jhead_cnt = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT;
|
|
|
|
|
c->fanout = le32_to_cpu(sup->fanout);
|
|
|
|
|
c->lsave_cnt = le32_to_cpu(sup->lsave_cnt);
|
|
|
|
|
c->rp_size = le64_to_cpu(sup->rp_size);
|
2012-02-08 06:50:56 +07:00
|
|
|
|
c->rp_uid = make_kuid(&init_user_ns, le32_to_cpu(sup->rp_uid));
|
|
|
|
|
c->rp_gid = make_kgid(&init_user_ns, le32_to_cpu(sup->rp_gid));
|
2008-07-14 23:08:37 +07:00
|
|
|
|
sup_flags = le32_to_cpu(sup->flags);
|
2008-11-01 19:57:49 +07:00
|
|
|
|
if (!c->mount_opts.override_compr)
|
|
|
|
|
c->default_compr = le16_to_cpu(sup->default_compr);
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
|
|
|
|
c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran);
|
|
|
|
|
memcpy(&c->uuid, &sup->uuid, 16);
|
|
|
|
|
c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT);
|
2011-05-06 03:33:20 +07:00
|
|
|
|
c->space_fixup = !!(sup_flags & UBIFS_FLG_SPACE_FIXUP);
|
2016-10-19 20:59:12 +07:00
|
|
|
|
c->double_hash = !!(sup_flags & UBIFS_FLG_DOUBLE_HASH);
|
2016-10-20 04:24:47 +07:00
|
|
|
|
c->encrypted = !!(sup_flags & UBIFS_FLG_ENCRYPTION);
|
|
|
|
|
|
2016-10-20 04:46:39 +07:00
|
|
|
|
if ((sup_flags & ~UBIFS_FLG_MASK) != 0) {
|
|
|
|
|
ubifs_err(c, "Unknown feature flags found: %#x",
|
|
|
|
|
sup_flags & ~UBIFS_FLG_MASK);
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 04:24:47 +07:00
|
|
|
|
#ifndef CONFIG_UBIFS_FS_ENCRYPTION
|
|
|
|
|
if (c->encrypted) {
|
|
|
|
|
ubifs_err(c, "file system contains encrypted files but UBIFS"
|
|
|
|
|
" was built without crypto support.");
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2008-07-14 23:08:37 +07:00
|
|
|
|
|
|
|
|
|
/* Automatically increase file system size to the maximum size */
|
|
|
|
|
c->old_leb_cnt = c->leb_cnt;
|
|
|
|
|
if (c->leb_cnt < c->vi.size && c->leb_cnt < c->max_leb_cnt) {
|
|
|
|
|
c->leb_cnt = min_t(int, c->max_leb_cnt, c->vi.size);
|
2010-09-19 22:34:26 +07:00
|
|
|
|
if (c->ro_mount)
|
2008-07-14 23:08:37 +07:00
|
|
|
|
dbg_mnt("Auto resizing (ro) from %d LEBs to %d LEBs",
|
|
|
|
|
c->old_leb_cnt, c->leb_cnt);
|
|
|
|
|
else {
|
|
|
|
|
dbg_mnt("Auto resizing (sb) from %d LEBs to %d LEBs",
|
|
|
|
|
c->old_leb_cnt, c->leb_cnt);
|
|
|
|
|
sup->leb_cnt = cpu_to_le32(c->leb_cnt);
|
|
|
|
|
err = ubifs_write_sb_node(c, sup);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
c->old_leb_cnt = c->leb_cnt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c->log_bytes = (long long)c->log_lebs * c->leb_size;
|
|
|
|
|
c->log_last = UBIFS_LOG_LNUM + c->log_lebs - 1;
|
|
|
|
|
c->lpt_first = UBIFS_LOG_LNUM + c->log_lebs;
|
|
|
|
|
c->lpt_last = c->lpt_first + c->lpt_lebs - 1;
|
|
|
|
|
c->orph_first = c->lpt_last + 1;
|
|
|
|
|
c->orph_last = c->orph_first + c->orph_lebs - 1;
|
|
|
|
|
c->main_lebs = c->leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS;
|
|
|
|
|
c->main_lebs -= c->log_lebs + c->lpt_lebs + c->orph_lebs;
|
|
|
|
|
c->main_first = c->leb_cnt - c->main_lebs;
|
|
|
|
|
|
|
|
|
|
err = validate_sb(c, sup);
|
|
|
|
|
out:
|
|
|
|
|
kfree(sup);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2011-05-07 05:58:22 +07:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* fixup_leb - fixup/unmap an LEB containing free space.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @lnum: the LEB number to fix up
|
|
|
|
|
* @len: number of used bytes in LEB (starting at offset 0)
|
|
|
|
|
*
|
|
|
|
|
* This function reads the contents of the given LEB number @lnum, then fixes
|
|
|
|
|
* it up, so that empty min. I/O units in the end of LEB are actually erased on
|
|
|
|
|
* flash (rather than being just all-0xff real data). If the LEB is completely
|
|
|
|
|
* empty, it is simply unmapped.
|
|
|
|
|
*/
|
|
|
|
|
static int fixup_leb(struct ubifs_info *c, int lnum, int len)
|
|
|
|
|
{
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
ubifs_assert(len >= 0);
|
|
|
|
|
ubifs_assert(len % c->min_io_size == 0);
|
|
|
|
|
ubifs_assert(len < c->leb_size);
|
|
|
|
|
|
|
|
|
|
if (len == 0) {
|
|
|
|
|
dbg_mnt("unmap empty LEB %d", lnum);
|
2011-06-03 18:22:05 +07:00
|
|
|
|
return ubifs_leb_unmap(c, lnum);
|
2011-05-07 05:58:22 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbg_mnt("fixup LEB %d, data len %d", lnum, len);
|
2011-06-03 18:03:25 +07:00
|
|
|
|
err = ubifs_leb_read(c, lnum, c->sbuf, 0, len, 1);
|
2011-05-07 05:58:22 +07:00
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
2012-05-14 22:55:51 +07:00
|
|
|
|
return ubifs_leb_change(c, lnum, c->sbuf, len);
|
2011-05-07 05:58:22 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* fixup_free_space - find & remap all LEBs containing free space.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
*
|
|
|
|
|
* This function walks through all LEBs in the filesystem and fiexes up those
|
|
|
|
|
* containing free/empty space.
|
|
|
|
|
*/
|
|
|
|
|
static int fixup_free_space(struct ubifs_info *c)
|
|
|
|
|
{
|
|
|
|
|
int lnum, err = 0;
|
|
|
|
|
struct ubifs_lprops *lprops;
|
|
|
|
|
|
|
|
|
|
ubifs_get_lprops(c);
|
|
|
|
|
|
|
|
|
|
/* Fixup LEBs in the master area */
|
|
|
|
|
for (lnum = UBIFS_MST_LNUM; lnum < UBIFS_LOG_LNUM; lnum++) {
|
|
|
|
|
err = fixup_leb(c, lnum, c->mst_offs + c->mst_node_alsz);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Unmap unused log LEBs */
|
|
|
|
|
lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
|
|
|
|
|
while (lnum != c->ltail_lnum) {
|
|
|
|
|
err = fixup_leb(c, lnum, 0);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
lnum = ubifs_next_log_lnum(c, lnum);
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-14 18:33:09 +07:00
|
|
|
|
/*
|
|
|
|
|
* Fixup the log head which contains the only a CS node at the
|
|
|
|
|
* beginning.
|
|
|
|
|
*/
|
|
|
|
|
err = fixup_leb(c, c->lhead_lnum,
|
|
|
|
|
ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size));
|
2011-05-07 05:58:22 +07:00
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Fixup LEBs in the LPT area */
|
|
|
|
|
for (lnum = c->lpt_first; lnum <= c->lpt_last; lnum++) {
|
|
|
|
|
int free = c->ltab[lnum - c->lpt_first].free;
|
|
|
|
|
|
|
|
|
|
if (free > 0) {
|
|
|
|
|
err = fixup_leb(c, lnum, c->leb_size - free);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Unmap LEBs in the orphans area */
|
|
|
|
|
for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) {
|
|
|
|
|
err = fixup_leb(c, lnum, 0);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fixup LEBs in the main area */
|
|
|
|
|
for (lnum = c->main_first; lnum < c->leb_cnt; lnum++) {
|
|
|
|
|
lprops = ubifs_lpt_lookup(c, lnum);
|
|
|
|
|
if (IS_ERR(lprops)) {
|
|
|
|
|
err = PTR_ERR(lprops);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lprops->free > 0) {
|
|
|
|
|
err = fixup_leb(c, lnum, c->leb_size - lprops->free);
|
|
|
|
|
if (err)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
ubifs_release_lprops(c);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_fixup_free_space - find & fix all LEBs with free space.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
*
|
|
|
|
|
* This function fixes up LEBs containing free space on first mount, if the
|
|
|
|
|
* appropriate flag was set when the FS was created. Each LEB with one or more
|
|
|
|
|
* empty min. I/O unit (i.e. free-space-count > 0) is re-written, to make sure
|
|
|
|
|
* the free space is actually erased. E.g., this is necessary for some NAND
|
|
|
|
|
* chips, since the free space may have been programmed like real "0xff" data
|
|
|
|
|
* (generating a non-0xff ECC), causing future writes to the not-really-erased
|
|
|
|
|
* NAND pages to behave badly. After the space is fixed up, the superblock flag
|
|
|
|
|
* is cleared, so that this is skipped for all future mounts.
|
|
|
|
|
*/
|
|
|
|
|
int ubifs_fixup_free_space(struct ubifs_info *c)
|
|
|
|
|
{
|
|
|
|
|
int err;
|
|
|
|
|
struct ubifs_sb_node *sup;
|
|
|
|
|
|
|
|
|
|
ubifs_assert(c->space_fixup);
|
|
|
|
|
ubifs_assert(!c->ro_mount);
|
|
|
|
|
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_msg(c, "start fixing up free space");
|
2011-05-07 05:58:22 +07:00
|
|
|
|
|
|
|
|
|
err = fixup_free_space(c);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
sup = ubifs_read_sb_node(c);
|
|
|
|
|
if (IS_ERR(sup))
|
|
|
|
|
return PTR_ERR(sup);
|
|
|
|
|
|
|
|
|
|
/* Free-space fixup is no longer required */
|
|
|
|
|
c->space_fixup = 0;
|
|
|
|
|
sup->flags &= cpu_to_le32(~UBIFS_FLG_SPACE_FIXUP);
|
|
|
|
|
|
|
|
|
|
err = ubifs_write_sb_node(c, sup);
|
|
|
|
|
kfree(sup);
|
|
|
|
|
if (err)
|
|
|
|
|
return err;
|
|
|
|
|
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 17:39:42 +07:00
|
|
|
|
ubifs_msg(c, "free space fixup complete");
|
2011-05-07 05:58:22 +07:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2016-10-20 04:24:47 +07:00
|
|
|
|
|
|
|
|
|
int ubifs_enable_encryption(struct ubifs_info *c)
|
|
|
|
|
{
|
|
|
|
|
int err;
|
|
|
|
|
struct ubifs_sb_node *sup;
|
|
|
|
|
|
|
|
|
|
if (c->encrypted)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (c->ro_mount || c->ro_media)
|
|
|
|
|
return -EROFS;
|
|
|
|
|
|
|
|
|
|
if (c->fmt_version < 5) {
|
|
|
|
|
ubifs_err(c, "on-flash format version 5 is needed for encryption");
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sup = ubifs_read_sb_node(c);
|
|
|
|
|
if (IS_ERR(sup))
|
|
|
|
|
return PTR_ERR(sup);
|
|
|
|
|
|
|
|
|
|
sup->flags |= cpu_to_le32(UBIFS_FLG_ENCRYPTION);
|
|
|
|
|
|
|
|
|
|
err = ubifs_write_sb_node(c, sup);
|
|
|
|
|
if (!err)
|
|
|
|
|
c->encrypted = 1;
|
|
|
|
|
kfree(sup);
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|