diff mbox

[OpenWrt-Devel,Request,rpcd] file: add reply to write function

Message ID CAPWOPQNL308yzo6WHO0QUK_yCcuk-LLOo9drGKHLW4g6sv0K4A@mail.gmail.com
State Changes Requested
Headers show

Commit Message

Lazar Demin May 18, 2016, 3:09 p.m. UTC
This patch adds a reply to the file write ubus call:
{
"code": 0,
"bytes": 9
}

Where code is the return code of the operation and bytes is the number of
bytes written.

Getting a response is helpful since it lets the user know if the write
operation was successful, knowing the number of bytes written allows for
further error checking.

Can this patch be merged into the rpcd repo?
diff mbox

Patch

Index: rpcd/file.c
===================================================================
--- rpcd.orig/file.c 2016-05-17 22:07:03.679363210 +0000
+++ rpcd/file.c 2016-05-17 22:08:15.627440178 +0000
@@ -315,6 +315,12 @@ 
  close(fd);
  sync();

+ blob_buf_init(&buf, 0);
+ blobmsg_add_u32 (&buf, "code",  rv);
+ blobmsg_add_u32 (&buf, "bytes", (int)data_len);
+ ubus_send_reply (ctx, req, buf.head);
+ blob_buf_free(&buf);
+
  if (rv)
  return rpc_errno_status();