]> www.infradead.org Git - mtd-utils.git/log
mtd-utils.git
14 years agofs-tests: integck: do not assume the FS is mounted after failure
Artem Bityutskiy [Thu, 21 Apr 2011 05:13:21 +0000 (08:13 +0300)]
fs-tests: integck: do not assume the FS is mounted after failure

If a power cut emulation error happens and we are trying to re-mount
the file-system, do not assume it is mounted because the failure could
have happened after it had had been unmounted but before it was
successfully mounted.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: add recovery remounting function
Artem Bityutskiy [Wed, 20 Apr 2011 14:25:01 +0000 (17:25 +0300)]
fs-tests: integck: add recovery remounting function

When re-mountig to recover from the emulated power-cut failure then we should
do a bit less fancy things, e.g., we should not try to re-mount to R/O and R/W
modes forth and back, but we should instead just unmount directly.

Additionally, we should not die if mount fails because there may be a power
cut emulation during mounting. Thus, create a separate function for recovering
and try to recover in a loop.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: simplify dirent manipulation
Artem Bityutskiy [Wed, 20 Apr 2011 13:32:16 +0000 (16:32 +0300)]
fs-tests: integck: simplify dirent manipulation

Teach 'add_dir_entry()' to allocate the file/dir/symlink object for
the client. This simplifies client's code. The only place where we
do not want to do this is when we are creating a hardling pointing
to an existing file.

Teach 'remove_dir_entry()' to free the file/dir/symlink object for
the client. Similarly, this simplifies client's code. The only place
where we do not want to do this is the rename function - when we
rename an object we want to only change its direntry, but not the
object itself.

But the main motivation for this change is not just to clean-up, but
to fix another memory leak. In the re-name function we free the
'rename_entry', but we did not free the corresponding object. This
patch fixes the situation.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not forget to free mount_opts
Artem Bityutskiy [Wed, 20 Apr 2011 13:14:12 +0000 (16:14 +0300)]
fs-tests: integck: do not forget to free mount_opts

The test forgets to free the args.mount_opts string on exit - fix this.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: iterate for ever in case of power cut testing
Artem Bityutskiy [Wed, 20 Apr 2011 13:08:30 +0000 (16:08 +0300)]
fs-tests: integck: iterate for ever in case of power cut testing

If the test runs in power-cut testing mode, do not exit in case of
EROFS error - but instead re-mount and start again.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: refuse R/O file-system
Artem Bityutskiy [Wed, 20 Apr 2011 13:01:05 +0000 (16:01 +0300)]
fs-tests: integck: refuse R/O file-system

Refuse to test the file-system if it is mounted Read-only.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: free all allocated memory on exit
Artem Bityutskiy [Wed, 20 Apr 2011 11:32:53 +0000 (14:32 +0300)]
fs-tests: integck: free all allocated memory on exit

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: assume that the parent is present in new_dir
Artem Bityutskiy [Wed, 20 Apr 2011 09:54:12 +0000 (12:54 +0300)]
fs-tests: integck: assume that the parent is present in new_dir

We always pass non-NULL 'parent' argument to 'new_dir()', so no need to
test it for NULL.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: lessen memory consumption even more
Artem Bityutskiy [Wed, 20 Apr 2011 08:44:49 +0000 (11:44 +0300)]
fs-tests: integck: lessen memory consumption even more

This patch kills the "name" field from 'struct file_info' where we stored
the original file name. We do not really need to keep this name around,
becaus it might have long gone and it is not very interesting. Besides,
we have several memory leaks where we leak 'file->name' strings, so this
is the easiest way to fix those leaks as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: lessen memory consumption
Artem Bityutskiy [Wed, 20 Apr 2011 08:37:46 +0000 (11:37 +0300)]
fs-tests: integck: lessen memory consumption

We do not need to store directory name in the 'struct dir_info' objects,
because we already have it in 'struct dir_entry_info'. So we duplicate
the names for directories in 'dir->name' and 'dir->entry->name'.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: clean up add_dir_entry usage
Artem Bityutskiy [Mon, 18 Apr 2011 14:47:29 +0000 (17:47 +0300)]
fs-tests: integck: clean up add_dir_entry usage

Make 'add_dir_entry()' consistent and allocate name for all types,
not only for 'd' and 's'. Also, since 'add_dir_entry()' sets the
parent - do not do this in the calling functions.

This is a clean-up which makes 'add_dir_entry()' more consistent.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: remove symlinks memory leaks
Artem Bityutskiy [Mon, 18 Apr 2011 14:41:22 +0000 (17:41 +0300)]
fs-tests: integck: remove symlinks memory leaks

When we create a symlink we also allocate a symlink_info structure
and the target path name. But when we remove a symlink - we do not
delete that memory. This patch fixes the issue.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: free raw write information
Artem Bityutskiy [Mon, 18 Apr 2011 14:36:12 +0000 (17:36 +0300)]
fs-tests: integck: free raw write information

The test leaks memory like hell because it does not free the raw writes
information. This patch fixes the leaks.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: introduce free_writes_info helper
Artem Bityutskiy [Mon, 18 Apr 2011 14:29:22 +0000 (17:29 +0300)]
fs-tests: integck: introduce free_writes_info helper

We have duplicated code for freeing write informatio - put it into
a helper function.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: fix memory leak in dir_new
Artem Bityutskiy [Mon, 18 Apr 2011 12:53:06 +0000 (15:53 +0300)]
fs-tests: integck: fix memory leak in dir_new

Do not initialize dir->name because add_dir_entry already does
this for us, so we leak the memory.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: fix memory lead in dir_remove
Artem Bityutskiy [Mon, 18 Apr 2011 12:50:22 +0000 (15:50 +0300)]
fs-tests: integck: fix memory lead in dir_remove

When removing a directory and freeing corresponding 'dir_info' object -
do not forget to free directory name as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make file_truncate_file return error
Artem Bityutskiy [Mon, 18 Apr 2011 11:54:23 +0000 (14:54 +0300)]
fs-tests: integck: make file_truncate_file return error

Teach 'file_truncate_file()' return an error to the caller if it fails
to open the file or to truncate it.

Additionally, check the error code from 'open()' in other places.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make file_open return error on failure
Artem Bityutskiy [Mon, 18 Apr 2011 11:47:45 +0000 (14:47 +0300)]
fs-tests: integck: make file_open return error on failure

Make 'file_open()' return an error to the caller if it fails to open
the file.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make operate_on_entry handle all errors
Artem Bityutskiy [Mon, 18 Apr 2011 11:40:31 +0000 (14:40 +0300)]
fs-tests: integck: make operate_on_entry handle all errors

Make 'operate_on_entry()' handle handle errors from all functions
it calls and return the error code to the caller.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach file_unlink_file return an error
Artem Bityutskiy [Mon, 18 Apr 2011 11:33:07 +0000 (14:33 +0300)]
fs-tests: integck: teach file_unlink_file return an error

Teach 'file_unlink_file()' return an error to the caller if the
file cannot be unlinked.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach dir_remove return error and fix a memory leak
Artem Bityutskiy [Mon, 18 Apr 2011 11:28:44 +0000 (14:28 +0300)]
fs-tests: integck: teach dir_remove return error and fix a memory leak

Teach 'dir_remove()' to return an error to the caller if it fails to
remove the directory. Also, there was a memory leak - the 'path'
string was not freed - fix it as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach symlink_remove return error on removal failure
Artem Bityutskiy [Mon, 18 Apr 2011 11:06:40 +0000 (14:06 +0300)]
fs-tests: integck: teach symlink_remove return error on removal failure

When 'symlink_remove()' fails to unling a symlink - return an error to
the calling function.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make rename_entry return error on failure
Artem Bityutskiy [Mon, 18 Apr 2011 11:01:00 +0000 (14:01 +0300)]
fs-tests: integck: make rename_entry return error on failure

Make 'rename_entry()' return an error to the caller when it fails
to rename a directory entry.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make operate_on_dir propagate errors up
Artem Bityutskiy [Mon, 18 Apr 2011 10:53:14 +0000 (13:53 +0300)]
fs-tests: integck: make operate_on_dir propagate errors up

Make 'operate_on_dir()' functions propogate errors up if any of
the functions it calls failed. This patch also makes 'operate_on_entry()'
return an error code, but without actual implementation.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach link_new to return error on creation failure
Artem Bityutskiy [Mon, 18 Apr 2011 10:41:38 +0000 (13:41 +0300)]
fs-tests: integck: teach link_new to return error on creation failure

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach symlink_new to return error on creation failure
Artem Bityutskiy [Mon, 18 Apr 2011 10:38:17 +0000 (13:38 +0300)]
fs-tests: integck: teach symlink_new to return error on creation failure

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach dir_new return error on creation failure
Artem Bityutskiy [Mon, 18 Apr 2011 10:07:57 +0000 (13:07 +0300)]
fs-tests: integck: teach dir_new return error on creation failure

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make file_new return error on create failure
Artem Bityutskiy [Mon, 18 Apr 2011 09:48:50 +0000 (12:48 +0300)]
fs-tests: integck: make file_new return error on create failure

Teach 'file_new()' to return -1 if it fails to create a file.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: fix placeholders when printing
Artem Bityutskiy [Mon, 18 Apr 2011 09:04:59 +0000 (12:04 +0300)]
fs-tests: integck: fix placeholders when printing

There is a lot of code where %u is used for printing off_t variables,
which may be actually 64-bit wide. Fix this by using %llu.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: use unsigned int everywhere
Artem Bityutskiy [Mon, 18 Apr 2011 08:59:56 +0000 (11:59 +0300)]
fs-tests: integck: use unsigned int everywhere

The test sometimes uses "unsigned" and sometimes "unsigned int". This
patch makes the code more consistent by making it use "unsigned int"
everywhere.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: rename BUFFER_SIZE
Artem Bityutskiy [Mon, 18 Apr 2011 08:54:04 +0000 (11:54 +0300)]
fs-tests: integck: rename BUFFER_SIZE

Rename 'BUFFER_SIZE' constant into 'IO_BUFFER_SIZE' to reflect what
is the buffer this constant is about.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach file_write_data return an error
Artem Bityutskiy [Mon, 18 Apr 2011 08:49:39 +0000 (11:49 +0300)]
fs-tests: integck: teach file_write_data return an error

Make 'file_write_data()' return an error in case of failure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: handle errors in file_mmap_write
Artem Bityutskiy [Mon, 18 Apr 2011 07:05:19 +0000 (10:05 +0300)]
fs-tests: integck: handle errors in file_mmap_write

Teach 'file_mmap_write()' to propagate failures up to the caller.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: handle all failures in operate_on_open_file
Artem Bityutskiy [Mon, 18 Apr 2011 06:50:30 +0000 (09:50 +0300)]
fs-tests: integck: handle all failures in operate_on_open_file

Make 'operate_on_open_file()' to handle possible 'fsync()' and 'fdatasync()'
errors by returning -1 up to the caller.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: handle errors in file_delete
Artem Bityutskiy [Fri, 15 Apr 2011 13:49:15 +0000 (16:49 +0300)]
fs-tests: integck: handle errors in file_delete

Teach 'file_delete()' and several other functions it calls
(like 'file_unlink()) to handle write errors and propagate the
up to the caller.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: teach file_truncate return error code
Artem Bityutskiy [Thu, 14 Apr 2011 11:50:22 +0000 (14:50 +0300)]
fs-tests: integck: teach file_truncate return error code

Teach 'file_truncate()' return an error code in case of failure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make more functions propogate error up
Artem Bityutskiy [Thu, 14 Apr 2011 11:38:23 +0000 (14:38 +0300)]
fs-tests: integck: make more functions propogate error up

Teach 'operate_on_open_file()', 'operate_on_an_open_file()', and
'do_an_operation()' propogate errors up.

Also move whole 'operate_on_file()' to a more logical place.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: handle errors when creating test data
Artem Bityutskiy [Thu, 14 Apr 2011 11:27:18 +0000 (14:27 +0300)]
fs-tests: integck: handle errors when creating test data

Make 'update_test_data()' and 'update_test_data()' check for errors
and return error in case of failure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: handle errors in remount_tested_fs
Artem Bityutskiy [Thu, 14 Apr 2011 10:32:06 +0000 (13:32 +0300)]
fs-tests: integck: handle errors in remount_tested_fs

Teach 'remount_tested_fs()' return error code when it fails
to mount the file-system.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: handle write failures in dir_new
Artem Bityutskiy [Thu, 14 Apr 2011 10:12:48 +0000 (13:12 +0300)]
fs-tests: integck: handle write failures in dir_new

Do not die in 'dir_new()' if it cannot create a new directory and
this is not because of ENOSPC. Return NULL for all errors.

Note, not all callers are ready to properly handle all errors so far.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: check deletion errors in rm_minus_rf_dir
Artem Bityutskiy [Thu, 14 Apr 2011 09:42:39 +0000 (12:42 +0300)]
fs-tests: integck: check deletion errors in rm_minus_rf_dir

Modify the 'rm_minus_rf_dir()' function to return -1 in case of any
errors during deletions. Make 'integck()' handle the errors. Also
introduce a 'pcv()' function to print error message if -v command
line option was specified.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: introduce power cut testing arguments
Artem Bityutskiy [Thu, 14 Apr 2011 09:20:31 +0000 (12:20 +0300)]
fs-tests: integck: introduce power cut testing arguments

Introduce new command line arguments for power cut testing:
-p to enable the power cut testing mode and -v to be verbose
about the errors. The real functionality is not implemented
so far.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agoserve_image: missing comma
Brian Norris [Thu, 21 Apr 2011 17:09:12 +0000 (10:09 -0700)]
serve_image: missing comma

Somebody didn't compile-test commit 9f4e6840.

Artem: my fault, apologies.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agoserve_image: adjust classifier and type for printf
Andy Shevchenko [Wed, 20 Apr 2011 09:35:10 +0000 (12:35 +0300)]
serve_image: adjust classifier and type for printf

The argument type of printf is __off64_t, meanwhile the classifier is "%ld".
We agreed to use PRIu64 in such case.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agolibmtd: use PRIu64 classifier for uint64_t printf arguments
Andy Shevchenko [Wed, 20 Apr 2011 09:35:09 +0000 (12:35 +0300)]
libmtd: use PRIu64 classifier for uint64_t printf arguments

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agomkfs.jffs2: fix casting of __off64_t
Andy Shevchenko [Wed, 20 Apr 2011 09:35:08 +0000 (12:35 +0300)]
mkfs.jffs2: fix casting of __off64_t

The casting of __off64_t to unsigned long potentially wrong for values higher
than ULONG_MAX.  Let's fix that by using PRIu64 classifier.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not expect max name length to be 256
Artem Bityutskiy [Wed, 13 Apr 2011 14:21:05 +0000 (17:21 +0300)]
fs-tests: integck: do not expect max name length to be 256

The 'make_name()' function assumes that the maxumum file name length
is 256 bytes, which is wrong. This patch fixes this.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: implement own version of CHECK
Artem Bityutskiy [Wed, 13 Apr 2011 14:09:36 +0000 (17:09 +0300)]
fs-tests: integck: implement own version of CHECK

Remove the final dependency on the common code - the CHECK() macro.
Now we are finally independent. The reason we needed this is that
we are going to improve integck to handle errors more gracefully,
in order to support failure testing better. And this requires changes
in the common code, but it is ancient and shared by many tests, and
we do not want to touch it. So we better make integck independent
and concentrate on integck only.

This patch also removes Makefile dependencies. And while on it, remove
the broken 'tests' target.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use tests_random_no
Artem Bityutskiy [Wed, 13 Apr 2011 13:49:20 +0000 (16:49 +0300)]
fs-tests: integck: do not use tests_random_no

Do not use the shared 'tests_random_no()' function but use our own
simple implementation instead. We do not need those rather complex
and difficult to understand computations.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use global common variables
Artem Bityutskiy [Wed, 13 Apr 2011 13:28:06 +0000 (16:28 +0300)]
fs-tests: integck: do not use global common variables

Do not use the 'tests_file_system_mount_dir' and 'tests_file_system_type'
variables because we do not depend on them any longer.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use tests_get_total_space
Artem Bityutskiy [Wed, 13 Apr 2011 13:25:28 +0000 (16:25 +0300)]
fs-tests: integck: do not use tests_get_total_space

Do not use the common tests_get_total_space but extend our own
get_free_space function and make it return both free and total
amount of space.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use tests_remount
Artem Bityutskiy [Wed, 13 Apr 2011 13:15:06 +0000 (16:15 +0300)]
fs-tests: integck: do not use tests_remount

Implement our own version of 'tests_remount()' instead of depending
on the common implementation.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use tests_fs_is_rootfs
Artem Bityutskiy [Wed, 13 Apr 2011 12:06:18 +0000 (15:06 +0300)]
fs-tests: integck: do not use tests_fs_is_rootfs

Do not use the shared 'tests_fs_is_rootfs()' function - introduce
'fsinfo.is_rootfs' flag and utilize it instead. This is another step
forward the goal to make integck independent of the common code.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: prefer to check for success
Artem Bityutskiy [Wed, 13 Apr 2011 11:27:34 +0000 (14:27 +0300)]
fs-tests: integck: prefer to check for success

Many of standard C libraries return 0 on success and -1 on failure.
Currently integck mostly checks for failure by comparing with -1, like:

CHECK(fsync(fd) != -1) /* Don't die if not failure */

but in some places the check is like

CHECK(fsync(fd) == 0) /* Don't die if success */

This patch harmonizes this an makes integck to use the second style
which seems to be more logical. Besides, the binary is smaller in
this case:

[dedekind@eru fs-tests (master)]$ size integrity/integck-old
   text    data     bss     dec     hex filename
  44677    1200   37408   83285   14555 integrity/integck
[dedekind@eru fs-tests (master)]$ size integrity/integck-new
   text    data     bss     dec     hex filename
  44661    1200   37408   83269   14545 integrity/integck

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use space after cast
Artem Bityutskiy [Wed, 13 Apr 2011 11:09:47 +0000 (14:09 +0300)]
fs-tests: integck: do not use space after cast

Since we are kernel people lets use the style we are accustomed
to - no space between the cast and the variable: (type)a, not (type) a.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use tests_clear_dir
Artem Bityutskiy [Tue, 12 Apr 2011 13:22:35 +0000 (16:22 +0300)]
fs-tests: integck: do not use tests_clear_dir

Do not use shared 'tests_clear_dir()' function which removes a directory
tree recursively, but instead use own implementation. This is because
I'm trying to make integck independend on the shared code because I
need this to do further improvements.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: clean up test directory creation
Artem Bityutskiy [Tue, 12 Apr 2011 12:15:53 +0000 (15:15 +0300)]
fs-tests: integck: clean up test directory creation

Move the test directory name to the fsinfo structure and do few
other cleanups while on it.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not use tests_cat_pid
Artem Bityutskiy [Tue, 12 Apr 2011 11:36:57 +0000 (14:36 +0300)]
fs-tests: integck: do not use tests_cat_pid

Do not use the shared 'tests_cat_pid' function but use a simple
sprintf instead. This is another step to make integck independent
of the common code.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: remove trailing backslashes from mount point
Artem Bityutskiy [Tue, 12 Apr 2011 11:29:08 +0000 (14:29 +0300)]
fs-tests: integck: remove trailing backslashes from mount point

The test is not working if the user specified mount point with a trailing
back-slash at the end. Note, this had not worked before my changes as well.
Fix this.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: move log10_initial_free to fsinfo
Artem Bityutskiy [Tue, 12 Apr 2011 11:03:09 +0000 (14:03 +0300)]
fs-tests: integck: move log10_initial_free to fsinfo

Similarly to the previous patches, move the log10_initial_free variable
to the fsinfo data structure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: add own get_free_space function
Artem Bityutskiy [Tue, 12 Apr 2011 09:25:32 +0000 (12:25 +0300)]
fs-tests: integck: add own get_free_space function

Do not use the shared 'tests_get_free_space' function but use own
implementation instead. This is another step to make integck independent
on the common infrastructure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: move more variables to fsinfo
Artem Bityutskiy [Tue, 12 Apr 2011 09:10:58 +0000 (12:10 +0300)]
fs-tests: integck: move more variables to fsinfo

Aggregate all the information about the tested file-system in
the fsinf object for better readability and cleanness. Move
'can_mmap' and 'check_nospc_files' there as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: move mem_page_size to fsinfo
Artem Bityutskiy [Tue, 12 Apr 2011 09:00:22 +0000 (12:00 +0300)]
fs-tests: integck: move mem_page_size to fsinfo

The fsinfo structure will aggregate all the information about the
tested file-system. Move 'mem_page_size' which we use for 'mmap()'
there as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: make integck function return error
Artem Bityutskiy [Tue, 12 Apr 2011 08:46:20 +0000 (11:46 +0300)]
fs-tests: integck: make integck function return error

Turn the 'void integck(void)' function into 'static int integck(void)'.
We need to teach the test to gracefully handle some error cases like
'EROFS' instead of failing and exiting straight away. And the ground
work for this is making all functions return errors. This is the first
tiny step in this direction.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: get rid of tests_check_test_file_system
Artem Bityutskiy [Mon, 11 Apr 2011 16:14:06 +0000 (19:14 +0300)]
fs-tests: integck: get rid of tests_check_test_file_system

Stop using the shared 'tests_check_test_file_system()' function but
instead, use own independed version of this function. This is another
step forward the goal to make integck independent of the common
shared code.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: clean-up copy_string
Artem Bityutskiy [Mon, 11 Apr 2011 15:30:57 +0000 (18:30 +0300)]
fs-tests: integck: clean-up copy_string

This is a clean-up patch which:
1. Simplifies copy_string by useng strdup instead of malloc
2. Adds an assertion which checks the input parameter agains NULL,
   instead of checking it.
3. Re-names it to dup_string which looks more readable to me.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: implement own parameters parsing
Artem Bityutskiy [Fri, 8 Apr 2011 16:02:04 +0000 (19:02 +0300)]
fs-tests: integck: implement own parameters parsing

Instead of using shared command line arguments parsing routine
implement own. The reason is that I want to add more parameters,
which are integck-specific. Also, longer-term plan is to make
integck independent of the common tests.c file.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: change tests defaults
Artem Bityutskiy [Mon, 11 Apr 2011 13:57:53 +0000 (16:57 +0300)]
fs-tests: integck: change tests defaults

Currently integck assumes that by default the file-system cannot
do shared writable mmap-ing and does not preserve accurate file
size after ENOSPC errors. And then it overrides these default
settings if this is UBIFS.

But it seems that only JFFS2 has those limitations. So make the
defaults to be the opposite and override them for JFFS2 only.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: shrink write_info even more
Artem Bityutskiy [Mon, 11 Apr 2011 11:55:49 +0000 (14:55 +0300)]
fs-tests: integck: shrink write_info even more

The 'struct write_info' data strucutre records information about
truncation, and has a separate integer field to specify if this is
a truncation or not. But it is too wasteful because we have huge
amount of these objects.

But it is easy to notice that the 'random_seed' field is not used
for truncation records, so we can use that as the truncation flag.

This patch introduces MAX_RANDOM_SEED macro and when the 'random_seed'
field is greater than that, we treat it as the truncation flag.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: abuse random_offset field nicer
Artem Bityutskiy [Mon, 11 Apr 2011 11:27:46 +0000 (14:27 +0300)]
fs-tests: integck: abuse random_offset field nicer

Currently integck uses the 'random_offset' filed to store the new file
length sometimes, thus abusing this field. But we can do this nicer -
introduce an anonymous union and add 'new_length' filed which will be
used instead of 'random_offset' to make the code look nicer.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: srink file_info structure even more
Artem Bityutskiy [Mon, 11 Apr 2011 10:48:38 +0000 (13:48 +0300)]
fs-tests: integck: srink file_info structure even more

The 'check_run_no' field does not have to be 64-bit, it can be
32-bit instead and we can save 4 bytes per object. Actually, it
could also be 16-bit, and we could make link_count 16-bit as well,
but that would need a bit more work.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: shrink file_info structure size
Artem Bityutskiy [Mon, 11 Apr 2011 10:07:26 +0000 (13:07 +0300)]
fs-tests: integck: shrink file_info structure size

We do not have to store boolean flags in 'int' variables which
consume 4 bytes each, we can store those in bit-fields instead.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: shrink dir_entry_info structure size
Artem Bityutskiy [Mon, 11 Apr 2011 08:22:48 +0000 (11:22 +0300)]
fs-tests: integck: shrink dir_entry_info structure size

Turn "int checked" flag into 'char' flag to lessen memory
consumption a bit. Indeed, the test allocates a lot of these
data objects, so the size decrease from 36 to 32 bytes on
32-bit platforms is good to have.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: ubi-tests: clean libubi.a and *.o
Andy Shevchenko [Wed, 13 Apr 2011 13:20:29 +0000 (16:20 +0300)]
tests: ubi-tests: clean libubi.a and *.o

The common.mk contains clean target that removes *.o and $(TARGETS). Thus, make
custom clean target only for libubi.a

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: checkfs: adjust Makefile
Andy Shevchenko [Wed, 13 Apr 2011 13:20:28 +0000 (16:20 +0300)]
tests: checkfs: adjust Makefile

This patch brings common Makefile (in terms of mtd-utils project) to the
checkfs test suite. Additionally it fixes a build error related to usage of
open().

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: fs-tests: read() returns ssize_t value
Andy Shevchenko [Wed, 13 Apr 2011 13:20:27 +0000 (16:20 +0300)]
tests: fs-tests: read() returns ssize_t value

Use ssize_t instead of size_t.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agomkfs.jffs2: fix casting of printf argument
Andy Shevchenko [Wed, 13 Apr 2011 13:20:25 +0000 (16:20 +0300)]
mkfs.jffs2: fix casting of printf argument

The compiler warns us about cast mismatch for %9lu specifier.  In original code
the argument has __off64_t type. Here is a simple type casting fix.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: use common printing macros
Artem Bityutskiy [Fri, 8 Apr 2011 13:25:51 +0000 (16:25 +0300)]
fs-tests: integck: use common printing macros

Instead of using printf() directly, use the shared mtd-utils printing
macros.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: include the common mtd-utils header
Artem Bityutskiy [Fri, 8 Apr 2011 12:27:03 +0000 (15:27 +0300)]
fs-tests: integck: include the common mtd-utils header

Include the commong mtd-utils "common.h" header in integck test to
make it possible to use shared macros.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: remove unnecessary check
Artem Bityutskiy [Mon, 28 Mar 2011 12:05:18 +0000 (15:05 +0300)]
fs-tests: integck: remove unnecessary check

The 'link_new()' function has only one user, and the user checks
that the third 'file' argument is non NULL, so remove this check
from 'link_new()'. Let's be consistent and assume the 3rd argument
is never NULL, just like the first and the second ones.

This is just a minor improvement.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: simplify dir_entry_info fields
Artem Bityutskiy [Mon, 28 Mar 2011 11:04:10 +0000 (14:04 +0300)]
fs-tests: integck: simplify dir_entry_info fields

Instead of using named union 'entry' in 'struct dir_entry_info'
and having to type long 'entry->entry.file', 'entry->entry.symlink',
etc, use anonymous union which makes the syntax simpler: 'entry->file',
'entry->symlink', etc.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: do not cast void pointers
Artem Bityutskiy [Mon, 28 Mar 2011 10:24:57 +0000 (13:24 +0300)]
fs-tests: integck: do not cast void pointers

The malloc function returns 'void *', so it is not necessary to
cast it when assigning. This is just a small clean-up patch.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: integck: introduce zalloc
Artem Bityutskiy [Mon, 28 Mar 2011 10:22:26 +0000 (13:22 +0300)]
fs-tests: integck: introduce zalloc

The integck test often allocates memory and fills it with zeroes.
Introduce a helper function for this frequent operation.

This is just a clean-up patch which makes the code 23 lines shorter.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agomtd-utils: switch ubi and ubifs tools to use common strtoX funcs
Artem Bityutskiy [Fri, 8 Apr 2011 14:58:55 +0000 (17:58 +0300)]
mtd-utils: switch ubi and ubifs tools to use common strtoX funcs

Instead of using strtol and Co directly, use our share simple_strtoX()
helpers. This is just a cleanup.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agomtd-utils: improve simple_strtoX usage commentary
Artem Bityutskiy [Fri, 8 Apr 2011 15:05:10 +0000 (18:05 +0300)]
mtd-utils: improve simple_strtoX usage commentary

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs_tests: make the test-suite finish faster
Artem Bityutskiy [Fri, 8 Apr 2011 14:09:45 +0000 (17:09 +0300)]
fs_tests: make the test-suite finish faster

Currently the stress tests may run up to 1 hour, make the limit
to be 6 minutes instead.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agomtd-utils: Makefile: introduce cscope target
Artem Bityutskiy [Fri, 8 Apr 2011 12:09:43 +0000 (15:09 +0300)]
mtd-utils: Makefile: introduce cscope target

Add a "cscope" target to make it easier to develop in the repository.
Indeed, many people like me are accustomed to "make cscope" in the
kernel, and it is very convenient to have this in mtd-utils as well.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agoMakefile: introduce new target tests in Makefile
Andy Shevchenko [Thu, 7 Apr 2011 13:10:38 +0000 (16:10 +0300)]
Makefile: introduce new target tests in Makefile

This patch appends Makefile to the tests subdirectory and introduces tests
target in the root Makefile.

Additionally the clean target removes temporary stuff under tests subdirectory
as well.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: jittertest: fix set of compiler warnings
Andy Shevchenko [Tue, 5 Apr 2011 14:32:29 +0000 (17:32 +0300)]
tests: jittertest: fix set of compiler warnings

- time() was used without prototype.
- the return value of read() and write() wasn't checked
- classificator in printf() was wrong for argument of size_t type

Don't continue to read the /proc/profile in case when write was failed.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: ubi-tests: seed_random_generator() was used w/o prototype
Andy Shevchenko [Tue, 5 Apr 2011 13:55:54 +0000 (16:55 +0300)]
tests: ubi-tests: seed_random_generator() was used w/o prototype

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: fs-tests: check return value of functions
Andy Shevchenko [Tue, 5 Apr 2011 13:55:52 +0000 (16:55 +0300)]
tests: fs-tests: check return value of functions

chdir() returns negative value in case of error.
fscanf() returns amount of successfully parsed parameters.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: checkfs: fix linker warnings
Andy Shevchenko [Tue, 5 Apr 2011 13:55:51 +0000 (16:55 +0300)]
tests: checkfs: fix linker warnings

The sys_errlist[errno] is deprecated. We should use strerror(errno) instead.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: checkfs: fix compiler warnings
Andy Shevchenko [Tue, 5 Apr 2011 13:55:50 +0000 (16:55 +0300)]
tests: checkfs: fix compiler warnings

There are two warnings:
 - strlen() is used without prototype
 - argument of printf() is unsigned long, but used specifier is for int

This patch fixes them.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agotests: make jittertest buildable
Andy Shevchenko [Tue, 5 Apr 2011 11:33:08 +0000 (14:33 +0300)]
tests: make jittertest buildable

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agomkfs.ubifs: check output first
Andy Shevchenko [Mon, 4 Apr 2011 08:21:15 +0000 (11:21 +0300)]
mkfs.ubifs: check output first

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>
14 years agolibmtd: fix OOB read and write interface v1.4.4
Artem Bityutskiy [Fri, 1 Apr 2011 08:11:15 +0000 (11:11 +0300)]
libmtd: fix OOB read and write interface

When reading and writing OOB we specify the address as absolute
offset from the beginning of the MTD device. This offset is
basically an absolute page offset plus the OOB offset. And it does
not have to be aligned to the min. I/O unit size (NAND page size).

So fix the 'do_oob_op()' function and remove incorrect checking
that the offset is page-aligned. This check leads to the following
errors:

libmtd: error!: unaligned address 2, mtd0 page size is 2048

But obviously, the intent was to write to offset 2 of the OOB area
of the very first NAND page.

Instead of that incorrect check, we should check that the OOB offset
we write to is within the OOB size and the length is withing the OOB
size. This patch adds such check.

Reported-by: Kelly Anderson <kelly@silka.with-linux.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tested-by: Kelly Anderson <kelly@silka.with-linux.com>
14 years agofs-tests: integck: improve re-mounting test coverage
Artem Bityutskiy [Thu, 24 Mar 2011 13:43:35 +0000 (15:43 +0200)]
fs-tests: integck: improve re-mounting test coverage

The integck tests re-mounts the file-system from time to time
and checks the integrity afterwords. And it re-mounts always
the same-way: unmount and then mount R/W back. However, it is
better to do it differently some times, e.g.:

* re-mount R/O then re-mount R/W
* unmount then mount R/W
* both of the above
* unmount, mount R/O, then re-mount R/W
* etc.

This will give better test coverage. This patch does exactly
that by improving the 'tests_remount()' function.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: perf: fix compilation warning
Artem Bityutskiy [Thu, 24 Mar 2011 11:32:44 +0000 (13:32 +0200)]
fs-tests: perf: fix compilation warning

Fix the following compilation warning:
perf.c: In function ‘perf’:
perf.c:144: warning: format ‘%lld’ expects type ‘long long int’, but argument 2 has type ‘int64_t’

by adding a (long long int) cast.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agofs-tests: test_1: fix compilation warnings
Artem Bityutskiy [Thu, 24 Mar 2011 08:19:21 +0000 (10:19 +0200)]
fs-tests: test_1: fix compilation warnings

Fix the following compilation warnings:
test_1.c: In function ‘test_1’:
test_1.c:67:4: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’
test_1.c:88:3: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’

The fix is to cast the argument with (unsigned long long).

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
14 years agonanddump: fail if -s parameter is unaligned
Artem Bityutskiy [Fri, 18 Mar 2011 11:38:02 +0000 (13:38 +0200)]
nanddump: fail if -s parameter is unaligned

Implement the feature which we planned long time ago - make nanddump
fail if the -s parameter is not NAND page-aligned. Also bump nanddump
version.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>