4 Commits
Author SHA1 Message Date
Richard Acayan 0b4c7bffaf fastrpc: hexagonrpcd: hexagonfs: mapped: return NULL for empty dirs
The mapped_or_empty file implementation uses NULL to denote when an
empty directory should be in place of a non-existent file. Changing the
pointer to the output has no effect. Change the implementation data to a
NULL pointer so empty directories function properly.
2023-12-04 19:50:34 -05:00
Richard Acayan 00b5f80608 fastrpc: hexagonrpcd: hexagonfs: initialize is_assigned in from_dirent
The is_assigned attribute should only be true when it is assigned a
numeric ID, otherwise it will not be closed. The from_dirent operations
in the implementations of a file type do not use the calloc() function,
so the is_assigned attribute is uninitialized. Initialize it to zero so
the open file can be closed when requested.
2023-12-04 19:50:24 -05:00
Richard Acayan 9ea9bed77b fastrpc: hexagonrpcd: listener: do not attempt to allocate zero outbufs
The malloc(3p) manual page states that an implementation may choose to
return a non-NULL pointer when the size is zero. This function assumes
that there is an element in the array if the pointer is not NULL. When
the size is zero, skip the allocation and return NULL.
2023-12-04 19:50:11 -05:00
Richard Acayan 23585daf67 qmi: add generated substitute
The qmic utility is rarely packaged in mainstream distributions, making
it inconvenient to set up a working build environment. Add generated
source files to enable compilation without qmic installed.
2023-12-04 19:49:59 -05:00
7 changed files with 142 additions and 7 deletions

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ which lines were entered by the user.
- libqrtr
- meson or make
- protobuf-c
- qmic (https://github.com/andersson/qmic)
- qmic (optional for regenerating QMI, at https://github.com/andersson/qmic)
# Installation
+2 -1
View File
@@ -110,6 +110,7 @@ static int mapped_openat(struct hexagonfs_fd *dir,
ctx->dir = NULL;
fd->is_assigned = false;
fd->up = dir;
fd->ops = &hexagonfs_mapped_ops;
fd->data = ctx;
@@ -227,7 +228,7 @@ static int mapped_or_empty_from_dirent(void *dirent_data, bool dir, void **fd_da
ret = mapped_from_dirent(dirent_data, dir, fd_data);
if (ret)
fd_data = NULL;
*fd_data = NULL;
return 0;
}
+2
View File
@@ -20,6 +20,7 @@
*/
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -69,6 +70,7 @@ static int virt_dir_openat(struct hexagonfs_fd *dir,
if (fd == NULL)
return -ENOMEM;
fd->is_assigned = false;
fd->up = dir;
fd->ops = ent->ops;
+8
View File
@@ -73,6 +73,14 @@ static struct fastrpc_io_buffer *allocate_outbufs(const struct fastrpc_function_
off_t off;
uint32_t *sizes;
/*
* POSIX allows malloc to return a non-NULL pointer to a zero-size area
* in memory. Since the code below assumes non-zero size if the pointer
* is non-NULL, exit early if we do not need to allocate anything.
*/
if (out_count == 0)
return NULL;
out_count = def->out_bufs + (def->out_nums && 1);
out = malloc(sizeof(struct fastrpc_io_buffer) * out_count);
if (out == NULL)
+12 -5
View File
@@ -19,10 +19,17 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
qmic = find_program('qmic')
qmic = find_program('qmic', required : false)
wrapper = files('qmic_wrapper.sh')
qmi = custom_target('qmi_sns_client',
command : [wrapper, qmic, '@INPUT@', '@OUTDIR@'],
input : 'sns_client.qmi',
output : ['qmi_sns_client.c', 'qmi_sns_client.h'])
if qmic.found()
qmi = custom_target('qmi_sns_client',
command : [wrapper, qmic, '@INPUT@', '@OUTDIR@'],
input : 'sns_client.qmi',
output : ['qmi_sns_client.c', 'qmi_sns_client.h'])
else
qmi = custom_target('qmi_sns_client',
command : ['cp', '@INPUT@', '@OUTDIR@'],
input : ['qmi_sns_client.c', 'qmi_sns_client.h'],
output : ['qmi_sns_client.c', 'qmi_sns_client.h'])
endif
+81
View File
@@ -0,0 +1,81 @@
#include <errno.h>
#include <string.h>
#include "qmi_sns_client.h"
struct qmi_elem_info sns_client_req_msg_v01_ei[] = {
{
.data_type = QMI_DATA_LEN,
.elem_len = 1,
.elem_size = sizeof(uint16_t),
.tlv_type = 1,
.offset = offsetof(struct sns_client_req_msg_v01, payload_len),
},
{
.data_type = QMI_UNSIGNED_1_BYTE,
.elem_len = 65535,
.elem_size = sizeof(uint8_t),
.array_type = VAR_LEN_ARRAY,
.tlv_type = 1,
.offset = offsetof(struct sns_client_req_msg_v01, payload),
},
{
.data_type = QMI_UNSIGNED_1_BYTE,
.elem_len = 1,
.elem_size = sizeof(uint8_t),
.tlv_type = 16,
.offset = offsetof(struct sns_client_req_msg_v01, unkfield_1),
},
{}
};
struct qmi_elem_info sns_client_resp_msg_v01_ei[] = {
{
.data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1,
.elem_size = sizeof(uint32_t),
.tlv_type = 2,
.offset = offsetof(struct sns_client_resp_msg_v01, unkfield_2),
},
{
.data_type = QMI_UNSIGNED_8_BYTE,
.elem_len = 1,
.elem_size = sizeof(uint64_t),
.tlv_type = 16,
.offset = offsetof(struct sns_client_resp_msg_v01, client_id),
},
{
.data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1,
.elem_size = sizeof(uint32_t),
.tlv_type = 17,
.offset = offsetof(struct sns_client_resp_msg_v01, result),
},
{}
};
struct qmi_elem_info sns_client_report_ind_msg_v01_ei[] = {
{
.data_type = QMI_UNSIGNED_8_BYTE,
.elem_len = 1,
.elem_size = sizeof(uint64_t),
.tlv_type = 1,
.offset = offsetof(struct sns_client_report_ind_msg_v01, client_id),
},
{
.data_type = QMI_DATA_LEN,
.elem_len = 1,
.elem_size = sizeof(uint16_t),
.tlv_type = 2,
.offset = offsetof(struct sns_client_report_ind_msg_v01, payload_len),
},
{
.data_type = QMI_UNSIGNED_1_BYTE,
.elem_len = 65535,
.elem_size = sizeof(uint8_t),
.array_type = VAR_LEN_ARRAY,
.tlv_type = 2,
.offset = offsetof(struct sns_client_report_ind_msg_v01, payload),
},
{}
};
+36
View File
@@ -0,0 +1,36 @@
#ifndef __QMI_SNS_CLIENT_H__
#define __QMI_SNS_CLIENT_H__
#include <stdint.h>
#include <stdbool.h>
#include "libqrtr.h"
#define SNS_CLIENT_REQ_V01 32
#define SNS_CLIENT_RESP_V01 32
#define SNS_CLIENT_IND_V01_SMALL 33
#define SNS_CLIENT_IND_V01_LARGE 34
struct sns_client_req_msg_v01 {
uint32_t payload_len;
uint8_t payload[65535];
uint8_t unkfield_1;
};
struct sns_client_resp_msg_v01 {
uint32_t unkfield_2;
uint64_t client_id;
uint32_t result;
};
struct sns_client_report_ind_msg_v01 {
uint64_t client_id;
uint32_t payload_len;
uint8_t payload[65535];
};
extern struct qmi_elem_info sns_client_req_msg_v01_ei[];
extern struct qmi_elem_info sns_client_resp_msg_v01_ei[];
extern struct qmi_elem_info sns_client_report_ind_msg_v01_ei[];
#endif