summaryrefslogtreecommitdiff
path: root/ubifs-utils
AgeCommit message (Collapse)Author
2018-11-01mkfs.ubifs: Store directory name len in the temporary indexRichard Weinberger
since names are no longer strings, we need to know the length. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement fscrypto context store as xattrRichard Weinberger
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement basic fscrypto context passingRichard Weinberger
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement UBIFS_FLG_ENCRYPTIONRichard Weinberger
...and set UBIFS format version Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Add basic fscrypto functionsRichard Weinberger
...maybe we should add them to crypto.c? Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Add fscrypto definesRichard Weinberger
most of them should be UAPI, therefore check using #ifndef Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Make r5 hash binary string awareRichard Weinberger
As of now all filenames known by UBIFS are strings with a NUL terminator. With encrypted filenames a filename can be any binary string and the r5 function cannot search for the NUL terminator. UBIFS always knows how long a filename is, therefore we can change the hash function to iterate over the filename length to work correctly with binary strings. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement UBIFS_FLG_DOUBLE_HASHDavid Oberhollenzer
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Add crypto helper functionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2018-10-02mkfs.ubifs: Fix xattr nlink valueSascha Hauer
The nlink value of a xattr node must always be one, it has nothing to do with the nlink value of the inode the attribute belongs to. The bug can be observed when mounting a mkfs.ubifs generated image which contains xattrs on directories or files with hardlinks to them. When mounting such an image with chk_fs = 1 it fails with: UBIFS error (ubi0:0 pid 1833): dbg_check_filesystem: inode 3308 nlink is 3, but calculated nlink is 1 Another bug that can be triggered is an assertion in ubifs_xattr_remove() which assures that the xattr i_nlink count should be one when the xattr is removed. Fixes: 50044ef ("mkfs.ubifs: Add extended attribute support") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-10-02mtd-utils: Instead of doing preprocessor magic, just output off_t as long longThorsten Glaser
Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write): In file included from ../git/lib/libmtd.c:40:0: ../git/lib/libmtd.c: In function 'mtd_read': ../git/include/common.h:110:18: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'off_t {aka long long int}' [-Wformat=] ../git/include/common.h:120:2: note: in expansion of macro 'errmsg' errmsg(fmt, ##__VA_ARGS__); \ ^~~~~~ ../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg' return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t, ^~~~~~~~~~ /usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here #define PRId32 "d" Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-14mkfs.ubifs: Implement selinux labelling support in mkfs.ubifs.Ritesh Harjani
This implements/adds selinux labelling support to mkfs.ubifs utility. It adds an extra option in configure to enable selinux labelling support and then finally in mkfs.ubifs adds an extra option to pass the file_contexts which is looked up for filesystem file labels. - Default behavior is kept without selinux so as to not break existing support where selinux library/headers may not be present. - If this is configured with --with-selinux then XATTR from the file_contexts(passed with --selinux option while mkfs.ubifs) will be taken and not from the host file's xattr. This is done to avoid the problem where the host OS may have selinux enabled and hence same xattr names will be present in both host filesystem files and from the --selinux=file passed. So the existing behavior is kept mutually exclusive and preference is given to selinux xattrs (if configured with --with-selinux). Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-14mkfs.ubifs: add_xattr is not depending on host XATTR supportRitesh Harjani
add_xattr adds the xattr to the ubifs image and has nothing to do with host XATTR support. Now that we are adding support where selinux interfaces may use this API even when host OS(where ubi/ubifs image is being created) does not support XATTR -so remove it from WITHOUT_XATTR #ifdef. Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-05mtd-utils: ubifs: fix typo in without_lzo definitionKoen Vandeputte
Fixes: 1d04b4d5361a ("fix build when WITHOUT_LZO is set") Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-03-07mkfs.ubifs: Allow root entry in device tableDavid Engraf
When using a local root folder the permissions, user and group settings are taken from the local folder. These permissions might be incorrect if the folder has been created for the local user. Creating an UBIFS image on my local system resulted in the following output on the target: drwx------ 17 1000 1000 1264 Jan 1 00:00 . drwx------ 17 1000 1000 1264 Jan 1 00:00 .. drwxr-xr-x 2 root root 9104 May 30 2017 bin drwxr-xr-x 7 root root 2760 Jan 1 00:00 dev ... mkfs.ubifs aborts with an error message when the device table contains a root entry. This patch allows setting the root folder permissions, user and group to overwrite local configurations. Signed-off-by: David Engraf <david.engraf@sysgo.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Remove self-assignments of unused paramtersDavid Oberhollenzer
Use casts to void instead. Clang generates warnings about that by default. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-30mkfs.ubifs: ignore EOPNOTSUPP when listing extended attributesPavel Roskin
Systems that don't support extended attributes should still be able to create ubifs images. Signed-off-by: Pavel Roskin <plroskin@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-04mkfs.ubifs: Apply squash-uids to the root nodeRomain Izard
The root node of the file system needs to be handled as a special case when removing the owner information from the input. Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-07-10mkfs-ubifs: fix inclusion of uuid.hRolf Eike Beer
The include directory exported by uuid.pc is */include/uuid, so uuid.h must be included without any directory in the path. This usually works out because uuid is installed in the normal prefix, so the parent directory of what uuid has as include dir ends up in the include path anyway. In case one uses a custom uuid outside of the regular include path this breaks. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Replace defunct ubifs_assertDavid Oberhollenzer
The ubifs assert defined in defs.h was only used in three places inside key.h and defined to never perform any checks at all. This patch replaces ubifs_assert in mkfs.ubifs with the regular libc assert macro. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-14ubi-utils: Return error code if command line option is unknownDaniel Wagner
The tools in question will quit with an exit code 0 if the command line option was not recognized. By returning an error code a calling script has the possibility to distinguish between a real success and an invalid invocation. We need to return -1 instead of EXIT_FAILURE to be consistent with the other exit code places. Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-05-31mkfs.ubifs: Add support for symlinks in device tableDavid Engraf
It is not possible to change ownership for symlinks in the device table file. This patch adds support for symlinks equal to mkfs.jffs2 and updates the sample device table file. The permission entry for symlinks in the device table must be set to 0777. Signed-off-by: David Engraf <david.engraf@sysgo.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-02Fix alignment trap triggered by NEON instructionsYuanjie Huang
NEON instruction VLD1.64 was used to copy 64 bits data after type casting, and they will trigger alignment trap. This patch uses memcpy to avoid alignment problem. Signed-off-by: Yuanjie Huang <Yuanjie.Huang@windriver.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Change build system to autotoolsRichard Weinberger
This patch is largely based on Richards original RFC. The major differences to the RFC patch are: - Add missing sumtools & mtdpart targets - Fix name of mkfs.jffs2 target - Add missing subdir-objects option for non-recursive make - Move all automake options to configure.ac - Add manpages to install target - Make XATTR & LZO support configurable - Install binaries to sbin directory like in the old build system - Install flash_erase wrapper script - Add files missing from distribution target Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17Remove duplicate copies of GPLv2 license textDavid Oberhollenzer
Some of the programs in the mtd-utils used to be seperate packages that were at some point merged into mtd-utils. As a result, some subdirectories contain their own README and COPYING files with copies of the GPLv2 license text. Since those programs are now part of mtd-utils that contains a copy of the GPLv2 in the file COPYING in the package root directory, those extra files can be removed, as there is no need for distributing an extra copy of the license text for each individual program in the bundle. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-01-24mkfs.ubifs: <sys/xattr.h>, not <attr/xattr.h>Brian Norris
To be consistent with mkfs.jffs2, and to get this to build on my machine, it looks like we should use <sys/xattr.h>, not <attr/xattr.h>. Fixes this error, seen on an Ubuntu 14.04 build system: ubifs-utils/mkfs.ubifs/mkfs.ubifs.c:30:24: fatal error: attr/xattr.h: No such file or directory #include <attr/xattr.h> ^ Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Reviewed-by: Richard Weinberger <richard@nod.at>
2015-12-09mkfs.ubifs: use gid from table instead 2x uidSebastian Andrzej Siewior
If the devtable is used then the tool uses uid twice and doesn't consider gid at all. This changes it to use gid & uid. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12mkfs.ubifs: fix compiler warning for WITHOUT_LZODaniel Walter
Fix compiler warning about an unused variable. ubifs-utils/mkfs.ubifs/compr.c:41:27: warning: ā€˜cā€™ defined but not used [-Wunused-variable] static struct ubifs_info *c = &info_; Signed-off-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12fix build when WITHOUT_LZO is setRolf Eike Beer
Make mkfs.ubifs honor the WITHOUT_LZO flag, too. Fixes this build error: mkfs.ubifs/compr.c:27:23: lzo/lzo1x.h: No such file or directory mkfs.ubifs/compr.c: In function `lzo_compress': mkfs.ubifs/compr.c:92: error: `lzo_uint' undeclared (first use in this function) mkfs.ubifs/compr.c:92: error: (Each undeclared identifier is reported only once mkfs.ubifs/compr.c:92: error: for each function it appears in.) mkfs.ubifs/compr.c:92: error: syntax error before "len" mkfs.ubifs/compr.c:95: error: `len' undeclared (first use in this function) mkfs.ubifs/compr.c:96: warning: implicit declaration of function `lzo1x_999_compress' mkfs.ubifs/compr.c:99: error: `LZO_E_OK' undeclared (first use in this function) mkfs.ubifs/compr.c: In function `init_compression': mkfs.ubifs/compr.c:201: error: `LZO1X_999_MEM_COMPRESS' undeclared (first use in this function) Signed-off-by: Rolf Eike Beer <eb@emlix.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: Optionally create extended attribute with inode numberSascha Hauer
This is done to allow creating images suitable for IMA directory appraisal. IMA creates a hash for directories and attaches this hash to the directory itself as an extended attribute. Among other things the inode numbers of the files are hashed. So, to create a valid hash in the UBIFS image the evmctl tool needs to know the inode numbers which the files in the UBIFS image will have. evmctl will read the inode numbers from the user.image-inode-number extended attribute. Since extended attributes are inodes themselves the inode numbers for the generated image will change when the extended attributes change, so to generate a correctly hashed UBIFS image, both evmctl and mkfs.ubifs must be run twice: 1) execute evmctl to iterate over the directory tree. This will create the security.ima and security.evm extended attributes. The existence of the attributes makes sure that subsequent calls to mkfs.ubifs will use the same inode numbers. evmctl will use the inode numbers from the host filesystem in this step which makes the resulting image unusable 2) execute mkfs.ubifs -a. This will create the user.image-inode-number extended attributes on files/directories added to the image. 3) execture evmctl again. This time evmctl will pick the inode numbers from the user.image-inode-number extended attribute instead of the ones from the host filesystem 4) execute mkfs.ubifs again. This will create the correct image. The now existing user.image-inode-number extended attributes are ignored and not added to the image. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: Add extended attribute supportSascha Hauer
This adds extended attribute support to mkfs.ubifs. When creating an image from a directory tree the existing extended attributes are added to the UBIFS image. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: simplify make_path with xasprintfSascha Hauer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: use xmalloc/xzalloc for allocating memorySascha Hauer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: change add_directory argument to 'existing'Sascha Hauer
A 'non_existing' argument which is only used with !non_existing is just too confusing. Change this to positive logic. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-11mtd-utils: Restructure the mtd-utils source.Dongsheng Yang
* There is no code modification in this commit, only moving * the files to proper place. The user tools looks a little messy as we place almost the all tools in the root directory of mtd-utils. To make it more clear, I propose to introduce the following structure for our source code. mtd-utils/ |-- lib |-- include |-- misc-utils |-- jffsX-utils |-- nand-utils |-- nor-utils |-- ubi-utils |-- ubifs-utils `-- tests Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>