Lines Matching refs:c

54 static int get_default_compressor(struct ubifs_info *c)  in get_default_compressor()  argument
56 if (ubifs_compr_present(c, UBIFS_COMPR_ZSTD)) in get_default_compressor()
59 if (ubifs_compr_present(c, UBIFS_COMPR_LZO)) in get_default_compressor()
62 if (ubifs_compr_present(c, UBIFS_COMPR_ZLIB)) in get_default_compressor()
75 static int create_default_filesystem(struct ubifs_info *c) in create_default_filesystem() argument
95 c->key_len = UBIFS_SK_LEN; in create_default_filesystem()
101 if (c->leb_cnt < 0x7FFFFFFF / DEFAULT_JNL_PERCENT) in create_default_filesystem()
103 jnl_lebs = c->leb_cnt * DEFAULT_JNL_PERCENT / 100; in create_default_filesystem()
105 jnl_lebs = (c->leb_cnt / 100) * DEFAULT_JNL_PERCENT; in create_default_filesystem()
109 if (jnl_lebs * c->leb_size > DEFAULT_MAX_JNL) in create_default_filesystem()
110 jnl_lebs = DEFAULT_MAX_JNL / c->leb_size; in create_default_filesystem()
118 tmp = 2 * (c->ref_node_alsz * jnl_lebs) + c->leb_size - 1; in create_default_filesystem()
119 log_lebs = tmp / c->leb_size; in create_default_filesystem()
122 if (c->leb_cnt - min_leb_cnt > 8) { in create_default_filesystem()
139 if (c->leb_cnt - min_leb_cnt > 1) in create_default_filesystem()
147 main_lebs = c->leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS - log_lebs; in create_default_filesystem()
151 c->lsave_cnt = DEFAULT_LSAVE_CNT; in create_default_filesystem()
152 c->max_leb_cnt = c->leb_cnt; in create_default_filesystem()
153 err = ubifs_create_dflt_lpt(c, &main_lebs, lpt_first, &lpt_lebs, in create_default_filesystem()
161 main_first = c->leb_cnt - main_lebs; in create_default_filesystem()
163 sup = kzalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_KERNEL); in create_default_filesystem()
164 mst = kzalloc(c->mst_node_alsz, GFP_KERNEL); in create_default_filesystem()
165 idx_node_size = ubifs_idx_node_sz(c, 1); in create_default_filesystem()
166 idx = kzalloc(ALIGN(idx_node_size, c->min_io_size), GFP_KERNEL); in create_default_filesystem()
167 ino = kzalloc(ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size), GFP_KERNEL); in create_default_filesystem()
168 cs = kzalloc(ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size), GFP_KERNEL); in create_default_filesystem()
177 tmp64 = (long long)max_buds * c->leb_size; in create_default_filesystem()
183 if (ubifs_authenticated(c)) { in create_default_filesystem()
185 sup->hash_algo = cpu_to_le16(c->auth_hash_algo); in create_default_filesystem()
186 err = ubifs_hmac_wkm(c, sup->hmac_wkm); in create_default_filesystem()
196 sup->min_io_size = cpu_to_le32(c->min_io_size); in create_default_filesystem()
197 sup->leb_size = cpu_to_le32(c->leb_size); in create_default_filesystem()
198 sup->leb_cnt = cpu_to_le32(c->leb_cnt); in create_default_filesystem()
199 sup->max_leb_cnt = cpu_to_le32(c->max_leb_cnt); in create_default_filesystem()
206 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt); in create_default_filesystem()
209 if (c->mount_opts.override_compr) in create_default_filesystem()
210 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type); in create_default_filesystem()
212 sup->default_compr = cpu_to_le16(get_default_compressor(c)); in create_default_filesystem()
216 main_bytes = (long long)main_lebs * c->leb_size; in create_default_filesystem()
233 tmp = ubifs_idx_node_sz(c, 1); in create_default_filesystem()
237 mst->ihead_offs = cpu_to_le32(ALIGN(tmp, c->min_io_size)); in create_default_filesystem()
239 mst->lpt_lnum = cpu_to_le32(c->lpt_lnum); in create_default_filesystem()
240 mst->lpt_offs = cpu_to_le32(c->lpt_offs); in create_default_filesystem()
241 mst->nhead_lnum = cpu_to_le32(c->nhead_lnum); in create_default_filesystem()
242 mst->nhead_offs = cpu_to_le32(c->nhead_offs); in create_default_filesystem()
243 mst->ltab_lnum = cpu_to_le32(c->ltab_lnum); in create_default_filesystem()
244 mst->ltab_offs = cpu_to_le32(c->ltab_offs); in create_default_filesystem()
245 mst->lsave_lnum = cpu_to_le32(c->lsave_lnum); in create_default_filesystem()
246 mst->lsave_offs = cpu_to_le32(c->lsave_offs); in create_default_filesystem()
250 mst->leb_cnt = cpu_to_le32(c->leb_cnt); in create_default_filesystem()
251 ubifs_copy_hash(c, hash_lpt, mst->hash_lpt); in create_default_filesystem()
255 tmp64 -= ALIGN(ubifs_idx_node_sz(c, 1), c->min_io_size); in create_default_filesystem()
256 tmp64 -= ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size); in create_default_filesystem()
259 tmp64 = ALIGN(ubifs_idx_node_sz(c, 1), c->min_io_size); in create_default_filesystem()
260 ino_waste = ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size) - in create_default_filesystem()
263 tmp64 -= ALIGN(ubifs_idx_node_sz(c, 1), 8); in create_default_filesystem()
267 tmp64 = ((long long)(c->main_lebs - 1) * c->dark_wm); in create_default_filesystem()
276 c->key_fmt = UBIFS_SIMPLE_KEY_FMT; in create_default_filesystem()
277 c->key_hash = key_r5_hash; in create_default_filesystem()
281 ino_key_init(c, &key, UBIFS_ROOT_INO); in create_default_filesystem()
282 br = ubifs_idx_branch(c, idx, 0); in create_default_filesystem()
283 key_write_idx(c, &key, &br->key); in create_default_filesystem()
292 ino_key_init_flash(c, &ino->key, UBIFS_ROOT_INO); in create_default_filesystem()
294 ino->creat_sqnum = cpu_to_le64(++c->max_sqnum); in create_default_filesystem()
322 err = ubifs_write_node_hmac(c, sup, UBIFS_SB_NODE_SZ, 0, 0, in create_default_filesystem()
327 err = ubifs_write_node(c, ino, UBIFS_INO_NODE_SZ, in create_default_filesystem()
332 ubifs_node_calc_hash(c, ino, hash); in create_default_filesystem()
333 ubifs_copy_hash(c, hash, ubifs_branch_hash(c, br)); in create_default_filesystem()
335 err = ubifs_write_node(c, idx, idx_node_size, main_first + DEFAULT_IDX_LEB, 0); in create_default_filesystem()
339 ubifs_node_calc_hash(c, idx, hash); in create_default_filesystem()
340 ubifs_copy_hash(c, hash, mst->hash_root_idx); in create_default_filesystem()
342 err = ubifs_write_node_hmac(c, mst, UBIFS_MST_NODE_SZ, UBIFS_MST_LNUM, 0, in create_default_filesystem()
347 err = ubifs_write_node_hmac(c, mst, UBIFS_MST_NODE_SZ, UBIFS_MST_LNUM + 1, in create_default_filesystem()
352 err = ubifs_write_node(c, cs, UBIFS_CS_NODE_SZ, UBIFS_LOG_LNUM, 0); in create_default_filesystem()
356 ubifs_msg(c, "default file-system created"); in create_default_filesystem()
379 static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup) in validate_sb() argument
384 if (!c->key_hash) { in validate_sb()
394 if (le32_to_cpu(sup->min_io_size) != c->min_io_size) { in validate_sb()
395 ubifs_err(c, "min. I/O unit mismatch: %d in superblock, %d real", in validate_sb()
396 le32_to_cpu(sup->min_io_size), c->min_io_size); in validate_sb()
400 if (le32_to_cpu(sup->leb_size) != c->leb_size) { in validate_sb()
401 ubifs_err(c, "LEB size mismatch: %d in superblock, %d real", in validate_sb()
402 le32_to_cpu(sup->leb_size), c->leb_size); in validate_sb()
406 if (c->log_lebs < UBIFS_MIN_LOG_LEBS || in validate_sb()
407 c->lpt_lebs < UBIFS_MIN_LPT_LEBS || in validate_sb()
408 c->orph_lebs < UBIFS_MIN_ORPH_LEBS || in validate_sb()
409 c->main_lebs < UBIFS_MIN_MAIN_LEBS) { in validate_sb()
419 min_leb_cnt = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs; in validate_sb()
420 min_leb_cnt += c->lpt_lebs + c->orph_lebs + c->jhead_cnt + 6; in validate_sb()
422 if (c->leb_cnt < min_leb_cnt || c->leb_cnt > c->vi.size) { in validate_sb()
423 ubifs_err(c, "bad LEB count: %d in superblock, %d on UBI volume, %d minimum required", in validate_sb()
424 c->leb_cnt, c->vi.size, min_leb_cnt); in validate_sb()
428 if (c->max_leb_cnt < c->leb_cnt) { in validate_sb()
429 ubifs_err(c, "max. LEB count %d less than LEB count %d", in validate_sb()
430 c->max_leb_cnt, c->leb_cnt); in validate_sb()
434 if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) { in validate_sb()
435 ubifs_err(c, "too few main LEBs count %d, must be at least %d", in validate_sb()
436 c->main_lebs, UBIFS_MIN_MAIN_LEBS); in validate_sb()
440 max_bytes = (long long)c->leb_size * UBIFS_MIN_BUD_LEBS; in validate_sb()
441 if (c->max_bud_bytes < max_bytes) { in validate_sb()
442 ubifs_err(c, "too small journal (%lld bytes), must be at least %lld bytes", in validate_sb()
443 c->max_bud_bytes, max_bytes); in validate_sb()
447 max_bytes = (long long)c->leb_size * c->main_lebs; in validate_sb()
448 if (c->max_bud_bytes > max_bytes) { in validate_sb()
449 ubifs_err(c, "too large journal size (%lld bytes), only %lld bytes available in the main area", in validate_sb()
450 c->max_bud_bytes, max_bytes); in validate_sb()
454 if (c->jhead_cnt < NONDATA_JHEADS_CNT + 1 || in validate_sb()
455 c->jhead_cnt > NONDATA_JHEADS_CNT + UBIFS_MAX_JHEADS) { in validate_sb()
460 if (c->fanout < UBIFS_MIN_FANOUT || in validate_sb()
461 ubifs_idx_node_sz(c, c->fanout) > c->leb_size) { in validate_sb()
466 if (c->lsave_cnt < 0 || (c->lsave_cnt > DEFAULT_LSAVE_CNT && in validate_sb()
467 c->lsave_cnt > c->max_leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS - in validate_sb()
468 c->log_lebs - c->lpt_lebs - c->orph_lebs)) { in validate_sb()
473 if (UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs + c->lpt_lebs + in validate_sb()
474 c->orph_lebs + c->main_lebs != c->leb_cnt) { in validate_sb()
479 if (c->default_compr >= UBIFS_COMPR_TYPES_CNT) { in validate_sb()
484 if (c->rp_size < 0 || max_bytes < c->rp_size) { in validate_sb()
495 if (!c->double_hash && c->fmt_version >= 5) { in validate_sb()
500 if (c->encrypted && c->fmt_version < 5) { in validate_sb()
508 ubifs_err(c, "bad superblock, error %d", err); in validate_sb()
509 ubifs_dump_node(c, sup, ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size)); in validate_sb()
521 static struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c) in ubifs_read_sb_node() argument
526 sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS); in ubifs_read_sb_node()
530 err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ, in ubifs_read_sb_node()
540 static int authenticate_sb_node(struct ubifs_info *c, in authenticate_sb_node() argument
549 if (c->authenticated && !authenticated) { in authenticate_sb_node()
550 ubifs_err(c, "authenticated FS forced, but found FS without authentication"); in authenticate_sb_node()
554 if (!c->authenticated && authenticated) { in authenticate_sb_node()
555 ubifs_err(c, "authenticated FS found, but no key given"); in authenticate_sb_node()
559 ubifs_msg(c, "Mounting in %sauthenticated mode", in authenticate_sb_node()
560 c->authenticated ? "" : "un"); in authenticate_sb_node()
562 if (!c->authenticated) in authenticate_sb_node()
570 ubifs_err(c, "superblock uses unknown hash algo %d", in authenticate_sb_node()
575 if (strcmp(hash_algo_name[hash_algo], c->auth_hash_name)) { in authenticate_sb_node()
576 ubifs_err(c, "This filesystem uses %s for hashing," in authenticate_sb_node()
578 c->auth_hash_name); in authenticate_sb_node()
587 if (ubifs_hmac_zero(c, sup->hmac)) { in authenticate_sb_node()
588 err = ubifs_sb_verify_signature(c, sup); in authenticate_sb_node()
590 err = ubifs_hmac_wkm(c, hmac_wkm); in authenticate_sb_node()
593 if (ubifs_check_hmac(c, hmac_wkm, sup->hmac_wkm)) { in authenticate_sb_node()
594 ubifs_err(c, "provided key does not fit"); in authenticate_sb_node()
597 err = ubifs_node_verify_hmac(c, sup, sizeof(*sup), in authenticate_sb_node()
603 ubifs_err(c, "Failed to authenticate superblock: %d", err); in authenticate_sb_node()
615 int ubifs_write_sb_node(struct ubifs_info *c, struct ubifs_sb_node *sup) in ubifs_write_sb_node() argument
617 int len = ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size); in ubifs_write_sb_node()
620 err = ubifs_prepare_node_hmac(c, sup, UBIFS_SB_NODE_SZ, in ubifs_write_sb_node()
625 return ubifs_leb_change(c, UBIFS_SB_LNUM, sup, len); in ubifs_write_sb_node()
636 int ubifs_read_superblock(struct ubifs_info *c) in ubifs_read_superblock() argument
641 if (c->empty) { in ubifs_read_superblock()
642 err = create_default_filesystem(c); in ubifs_read_superblock()
647 sup = ubifs_read_sb_node(c); in ubifs_read_superblock()
651 c->sup_node = sup; in ubifs_read_superblock()
653 c->fmt_version = le32_to_cpu(sup->fmt_version); in ubifs_read_superblock()
654 c->ro_compat_version = le32_to_cpu(sup->ro_compat_version); in ubifs_read_superblock()
660 if (c->fmt_version > UBIFS_FORMAT_VERSION) { in ubifs_read_superblock()
661 ubifs_assert(c, !c->ro_media || c->ro_mount); in ubifs_read_superblock()
662 if (!c->ro_mount || in ubifs_read_superblock()
663 c->ro_compat_version > UBIFS_RO_COMPAT_VERSION) { in ubifs_read_superblock()
664 …ubifs_err(c, "on-flash format version is w%d/r%d, but software only supports up to version w%d/r%d… in ubifs_read_superblock()
665 c->fmt_version, c->ro_compat_version, in ubifs_read_superblock()
668 if (c->ro_compat_version <= UBIFS_RO_COMPAT_VERSION) { in ubifs_read_superblock()
669 ubifs_msg(c, "only R/O mounting is possible"); in ubifs_read_superblock()
681 c->rw_incompat = 1; in ubifs_read_superblock()
684 if (c->fmt_version < 3) { in ubifs_read_superblock()
685 ubifs_err(c, "on-flash format version %d is not supported", in ubifs_read_superblock()
686 c->fmt_version); in ubifs_read_superblock()
693 c->key_hash = key_r5_hash; in ubifs_read_superblock()
694 c->key_hash_type = UBIFS_KEY_HASH_R5; in ubifs_read_superblock()
698 c->key_hash = key_test_hash; in ubifs_read_superblock()
699 c->key_hash_type = UBIFS_KEY_HASH_TEST; in ubifs_read_superblock()
703 c->key_fmt = sup->key_fmt; in ubifs_read_superblock()
705 switch (c->key_fmt) { in ubifs_read_superblock()
707 c->key_len = UBIFS_SK_LEN; in ubifs_read_superblock()
710 ubifs_err(c, "unsupported key format"); in ubifs_read_superblock()
715 c->leb_cnt = le32_to_cpu(sup->leb_cnt); in ubifs_read_superblock()
716 c->max_leb_cnt = le32_to_cpu(sup->max_leb_cnt); in ubifs_read_superblock()
717 c->max_bud_bytes = le64_to_cpu(sup->max_bud_bytes); in ubifs_read_superblock()
718 c->log_lebs = le32_to_cpu(sup->log_lebs); in ubifs_read_superblock()
719 c->lpt_lebs = le32_to_cpu(sup->lpt_lebs); in ubifs_read_superblock()
720 c->orph_lebs = le32_to_cpu(sup->orph_lebs); in ubifs_read_superblock()
721 c->jhead_cnt = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT; in ubifs_read_superblock()
722 c->fanout = le32_to_cpu(sup->fanout); in ubifs_read_superblock()
723 c->lsave_cnt = le32_to_cpu(sup->lsave_cnt); in ubifs_read_superblock()
724 c->rp_size = le64_to_cpu(sup->rp_size); in ubifs_read_superblock()
725 c->rp_uid = make_kuid(&init_user_ns, le32_to_cpu(sup->rp_uid)); in ubifs_read_superblock()
726 c->rp_gid = make_kgid(&init_user_ns, le32_to_cpu(sup->rp_gid)); in ubifs_read_superblock()
728 if (!c->mount_opts.override_compr) in ubifs_read_superblock()
729 c->default_compr = le16_to_cpu(sup->default_compr); in ubifs_read_superblock()
731 c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran); in ubifs_read_superblock()
732 memcpy(&c->uuid, &sup->uuid, 16); in ubifs_read_superblock()
733 c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT); in ubifs_read_superblock()
734 c->space_fixup = !!(sup_flags & UBIFS_FLG_SPACE_FIXUP); in ubifs_read_superblock()
735 c->double_hash = !!(sup_flags & UBIFS_FLG_DOUBLE_HASH); in ubifs_read_superblock()
736 c->encrypted = !!(sup_flags & UBIFS_FLG_ENCRYPTION); in ubifs_read_superblock()
738 err = authenticate_sb_node(c, sup); in ubifs_read_superblock()
743 ubifs_err(c, "Unknown feature flags found: %#x", in ubifs_read_superblock()
749 if (!IS_ENABLED(CONFIG_FS_ENCRYPTION) && c->encrypted) { in ubifs_read_superblock()
750 ubifs_err(c, "file system contains encrypted files but UBIFS" in ubifs_read_superblock()
757 if (c->leb_cnt < c->vi.size && c->leb_cnt < c->max_leb_cnt) { in ubifs_read_superblock()
758 int old_leb_cnt = c->leb_cnt; in ubifs_read_superblock()
760 c->leb_cnt = min_t(int, c->max_leb_cnt, c->vi.size); in ubifs_read_superblock()
761 sup->leb_cnt = cpu_to_le32(c->leb_cnt); in ubifs_read_superblock()
763 c->superblock_need_write = 1; in ubifs_read_superblock()
766 old_leb_cnt, c->leb_cnt); in ubifs_read_superblock()
769 c->log_bytes = (long long)c->log_lebs * c->leb_size; in ubifs_read_superblock()
770 c->log_last = UBIFS_LOG_LNUM + c->log_lebs - 1; in ubifs_read_superblock()
771 c->lpt_first = UBIFS_LOG_LNUM + c->log_lebs; in ubifs_read_superblock()
772 c->lpt_last = c->lpt_first + c->lpt_lebs - 1; in ubifs_read_superblock()
773 c->orph_first = c->lpt_last + 1; in ubifs_read_superblock()
774 c->orph_last = c->orph_first + c->orph_lebs - 1; in ubifs_read_superblock()
775 c->main_lebs = c->leb_cnt - UBIFS_SB_LEBS - UBIFS_MST_LEBS; in ubifs_read_superblock()
776 c->main_lebs -= c->log_lebs + c->lpt_lebs + c->orph_lebs; in ubifs_read_superblock()
777 c->main_first = c->leb_cnt - c->main_lebs; in ubifs_read_superblock()
779 err = validate_sb(c, sup); in ubifs_read_superblock()
795 static int fixup_leb(struct ubifs_info *c, int lnum, int len) in fixup_leb() argument
799 ubifs_assert(c, len >= 0); in fixup_leb()
800 ubifs_assert(c, len % c->min_io_size == 0); in fixup_leb()
801 ubifs_assert(c, len < c->leb_size); in fixup_leb()
805 return ubifs_leb_unmap(c, lnum); in fixup_leb()
809 err = ubifs_leb_read(c, lnum, c->sbuf, 0, len, 1); in fixup_leb()
813 return ubifs_leb_change(c, lnum, c->sbuf, len); in fixup_leb()
823 static int fixup_free_space(struct ubifs_info *c) in fixup_free_space() argument
828 ubifs_get_lprops(c); in fixup_free_space()
832 err = fixup_leb(c, lnum, c->mst_offs + c->mst_node_alsz); in fixup_free_space()
838 lnum = ubifs_next_log_lnum(c, c->lhead_lnum); in fixup_free_space()
839 while (lnum != c->ltail_lnum) { in fixup_free_space()
840 err = fixup_leb(c, lnum, 0); in fixup_free_space()
843 lnum = ubifs_next_log_lnum(c, lnum); in fixup_free_space()
850 err = fixup_leb(c, c->lhead_lnum, in fixup_free_space()
851 ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size)); in fixup_free_space()
856 for (lnum = c->lpt_first; lnum <= c->lpt_last; lnum++) { in fixup_free_space()
857 int free = c->ltab[lnum - c->lpt_first].free; in fixup_free_space()
860 err = fixup_leb(c, lnum, c->leb_size - free); in fixup_free_space()
867 for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { in fixup_free_space()
868 err = fixup_leb(c, lnum, 0); in fixup_free_space()
874 for (lnum = c->main_first; lnum < c->leb_cnt; lnum++) { in fixup_free_space()
875 lprops = ubifs_lpt_lookup(c, lnum); in fixup_free_space()
882 err = fixup_leb(c, lnum, c->leb_size - lprops->free); in fixup_free_space()
889 ubifs_release_lprops(c); in fixup_free_space()
906 int ubifs_fixup_free_space(struct ubifs_info *c) in ubifs_fixup_free_space() argument
909 struct ubifs_sb_node *sup = c->sup_node; in ubifs_fixup_free_space()
911 ubifs_assert(c, c->space_fixup); in ubifs_fixup_free_space()
912 ubifs_assert(c, !c->ro_mount); in ubifs_fixup_free_space()
914 ubifs_msg(c, "start fixing up free space"); in ubifs_fixup_free_space()
916 err = fixup_free_space(c); in ubifs_fixup_free_space()
921 c->space_fixup = 0; in ubifs_fixup_free_space()
924 c->superblock_need_write = 1; in ubifs_fixup_free_space()
926 ubifs_msg(c, "free space fixup complete"); in ubifs_fixup_free_space()
930 int ubifs_enable_encryption(struct ubifs_info *c) in ubifs_enable_encryption() argument
933 struct ubifs_sb_node *sup = c->sup_node; in ubifs_enable_encryption()
938 if (c->encrypted) in ubifs_enable_encryption()
941 if (c->ro_mount || c->ro_media) in ubifs_enable_encryption()
944 if (c->fmt_version < 5) { in ubifs_enable_encryption()
945 ubifs_err(c, "on-flash format version 5 is needed for encryption"); in ubifs_enable_encryption()
951 err = ubifs_write_sb_node(c, sup); in ubifs_enable_encryption()
953 c->encrypted = 1; in ubifs_enable_encryption()