#
7037c96d |
| 18-Apr-2024 |
ZhaoLong Wang <wangzhaolong1@huawei.com> |
ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity
The UBIFS_DFS_DIR_LEN macro, which defines the maximum length of the UBIFS debugfs directory name, has an incorrect formula
ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity
The UBIFS_DFS_DIR_LEN macro, which defines the maximum length of the UBIFS debugfs directory name, has an incorrect formula and misleading comments. The current formula is (3 + 1 + 2*2 + 1), which assumes that both UBI device number and volume ID are limited to 2 characters. However, UBI device number ranges from 0 to 31 (2 characters), and volume ID ranges from 0 to 127 (up to 3 characters).
Although the current code works due to the cancellation of mathematical errors (9 + 1 = 10, which matches the correct UBIFS_DFS_DIR_LEN value), it can lead to confusion and potential issues in the future.
This patch aims to improve the code clarity and maintainability by making the following changes:
1. Corrects the UBIFS_DFS_DIR_LEN macro definition to (3 + 1 + 2 + 3 + 1), accommodating the maximum lengths of both UBI device number and volume ID, plus the separators and null terminator. 2. Updates the snprintf calls to use UBIFS_DFS_DIR_LEN instead of UBIFS_DFS_DIR_LEN + 1, removing the unnecessary +1. 3. Modifies the error checks to compare against UBIFS_DFS_DIR_LEN using >= instead of >, aligning with the corrected macro definition. 4. Removes the redundant +1 in the dfs_dir_name array definitions in ubi.h and debug.h.
While these changes do not affect the runtime behavior, they make the code more readable, maintainable, and less prone to future errors.
v2->v3:
- Removes the duplicated UBIFS_DFS_DIR_LEN and UBIFS_DFS_DIR_NAME macro definitions in ubifs.h, as they are already defined in debug.h.
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
show more ...
|
#
bf6dab7a |
| 16-Jun-2020 |
Zhihao Cheng <chengzhihao1@huawei.com> |
ubifs: ubifs_dump_sleb: Remove unused function
Function ubifs_dump_sleb() is defined but unused, it can be removed.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Wein
ubifs: ubifs_dump_sleb: Remove unused function
Function ubifs_dump_sleb() is defined but unused, it can be removed.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
show more ...
|
#
c4c0d19d |
| 16-Jun-2020 |
Zhihao Cheng <chengzhihao1@huawei.com> |
ubifs: Limit dumping length by size of memory which is allocated for the node
To prevent memory out-of-bounds accessing in ubifs_dump_node(), actual dumping length should be restricted by another co
ubifs: Limit dumping length by size of memory which is allocated for the node
To prevent memory out-of-bounds accessing in ubifs_dump_node(), actual dumping length should be restricted by another condition(size of memory which is allocated for the node).
This patch handles following situations (These situations may be caused by bit flipping due to hardware error, writing bypass ubifs, unknown bugs in ubifs, etc.): 1. bad node_len: Dumping data according to 'ch->len' which may exceed the size of memory allocated for node. 2. bad node content: Some kinds of node can record additional data, eg. index node and orphan node, make sure the size of additional data not beyond the node length. 3. node_type changes: Read data according to type A, but expected type B, before that, node is allocated according to type B's size. Length of type A node is greater than type B node.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
show more ...
|
#
702d6a83 |
| 12-Jun-2019 |
Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
ubifs: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic sh
ubifs: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Cc: Richard Weinberger <richard@nod.at> Cc: Artem Bityutskiy <dedekind1@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: linux-mtd@lists.infradead.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20190612152120.GA17450@kroah.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
#
2b27bdcc |
| 29-May-2019 |
Thomas Gleixner <tglx@linutronix.de> |
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336
Based on 1 normalized pattern(s):
this program is free software you can redistribute it and or modify it under the terms of th
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336
Based on 1 normalized pattern(s):
this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 51 franklin st fifth floor boston ma 02110 1301 usa
extracted by the scancode license scanner the SPDX license identifier
GPL-2.0-only
has been chosen to replace the boilerplate/reference in 246 file(s).
Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190530000436.674189849@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
#
2e52eb74 |
| 12-Jul-2018 |
Richard Weinberger <richard@nod.at> |
ubifs: Rework ubifs_assert()
With having access to struct ubifs_info in ubifs_assert() we can give more information when an assert is failing. By using ubifs_err() we can tell which UBIFS instance f
ubifs: Rework ubifs_assert()
With having access to struct ubifs_info in ubifs_assert() we can give more information when an assert is failing. By using ubifs_err() we can tell which UBIFS instance failed.
Also multiple actions can be taken now. We support: - report: This is what UBIFS did so far, just report the failure and go on. - read-only: Switch to read-only mode. - panic: shoot the kernel in the head.
Signed-off-by: Richard Weinberger <richard@nod.at>
show more ...
|
#
6eb61d58 |
| 12-Jul-2018 |
Richard Weinberger <richard@nod.at> |
ubifs: Pass struct ubifs_info to ubifs_assert()
This allows us to have more context in ubifs_assert() and take different actions depending on the configuration.
Signed-off-by: Richard Weinberger <r
ubifs: Pass struct ubifs_info to ubifs_assert()
This allows us to have more context in ubifs_assert() and take different actions depending on the configuration.
Signed-off-by: Richard Weinberger <richard@nod.at>
show more ...
|
#
3668b70f |
| 27-Aug-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: print less
UBIFS currently prints a lot of information when it mounts a volume, which bothers some people. Make it less chatty - print only important information by default.
Get rid of 'dbg_
UBIFS: print less
UBIFS currently prints a lot of information when it mounts a volume, which bothers some people. Make it less chatty - print only important information by default.
Get rid of 'dbg_msg()' macro completely.
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
show more ...
|
#
6b38d03f |
| 27-Aug-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: use pr_ helper instead of printk
Use 'pr_err()' instead of 'printk(KERN_ERR', etc.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
#
c45640d8 |
| 22-Aug-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: print PID in debug messages
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
#
65b455b1 |
| 21-Aug-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: fix complaints about too small debug buffer size
When debugging is enabled, we use a temporary on-stack buffer for formatting the key strings like "(11368871, direntry, 0xcd0750)". The buffer
UBIFS: fix complaints about too small debug buffer size
When debugging is enabled, we use a temporary on-stack buffer for formatting the key strings like "(11368871, direntry, 0xcd0750)". The buffer size is 32 bytes and sometimes it is not enough to fit the key string - e.g., when inode numbers are high. This is not fatal, but the key strings are incomplete and UBIFS complains like this:
UBIFS assert failed in dbg_snprintf_key at 137 (pid 1)
This is a regression caused by "515315a UBIFS: fix key printing".
Fix the issue by increasing the buffer to 48 bytes.
Reported-by: Michael Hench <michaelhench@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Tested-by: Michael Hench <michaelhench@gmail.com> Cc: stable@vger.kernel.org [v3.3+]
show more ...
|
#
06bef945 |
| 14-Jul-2012 |
Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> |
UBIFS: add debugfs knob to switch to R/O mode
This patch adds another debugfs knob which switches UBIFS to R/O mode. I needed it while trying to reproduce the 'first log node is not CS node' bug. Wi
UBIFS: add debugfs knob to switch to R/O mode
This patch adds another debugfs knob which switches UBIFS to R/O mode. I needed it while trying to reproduce the 'first log node is not CS node' bug. Without this debugfs knob you have to perform a power cut to repruduce the bug. The knob is named 'ro_error' and all it does is it sets the 'ro_error' UBIFS flag which makes UBIFS disallow any further writes - even write-back will fail with -EROFS. Useful for debugging.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
show more ...
|
#
b36a261e |
| 14-May-2012 |
Richard Weinberger <richard@nod.at> |
UBI: Kill data type hint
We do not need this feature and to our shame it even was not working and there was a bug found very recently. -- Artem Bityutskiy
Without the data type hint UBI2 (fastmap)
UBI: Kill data type hint
We do not need this feature and to our shame it even was not working and there was a bug found very recently. -- Artem Bityutskiy
Without the data type hint UBI2 (fastmap) will be easier to implement.
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
show more ...
|
#
a6aae4dd |
| 16-May-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: get rid of dbg_err
This patch removes the 'dbg_err()' macro and we now use 'ubifs_err()' instead. The idea of 'dbg_err()' was to compile out some error message to make the binary a bit smalle
UBIFS: get rid of dbg_err
This patch removes the 'dbg_err()' macro and we now use 'ubifs_err()' instead. The idea of 'dbg_err()' was to compile out some error message to make the binary a bit smaller - but I think it was a bad idea.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
show more ...
|
#
f70b7e52 |
| 16-May-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: remove Kconfig debugging option
Have the debugging stuff always compiled-in instead. It simplifies maintanance a lot.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
#
1baafd28 |
| 16-May-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: remove a couple of unused macros
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
#
edf6be24 |
| 16-May-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: rename dumping functions
This commit re-names all functions which dump something from "dbg_dump_*()" to "ubifs_dump_*()". This is done for consistency with UBI and because this way it will be
UBIFS: rename dumping functions
This commit re-names all functions which dump something from "dbg_dump_*()" to "ubifs_dump_*()". This is done for consistency with UBI and because this way it will be more logical once we remove the debugging sompilation option.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
show more ...
|
#
7c46d0ae |
| 16-May-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: get rid of dbg_dump_stack
In case of errors we almost always need the stack dump - it makes no sense to compile it out. Remove the 'dbg_dump_stack()' function completely.
Signed-off-by: Arte
UBIFS: get rid of dbg_dump_stack
In case of errors we almost always need the stack dump - it makes no sense to compile it out. Remove the 'dbg_dump_stack()' function completely.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
show more ...
|
#
b06283c7 |
| 18-Jan-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: make the dbg_lock spinlock static
Remove the usage of the 'dbg_lock' spinlock from 'dbg_err()' and make it static.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
#
e234b5f2 |
| 14-Jan-2012 |
Dominique Martinet <asmadeus@codewreck.org> |
UBIFS: fix non-debug configuration build
Fix a brown paperbag bug introduced by me in the previous commit. I was in hurry and forgot about the non-debug case completely.
Artem: amend the commit mes
UBIFS: fix non-debug configuration build
Fix a brown paperbag bug introduced by me in the previous commit. I was in hurry and forgot about the non-debug case completely.
Artem: amend the commit message and tweak the patch to preserve alignment. This made the patch a bit less readable, though.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
show more ...
|
#
515315a1 |
| 13-Jan-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: fix key printing
Before commit 56e46742e846e4de167dde0e1e1071ace1c882a5 we have had locking around all printing macros and we could use static buffers for creating key strings and printing th
UBIFS: fix key printing
Before commit 56e46742e846e4de167dde0e1e1071ace1c882a5 we have had locking around all printing macros and we could use static buffers for creating key strings and printing them. However, now we do not have that locking and we cannot use static buffers. This commit removes the old DBGKEY() macros and introduces few new helper macros for printing debugging messages plus a key at the end. Thankfully, all the messages are already structures in a way that the key is printed in the end.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
show more ...
|
#
d34315da |
| 10-Jan-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: fix debugging messages
Patch 56e46742e846e4de167dde0e1e1071ace1c882a5 broke UBIFS debugging messages: before that commit when UBIFS debugging was enabled, users saw few useful debugging messa
UBIFS: fix debugging messages
Patch 56e46742e846e4de167dde0e1e1071ace1c882a5 broke UBIFS debugging messages: before that commit when UBIFS debugging was enabled, users saw few useful debugging messages after mount. However, that patch turned 'dbg_msg()' into 'pr_debug()', so to enable the debugging messages users have to enable them first via /sys/kernel/debug/dynamic_debug/control, which is very impractical.
This commit makes 'dbg_msg()' to use 'printk()' instead of 'pr_debug()', just as it was before the breakage.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@kernel.org [3.0+]
show more ...
|
#
1f5d78dc |
| 11-Jan-2012 |
Artem Bityutskiy <artem.bityutskiy@linux.intel.com> |
UBIFS: make debugging messages light again
We switch to dynamic debugging in commit 56e46742e846e4de167dde0e1e1071ace1c882a5 but did not take into account that now we do not control anymore whether
UBIFS: make debugging messages light again
We switch to dynamic debugging in commit 56e46742e846e4de167dde0e1e1071ace1c882a5 but did not take into account that now we do not control anymore whether a specific message is enabled or not. So now we lock the "dbg_lock" and release it in every debugging macro, which make them not so light-weight.
This commit removes the "dbg_lock" protection from the debugging macros to fix the issue.
The downside is that now our DBGKEY() stuff is broken, but this is not critical at all and will be fixed later.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@kernel.org [3.0+]
show more ...
|
#
d37854cf |
| 22-Aug-2011 |
Artem Bityutskiy <artem.bityutskiy@intel.com> |
UBIFS: introduce a helper to dump scanning info
This commit adds 'dbg_dump_sleb()' helper function to dump scanning information.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
#
016f1c54 |
| 11-Aug-2011 |
Michal Marek <mmarek@suse.cz> |
UBIFS: not build debug messages with CONFIG_UBIFS_FS_DEBUG disabled
With $ grep -e UBIFS_FS_DEBUG -e DYNAMIC_DEBUG .config # CONFIG_UBIFS_FS_DEBUG is not set CONFIG_DYNAMIC_DEBUG=y
Debug mess
UBIFS: not build debug messages with CONFIG_UBIFS_FS_DEBUG disabled
With $ grep -e UBIFS_FS_DEBUG -e DYNAMIC_DEBUG .config # CONFIG_UBIFS_FS_DEBUG is not set CONFIG_DYNAMIC_DEBUG=y
Debug messages are kept in the object files due to the dynamic_pr_debug() macro, even if they are never going to be printed: $ make fs/ubifs/super.o $ strings fs/ubifs/super.o | grep 'compiled on' compiled on: Aug 11 2011 at 12:21:38
Use plain printk to fix this.
Signed-off-by: Michal Marek <mmarek@suse.cz> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
show more ...
|