Fixes problems with ubi(fs).
Signed-off-by: Luka Perkov <[email protected]>
---
file.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/file.c b/file.c
index 8eef2b5..f9c65a2 100644
--- a/file.c
+++ b/file.c
@@ -214,8 +214,14 @@ rpc_file_write(struct ubus_context *ctx, struct
ubus_object *obj,
if ((fd = open(blobmsg_data(tb[RPC_F_PATH]), O_CREAT | O_TRUNC |
O_WRONLY)) < 0)
return rpc_errno_status();
- write(fd, blobmsg_data(tb[RPC_F_DATA]),
blobmsg_data_len(tb[RPC_F_DATA]));
+ if (write(fd, blobmsg_data(tb[RPC_F_DATA]),
blobmsg_data_len(tb[RPC_F_DATA])) < 0)
+ return rpc_errno_status();
+
+ if (fsync(fd) < 0)
+ return rpc_errno_status();
+
close(fd);
+ sync();
return 0;
}
--
1.8.5.3
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel