aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/rfs.c
Commit message (Collapse)AuthorAgeFilesLines
* ipc_nv_data_md5_calculate: handle size mismatch betterreplicant-6.0-0004-rc4Denis 'GNUtoo' Carikli2020-12-031-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently libsamsung-ipc assumes that the size of nv_data.bin files are always 0x200000. While it's supposed to be the case for all the devices we support, it is still a good idea to make sure that a meaningful error message is reported to the users of nv_data-md5. For instance if we created an empty file of 1 kB with the following command: $ ddrescue -s 1k /dev/zero zero.img and that we used nv_data-md5 on it: $ ./tools/nv_data-md5 zero.img [ipc] file_data_read: Error: rc < 0 [ipc] ipc_nv_data_md5_calculate failed: data is NULL Calculating nv_data backup md5 failed we had a completely meaningless error message. With this patch the error message looks like that instead: $ ./tools/nv_data-md5 zero.img [ipc] ipc_nv_data_md5_calculate: Checking zero.img size failed: requested size: 2097152, file size: 1000 Calculating nv_data backup md5 failed Here users have at least a fighting chance of being able to understand what is going wrong. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: rfs: fix incorrect sign comparison for md5 file lengthJoonas Kylmälä2020-12-031-3/+5
| | | | | | | | | | | | | | | | | | When compiling with warnings (-Werror -W -Wall -Wunused -Wunused-function) enabled we get: rfs.c: In function ‘ipc_nv_data_md5_path_check’: rfs.c:115:17: error: comparison of integer expressions of different signedness: ‘__off_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare] if (st.st_size < 2 * sizeof(char) * MD5_DIGEST_LENGTH) { ^ This simplifies the comparison by making sure we have exactly 32 bytes (2*MD5_DIGEST_LENGTH, i.e. md5 digest in ascii) in the file we read the MD5 digest from. Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Tested-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Acked-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: use #include "file" instead of #include <file> when relevantDenis 'GNUtoo' Carikli2020-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way <> and "" are included are implementation defined according to the C18 standard[1]: A preprocessing directive of the form # include < h-char-sequence > new-line searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined. A preprocessing directive of the form # include " q-char-sequence " new-line causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read And the GCC documentation has the following on #include directives[2]: Both user and system header files are included using the preprocessing directive ‘#include’. It has two variants: #include <file> This variant is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the -I option (see Invocation). #include "file" This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. You can prepend directories to the list of quote directories with the -iquote option. References: ----------- [1]The standard doesn't seem to be available for free, but the draft can be downloaded from the following URL: https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf [2]https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: rfs: switch to Linux code styleDenis 'GNUtoo' Carikli2020-06-271-570/+606
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This contains no functional changes. The commented out code if any has also been preserved as it could be relevant to the understanding of the code. It will be kept until we understand why the code has been commented. In that case we either need to remove it completely or to replace it by a comment explaining why not having that code was necessary. For __FUNCTION__, according to checkpatch.pl, it's gcc specific: WARNING: __func__ should be used instead of gcc specific __FUNCTION__ However __func__ is part of the C18 standard[1]. In the "6.4.2.2 Predefined identifiers" section, we have: "The identifier __func__ shall be implicitly declared by the translator as if, immediately following the opening brace of each function definition, the declaration static const char __func__[] = "function-name"; " References: ----------- [1]The standard doesn't seem to be available for free, but the draft can be downloaded from the following URL: https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Reviewed-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
* rfs.c: fix integer comparison sign with variableDenis 'GNUtoo' Carikli2020-02-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With: ./configure CC=clang CFLAGS=-W -Wall -Wno-unused \ --no-create --no-recursion we have: rfs.c:86:20: warning: comparison of integers of different signs: '__off_t' (aka 'long') and 'size_t' (aka 'unsigned int') [-Wsign-compare] if (st.st_size != size) { ~~~~~~~~~~ ^ ~~~~ rfs.c:146:20: warning: comparison of integers of different signs: '__off_t' (aka 'long') and 'size_t' (aka 'unsigned int') [-Wsign-compare] if (st.st_size != size) { ~~~~~~~~~~ ^ ~~~~ This is caused by the following code: size_t size; [...] rc = stat([...], &st); if (st.st_size != size) { [...] } However the type of size is wrong as the stat system call returns a stat structure which has the following field: off_t st_size; /* Total size, in bytes */ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* file_data_{read,write}: Add loggingDenis 'GNUtoo' Carikli2020-01-301-14/+14
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc_nv_data_md5_calculate: print errors when ipc_client is defined.Denis 'GNUtoo' Carikli2020-01-301-10/+15
| | | | | | | Without that, there are no ways to know the cause of failures with ipc_nv_data_md5_calculate. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* rfs.c: silence uninitialized variable warningDenis 'GNUtoo' Carikli2019-12-051-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* rfs.c: get rid of unused variablesDenis 'GNUtoo' Carikli2019-12-051-1/+0
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* rfs: Proper helpersPaul Kocialkowski2014-08-041-32/+53
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* rfs: Size function for helpers that return data with non-explicit sizePaul Kocialkowski2014-08-021-5/+19
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Offset is unsigned intPaul Kocialkowski2014-07-261-4/+5
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* utils: Shared libraries don't allow for internal functionsPaul Kocialkowski2014-07-261-1/+0
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* rfs: Chunk size is not always greater than sizePaul Kocialkowski2014-02-261-2/+2
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Global include pathPaul Kocialkowski2014-02-261-2/+2
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* rfs: Consistent coding style, cleanup and fresh new implementationPaul Kocialkowski2014-02-151-551/+482
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* utils: Files rename, new functions, proper types and few other cleanupsPaul Kocialkowski2014-02-131-7/+7
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* rfs: Proper IPC functions for nv_data specs, without generic fallback valuesPaul Kocialkowski2014-02-111-190/+49
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Follow consistent coding style in headersPaul Kocialkowski2014-02-061-11/+11
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Good-looking copyright blocks, with the right order in copyright linesPaul Kocialkowski2014-01-251-1/+0
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* rfs.c: Fix coding style and compilation warningsPaul Kocialkowski2013-07-031-31/+29
| | | | | Change-Id: I00d93d54e5b9bc645c65a9bd72fb0b6edae822ad Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* rfs.c: Coding style cosmeticsPaul Kocialkowski2013-06-271-86/+83
| | | | | Change-Id: I6d3745a75d6cb8ee945a4636fd6e6c2ff5ce4c66 Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Coding style: Move ; around in for statementsPaul Kocialkowski2013-06-251-1/+1
| | | | | Change-Id: I08cc4a5c404d1b513c56aa1eaeb68dfa6768a4e4 Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Add newline and indentation on long functions namesPaul Kocialkowski2013-06-251-2/+4
| | | | | Change-Id: Ie393301a04523816e7aa674e57a4c3a2eb93247e Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Refactor code for consistent coding style and avoid using assertPaul Kocialkowski2013-06-251-3/+3
| | | | | Change-Id: Idca5edb70869e07d35744301b185df02e42f5b4c Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Renamed ipc_private.h to ipc.hPaul Kocialkowski2013-06-251-1/+1
| | | | | Change-Id: Ie80159518b6d7d1a6422d3dc47a903eb7fdad6d8 Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Moved radio.h and types.h to samsung-ipc.h (API) and protocol.h (IPC protocol).Paul Kocialkowski2013-06-251-2/+2
| | | | | | | Also some minor headers cosmetics. Change-Id: Id2b988b118d956e91827b9b840e3f384424593ae Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* switch to GPLv2+ as license as decided by all authors per mailSimon Busch2012-09-211-1/+1
|
* rfs: fix warnings about ignored return results from std. library functionsSimon Busch2012-08-091-52/+185
|
* First round of fixing unnecessary warningsSimon Busch2012-08-081-5/+7
|
* Prefix method correctly with ipc_client_Simon Busch2012-08-081-8/+8
|
* Reworked nv_data handling in nv_data_specs, moved some functions to gprs_specsPaul Kocialkowski2012-07-041-81/+98
| | | | | | | | | | | | | | nv_data: * Reworked device-specific nv_data passthrough functions * Moved default values in rfs.h * Added more specific infos (size, chunk size, secret) * Applied to xmm6260 device gprs: * Moved non-io-related gprs handlers to gprs_specs * Applied to crespo, aries and xmm6260 devices Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* RFS: Changed chunk size to 0x1000 when reading nv_dataPaul Kocialkowski2012-07-041-6/+6
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Set nv_data paths functions non-static so they can be reused in device codePaul Kocialkowski2012-07-041-5/+5
| | | | Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
* Allow EFS path to be overriden per-boardAlexander Tarasikov2012-07-041-31/+100
|
* rfs: only dump RFS message content when debugging is enabledSimon Busch2012-02-231-0/+4
|
* rfs: it should be possible for the modem to write at offset zeroSimon Busch2012-02-231-3/+3
|
* Revert "rfs.c: return NULL in case of error"PaulK2012-02-011-1/+1
| | | | This reverts commit b93b917a70a6c85bfa2bd3789989b90b2e530abf.
* rfs.c: return NULL in case of errorPaulK2012-02-011-1/+1
|
* Fixed coding style: space after if, for, while, etcPaulK2012-02-011-37/+37
|
* RFS NV item handling methods are now sending the io confirmation message ↵Simon Busch2012-02-211-9/+6
| | | | directly
* Import two methods from samsung-ril to deal with rfs read/write nv item ↵Simon Busch2012-02-201-1/+66
| | | | message types
* Cleanup indentation in rfs.cSimon Busch2012-02-171-276/+276
| | | | Signed-off-by: Simon Busch <morphis@gravedo.de>
* Moved nv_data functions and headers to rfs.c/rfs.h, plus some fixesPaulK2011-12-311-0/+622