Message ID | 20220426000032.622524-1-luiz.dentz@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [BlueZ] client/player: Add transport.receive command | expand |
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=635496 ---Test result--- Test Summary: CheckPatch PASS 1.47 seconds GitLint FAIL 1.00 seconds Prep - Setup ELL PASS 42.46 seconds Build - Prep PASS 0.72 seconds Build - Configure PASS 8.61 seconds Build - Make FAIL 5.64 seconds Make Check FAIL 1.51 seconds Make Check w/Valgrind FAIL 12.79 seconds Make Distcheck FAIL 32.88 seconds Build w/ext ELL - Configure PASS 8.50 seconds Build w/ext ELL - Make FAIL 6.00 seconds Incremental Build with patchesPASS 0.00 seconds Details ############################## Test: GitLint - FAIL Desc: Run gitlint with rule in .gitlint Output: [BlueZ] client/player: Add transport.receive command 9: B3 Line contains hard tab characters (\t): " receive [filename]" ############################## Test: Build - Make - FAIL Desc: Build the BlueZ source tree Output: In file included from /usr/include/fcntl.h:301, from client/player.c:22: In function ‘open’, inlined from ‘open_file’ at client/player.c:2470:7, inlined from ‘cmd_receive_transport’ at client/player.c:2561:17: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 50 | __open_missing_mode (); | ^~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [Makefile:7277: client/player.o] Error 1 make: *** [Makefile:4310: all] Error 2 ############################## Test: Make Check - FAIL Desc: Run 'make check' Output: In file included from /usr/include/fcntl.h:301, from client/player.c:22: In function ‘open’, inlined from ‘open_file’ at client/player.c:2470:7, inlined from ‘cmd_receive_transport’ at client/player.c:2561:17: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 50 | __open_missing_mode (); | ^~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [Makefile:7277: client/player.o] Error 1 make: *** [Makefile:11283: check] Error 2 ############################## Test: Make Check w/Valgrind - FAIL Desc: Run 'make check' with Valgrind Output: In file included from /usr/include/fcntl.h:301, from client/player.c:22: In function ‘open’, inlined from ‘open_file’ at client/player.c:2470:7, inlined from ‘cmd_receive_transport’ at client/player.c:2561:17: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 50 | __open_missing_mode (); | ^~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [Makefile:7277: client/player.o] Error 1 make: *** [Makefile:4310: all] Error 2 ############################## Test: Make Distcheck - FAIL Desc: Run distcheck to check the distribution Output: In file included from /usr/include/fcntl.h:301, from ../../client/player.c:22: In function ‘open’, inlined from ‘open_file’ at ../../client/player.c:2470:7, inlined from ‘cmd_receive_transport’ at ../../client/player.c:2561:17: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 50 | __open_missing_mode (); | ^~~~~~~~~~~~~~~~~~~~~~ make[2]: *** [Makefile:7277: client/player.o] Error 1 make[1]: *** [Makefile:4310: all] Error 2 make: *** [Makefile:11204: distcheck] Error 1 ############################## Test: Build w/ext ELL - Make - FAIL Desc: Build BlueZ source with '--enable-external-ell' configuration Output: In file included from /usr/include/fcntl.h:301, from client/player.c:22: In function ‘open’, inlined from ‘open_file’ at client/player.c:2470:7, inlined from ‘cmd_receive_transport’ at client/player.c:2561:17: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 50 | __open_missing_mode (); | ^~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [Makefile:7277: client/player.o] Error 1 make: *** [Makefile:4310: all] Error 2 --- Regards, Linux Bluetooth
diff --git a/client/player.c b/client/player.c index 315cde712..9f41c1b83 100644 --- a/client/player.c +++ b/client/player.c @@ -81,10 +81,13 @@ static GList *transports = NULL; struct transport { int sk; int mtu[2]; + char *filename; + int fd; struct io *io; uint32_t seq; } transport = { .sk = -1, + .fd = -1, }; static void endpoint_unregister(void *data) @@ -2219,7 +2222,7 @@ static bool transport_disconnected(struct io *io, void *user_data) static bool transport_recv(struct io *io, void *user_data) { uint8_t buf[1024]; - int ret; + int ret, len; ret = read(io_get_fd(io), buf, sizeof(buf)); if (ret < 0) { @@ -2232,6 +2235,13 @@ static bool transport_recv(struct io *io, void *user_data) transport.seq++; + if (transport.fd) { + len = write(transport.fd, buf, ret); + if (len < 0) + bt_shell_printf("Unable to write: %s (%d)", + strerror(errno), -errno); + } + return true; } @@ -2451,13 +2461,13 @@ static void cmd_release_transport(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static int open_file(const char *filename) +static int open_file(const char *filename, int flags) { int fd = -1; bt_shell_printf("Opening %s ...\n", filename); - fd = open(filename, O_RDONLY); + fd = open(filename, flags); if (fd <= 0) bt_shell_printf("Can't open file %s: %s\n", filename, strerror(errno)); @@ -2514,7 +2524,7 @@ static void cmd_send_transport(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } - fd = open_file(argv[1]); + fd = open_file(argv[1], O_RDONLY); bt_shell_printf("Sending ...\n"); err = transport_send(fd); @@ -2527,6 +2537,38 @@ static void cmd_send_transport(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static void transport_close(void) +{ + if (transport.fd < 0) + return; + + close(transport.fd); + transport.fd = -1; + + free(transport.filename); + transport.filename = NULL; +} + +static void cmd_receive_transport(int argc, char *argv[]) +{ + if (argc == 1) { + bt_shell_printf("Filename: %s\n", transport.filename); + return bt_shell_noninteractive_quit(EXIT_SUCCESS); + } + + transport_close(); + + transport.fd = open_file(argv[1], O_RDWR | O_CREAT); + if (transport.fd < 0) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + transport.filename = strdup(argv[1]); + + bt_shell_printf("Filename: %s\n", transport.filename); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + static void volume_callback(const DBusError *error, void *user_data) { if (dbus_error_is_set(error)) { @@ -2589,6 +2631,8 @@ static const struct bt_shell_menu transport_menu = { transport_generator }, { "send", "<filename>", cmd_send_transport, "Send contents of a file" }, + { "receive", "[filename]", cmd_receive_transport, + "Get/Set file to receive" }, { "volume", "<transport> [value]", cmd_volume_transport, "Get/Set transport volume", transport_generator }, @@ -2617,4 +2661,5 @@ void player_add_submenu(void) void player_remove_submenu(void) { g_dbus_client_unref(client); + transport_close(); }
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This adds transport.receive command: Get/Set file to receive Usage: receive [filename] --- client/player.c | 53 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-)