Message ID | 20250304115856.1511495-1-quic_amisjain@quicinc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v5] obex: Add messages_get_message() implementation for MAP plugin | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/BuildEll | success | Build ELL PASS |
tedd_an/BluezMake | success | Bluez Make PASS |
tedd_an/MakeCheck | success | Bluez Make Check PASS |
tedd_an/MakeDistcheck | success | Make Distcheck PASS |
tedd_an/CheckValgrind | success | Check Valgrind PASS |
tedd_an/CheckSmatch | success | CheckSparse PASS |
tedd_an/bluezmakeextell | success | Make External ELL PASS |
tedd_an/ScanBuild | success | Scan Build PASS |
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=940016 ---Test result--- Test Summary: CheckPatch PENDING 0.29 seconds GitLint PENDING 0.30 seconds BuildEll PASS 20.82 seconds BluezMake PASS 1445.51 seconds MakeCheck PASS 12.66 seconds MakeDistcheck PASS 156.73 seconds CheckValgrind PASS 213.15 seconds CheckSmatch PASS 282.63 seconds bluezmakeextell PASS 97.30 seconds IncrementalBuild PENDING 0.36 seconds ScanBuild PASS 863.09 seconds Details ############################## Test: CheckPatch - PENDING Desc: Run checkpatch.pl script Output: ############################## Test: GitLint - PENDING Desc: Run gitlint Output: ############################## Test: IncrementalBuild - PENDING Desc: Incremental build with the patches in the series Output: --- Regards, Linux Bluetooth
diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index 10b972d65..bf8d689ad 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -408,6 +408,7 @@ static void get_message_cb(void *session, int err, gboolean fmore, } g_string_append(mas->buffer, chunk); + mas->finished = TRUE; proceed: if (err != -EAGAIN) @@ -612,11 +613,11 @@ static void *message_open(const char *name, int oflag, mode_t mode, return NULL; } + mas->buffer = g_string_new(""); + *err = messages_get_message(mas->backend_data, name, 0, get_message_cb, mas); - mas->buffer = g_string_new(""); - if (*err < 0) return NULL; else diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index e313c6163..491203a97 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -18,6 +18,8 @@ #include <errno.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> +#include <sys/mman.h> #include "obexd/src/log.h" @@ -516,7 +518,56 @@ int messages_get_message(void *session, const char *handle, messages_get_message_cb callback, void *user_data) { - return -ENOSYS; + struct session *s = session; + FILE *fp; + char *path; + char *msg, *buffer; + int file_size, err = 0; + struct stat file_info; + + DBG(" "); + path = g_build_filename(s->cwd_absolute, handle, NULL); + fp = fopen(path, "r"); + if (fp == NULL) { + DBG("fopen() failed"); + err = -EBADR; + goto file_open_err; + } + + if (fstat (fileno(fp), &file_info) == -1) { + DBG("Error getting file size"); + err = -EBADR; + goto mmap_err; + } + + file_size = file_info.st_size; + + msg = (char *) mmap(0, file_size, PROT_READ, MAP_PRIVATE, fileno(fp), 0); + if (msg == MAP_FAILED) { + DBG("Error mapping file"); + err = -EBADR; + goto mmap_err; + } + + buffer = (char *) malloc(file_size * sizeof(char)); + strcpy(buffer, msg); + + if (callback) + callback(session, 0, 0, buffer, user_data); + + if (munmap(msg, file_size) == -1) { + DBG("Error unmapping"); + err = -EBADR; + goto munmap_err; + } + +munmap_err: + free(buffer); +mmap_err: + fclose(fp); +file_open_err: + g_free(path); + return err; } int messages_update_inbox(void *session, messages_status_cb callback,