aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-02-11 18:12:04 +0100
committerPaul Kocialkowski <contact@paulk.fr>2014-02-11 18:12:04 +0100
commite306f8923ecf41d9cdd65f16ff7f0715db447306 (patch)
tree835f7324caa53d1b1666c988a95bbc14cc20d722 /samsung-ipc
parent5482a778f9574c2cf3d941d5065bad58a30d79cc (diff)
downloadexternal_libsamsung-ipc-e306f8923ecf41d9cdd65f16ff7f0715db447306.zip
external_libsamsung-ipc-e306f8923ecf41d9cdd65f16ff7f0715db447306.tar.gz
external_libsamsung-ipc-e306f8923ecf41d9cdd65f16ff7f0715db447306.tar.bz2
rfs: Proper IPC functions for nv_data specs, without generic fallback values
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/devices/aries/aries_ipc.c10
-rw-r--r--samsung-ipc/devices/aries/aries_ipc.h1
-rw-r--r--samsung-ipc/devices/crespo/crespo_ipc.c10
-rw-r--r--samsung-ipc/devices/crespo/crespo_ipc.h1
-rw-r--r--samsung-ipc/devices/galaxys2/galaxys2_ipc.c10
-rw-r--r--samsung-ipc/devices/galaxys2/galaxys2_ipc.h1
-rw-r--r--samsung-ipc/devices/i9300/i9300_ipc.c10
-rw-r--r--samsung-ipc/devices/i9300/i9300_ipc.h1
-rw-r--r--samsung-ipc/devices/maguro/maguro_ipc.c8
-rw-r--r--samsung-ipc/devices/maguro/maguro_ipc.h5
-rw-r--r--samsung-ipc/devices/n7100/n7100_ipc.c10
-rw-r--r--samsung-ipc/devices/n7100/n7100_ipc.h1
-rw-r--r--samsung-ipc/devices/piranha/piranha_ipc.c10
-rw-r--r--samsung-ipc/devices/piranha/piranha_ipc.h1
-rw-r--r--samsung-ipc/devices/xmm6160/xmm6160.c4
-rw-r--r--samsung-ipc/devices/xmm6160/xmm6160.h8
-rw-r--r--samsung-ipc/devices/xmm6260/xmm6260.h8
-rw-r--r--samsung-ipc/devices/xmm6260/xmm6260_hsic.c4
-rw-r--r--samsung-ipc/devices/xmm6260/xmm6260_mipi.c4
-rw-r--r--samsung-ipc/ipc.c70
-rw-r--r--samsung-ipc/ipc.h5
-rw-r--r--samsung-ipc/ipc_devices.c20
-rw-r--r--samsung-ipc/rfs.c239
23 files changed, 226 insertions, 215 deletions
diff --git a/samsung-ipc/devices/aries/aries_ipc.c b/samsung-ipc/devices/aries/aries_ipc.c
index 97df116..40e03d3 100644
--- a/samsung-ipc/devices/aries/aries_ipc.c
+++ b/samsung-ipc/devices/aries/aries_ipc.c
@@ -803,4 +803,14 @@ struct ipc_gprs_specs aries_ipc_gprs_specs = {
.gprs_get_capabilities = aries_ipc_gprs_get_capabilities,
};
+struct ipc_nv_data_specs aries_ipc_nv_data_specs = {
+ .nv_data_path = XMM6160_NV_DATA_PATH,
+ .nv_data_md5_path = XMM6160_NV_DATA_MD5_PATH,
+ .nv_data_backup_path = XMM6160_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = XMM6160_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6160_NV_DATA_SECRET,
+ .nv_data_size = XMM6160_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6160_NV_DATA_CHUNK_SIZE,
+};
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/aries/aries_ipc.h b/samsung-ipc/devices/aries/aries_ipc.h
index e410dd2..bb42f27 100644
--- a/samsung-ipc/devices/aries/aries_ipc.h
+++ b/samsung-ipc/devices/aries/aries_ipc.h
@@ -58,6 +58,7 @@ extern struct ipc_ops aries_ipc_fmt_ops;
extern struct ipc_ops aries_ipc_rfs_ops;
extern struct ipc_handlers aries_ipc_handlers;
extern struct ipc_gprs_specs aries_ipc_gprs_specs;
+extern struct ipc_nv_data_specs aries_ipc_nv_data_specs;
#endif
diff --git a/samsung-ipc/devices/crespo/crespo_ipc.c b/samsung-ipc/devices/crespo/crespo_ipc.c
index 457cd48..b29c4fc 100644
--- a/samsung-ipc/devices/crespo/crespo_ipc.c
+++ b/samsung-ipc/devices/crespo/crespo_ipc.c
@@ -556,4 +556,14 @@ struct ipc_gprs_specs crespo_ipc_gprs_specs = {
.gprs_get_capabilities = crespo_ipc_gprs_get_capabilities,
};
+struct ipc_nv_data_specs crespo_ipc_nv_data_specs = {
+ .nv_data_path = XMM6160_NV_DATA_PATH,
+ .nv_data_md5_path = XMM6160_NV_DATA_MD5_PATH,
+ .nv_data_backup_path = XMM6160_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = XMM6160_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6160_NV_DATA_SECRET,
+ .nv_data_size = XMM6160_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6160_NV_DATA_CHUNK_SIZE,
+};
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/crespo/crespo_ipc.h b/samsung-ipc/devices/crespo/crespo_ipc.h
index 85bf21d..ff984d8 100644
--- a/samsung-ipc/devices/crespo/crespo_ipc.h
+++ b/samsung-ipc/devices/crespo/crespo_ipc.h
@@ -43,6 +43,7 @@ extern struct ipc_ops crespo_ipc_rfs_ops;
extern struct ipc_handlers crespo_ipc_handlers;
extern struct ipc_gprs_specs crespo_ipc_gprs_specs_single;
extern struct ipc_gprs_specs crespo_ipc_gprs_specs;
+extern struct ipc_nv_data_specs crespo_ipc_nv_data_specs;
#endif
diff --git a/samsung-ipc/devices/galaxys2/galaxys2_ipc.c b/samsung-ipc/devices/galaxys2/galaxys2_ipc.c
index 5c1c9c3..44a315b 100644
--- a/samsung-ipc/devices/galaxys2/galaxys2_ipc.c
+++ b/samsung-ipc/devices/galaxys2/galaxys2_ipc.c
@@ -414,4 +414,14 @@ struct ipc_gprs_specs galaxys2_ipc_gprs_specs = {
.gprs_get_capabilities = galaxys2_ipc_gprs_get_capabilities,
};
+struct ipc_nv_data_specs galaxys2_ipc_nv_data_specs = {
+ .nv_data_path = XMM6260_NV_DATA_PATH,
+ .nv_data_md5_path = XMM6260_NV_DATA_MD5_PATH,
+ .nv_data_backup_path = XMM6260_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = XMM6260_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6260_NV_DATA_SECRET,
+ .nv_data_size = XMM6260_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6260_NV_DATA_CHUNK_SIZE,
+};
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/galaxys2/galaxys2_ipc.h b/samsung-ipc/devices/galaxys2/galaxys2_ipc.h
index b8b6a12..7d68465 100644
--- a/samsung-ipc/devices/galaxys2/galaxys2_ipc.h
+++ b/samsung-ipc/devices/galaxys2/galaxys2_ipc.h
@@ -42,6 +42,7 @@ extern struct ipc_ops galaxys2_ipc_fmt_ops;
extern struct ipc_ops galaxys2_ipc_rfs_ops;
extern struct ipc_handlers galaxys2_ipc_handlers;
extern struct ipc_gprs_specs galaxys2_ipc_gprs_specs;
+extern struct ipc_nv_data_specs galaxys2_ipc_nv_data_specs;
#endif
diff --git a/samsung-ipc/devices/i9300/i9300_ipc.c b/samsung-ipc/devices/i9300/i9300_ipc.c
index 59c2eb5..b7364df 100644
--- a/samsung-ipc/devices/i9300/i9300_ipc.c
+++ b/samsung-ipc/devices/i9300/i9300_ipc.c
@@ -408,4 +408,14 @@ struct ipc_gprs_specs i9300_ipc_gprs_specs = {
.gprs_get_capabilities = i9300_ipc_gprs_get_capabilities,
};
+struct ipc_nv_data_specs i9300_ipc_nv_data_specs = {
+ .nv_data_path = XMM6260_NV_DATA_PATH,
+ .nv_data_md5_path = XMM6260_NV_DATA_MD5_PATH,
+ .nv_data_backup_path = XMM6260_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = XMM6260_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6260_NV_DATA_SECRET,
+ .nv_data_size = XMM6260_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6260_NV_DATA_CHUNK_SIZE,
+};
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/i9300/i9300_ipc.h b/samsung-ipc/devices/i9300/i9300_ipc.h
index 6eceb21..901c28d 100644
--- a/samsung-ipc/devices/i9300/i9300_ipc.h
+++ b/samsung-ipc/devices/i9300/i9300_ipc.h
@@ -42,6 +42,7 @@ extern struct ipc_ops i9300_ipc_fmt_ops;
extern struct ipc_ops i9300_ipc_rfs_ops;
extern struct ipc_handlers i9300_ipc_handlers;
extern struct ipc_gprs_specs i9300_ipc_gprs_specs;
+extern struct ipc_nv_data_specs i9300_ipc_nv_data_specs;
#endif
diff --git a/samsung-ipc/devices/maguro/maguro_ipc.c b/samsung-ipc/devices/maguro/maguro_ipc.c
index 9b824a0..15c72ac 100644
--- a/samsung-ipc/devices/maguro/maguro_ipc.c
+++ b/samsung-ipc/devices/maguro/maguro_ipc.c
@@ -393,9 +393,11 @@ struct ipc_gprs_specs maguro_ipc_gprs_specs = {
struct ipc_nv_data_specs maguro_ipc_nv_data_specs = {
.nv_data_path = MAGURO_NV_DATA_PATH,
.nv_data_md5_path = MAGURO_NV_DATA_MD5_PATH,
- .nv_state_path = MAGURO_NV_STATE_PATH,
- .nv_data_bak_path = MAGURO_NV_DATA_BAK_PATH,
- .nv_data_md5_bak_path = MAGURO_NV_DATA_MD5_BAK_PATH,
+ .nv_data_backup_path = MAGURO_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = MAGURO_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6260_NV_DATA_SECRET,
+ .nv_data_size = XMM6260_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6260_NV_DATA_CHUNK_SIZE,
};
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/maguro/maguro_ipc.h b/samsung-ipc/devices/maguro/maguro_ipc.h
index 67836ba..c58178c 100644
--- a/samsung-ipc/devices/maguro/maguro_ipc.h
+++ b/samsung-ipc/devices/maguro/maguro_ipc.h
@@ -38,9 +38,8 @@
#define MAGURO_NV_DATA_PATH "/factory/nv_data.bin"
#define MAGURO_NV_DATA_MD5_PATH "/factory/nv_data.bin.md5"
-#define MAGURO_NV_STATE_PATH "/factory/.nv_state"
-#define MAGURO_NV_DATA_BAK_PATH "/factory/.nv_data.bak"
-#define MAGURO_NV_DATA_MD5_BAK_PATH "/factory/.nv_data.bak.md5"
+#define MAGURO_NV_DATA_BACKUP_PATH "/factory/.nv_data.bak"
+#define MAGURO_NV_DATA_BACKUP_MD5_PATH "/factory/.nv_data.bak.md5"
struct maguro_ipc_transport_data {
int fd;
diff --git a/samsung-ipc/devices/n7100/n7100_ipc.c b/samsung-ipc/devices/n7100/n7100_ipc.c
index 03c30dc..ad118da 100644
--- a/samsung-ipc/devices/n7100/n7100_ipc.c
+++ b/samsung-ipc/devices/n7100/n7100_ipc.c
@@ -408,4 +408,14 @@ struct ipc_gprs_specs n7100_ipc_gprs_specs = {
.gprs_get_capabilities = n7100_ipc_gprs_get_capabilities,
};
+struct ipc_nv_data_specs n7100_ipc_nv_data_specs = {
+ .nv_data_path = XMM6260_NV_DATA_PATH,
+ .nv_data_md5_path = XMM6260_NV_DATA_MD5_PATH,
+ .nv_data_backup_path = XMM6260_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = XMM6260_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6260_NV_DATA_SECRET,
+ .nv_data_size = XMM6260_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6260_NV_DATA_CHUNK_SIZE,
+};
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/n7100/n7100_ipc.h b/samsung-ipc/devices/n7100/n7100_ipc.h
index a081315..0008627 100644
--- a/samsung-ipc/devices/n7100/n7100_ipc.h
+++ b/samsung-ipc/devices/n7100/n7100_ipc.h
@@ -42,6 +42,7 @@ extern struct ipc_ops n7100_ipc_fmt_ops;
extern struct ipc_ops n7100_ipc_rfs_ops;
extern struct ipc_handlers n7100_ipc_handlers;
extern struct ipc_gprs_specs n7100_ipc_gprs_specs;
+extern struct ipc_nv_data_specs n7100_ipc_nv_data_specs;
#endif
diff --git a/samsung-ipc/devices/piranha/piranha_ipc.c b/samsung-ipc/devices/piranha/piranha_ipc.c
index 5bdd0cd..88754dd 100644
--- a/samsung-ipc/devices/piranha/piranha_ipc.c
+++ b/samsung-ipc/devices/piranha/piranha_ipc.c
@@ -355,4 +355,14 @@ struct ipc_gprs_specs piranha_ipc_gprs_specs = {
.gprs_get_capabilities = piranha_ipc_gprs_get_capabilities,
};
+struct ipc_nv_data_specs piranha_ipc_nv_data_specs = {
+ .nv_data_path = XMM6260_NV_DATA_PATH,
+ .nv_data_md5_path = XMM6260_NV_DATA_MD5_PATH,
+ .nv_data_backup_path = XMM6260_NV_DATA_BACKUP_PATH,
+ .nv_data_backup_md5_path = XMM6260_NV_DATA_BACKUP_MD5_PATH,
+ .nv_data_secret = XMM6260_NV_DATA_SECRET,
+ .nv_data_size = XMM6260_NV_DATA_SIZE,
+ .nv_data_chunk_size = XMM6260_NV_DATA_CHUNK_SIZE,
+};
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/devices/piranha/piranha_ipc.h b/samsung-ipc/devices/piranha/piranha_ipc.h
index 5c857fc..7cff520 100644
--- a/samsung-ipc/devices/piranha/piranha_ipc.h
+++ b/samsung-ipc/devices/piranha/piranha_ipc.h
@@ -43,6 +43,7 @@ extern struct ipc_ops piranha_ipc_rfs_ops;
extern struct ipc_handlers piranha_ipc_handlers;
extern struct ipc_gprs_specs piranha_ipc_gprs_specs;
extern struct ipc_nv_data_specs piranha_ipc_nv_data_specs;
+extern struct ipc_nv_data_specs piranha_ipc_nv_data_specs;
#endif
diff --git a/samsung-ipc/devices/xmm6160/xmm6160.c b/samsung-ipc/devices/xmm6160/xmm6160.c
index 8374541..2af6837 100644
--- a/samsung-ipc/devices/xmm6160/xmm6160.c
+++ b/samsung-ipc/devices/xmm6160/xmm6160.c
@@ -252,7 +252,7 @@ int xmm6160_nv_data_send(struct ipc_client *client, int device_fd,
}
ipc_client_log(client, "Checked nv_data md5");
- nv_data = file_data_read(nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client));
+ nv_data = file_data_read(ipc_client_nv_data_path(client), ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
if (nv_data == NULL) {
ipc_client_log(client, "Reading nv_data failed");
goto error;
@@ -260,7 +260,7 @@ int xmm6160_nv_data_send(struct ipc_client *client, int device_fd,
ipc_client_log(client, "Read nv_data");
p = (unsigned char *) nv_data;
- nv_size = nv_data_size(client);
+ nv_size = ipc_client_nv_data_size(client);
if (device_address != NULL) {
memcpy(device_address, p, nv_size);
diff --git a/samsung-ipc/devices/xmm6160/xmm6160.h b/samsung-ipc/devices/xmm6160/xmm6160.h
index 2d2bdf9..14f337a 100644
--- a/samsung-ipc/devices/xmm6160/xmm6160.h
+++ b/samsung-ipc/devices/xmm6160/xmm6160.h
@@ -28,6 +28,14 @@
#define XMM6160_PSI_ACK 0x01
#define XMM6160_BOOTCORE_VERSION 0xF0
+#define XMM6160_NV_DATA_PATH "/efs/nv_data.bin"
+#define XMM6160_NV_DATA_MD5_PATH "/efs/nv_data.bin.md5"
+#define XMM6160_NV_DATA_BACKUP_PATH "/efs/.nv_data.bak"
+#define XMM6160_NV_DATA_BACKUP_MD5_PATH "/efs/.nv_data.bak.md5"
+#define XMM6160_NV_DATA_SECRET "Samsung_Android_RIL"
+#define XMM6160_NV_DATA_SIZE 0x200000
+#define XMM6160_NV_DATA_CHUNK_SIZE 0x1000
+
int xmm6160_psi_send(struct ipc_client *client, int serial_fd,
void *psi_data, unsigned short psi_size);
int xmm6160_firmware_send(struct ipc_client *client, int device_fd,
diff --git a/samsung-ipc/devices/xmm6260/xmm6260.h b/samsung-ipc/devices/xmm6260/xmm6260.h
index 64f7938..c116ede 100644
--- a/samsung-ipc/devices/xmm6260/xmm6260.h
+++ b/samsung-ipc/devices/xmm6260/xmm6260.h
@@ -38,6 +38,14 @@
#define XMM6260_NV_DATA_ADDRESS 0x60E80000
#define XMM6260_MPS_DATA_ADDRESS 0x61080000
+#define XMM6260_NV_DATA_PATH "/efs/nv_data.bin"
+#define XMM6260_NV_DATA_MD5_PATH "/efs/nv_data.bin.md5"
+#define XMM6260_NV_DATA_BACKUP_PATH "/efs/.nv_data.bak"
+#define XMM6260_NV_DATA_BACKUP_MD5_PATH "/efs/.nv_data.bak.md5"
+#define XMM6260_NV_DATA_SECRET "Samsung_Android_RIL"
+#define XMM6260_NV_DATA_SIZE 0x200000
+#define XMM6260_NV_DATA_CHUNK_SIZE 0x1000
+
unsigned char xmm6260_crc_calculate(void *buffer, int length);
#endif
diff --git a/samsung-ipc/devices/xmm6260/xmm6260_hsic.c b/samsung-ipc/devices/xmm6260/xmm6260_hsic.c
index e4162ae..ed3b453 100644
--- a/samsung-ipc/devices/xmm6260/xmm6260_hsic.c
+++ b/samsung-ipc/devices/xmm6260/xmm6260_hsic.c
@@ -561,14 +561,14 @@ int xmm6260_hsic_nv_data_send(struct ipc_client *client, int device_fd)
}
ipc_client_log(client, "Checked nv_data md5");
- nv_data = file_data_read(nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client));
+ nv_data = file_data_read(ipc_client_nv_data_path(client), ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
if (nv_data == NULL) {
ipc_client_log(client, "Reading nv_data failed");
goto error;
}
ipc_client_log(client, "Read nv_data");
- nv_size = nv_data_size(client);
+ nv_size = ipc_client_nv_data_size(client);
rc = xmm6260_hsic_modem_data_send(device_fd, nv_data, nv_size, XMM6260_NV_DATA_ADDRESS);
if (rc < 0)
diff --git a/samsung-ipc/devices/xmm6260/xmm6260_mipi.c b/samsung-ipc/devices/xmm6260/xmm6260_mipi.c
index df31755..4f11361 100644
--- a/samsung-ipc/devices/xmm6260/xmm6260_mipi.c
+++ b/samsung-ipc/devices/xmm6260/xmm6260_mipi.c
@@ -611,14 +611,14 @@ int xmm6260_mipi_nv_data_send(struct ipc_client *client, int device_fd)
}
ipc_client_log(client, "Checked nv_data md5");
- nv_data = file_data_read(nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client));
+ nv_data = file_data_read(ipc_client_nv_data_path(client), ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
if (nv_data == NULL) {
ipc_client_log(client, "Reading nv_data failed");
goto error;
}
ipc_client_log(client, "Read nv_data");
- nv_size = nv_data_size(client);
+ nv_size = ipc_client_nv_data_size(client);
rc = xmm6260_mipi_modem_data_send(device_fd, nv_data, nv_size, XMM6260_NV_DATA_ADDRESS);
if (rc < 0)
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index 26716af..553880f 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -444,4 +444,74 @@ int ipc_client_gprs_get_capabilities(struct ipc_client *client,
return client->gprs_specs->gprs_get_capabilities(capabilities);
}
+char *ipc_client_nv_data_path(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_path == NULL)
+ return NULL;
+
+ return client->nv_data_specs->nv_data_path;
+}
+
+char *ipc_client_nv_data_md5_path(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_md5_path == NULL)
+ return NULL;
+
+ return client->nv_data_specs->nv_data_md5_path;
+}
+
+char *ipc_client_nv_data_backup_path(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_backup_path == NULL)
+ return NULL;
+
+ return client->nv_data_specs->nv_data_backup_path;
+}
+
+char *ipc_client_nv_data_backup_md5_path(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_backup_md5_path == NULL)
+ return NULL;
+
+ return client->nv_data_specs->nv_data_backup_md5_path;
+}
+
+char *ipc_client_nv_data_secret(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_secret == NULL)
+ return NULL;
+
+ return client->nv_data_specs->nv_data_secret;
+}
+
+int ipc_client_nv_data_size(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_size == 0)
+ return -1;
+
+ return client->nv_data_specs->nv_data_size;
+}
+
+int ipc_client_nv_data_chunk_size(struct ipc_client *client)
+{
+ if (client == NULL ||
+ client->nv_data_specs == NULL ||
+ client->nv_data_specs->nv_data_chunk_size == 0)
+ return -1;
+
+ return client->nv_data_specs->nv_data_chunk_size;
+}
+
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/ipc.h b/samsung-ipc/ipc.h
index 7e98004..0017994 100644
--- a/samsung-ipc/ipc.h
+++ b/samsung-ipc/ipc.h
@@ -71,9 +71,8 @@ struct ipc_gprs_specs {
struct ipc_nv_data_specs {
char *nv_data_path;
char *nv_data_md5_path;
- char *nv_data_bak_path;
- char *nv_data_md5_bak_path;
- char *nv_state_path;
+ char *nv_data_backup_path;
+ char *nv_data_backup_md5_path;
char *nv_data_secret;
int nv_data_size;
int nv_data_chunk_size;
diff --git a/samsung-ipc/ipc_devices.c b/samsung-ipc/ipc_devices.c
index 13044c9..dec61c2 100644
--- a/samsung-ipc/ipc_devices.c
+++ b/samsung-ipc/ipc_devices.c
@@ -32,7 +32,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &crespo_ipc_rfs_ops,
.handlers = &crespo_ipc_handlers,
.gprs_specs = &crespo_ipc_gprs_specs_single,
- .nv_data_specs = NULL,
+ .nv_data_specs = &crespo_ipc_nv_data_specs,
},
{
.name = "crespo",
@@ -42,7 +42,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &crespo_ipc_rfs_ops,
.handlers = &crespo_ipc_handlers,
.gprs_specs = &crespo_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &crespo_ipc_nv_data_specs,
},
{
.name = "aries",
@@ -52,7 +52,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &aries_ipc_rfs_ops,
.handlers = &aries_ipc_handlers,
.gprs_specs = &aries_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &aries_ipc_nv_data_specs,
},
{
.name = "aries",
@@ -62,7 +62,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &aries_ipc_rfs_ops,
.handlers = &aries_ipc_handlers,
.gprs_specs = &aries_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &aries_ipc_nv_data_specs,
},
{
.name = "galaxys2",
@@ -72,7 +72,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &galaxys2_ipc_rfs_ops,
.handlers = &galaxys2_ipc_handlers,
.gprs_specs = &galaxys2_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &galaxys2_ipc_nv_data_specs,
},
{
.name = "galaxys2",
@@ -82,7 +82,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &galaxys2_ipc_rfs_ops,
.handlers = &galaxys2_ipc_handlers,
.gprs_specs = &galaxys2_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &galaxys2_ipc_nv_data_specs,
},
{
.name = "maguro",
@@ -102,7 +102,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &piranha_ipc_rfs_ops,
.handlers = &piranha_ipc_handlers,
.gprs_specs = &piranha_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &piranha_ipc_nv_data_specs,
},
{
.name = "piranha",
@@ -112,7 +112,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &piranha_ipc_rfs_ops,
.handlers = &piranha_ipc_handlers,
.gprs_specs = &piranha_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &piranha_ipc_nv_data_specs,
},
{
.name = "i9300",
@@ -122,7 +122,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &i9300_ipc_rfs_ops,
.handlers = &i9300_ipc_handlers,
.gprs_specs = &i9300_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &i9300_ipc_nv_data_specs,
},
{
.name = "n7100",
@@ -132,7 +132,7 @@ struct ipc_device_desc ipc_devices[] = {
.rfs_ops = &n7100_ipc_rfs_ops,
.handlers = &n7100_ipc_handlers,
.gprs_specs = &n7100_ipc_gprs_specs,
- .nv_data_specs = NULL,
+ .nv_data_specs = &n7100_ipc_nv_data_specs,
},
};
diff --git a/samsung-ipc/rfs.c b/samsung-ipc/rfs.c
index 0607abe..a386775 100644
--- a/samsung-ipc/rfs.c
+++ b/samsung-ipc/rfs.c
@@ -33,6 +33,8 @@
#include "ipc.h"
#include "util.h"
+#define MD5_STRING_SIZE MD5_DIGEST_LENGTH * 2 + 1
+
void md5hash2string(char *out, unsigned char *in)
{
int i;
@@ -50,86 +52,6 @@ void md5hash2string(char *out, unsigned char *in)
}
}
-char *nv_data_path(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_path == NULL)
- return NV_DATA_PATH_DEFAULT;
-
- return client->nv_data_specs->nv_data_path;
-}
-
-char *nv_data_md5_path(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_md5_path == NULL)
- return NV_DATA_MD5_PATH_DEFAULT;
-
- return client->nv_data_specs->nv_data_md5_path;
-}
-
-char *nv_data_bak_path(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_bak_path == NULL)
- return NV_DATA_BAK_PATH_DEFAULT;
-
- return client->nv_data_specs->nv_data_bak_path;
-}
-
-char *nv_data_md5_bak_path(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_md5_bak_path == NULL)
- return NV_DATA_MD5_BAK_PATH_DEFAULT;
-
- return client->nv_data_specs->nv_data_md5_bak_path;
-}
-
-char *nv_state_path(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_state_path == NULL)
- return NV_STATE_PATH_DEFAULT;
-
- return client->nv_data_specs->nv_state_path;
-}
-
-char *nv_data_secret(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_secret == NULL)
- return NV_DATA_SECRET_DEFAULT;
-
- return client->nv_data_specs->nv_data_secret;
-}
-
-int nv_data_size(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_size == 0)
- return NV_DATA_SIZE_DEFAULT;
-
- return client->nv_data_specs->nv_data_size;
-}
-
-int nv_data_chunk_size(struct ipc_client *client)
-{
- if (client == NULL ||
- client->nv_data_specs == NULL ||
- client->nv_data_specs->nv_data_chunk_size == 0)
- return NV_DATA_CHUNK_SIZE_DEFAULT;
-
- return client->nv_data_specs->nv_data_chunk_size;
-}
-
void nv_data_generate(struct ipc_client *client)
{
return;
@@ -156,9 +78,9 @@ void nv_data_md5_generate(struct ipc_client *client)
ipc_client_log(client, "nv_data_md5_generate: enter");
ipc_client_log(client, "nv_data_md5_generate: generating MD5 hash");
- nv_data_p = file_data_read(nv_data_path(client),
- nv_data_size(client), nv_data_chunk_size(client));
- nv_data_md5_compute(nv_data_p, nv_data_size(client), nv_data_secret(client), nv_data_md5_hash);
+ nv_data_p = file_data_read(ipc_client_nv_data_path(client),
+ ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
+ nv_data_md5_compute(nv_data_p, ipc_client_nv_data_size(client), ipc_client_nv_data_secret(client), nv_data_md5_hash);
free(nv_data_p);
/* Alloc the memory for the md5 hash string. */
@@ -172,7 +94,7 @@ void nv_data_md5_generate(struct ipc_client *client)
ipc_client_log(client, "nv_data_md5_generate: writing MD5 hash");
/* Write the MD5 hash in nv_data.bin.md5. */
- fd = open(nv_data_md5_path(client), O_RDWR | O_CREAT | O_TRUNC, 0644);
+ fd = open(ipc_client_nv_data_md5_path(client), O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
{
ipc_client_log(client, "nv_data_md5_generate: fd open failed");
@@ -214,20 +136,20 @@ void nv_data_backup_create(struct ipc_client *client)
ipc_client_log(client, "nv_data_backup_create: enter");
- if (stat(nv_data_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_backup_create: nv_data.bin missing");
nv_data_generate(client);
}
- if (nv_stat.st_size != nv_data_size(client))
+ if (nv_stat.st_size != ipc_client_nv_data_size(client))
{
ipc_client_log(client, "nv_data_backup_create: wrong nv_data.bin size");
nv_data_generate(client);
return;
}
- if (stat(nv_data_md5_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_md5_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_backup_create: nv_data.bin.md5 missing");
nv_data_generate(client);
@@ -242,15 +164,15 @@ void nv_data_backup_create(struct ipc_client *client)
memset(nv_data_md5_hash_string, 0, MD5_STRING_SIZE);
/* Read the content of the backup file. */
- nv_data_p = file_data_read(nv_data_path(client),
- nv_data_size(client), nv_data_chunk_size(client));
+ nv_data_p = file_data_read(ipc_client_nv_data_path(client),
+ ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
/* Compute the backup file MD5 hash. */
- nv_data_md5_compute(nv_data_p, nv_data_size(client), nv_data_secret(client), nv_data_md5_hash);
+ nv_data_md5_compute(nv_data_p, ipc_client_nv_data_size(client), ipc_client_nv_data_secret(client), nv_data_md5_hash);
md5hash2string(nv_data_md5_hash_string, nv_data_md5_hash);
/* Read the stored backup file MD5 hash. */
- fd = open(nv_data_md5_path(client), O_RDONLY);
+ fd = open(ipc_client_nv_data_md5_path(client), O_RDONLY);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_create: failed to openstored backup file with MD5 hash");
@@ -278,7 +200,7 @@ void nv_data_backup_create(struct ipc_client *client)
ipc_client_log(client, "nv_data_backup_create: MD5 hash mismatch on backup file");
ipc_client_log(client, "nv_data_backup_create: Consider the computed one as correct");
- fd = open(nv_data_md5_path(client), O_WRONLY);
+ fd = open(ipc_client_nv_data_md5_path(client), O_WRONLY);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_create: failed to open file with MD5 hash of data file");
@@ -310,7 +232,7 @@ nv_data_backup_create_write:
{
ipc_client_log(client, "nv_data_backup_create: .nv_data.bak write try #%d", nv_data_write_tries + 1);
- fd = open(nv_data_bak_path(client), O_RDWR | O_CREAT | O_TRUNC, 0644);
+ fd = open(ipc_client_nv_data_backup_path(client), O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_create: negative fd while opening /efs/.nv_data.bak, error: %s", strerror(errno));
@@ -318,8 +240,8 @@ nv_data_backup_create_write:
continue;
}
- rc = write(fd, nv_data_p, nv_data_size(client));
- if (rc < nv_data_size(client))
+ rc = write(fd, nv_data_p, ipc_client_nv_data_size(client));
+ if (rc < ipc_client_nv_data_size(client))
{
ipc_client_log(client, "nv_data_backup_create: wrote less (%d) than what we expected (%d) on /efs/.nv_data.bak, error: %s", strerror(errno));
close(fd);
@@ -334,16 +256,16 @@ nv_data_backup_create_write:
if (nv_data_write_tries == 5)
{
ipc_client_log(client, "nv_data_backup_create: writing nv_data.bin to .nv_data.bak failed too many times");
- unlink(nv_data_bak_path(client));
+ unlink(ipc_client_nv_data_backup_path(client));
goto exit;
}
/* Read the newly-written .nv_data.bak. */
- nv_data_bak_p = file_data_read(nv_data_bak_path(client),
- nv_data_size(client), nv_data_chunk_size(client));
+ nv_data_bak_p = file_data_read(ipc_client_nv_data_backup_path(client),
+ ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
/* Compute the MD5 hash for nv_data.bin. */
- nv_data_md5_compute(nv_data_bak_p, nv_data_size(client), nv_data_secret(client), nv_data_md5_hash);
+ nv_data_md5_compute(nv_data_bak_p, ipc_client_nv_data_size(client), ipc_client_nv_data_secret(client), nv_data_md5_hash);
md5hash2string(nv_data_md5_hash_string, nv_data_md5_hash);
if (nv_data_bak_p != NULL)
@@ -362,7 +284,7 @@ nv_data_backup_create_write:
}
/* Write the MD5 hash in .nv_data.bak.md5. */
- fd = open(nv_data_md5_bak_path(client), O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ fd = open(ipc_client_nv_data_backup_md5_path(client), O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_create: failed to open MD5 hash file");
@@ -378,25 +300,6 @@ nv_data_backup_create_write:
}
close(fd);
- /* Write the correct .nv_state. */
- fd = open(nv_state_path(client), O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd < 0)
- {
- ipc_client_log(client, "nv_data_backup_create: failed to open NV state file");
- goto exit;
- }
-
- data = '1';
- rc = write(fd, &data, sizeof(data));
- if (rc < 0)
- {
- ipc_client_log(client, "nv_data_backup_create: failed to write state of NV data");
- close(fd);
- goto exit;
- }
-
- close(fd);
-
exit:
if (nv_data_p != NULL)
free(nv_data_p);
@@ -426,7 +329,7 @@ void nv_data_backup_restore(struct ipc_client *client)
ipc_client_log(client, "nv_data_backup_restore: enter");
- if (stat(nv_data_bak_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_backup_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_backup_restore: .nv_data.bak missing");
nv_data_generate(client);
@@ -434,7 +337,7 @@ void nv_data_backup_restore(struct ipc_client *client)
return;
}
- if (nv_stat.st_size != nv_data_size(client))
+ if (nv_stat.st_size != ipc_client_nv_data_size(client))
{
ipc_client_log(client, "nv_data_backup_restore: wrong .nv_data.bak size");
nv_data_generate(client);
@@ -442,7 +345,7 @@ void nv_data_backup_restore(struct ipc_client *client)
return;
}
- if (stat(nv_data_md5_bak_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_backup_md5_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_backup_restore: .nv_data.bak.md5 missing");
nv_data_generate(client);
@@ -458,15 +361,15 @@ void nv_data_backup_restore(struct ipc_client *client)
memset(nv_data_md5_hash_string, 0, MD5_STRING_SIZE);
/* Read the content of the backup file. */
- nv_data_bak_p = file_data_read(nv_data_bak_path(client),
- nv_data_size(client), nv_data_chunk_size(client));
+ nv_data_bak_p = file_data_read(ipc_client_nv_data_backup_path(client),
+ ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
/* Compute the backup file MD5 hash. */
- nv_data_md5_compute(nv_data_bak_p, nv_data_size(client), nv_data_secret(client), nv_data_md5_hash);
+ nv_data_md5_compute(nv_data_bak_p, ipc_client_nv_data_size(client), ipc_client_nv_data_secret(client), nv_data_md5_hash);
md5hash2string(nv_data_md5_hash_string, nv_data_md5_hash);
/* Read the stored backup file MD5 hash. */
- fd = open(nv_data_md5_bak_path(client), O_RDONLY);
+ fd = open(ipc_client_nv_data_backup_md5_path(client), O_RDONLY);
rc = read(fd, nv_data_md5_hash_read, MD5_STRING_SIZE);
if (rc < 0)
{
@@ -488,7 +391,7 @@ void nv_data_backup_restore(struct ipc_client *client)
ipc_client_log(client, "nv_data_backup_restore: MD5 hash mismatch on backup file");
ipc_client_log(client, "nv_data_backup_restore: Consider the computed one as correct");
- fd = open(nv_data_md5_bak_path(client), O_WRONLY);
+ fd = open(ipc_client_nv_data_backup_md5_path(client), O_WRONLY);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_restore: failed to open MD5 hash backup file");
@@ -521,7 +424,7 @@ nv_data_backup_restore_write:
{
ipc_client_log(client, "nv_data_backup_restore: nv_data.bin write try #%d", nv_data_write_tries + 1);
- fd = open(nv_data_path(client), O_RDWR | O_CREAT | O_TRUNC, 0644);
+ fd = open(ipc_client_nv_data_path(client), O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_restore: negative fd while opening /efs/nv_data.bin, error: %s", strerror(errno));
@@ -529,8 +432,8 @@ nv_data_backup_restore_write:
continue;
}
- rc = write(fd, nv_data_bak_p, nv_data_size(client));
- if (rc < nv_data_size(client))
+ rc = write(fd, nv_data_bak_p, ipc_client_nv_data_size(client));
+ if (rc < ipc_client_nv_data_size(client))
{
ipc_client_log(client, "nv_data_backup_restore: wrote less (%d) than what we expected (%d) on /efs/nv_data.bin, error: %s", strerror(errno));
close(fd);
@@ -545,16 +448,16 @@ nv_data_backup_restore_write:
if (nv_data_write_tries == 5)
{
ipc_client_log(client, "nv_data_backup_restore: writing the backup to nv_data.bin failed too many times");
- unlink(nv_data_path(client));
+ unlink(ipc_client_nv_data_path(client));
goto exit;
}
/* Read the newly-written nv_data.bin. */
- nv_data_p = file_data_read(nv_data_path(client),
- nv_data_size(client), nv_data_chunk_size(client));
+ nv_data_p = file_data_read(ipc_client_nv_data_path(client),
+ ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
/* Compute the MD5 hash for nv_data.bin. */
- nv_data_md5_compute(nv_data_p, nv_data_size(client), nv_data_secret(client), nv_data_md5_hash);
+ nv_data_md5_compute(nv_data_p, ipc_client_nv_data_size(client), ipc_client_nv_data_secret(client), nv_data_md5_hash);
md5hash2string(nv_data_md5_hash_string, nv_data_md5_hash);
if (nv_data_p != NULL)
@@ -576,7 +479,7 @@ nv_data_backup_restore_write:
}
/* Write the MD5 hash in nv_data.bin.md5. */
- fd = open(nv_data_md5_path(client), O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ fd = open(ipc_client_nv_data_md5_path(client), O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
{
ipc_client_log(client, "nv_data_backup_restore: failed to open file with MD5 hash");
@@ -592,25 +495,6 @@ nv_data_backup_restore_write:
}
close(fd);
- /* Write the correct .nv_state. */
- fd = open(nv_state_path(client), O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd < 0)
- {
- ipc_client_log(client, "nv_data_backup_restore: failed to open NV state file");
- goto exit;
- }
-
- data = '1';
- rc = write(fd, &data, sizeof(data));
- if (rc < 0)
- {
- ipc_client_log(client, "nv_data_backup_restore: failed to write state to file");
- close(fd);
- goto exit;
- }
-
- close(fd);
-
exit:
if (nv_data_bak_p != NULL)
free(nv_data_bak_p);
@@ -625,60 +509,35 @@ exit:
int nv_data_check(struct ipc_client *client)
{
struct stat nv_stat;
- int nv_state_fd = -1;
- int nv_state = 0;
int rc;
ipc_client_log(client, "nv_data_check: enter");
- if (stat(nv_data_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_check: nv_data.bin missing");
nv_data_backup_restore(client);
- stat(nv_data_path(client), &nv_stat);
+ stat(ipc_client_nv_data_path(client), &nv_stat);
}
- if (nv_stat.st_size != nv_data_size(client))
+ if (nv_stat.st_size != ipc_client_nv_data_size(client))
{
ipc_client_log(client, "nv_data_check: wrong nv_data.bin size");
nv_data_backup_restore(client);
}
- if (stat(nv_data_md5_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_md5_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_check: nv_data.bin.md5 missing");
nv_data_backup_restore(client);
}
- if (stat(nv_data_bak_path(client), &nv_stat) < 0 || stat(nv_data_md5_bak_path(client), &nv_stat) < 0)
+ if (stat(ipc_client_nv_data_backup_path(client), &nv_stat) < 0 || stat(ipc_client_nv_data_backup_md5_path(client), &nv_stat) < 0)
{
ipc_client_log(client, "nv_data_check: .nv_data.bak or .nv_data.bak.md5 missing");
nv_data_backup_create(client);
}
- nv_state_fd = open(nv_state_path(client), O_RDONLY);
-
- if (nv_state_fd < 0 || fstat(nv_state_fd, &nv_stat) < 0)
- {
- ipc_client_log(client, "nv_data_check: .nv_state missing");
- nv_data_backup_restore(client);
- }
-
- rc = read(nv_state_fd, &nv_state, sizeof(nv_state));
- if (rc < 0)
- {
- ipc_client_log(client, "nv_data_check: couldn't read state of NV item from file");
- return -1;
- }
-
- close(nv_state_fd);
-
- if (nv_state != '1')
- {
- ipc_client_log(client, "nv_data_check: bad nv_state");
- nv_data_backup_restore(client);
- }
-
ipc_client_log(client, "nv_data_check: everything should be alright");
ipc_client_log(client, "nv_data_check: exit");
@@ -704,17 +563,17 @@ int nv_data_md5_check(struct ipc_client *client)
memset(nv_data_md5_hash_read, 0, MD5_STRING_SIZE);
memset(nv_data_md5_hash_string, 0, MD5_STRING_SIZE);
- nv_data_p = file_data_read(nv_data_path(client),
- nv_data_size(client), nv_data_chunk_size(client));
+ nv_data_p = file_data_read(ipc_client_nv_data_path(client),
+ ipc_client_nv_data_size(client), ipc_client_nv_data_chunk_size(client));
data_p = nv_data_p;
- nv_data_md5_compute(data_p, nv_data_size(client), nv_data_secret(client), nv_data_md5_hash);
+ nv_data_md5_compute(data_p, ipc_client_nv_data_size(client), ipc_client_nv_data_secret(client), nv_data_md5_hash);
md5hash2string(nv_data_md5_hash_string, nv_data_md5_hash);
free(nv_data_p);
- fd = open(nv_data_md5_path(client), O_RDONLY);
+ fd = open(ipc_client_nv_data_md5_path(client), O_RDONLY);
/* Read the md5 stored in the file. */
rc = read(fd, nv_data_md5_hash_read, MD5_STRING_SIZE);
@@ -766,7 +625,7 @@ int nv_data_read(struct ipc_client *client, int offset, int length, char *buf)
if (nv_data_check(client) < 0)
return -1;
- fd = open(nv_data_path(client), O_RDONLY);
+ fd = open(ipc_client_nv_data_path(client), O_RDONLY);
if (fd < 0) {
ipc_client_log(client, "nv_data_read: nv_data file fd is negative");
return -1;
@@ -805,7 +664,7 @@ int nv_data_write(struct ipc_client *client, int offset, int length, char *buf)
if (nv_data_check(client) < 0)
return -1;
- fd = open(nv_data_path(client), O_WRONLY);
+ fd = open(ipc_client_nv_data_path(client), O_WRONLY);
if (fd < 0) {
ipc_client_log(client, "nv_data_write: nv_data file fd is negative");
return -1;