X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=file.c;h=e4c957eef291fa355ab1b4a7b43c851c61057853;hb=4cc6a9deb8eb65c8771ed56ae9fc950f3efa99c6;hp=8eef2b5013acf8c3c6a7f95bfb61d63f5aca622d;hpb=11f5072bb197c8571518222f8d6572b66338dc8d;p=project%2Frpcd.git diff --git a/file.c b/file.c index 8eef2b5..e4c957e 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; } @@ -606,6 +612,6 @@ rpc_file_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx) return ubus_add_object(ctx, &obj); } -const struct rpc_plugin rpc_plugin = { +struct rpc_plugin rpc_plugin = { .init = rpc_file_api_init };