aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-08-31 18:05:15 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-09-21 02:29:38 +0200
commit78f71fc2df35d4f0d259bb7a2591f7c61076ca12 (patch)
tree21afd56e5cb2f62efc6cdbf4e1e1d791f690fb29
parentd32e569d045fa2d7f360b3df955da5bded2e7ef1 (diff)
downloadhardware_replicant_libsamsung-ipc-78f71fc2df35d4f0d259bb7a2591f7c61076ca12.tar.gz
hardware_replicant_libsamsung-ipc-78f71fc2df35d4f0d259bb7a2591f7c61076ca12.tar.bz2
hardware_replicant_libsamsung-ipc-78f71fc2df35d4f0d259bb7a2591f7c61076ca12.zip
samsung-ipc: utils.c: file_data_{read,write}: report open error
Mounting the EFS on your local computer can result in user id and permissions mismatch because the /etc/fstab doesn't always match the user ids used by Android. For instance here's the GT-N7000 EFS on my laptop: $ ls -l [...]/nv_data.bin -rwx------ 1 1001 1001 2097152 1 janv. 2000 [...]/nv_data.bin When using nv_data-md5 on it we have: $ ./tools/nv_data-md5 [...]/nv_data.bin [ipc] file_data_read: Error: fd: -1 [ipc] ipc_nv_data_md5_calculate failed: data is NULL Calculating nv_data backup md5 failed The error was too cryptic, and I ended up having to dig into the source code to understand what was going on. With this patch we now have an error message that is easier to understand: $ ./tools/nv_data-md5 [...]/nv_data.bin [ipc] file_data_read open failed with error 13: Permission denied [ipc] ipc_nv_data_md5_calculate failed: data is NULL Calculating nv_data backup md5 failed Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--samsung-ipc/utils.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/samsung-ipc/utils.c b/samsung-ipc/utils.c
index 85f06cf..0e6bc2f 100644
--- a/samsung-ipc/utils.c
+++ b/samsung-ipc/utils.c
@@ -18,6 +18,7 @@
*/
#include <ctype.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
@@ -70,7 +71,9 @@ void *file_data_read(struct ipc_client *client, const char *path, size_t size,
fd = open(path, O_RDONLY);
if (fd < 0) {
- ipc_client_log(client, "%s: Error: fd: %d ", __func__, fd);
+ rc = errno;
+ ipc_client_log(client, "%s open failed with error %d: %s", __func__, rc,
+ strerror(rc));
goto error;
}
@@ -147,8 +150,9 @@ int file_data_write(struct ipc_client *client, const char *path,
fd = open(path, O_WRONLY | O_CREAT, 0644);
if (fd < 0) {
- ipc_client_log(client, "%s: open failed with error %d",
- __func__, fd);
+ rc = errno;
+ ipc_client_log(client, "%s open failed with error %d: %s",
+ __func__, rc, strerror(rc));
goto error;
}