aboutsummaryrefslogtreecommitdiff
path: root/mkfs.ubifs/mkfs.ubifs.c
AgeCommit message (Collapse)Author
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>
2014-10-20mkfs.ubifs: start using common codeArtem Bityutskiy
Several commonly used macros are now defined in 'common.h', let's start using them in mkfs.ubifs, instead of duplicating them. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-03-31mkfs.ubifs: correct and improve LEB size error printsBrian Norris
The error message is incorrect for "too small LEB size" -- we were printing the minimum I/O size instead of the LEB size. At the same time, let's print the max LEB size along with the message for "too large LEB size", to be consistent and more helpful. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01use xstrdup in a few more placesMike Frysinger
These call sites either assume there is no failure (they deref the pointer right away), or the exit themselves. Use xstrdup() instead. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01mkfs.ubifs: allow reformatting of devicesMike Frysinger
Sometimes I want to re-initialize an existing ubifs, but the tool currently bails out if the volume is already formatted. Prompt the user instead so they can decide. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-10-26mkfs.ubifs: Improve error handling of is_contained()Marcus Prebble
The is_contained() function returns -1 if an error occurs when canonicalizing the output file path/root directory. This resulted in the confusing error message 'Error: The output file cannot be in the UBIFS root' when specifying a non-existent directory for the output. This patch changes the error handling to display a different error message for the case when is_contained() returns -1. Additionally it frees all memory allocated by is_contained(). Signed-off-by: Marcus Prebble <marcus.prebble@axis.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-10-11mkfs.ubifs: rewrite path checkingArtem Bityutskiy
We use the 'in_path()' function to check whether the output image is withing the mkfs.ubifs root directory or not. However, this function is not correct and it fails for the following situation, as Marcus Prebble <marcus.prebble@axis.com> reports: 1. We have our root file-system mounted at / and want to build an image out of it. 2. We have tmpfs mounted at /tmp 3. We mount the root file-system under /tmp/newroot 4. We run mkfs.ubifs with -r /tmp/newroot -o /tmp/image And this fails. It fails because 'in_path()' misses this use-case. This patch re-implements the check completely. Now we use 'realpath()' to find canonical paths and just check that the output file is not under the root mkfs.ubifs directory. Reported-by: Marcus Prebble <marcus.prebble@axis.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Tested-by: Marcus Prebble <marcus.prebble@axis.com>
2012-09-25consistency between u_int32_t / off_t / off64_tRichard Genoud
We should use the off_t type instead of off64_t or u_int32_t as its length is controlled by the WITHOUT_LARGEFILE flag. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-22UBI: sync ubi-user.h with kernel v3.6-rc1Richard Genoud
Also remove the eraseblock type support, because kernel commit a65a0eb6d198e058687a9214683bd1c418f20d39 set the dtype parameter as obsolete. Also adjust to some renames: * 'UBI_PROP_DIRECT_WRITE' -> 'UBI_VOL_PROP_DIRECT_WRITE' * 'struct ubi_set_prop_req' -> 'struct ubi_set_vol_prop_req'. * 'UBI_IOCSETPROP' -> 'UBI_IOCSETVOLPROP' Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-03-07mkfs.ubifs: do not ignore --max-leb-cnt when formatting an UBI volumeArtem Bityutskiy
When the output file is an UBI volume - mkfs.ubifs just sets --max-leb-cnt to the volume size and ignores the user-supplied --max-leb-cnt value, which is wrong. Let's set it to the volume size only if the user did not supply --max-leb-cnt. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2011-08-20mkfs.ubifs/ubinize: increase PEB size limit to 2MiBViktar Palstsiuk
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-07-04mkfs.ubifs: fix a gcc warningArtem Bityutskiy
This patch "fixes" the following gcc warning: mkfs.ubifs/mkfs.ubifs.c: In function ‘main’: mkfs.ubifs/ubifs.h:420:2: warning: ‘child_cnt’ may be used uninitialized in this function [-Wuninitialized] mkfs.ubifs/mkfs.ubifs.c:1735:6: note: ‘child_cnt’ was declared here by initializing the ‘child_cnt’ to zero. Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-07-04mkfs.ubifs: remove root inode squash featureArtem Bityutskiy
Remove the -squash-rino-perm mkfs.ubifs option as this was planned. Remove the corresponding record from the feature-removal-schedule.txt file. Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-29mtd-utils: switch more utils to unified versioningBrian Norris
More utilities now use the common VERSION system. For utils that printed a very simple message, we use the new common_print_version() "function." Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-29mkfs.ubifs: use common.hBrian Norris
To use more unified versioning and to re-use other existing code, switch to common.h. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-03mkfs.ubifs: trivial: 2.6.40 -> 3.0Ben Gardiner
In commit 04665066ebedb0a31335b525fb5f19df32cb8cfe it was noted that the free space fixup feature would be available in kernels 2.6.40 or greater. Since then it has been decided that the release following 2.6.39 will be 3.0. Replace the instances of 2.6.40 with 3.0. Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-05-20mkfs.ubifs: add "-F" option for "free-space fixup"Matthew L. Creech
This adds a superblock flag indicating that "free-space fixup" is needed, and allows it to be set by the user via the "-F" command-line option. The first time the filesystem is mounted, this flag will trigger a one-time re-mapping of all LEBs containing free space. This fixes problems seen on some NAND flashes when a non-UBIFS-aware flash programmer is used. Artem: add a bit more help text, tweaked the patch a bit. Thanks to Ben Gardiner <bengardiner@nanometrics.ca> for help. Signed-off-by: Matthew L. Creech <mlcreech@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-04-04mkfs.ubifs: check output firstAndy Shevchenko
Artem: this is jut a clean-up, no functional changes. Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-03-18mkfs.ubifs: deprecate squash-rino-perm optionsArtem Bityutskiy
As we have planned, make --nosquash-rino-perm option to be the default. Deprecate both options at the same time and print a warning if they are used. Later we can remove them Also, bump mkfs.ubifs version number. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-25mkfs.ubifs: Fix typo in short options of mkfs.ubifsVivenzio Pagliari
The short option for specifying the count of erase blocks for orphans '-p' was not detected due to a typo. Signed-off-by: Vivenzio Pagliari <vivenzio.pagliari@gmx.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-24mkfs.ubifs: Fix --squash-rino-perm / --nosquash-rino-permKevin Cernekee
This addresses a couple of issues: 1) Code was only allowing these options if --root was NOT specified (the opposite of the documented usage) 2) -q / -Q short options did not work 3) Spacing fixes in the error/warning strings Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-23mkfs.ubifs: Fix heap corruption on LEB overrunKevin Cernekee
If max_leb_cnt (-c option) is set too low, set_lprops() will corrupt the heap and may result in a scary looking crash: $ bin/mkfs.ubifs -U -r romfs -o ubifs.img -m 512 -e 15360 -c 39 Error: max_leb_cnt too low (241 needed) *** glibc detected *** bin/mkfs.ubifs: double free or corruption (!prev): 0x088fe070 *** ======= Backtrace: ========= /lib32/libc.so.6(+0x6c231)[0xf75fb231] /lib32/libc.so.6(+0x6dab8)[0xf75fcab8] /lib32/libc.so.6(cfree+0x6d)[0xf75ffb9d] bin/mkfs.ubifs[0x804e801] bin/mkfs.ubifs[0x804e94b] bin/mkfs.ubifs[0x804e99d] /lib32/libc.so.6(__libc_start_main+0xe6)[0xf75a5bd6] bin/mkfs.ubifs(__fxstat64+0x55)[0x80491e1] ======= Memory map: ======== 08048000-0805d000 r-xp 00000000 08:08 10012045 /work/bin/mkfs.ubifs 0805d000-0805e000 rwxp 00015000 08:08 10012045 /work/bin/mkfs.ubifs 088fe000-08945000 rwxp 00000000 00:00 0 [heap] f73e1000-f73fe000 r-xp 00000000 08:05 2228842 /usr/lib32/libgcc_s.so.1 f73fe000-f73ff000 r-xp 0001c000 08:05 2228842 /usr/lib32/libgcc_s.so.1 f73ff000-f7400000 rwxp 0001d000 08:05 2228842 /usr/lib32/libgcc_s.so.1 f7400000-f7421000 rwxp 00000000 00:00 0 f7421000-f7500000 ---p 00000000 00:00 0 f751c000-f758f000 rwxp 00000000 00:00 0 f758f000-f76e2000 r-xp 00000000 08:05 426288 /lib32/libc-2.11.1.so f76e2000-f76e3000 ---p 00153000 08:05 426288 /lib32/libc-2.11.1.so f76e3000-f76e5000 r-xp 00153000 08:05 426288 /lib32/libc-2.11.1.so f76e5000-f76e6000 rwxp 00155000 08:05 426288 /lib32/libc-2.11.1.so f76e6000-f76e9000 rwxp 00000000 00:00 0 f76e9000-f770d000 r-xp 00000000 08:05 426296 /lib32/libm-2.11.1.so f770d000-f770e000 r-xp 00023000 08:05 426296 /lib32/libm-2.11.1.so f770e000-f770f000 rwxp 00024000 08:05 426296 /lib32/libm-2.11.1.so f772a000-f772c000 rwxp 00000000 00:00 0 f772c000-f772d000 r-xp 00000000 00:00 0 [vdso] f772d000-f7749000 r-xp 00000000 08:05 6062081 /lib32/ld-2.11.1.so f7749000-f774a000 r-xp 0001b000 08:05 6062081 /lib32/ld-2.11.1.so f774a000-f774b000 rwxp 0001c000 08:05 6062081 /lib32/ld-2.11.1.so ffb58000-ffb6d000 rwxp 00000000 00:00 0 [stack] Aborted New code aborts cleanly, and still calculates the number of LEBs required: $ bin/mkfs.ubifs -U -r romfs -o tmp/ubifs.img -m 512 -e 15360 -c 39 Error: max_leb_cnt too low (241 needed) $ echo $? 255 $ bin/mkfs.ubifs -U -r romfs -o tmp/ubifs.img -m 512 -e 15360 -c 240 Error: max_leb_cnt too low (241 needed) $ bin/mkfs.ubifs -U -r romfs -o tmp/ubifs.img -m 512 -e 15360 -c 241 $ Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-23mkfs.ubifs: do not override root inode permissionsArtem Bityutskiy
When mkfs.ubifs is used with -r dir, it does not make the root UBIFS inode uid/gid/permissions to be equivalent to dir's permissions, but it makes root inode permissions to be equivalent to uid = git = 0 (root) and permissions = u+rwx go+rx. Unfortunately, we cannot simply fix this bug, because mkfs.ubifs is already used in production. Thus, we have introduce --squash-rino-perm option which is the default and it preserves the old mkfs.ubifs behavior. We also introduce --nosquash-rino-perm option which fixes mkfs.ubifs behavior. If none of these options is used, we print a warning. The plan is to make everyone use one of these options, then make --nosquash-rino-perm to be the default and remove the warning, and then eventually deprecate and remove both options. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-01rename crc32 to mtd_crc32Artem Bityutskiy
Because of namespace collisions mkfs.ubifs uses crc32() implementation from /lib/libz.so.1, which generates incompatible CRC and later on the kernel reports many CRC errors. Fix this by re-naming mtd-utils' crc32 function to mtd_crc32. Reported-by: Jon Povey <Jon.Povey@racelogic.co.uk> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-17mkfs.ubifs: fix compilation warningArtem Bityutskiy
Fix the following warning: mkfs.ubifs.c: In function ‘add_dent_node’: mkfs.ubifs.c:1172: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘ino_t’ mkfs.ubifs.c:1172: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 6 has type ‘ino_t’ Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-13mtd-utils: move libmtd source files to lib/ subdirectoryKevin Cernekee
Source files for libmtd, crc32, and fec are scattered throughout the tree. Move them to a central location so they can be built into a common "libmtd.a" library used by all mtd-utils programs. This patch only renames/deletes files and does not change the content. Also modify the build system and source code so that libmtd.a can be built from a "common" location (lib/). Statically link all utilities at the top level with libmtd.a . Minor changes to mkfs.ubifs to allow using the common crc32 implementation. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-06-05mkfs.ubifs: inclreas version to 1.3Artem Bityutskiy
... because of the previous serious bug-fix. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-06-05mkfs.ubifs: fix brown paper-bag bugArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-05-27mkfs.ubifs: use libubi to format UBI volumeCorentin Chary
libubi is now used to format directly UBI volume. Typing mkfs.ubifs /dev/ubi0_0 is now possible. dtypes should be ok as they are taken from UBIFS code. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-05-25mkfs.ubifs: remove duplicated codeCorentin Chary
ino->uid = cpu_to_le32(st->st_uid); ino->gid = cpu_to_le32(st->st_gid); was present twice. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-05-11mkfs.ubifs: fix -U option handlingKevin Cernekee
The long form (--squash-uids) is correct, but the short form (-U) is not. Signed-off-by: Kevin Cernekee <kpc.mtd@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-02-12mkfs.ubifs: eliminate compiler warningsAdrian Hunter
The warnings were: lpt.c: In function ‘create_lpt’: lpt.c:552: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long long int’ mkfs.ubifs.c: In function ‘do_openat’: mkfs.ubifs.c:251: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result mkfs.ubifs.c: In function ‘get_options’: mkfs.ubifs.c:542: warning: format not a string literal and no format arguments Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-01-28mkfs.ubifs: update program version to 1.2Artem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-01-28mkfs.ubifs: support reserved space allocationArtem Bityutskiy
UBIFS may reserve some amount of flash space for the super-user, ant this amount is stored in the superblock. Currently mkfs.ubifs always puts 0 there. This patch adds -R option which may be used to specify size of the reserved space. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2009-01-16mkfs.ubifs: fix various warningsArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-12-09mkfs.ubifs: fix "smal" typoMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-10-23mkfs.ubifs: make program version 1.1.Artem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-10-22Fix favor LZO implementationArtem Bityutskiy
Use c->favor_percent, not c->favor_lzo. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-10-22Introduce favor_lzo compressor optionsArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-10-22Make "c" globalArtem Bityutskiy
We need to have access to "c" from various files. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-10-22Define the worst case compression constantArtem Bityutskiy
It will be used in the next patches. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-10-22UBIFS: rename crc32 functionArtem Bityutskiy
Zlib headers also declare crc32 symbol and it confilicts with our crc32 fuction. So rename it. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-09-07mkfs.ubifs: amend help printArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-09-05mkfs.ubifs: check max_leb_countArtem Bityutskiy
Complain and exit if max. count of LEBs was not specified. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-08-19mkfs.ubifs: set program version as 1.0Artem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-08-19Add mkfs.ubifsArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>