yaffs2.git
2 years agoFix sleep logic in background gc thread example
Charles Manning [Tue, 1 Jun 2021 23:28:43 +0000 (11:28 +1200)]
Fix sleep logic in background gc thread example

The logic to sleep longer was the wrong way around.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
2 years agoIndex the block state string list because the order was wrong.
Charles Manning [Tue, 25 May 2021 22:45:13 +0000 (10:45 +1200)]
Index the block state string list because the order was wrong.

Thanks to Cory Wiltshire for pointing out the problem and proposing
a fix.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
2 years agokernel Makefile won't work after moving cache handling into a separated file.
Luca (Wei) Chen [Tue, 25 May 2021 21:27:57 +0000 (09:27 +1200)]
kernel Makefile won't work after moving cache handling into a separated file.

Signed-off-by: Luca (Wei) Chen <wei@cvluca.com>
2 years agoyaffs_guts.c : Fix missing temporary buffers when doing yaffs format on inband tags.
Charles Manning [Sat, 15 May 2021 00:33:36 +0000 (12:33 +1200)]
yaffs_guts.c : Fix missing temporary buffers when doing yaffs format on inband tags.

The low level init was not setting up temporary buffers. This was causing yaffs_format
to crash in the case of formating a device with inband tags.

Solution is to move the temporary buffer creation into low level init.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
2 years agoNew yaffs2_image_maker tool to work with 4kB pages - still under test
Charles Manning [Tue, 11 May 2021 04:32:26 +0000 (16:32 +1200)]
New yaffs2_image_maker tool to work with 4kB pages - still under test

This appears to be working but more testing required.

The tool now takes two new parameters for modifying the bytes per page
and pages per block.

For instance to create an inband tags image using 4kB virtual pages (ie. 32
virtual pages per block) try:

./yaffs2_image_maker -i test-dir2 -o outimage -w working_file -I -c 4096  -B 32

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoyaffs_image_maker: Add ability to handle oob tags and no tags ecc
Charles Manning [Fri, 26 Mar 2021 01:59:43 +0000 (14:59 +1300)]
yaffs_image_maker: Add ability to handle oob tags and no tags ecc

This still has some limits - it assumes 2k pages.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd a README for the image maker
Charles Manning [Thu, 18 Mar 2021 00:38:19 +0000 (13:38 +1300)]
Add a README for the image maker

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd endian feature to image maker and do some tidy up.
Charles Manning [Thu, 18 Mar 2021 00:24:54 +0000 (13:24 +1300)]
Add endian feature to image maker and do some tidy up.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd an image maker tool that generates image files for 2k page * 64 devices
Charles Manning [Wed, 17 Mar 2021 22:53:23 +0000 (11:53 +1300)]
Add an image maker tool that generates image files for 2k page * 64 devices

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoSome clean up and more modular cache management
Charles Manning [Tue, 16 Mar 2021 23:10:16 +0000 (12:10 +1300)]
Some clean up and more modular cache management

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd CONFIG_YAFFS_NO_YAFFS1 flag to remove yaffs1 code when not needed
Charles Manning [Thu, 9 Jul 2020 02:16:29 +0000 (14:16 +1200)]
Add CONFIG_YAFFS_NO_YAFFS1 flag to remove yaffs1 code when not needed

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoMove cache code to own file
Charles Manning [Thu, 9 Jul 2020 01:34:12 +0000 (13:34 +1200)]
Move cache code to own file

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoMove cache handling into its own file
Charles Manning [Thu, 9 Jul 2020 01:31:03 +0000 (13:31 +1200)]
Move cache handling into its own file

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd CONFIG_YAFFS_SMALL_RAM to reduce RAM footprint
Charles Manning [Thu, 9 Jul 2020 01:28:23 +0000 (13:28 +1200)]
Add CONFIG_YAFFS_SMALL_RAM to reduce RAM footprint

Reduce number of handles and search contexts.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd CONFIG_YAFFS_NO_TRACE to turn off all tracing
Charles Manning [Thu, 9 Jul 2020 01:24:30 +0000 (13:24 +1200)]
Add CONFIG_YAFFS_NO_TRACE to turn off all tracing

This allows a foootprint reduction.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoyaffs-vfs-multi.c: Handle search context properly to prevent leaking
Charles Manning [Thu, 25 Jun 2020 04:01:27 +0000 (16:01 +1200)]
yaffs-vfs-multi.c: Handle search context properly to prevent leaking

Fix potential memory leak due to search context not being closed properly.

Thank you to George Pee for reporting this issue.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoAdd malloc monitoring to get a sense of RAM use
Charles Manning [Fri, 19 Jun 2020 01:52:21 +0000 (13:52 +1200)]
Add malloc monitoring to get a sense of RAM use

Note this should only be monitoring the malloc usage by Yaffs, not the
malloc usage in things like flash simulators which are not relevant in
real systems.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoBegign bug: Fix incorrect return value
Charles Manning [Fri, 19 Jun 2020 01:43:45 +0000 (13:43 +1200)]
Begign bug: Fix incorrect return value

The return value was not being used, but it was wrong.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoMerge branch 'sizeofsizeof'
Charles Manning [Fri, 15 May 2020 02:36:57 +0000 (14:36 +1200)]
Merge branch 'sizeofsizeof'

Fix two bugs:

sizeof(sizeof(hdr)) used instaed of sizeof(hr)

remounting a read-only fs in rw did not clean up defered operations
properly.

3 years agoAdd some RTEMS notes
Charles Manning [Fri, 15 May 2020 02:35:17 +0000 (14:35 +1200)]
Add some RTEMS notes

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoHandle cleanup when remounting rw after mounting read-only
Charles Manning [Fri, 15 May 2020 01:57:54 +0000 (13:57 +1200)]
Handle cleanup when remounting rw after mounting read-only

Deferend clean ups were not happening properly.

Thanks to andriy.grytsenko@globallogic.com for providing a
patch that forms the babsis of these changes.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agoMake buffers larger to stop compiler complaining
Charles Manning [Fri, 15 May 2020 01:44:10 +0000 (13:44 +1200)]
Make buffers larger to stop compiler complaining

The buffers were not overflowing, but the check was complaining.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
3 years agofix wrong use of sizeof in yaffs_checkpt_close
liaohua [Thu, 23 Apr 2020 03:30:20 +0000 (11:30 +0800)]
fix wrong use of sizeof in yaffs_checkpt_close

There is a distinct bug that sizeof was used incorrectly,
causing the judgment to be ineffective and always flushing checkpt buffer.

Signed-off-by: liaohua <liaohua4@huawei.com>
4 years agoAdd test to dereference symlink rtems-merge
Charles Manning [Thu, 19 Mar 2020 03:04:35 +0000 (16:04 +1300)]
Add test to dereference symlink

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agoAdd more basic tests and some clean up.
Charles Manning [Thu, 19 Mar 2020 02:15:24 +0000 (15:15 +1300)]
Add more basic tests and some clean up.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agoAdd stats to flash simulator
Charles Manning [Thu, 19 Mar 2020 02:14:30 +0000 (15:14 +1300)]
Add stats to flash simulator

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agortems yests: FSX
Charles Manning [Tue, 17 Mar 2020 19:51:12 +0000 (08:51 +1300)]
rtems yests: FSX

Add readme and some tweaks.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agoAdd fsx file test and split up basic tests.
Charles Manning [Tue, 17 Mar 2020 03:45:01 +0000 (16:45 +1300)]
Add fsx file test and split up basic tests.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agortems support: Rudimentary test harness now working.
Charles Manning [Fri, 13 Mar 2020 03:33:23 +0000 (16:33 +1300)]
rtems support: Rudimentary test harness now working.

Lots more test cases to add.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agoMakefile.rtems: Add a few missing files
Charles Manning [Fri, 13 Mar 2020 01:33:31 +0000 (14:33 +1300)]
Makefile.rtems: Add a few missing files

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agoyaffs_tagsmarshall.c: Fix prototype dependency
Charles Manning [Fri, 13 Mar 2020 01:32:24 +0000 (14:32 +1300)]
yaffs_tagsmarshall.c: Fix prototype dependency

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agortems_yaffs: Remove unnecessary flushing of symlink
Charles Manning [Thu, 12 Mar 2020 23:26:37 +0000 (12:26 +1300)]
rtems_yaffs: Remove unnecessary flushing of symlink

Flushing only has meaning on regular files which have cached data.
Symlinks do not have any cached data, therefore flushing has no purpose. Remove.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agortems-yaffs: Checkpoint the filesystem at unmount time
Jonathan Brandmeyer [Thu, 12 Mar 2020 23:01:06 +0000 (12:01 +1300)]
rtems-yaffs: Checkpoint the filesystem at unmount time

Adding a checkpoint greatly reduces the amount of time required to mount
the filesystem on the next boot.  After a clean unmount, remount time
is only a second or few.  After an unclean reboot, remount time requires
a scan of the filesystem, which can take a few minutes.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agortems_yaffs: Add symlink support
Jonathan BrandMeyer [Thu, 12 Mar 2020 22:54:55 +0000 (11:54 +1300)]
rtems_yaffs: Add symlink support

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agortems-yaffs: Modes to freshen to latest Yaffs and build in yaffs2/rtems
Charles Manning [Thu, 6 Feb 2020 22:20:32 +0000 (11:20 +1300)]
rtems-yaffs: Modes to freshen to latest Yaffs and build in yaffs2/rtems

Makefile uses symlinks to files outside yaffs2/rtems aso that rtems can be built without
modifying the directory structure and deleting files.

Various tweaks needed to support changes in function prototypes.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agoImport rtems wrapper from rtems git
Sebastian Huber [Thu, 6 Feb 2020 20:03:41 +0000 (09:03 +1300)]
Import rtems wrapper from rtems git

https://git.rtems.org/sebh/rtems-yaffs2.git/
Commit:  23be2ac372173ecf701a0a

Most of this work was authored by

Sebastian Huber <sebastian.huber@embedded-brains.de>
Sebastien Bourdeauducq <sebastien@milkymist.org>

Note that the RTEMS licencing applies to all the rtems wrapper code.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
4 years agofix memory leak when /proc/yaffs is read
Charles Manning [Mon, 21 Oct 2019 19:46:14 +0000 (08:46 +1300)]
fix memory leak when /proc/yaffs is read

Thanks to Jisheng Zhang <Jisheng.Zhang@synaptics.com> for supplying this patch

There is a kernel memory leak observed when the proc file /proc/yaffs
is read. This reason is that in yaffs_proc_open, single_open is called
and the respective release function is not called during release.

Fix with correct release function - single_release().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
5 years agoFix race yaffs_flush_inodes against iput
chengchao [Mon, 28 Jan 2019 03:19:15 +0000 (11:19 +0800)]
Fix race yaffs_flush_inodes against iput

needs inode->i_sb->s_inode_list_lock protects
  inode->i_sb->s_inodes, inode->i_sb_list

Signed-off-by: chengchao <chengchao@kedacom.com>
5 years agoAkiko: Fix Yaffs Linux compilation for 4.9 to 4.19
Charles Manning [Tue, 15 Jan 2019 00:00:17 +0000 (13:00 +1300)]
Akiko: Fix Yaffs Linux compilation for 4.9 to 4.19

Thanks Akiko for supplying this patch

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
5 years agoOnly load name if read succeeds
Charles Manning [Mon, 14 Jan 2019 23:58:21 +0000 (12:58 +1300)]
Only load name if read succeeds

Thanks Akiko for supplying this patch.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
5 years agoMerge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
Charles Manning [Mon, 6 Aug 2018 21:48:35 +0000 (09:48 +1200)]
Merge branch 'master' of ssh://aleph1.co.uk/home/aleph1/git/yaffs2

5 years agoClean up some version dependencies
Charles Manning [Mon, 6 Aug 2018 21:48:11 +0000 (09:48 +1200)]
Clean up some version dependencies

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
5 years agoFix hang caused by returning with lock held
Charles Manning [Mon, 23 Jul 2018 05:04:23 +0000 (17:04 +1200)]
Fix hang caused by returning with lock held

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
5 years agoFix building for mkyaffsimage and mkyaffs2image
Charles Manning [Mon, 23 Jul 2018 03:26:09 +0000 (15:26 +1200)]
Fix building for mkyaffsimage and mkyaffs2image

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
6 years agoFix copyright
Charles Manning [Mon, 26 Feb 2018 04:34:01 +0000 (17:34 +1300)]
Fix copyright

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
6 years agoClean up some compilation warnings for VxWorks aleph1-release
Charles Manning [Fri, 11 Aug 2017 04:28:05 +0000 (16:28 +1200)]
Clean up some compilation warnings for VxWorks

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
6 years agoAdd Adre's patch for Linux 4.9
Charles Manning [Sun, 7 May 2017 22:02:11 +0000 (10:02 +1200)]
Add Adre's patch for Linux 4.9

Kudos to Andre Renaud <andre@ignavus.net>

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoAdd struct definition to yaffs_nameval header
Charles Manning [Thu, 6 Apr 2017 02:11:05 +0000 (14:11 +1200)]
Add struct definition to yaffs_nameval header

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoyaffs direct: Fix opening of a directory.
Charles Manning [Mon, 3 Apr 2017 04:49:42 +0000 (16:49 +1200)]
yaffs direct: Fix opening of a directory.

If opening a directory using yaffs_open(), Yaffs Direct was checking
that the file was being opened with O_RDONLY.

In fact those flags should actually be ignored and it should be treated
as if opened O_RDONLY.

Therefore override flags if opening a directory.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoChanges to test scripts
Charles Manning [Sat, 3 Dec 2016 05:47:16 +0000 (18:47 +1300)]
Changes to test scripts

These just clean up a few things.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoFix yaffs_endian.h for Linux
Charles Manning [Sat, 3 Dec 2016 05:43:00 +0000 (18:43 +1300)]
Fix yaffs_endian.h for Linux

Yaffs loff_t is kept as loff_t and converted into Y_LOFF_T when
when exported for Yaffs Direct.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoChanges to enable Linux 4.8 compilation
Andre Renaud [Tue, 25 Oct 2016 01:18:11 +0000 (14:18 +1300)]
Changes to enable Linux 4.8 compilation

7 years agotimothy-tests: Fix paths for wrongly failing tests
Charles Manning [Fri, 8 Jul 2016 01:50:44 +0000 (13:50 +1200)]
timothy-tests: Fix paths for wrongly failing tests

All pass now.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agotimothy-tests: Change mountpoint names to match test framework
Charles Manning [Fri, 8 Jul 2016 01:30:52 +0000 (13:30 +1200)]
timothy-tests: Change mountpoint names to match test framework

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoGet timothy quick tests building cleanly.
Charles Manning [Fri, 8 Jul 2016 00:43:57 +0000 (12:43 +1200)]
Get timothy quick tests building cleanly.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoMore compilation clean up
Charles Manning [Wed, 6 Jul 2016 22:09:48 +0000 (10:09 +1200)]
More compilation clean up

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoCompilation clean up
Charles Manning [Wed, 6 Jul 2016 21:30:35 +0000 (09:30 +1200)]
Compilation clean up

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoChean up nand test script
Charles Manning [Tue, 5 Jul 2016 04:47:41 +0000 (16:47 +1200)]
Chean up nand test script

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoyaffs2: Yaffs endian support
Charles Manning [Sat, 2 Jul 2016 00:11:34 +0000 (12:11 +1200)]
yaffs2: Yaffs endian support

Allow the forcing of endians so that Yaffs can be used on mixed endian
machines, or a flash image can be extracted and used elsewhere.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoChange checkpoint object to using a bitfield
Charles Manning [Tue, 14 Jun 2016 02:30:01 +0000 (14:30 +1200)]
Change checkpoint object to using a bitfield

This is done to support changing to support endian
manipulation.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoAdd ability to hide lost_n_found directory
Charles Manning [Mon, 6 Jun 2016 02:16:07 +0000 (14:16 +1200)]
Add ability to hide lost_n_found directory

Some people don't want it showing up in the directory structure.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
7 years agoSplit qsort from the main Yaffs Direct base
Charles Manning [Sun, 1 May 2016 19:23:33 +0000 (07:23 +1200)]
Split qsort from the main Yaffs Direct base

Use the system qsort if available. If not, then add in the
optional qsort.c

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoWrite object headers with stored file extents charles_experiment
Charles Manning [Mon, 7 Mar 2016 19:03:06 +0000 (08:03 +1300)]
Write object headers with stored file extents

Previously file object headers were being written with file extents
rather than stored extents.

This could lead to situations where the data in the cache was not yet
written to flash but had been accounted for in the object header file
size.

Under power fail this could cause zero-filled blobs at the end of a file.

This change tracks the stored file size and only write object headers
reflecting the extents of the file that has actually been stored to flash,
thus avoiding the holes.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs_vfs_multi.c: Some cleanups
Charles Manning [Mon, 7 Mar 2016 18:51:02 +0000 (07:51 +1300)]
yaffs_vfs_multi.c: Some cleanups

Remove some build time strings so that the binary deos not change
every time the code is compiled.

Add some support for kernel changes

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoChange enums to u32 for stored fields
Charles Manning [Wed, 2 Mar 2016 02:27:31 +0000 (15:27 +1300)]
Change enums to u32 for stored fields

enum sizes are not fixed, so it is better to specify an actual sized
storage element.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoAdd usr mode flags
Charles Manning [Sun, 6 Dec 2015 06:25:48 +0000 (19:25 +1300)]
Add usr mode flags

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoFurther extensions for VxWorks wrapper
Charles Manning [Wed, 11 Nov 2015 03:51:28 +0000 (16:51 +1300)]
Further extensions for VxWorks wrapper

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoSome changes to get VxWorks wrapper working
Charles Manning [Thu, 22 Oct 2015 20:05:56 +0000 (09:05 +1300)]
Some changes to get VxWorks wrapper working

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: Remove unnecessary variable from checkpooint reading
Charles Manning [Mon, 1 Jun 2015 22:17:57 +0000 (10:17 +1200)]
yaffs: Remove unnecessary variable from checkpooint reading

No point in tracking ok if we're also going to break.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: Keep checkpt rd/wr buffers
Charles Manning [Mon, 1 Jun 2015 21:52:23 +0000 (09:52 +1200)]
yaffs: Keep checkpt rd/wr buffers

Continual malloc/free on some systemcs can cause fragmentation. Better
to just allocate the buffers once and hold unto them.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: Remove unused variable
Charles Manning [Sun, 31 May 2015 00:11:09 +0000 (12:11 +1200)]
yaffs: Remove unused variable

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs direct: Fix wrong condition for O_CREAT | O_EXCL
Charles Manning [Sat, 30 May 2015 23:45:03 +0000 (11:45 +1200)]
yaffs direct: Fix wrong condition for O_CREAT | O_EXCL

Thanks Chris for pointing this out.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: Clean up defeated conditional.
Charles Manning [Thu, 28 May 2015 21:09:48 +0000 (09:09 +1200)]
yaffs: Clean up defeated conditional.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: Add handling for . and .. at end of path
Charles Manning [Thu, 21 May 2015 21:54:08 +0000 (09:54 +1200)]
yaffs: Add handling for . and .. at end of path

yaffs_opendir("/nand/x/./") or yaffs_opendir("/nand/x/../") were
not working, but yaffs_opendir("/nand/x/.") and yaffs_opendir("/nand/x/..")
were.

Make them all work.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoAdd some more basic tests
Charles Manning [Thu, 21 May 2015 21:52:52 +0000 (09:52 +1200)]
Add some more basic tests

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: Fix yaffs_readdir when dereferencing a symlink
Charles Manning [Thu, 21 May 2015 05:27:01 +0000 (17:27 +1200)]
yaffs: Fix yaffs_readdir when dereferencing a symlink

If the directory is a symlink then follow the symlink.

eg
yaffs_mount("/nand/");
yaffs_symlink("x", "/nand/sym");
yaffs_mkdir("/nand/x",0666);

After that:

yaffs_opendir("/nand/sym/") works, but opendir("/nand/sym") fails because the
symlink itself is found. Fix by dereferencing the symlink in yaffs_opendir().

Thanks to Trent Lillehaugen for finding that.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoFix directory look up.
Charles Manning [Tue, 19 May 2015 22:21:52 +0000 (10:21 +1200)]
Fix directory look up.

Thanks to Trent Lillehaugen for new algorithm:

Let's say I have two yaffs partitions: "/" and "/foo".
If I call, yaffs_mkdir("/foobar", 0), yaffsfs_FindDevice will match the path
with the "/foo" partition.  I would expect it to match "/" instead.
It will also match "/fo/o/bar" with "/foo", again I think it should match
with "/".

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
8 years agoyaffs: fix missing checkpooint on yaffs remount
Charles Manning [Sun, 17 May 2015 08:02:46 +0000 (20:02 +1200)]
yaffs: fix missing checkpooint on yaffs remount

For yaffs file system, the mode of reading or writing is restricted at
four pointer where are mnt->mnt_flags,mnt->mnt_sb->s_flags,mtd->flags
and dev->read_only,the first three is used handle file and file
system(eg,remount) operation, and last one(dev->read_only) almost is used
handle checkpoint of yaffs2. However, in current code, the dev->read_only
only can be changed at first time when the yaffs2 file system is mounted,
later it can't be changed again(eg,mount -o remount), the result is that
the checkpoint's saving operation always can't succeed if you set readonly
mode for yaffs2 file system when it is mounted at the first time.

To fix this issue, we implement yaffs_remount_fs() which allows the
rootfs to be remounted as r/w.

Also fix one missing argument in yaffs_flush_whole_cache() call.

Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
8 years agoFix vfs calls to yaffs_flush_file
Charles Manning [Sun, 17 May 2015 05:42:36 +0000 (17:42 +1200)]
Fix vfs calls to yaffs_flush_file

Add extra argument.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoyaffs-direct: Basic tests. Add lpthread flag for background gc support
Charles Manning [Wed, 6 Aug 2014 23:25:05 +0000 (11:25 +1200)]
yaffs-direct: Basic tests. Add lpthread flag for background gc support

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoRemove unused WinCE Makefile
Charles Manning [Wed, 6 Aug 2014 23:23:38 +0000 (11:23 +1200)]
Remove unused WinCE Makefile

THis was for copying the yaffs direct files needed for WinCE.

This is no longer needed since we can just copy the files from
yaffs2/direct/*.[ch]

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoyaffs direct: Add some missing reldev functions
Charles Manning [Tue, 5 Aug 2014 23:22:11 +0000 (11:22 +1200)]
yaffs direct: Add some missing reldev functions

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoTest tweaks
Charles Manning [Tue, 5 Aug 2014 21:27:34 +0000 (09:27 +1200)]
Test tweaks

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoSome yaffsfs cleanups for WinCE
Charles Manning [Tue, 5 Aug 2014 21:26:59 +0000 (09:26 +1200)]
Some yaffsfs cleanups for WinCE

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoYaffs: Change cache policy
Charles Manning [Tue, 22 Jul 2014 21:33:04 +0000 (09:33 +1200)]
Yaffs: Change cache policy

When the cache is full and a new cache entry is needed, then space has
to be made. This is sometimes termed push out.

Until now, the push out involved finding the least recently used cache
entry then pushing out all entries in the same file.

This had the unintended consequence of making "bursty" writes and forcing
extra reads under some conditions.

Since the same code path was being used for fsync() and flushing, this
also meant that flushing a file caused the file to be thrown out of the
cache. That is not a very useful thing to do.

These changes are twofold:

1. Only push out the LRU cache entry, rather than the whole file. This
makes for a "smoother" push out. It also saves some reads.

2. Flushing a file no longer invalidates the file in cache, it just writes
dirty cache entries. This makes better use of the cache.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoUpdate to support Linux 3.14/3.15
Charles Manning [Wed, 18 Jun 2014 02:21:03 +0000 (14:21 +1200)]
Update to support Linux 3.14/3.15

Thanks to Andre Renaud for doing some of this.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
9 years agoyaffs direct: Expose background garbage collection
Charles Manning [Wed, 7 May 2014 01:07:25 +0000 (13:07 +1200)]
yaffs direct: Expose background garbage collection

Expose background garbage collection and add a demo
pthread implementation of background gc.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoyaffs: Clean up bitfield types
Charles Manning [Sat, 29 Mar 2014 21:24:55 +0000 (10:24 +1300)]
yaffs: Clean up bitfield types

It happens that the C spec says compilers can choose whether to treat
int bitfields as signed or unsigned.

In some cases, int was being used and signed was expected. The IAR
ARM compiler in particular treats int bitfields as unsigned.

Clean up these plus a few other bitfield usages to make the size and
type explicit.

Thanks to ChungKang Hu for identifying this issue.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoyaffs-direct: Add reldir and reldev interfaces
Charles Manning [Tue, 25 Mar 2014 00:26:39 +0000 (13:26 +1300)]
yaffs-direct: Add reldir and reldev interfaces

These interfaces allow far more flexibility in the way Yaffs Direct
is hooked up to an RTOS VFS.

The "normal" interface requires a fully, qualified path, which is
a pain to achieve in some RTOSs.

The new interfaces allow calls to be done with paths relative to a
directory or to a device. This tends to make some RTOS integration
cleaner.

Example
 yaffs_open("/mountpoint-name/dir/file",...);
now has two alternatives:
 yaffs_open_reldir(root_dir,"dir/file",...);
or
 yaffs_open_reldev(dev, "dir/file",...);

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoMerge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
Charles Manning [Tue, 4 Mar 2014 01:11:14 +0000 (14:11 +1300)]
Merge branch 'master' of ssh://aleph1.co.uk/home/aleph1/git/yaffs2

10 years agoyaffs-direct: Fix object leak caused by defered free
Charles Manning [Tue, 4 Mar 2014 01:04:00 +0000 (14:04 +1300)]
yaffs-direct: Fix object leak caused by defered free

The change to dtest.c adds a test case that was leaking objects.
The change to yaffsfs.c fixes this.

This leak was triggered by sequences of the following form:

yaffs_open(file_name, ...); /* create obj */
...
yaffs_unlink(file_name);
yaffs_close(file_name);

When the file was closed, obj->my_inode was not NULL when yaffs_del_obj() is
called, therefore the object was not released properly.

The fix "unstitches" the object before the call to yaffs_del_obj(), so that
obj->my_inode is NULL and the object freeing is done correctly.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoApply fixes in cisco patch to yaffs_vfs_single
Charles Manning [Tue, 21 Jan 2014 23:32:13 +0000 (12:32 +1300)]
Apply fixes in cisco patch to yaffs_vfs_single

Cisco patched the multi version. This manually drags the fixes to the
single version too.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoUse IS_ERR to validate return value from get_mtd_device()
Kjetil Aamodt [Mon, 9 Sep 2013 14:23:20 +0000 (16:23 +0200)]
Use IS_ERR to validate return value from get_mtd_device()

Testing has shown that is needed.

10 years agoReturn from yaffs_internal_read_super if kmalloc fail
Kjetil Aamodt [Mon, 9 Sep 2013 13:24:52 +0000 (15:24 +0200)]
Return from yaffs_internal_read_super if kmalloc fail

Return if either, or both, of dev and context failed to
kmalloc(). kfree() handles NULL as argument so utilise that to
simplify code.

10 years agoChange the object type if it turns out to be wrong during a scan
Charles Manning [Tue, 21 Jan 2014 23:14:26 +0000 (12:14 +1300)]
Change the object type if it turns out to be wrong during a scan

This might result in some files ending up in lost but at least we
can get the file system to mount.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoRemove block number check from summary verification
Charles Manning [Mon, 20 Jan 2014 01:38:57 +0000 (14:38 +1300)]
Remove block number check from summary verification

The summary already has other verification. This one is not needed.

The check caused summaries to be ignored if they were not on the
numbered block. This caused problems when a summary was embedded in an
image and the image is written to a flash with bad blocks.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoMerge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
Charles Manning [Thu, 11 Jul 2013 05:46:25 +0000 (17:46 +1200)]
Merge branch 'master' of ssh://aleph1.co.uk/home/aleph1/git/yaffs2

10 years agoAdd some extra debugging to yaffs_vfs_multi.c
Charles Manning [Thu, 11 Jul 2013 05:45:33 +0000 (17:45 +1200)]
Add some extra debugging to yaffs_vfs_multi.c

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoAdd some yaffs debug functions for inspecting run-time state.
Charles Manning [Thu, 11 Jul 2013 05:40:46 +0000 (17:40 +1200)]
Add some yaffs debug functions for inspecting run-time state.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
10 years agoInitialise device properly when doing a format.
Charles Manning [Thu, 11 Jul 2013 05:33:53 +0000 (17:33 +1200)]
Initialise device properly when doing a format.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>