mirror of
https://github.com/linux-msm/rmtfs.git
synced 2026-01-25 12:45:23 +01:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14cb1ee69f | ||
|
|
f9847a777c | ||
|
|
f7566e4c82 | ||
|
|
27b3a6f00f | ||
|
|
2ee01bf752 | ||
|
|
586372e575 | ||
|
|
19d1acb728 | ||
|
|
44facf5694 | ||
|
|
5b214f61b9 | ||
|
|
b61c22b1cd | ||
|
|
b46235296f | ||
|
|
f24570816b | ||
|
|
33e1e40615 | ||
|
|
a2df4bd096 | ||
|
|
e4e6212c86 | ||
|
|
44fcb2ec64 | ||
|
|
0caf528637 | ||
|
|
cc5d4df973 | ||
|
|
75cb81d197 | ||
|
|
7a5ae7e0a5 |
10
Makefile
10
Makefile
@@ -6,6 +6,8 @@ prefix = /usr/local
|
|||||||
bindir := $(prefix)/bin
|
bindir := $(prefix)/bin
|
||||||
servicedir := $(prefix)/lib/systemd/system
|
servicedir := $(prefix)/lib/systemd/system
|
||||||
|
|
||||||
|
RMTFS_EFS_PATH ?= /var/lib/rmtfs
|
||||||
|
|
||||||
SRCS := qmi_rmtfs.c rmtfs.c rproc.c sharedmem.c storage.c util.c
|
SRCS := qmi_rmtfs.c rmtfs.c rproc.c sharedmem.c storage.c util.c
|
||||||
OBJS := $(SRCS:.c=.o)
|
OBJS := $(SRCS:.c=.o)
|
||||||
|
|
||||||
@@ -15,13 +17,15 @@ $(OUT): $(OBJS)
|
|||||||
%.c: %.qmi
|
%.c: %.qmi
|
||||||
qmic -k < $<
|
qmic -k < $<
|
||||||
|
|
||||||
rmtfs.service: rmtfs.service.in
|
%.service: %.service.in
|
||||||
@sed 's+RMTFS_PATH+$(bindir)+g' $< > $@
|
@sed -e 's+RMTFS_PATH+$(bindir)+g' -e 's+RMTFS_EFS_PATH+$(RMTFS_EFS_PATH)+g' $< > $@
|
||||||
|
|
||||||
install: $(OUT) rmtfs.service
|
install: $(OUT) rmtfs.service rmtfs-dir.service
|
||||||
@install -D -m 755 $(OUT) $(DESTDIR)$(prefix)/bin/$(OUT)
|
@install -D -m 755 $(OUT) $(DESTDIR)$(prefix)/bin/$(OUT)
|
||||||
@install -D -m 644 rmtfs.service $(DESTDIR)$(servicedir)/rmtfs.service
|
@install -D -m 644 rmtfs.service $(DESTDIR)$(servicedir)/rmtfs.service
|
||||||
|
@install -D -m 644 rmtfs-dir.service $(DESTDIR)$(servicedir)/rmtfs-dir.service
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OUT) $(OBJS) rmtfs.service
|
rm -f $(OUT) $(OBJS) rmtfs.service
|
||||||
|
rm -f $(OUT) $(OBJS) rmtfs-dir.service
|
||||||
|
|
||||||
|
|||||||
11
rmtfs-dir.service.in
Normal file
11
rmtfs-dir.service.in
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Qualcomm remotefs service
|
||||||
|
Before=NetworkManager.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=RMTFS_PATH/rmtfs -s -o RMTFS_EFS_PATH
|
||||||
|
Restart=always
|
||||||
|
RestartSec=1
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
23
rmtfs.c
23
rmtfs.c
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
static struct rmtfs_mem *rmem;
|
static struct rmtfs_mem *rmem;
|
||||||
static sig_atomic_t sig_int_count;
|
static sig_atomic_t sig_int_count;
|
||||||
|
static char slot_suffix[SLOT_SUFFIX_LEN];
|
||||||
|
|
||||||
static bool dbgprintf_enabled;
|
static bool dbgprintf_enabled;
|
||||||
static void dbgprintf(const char *fmt, ...)
|
static void dbgprintf(const char *fmt, ...)
|
||||||
@@ -69,7 +70,7 @@ static void rmtfs_open(int sock, const struct qrtr_packet *pkt)
|
|||||||
goto respond;
|
goto respond;
|
||||||
}
|
}
|
||||||
|
|
||||||
rmtfd = storage_open(pkt->node, req.path);
|
rmtfd = storage_open(pkt->node, req.path, slot_suffix);
|
||||||
if (!rmtfd) {
|
if (!rmtfd) {
|
||||||
qmi_result_error(&resp.result, QMI_RMTFS_ERR_INTERNAL);
|
qmi_result_error(&resp.result, QMI_RMTFS_ERR_INTERNAL);
|
||||||
goto respond;
|
goto respond;
|
||||||
@@ -151,11 +152,11 @@ static void rmtfs_iovec(int sock, struct qrtr_packet *pkt)
|
|||||||
struct rmtfs_iovec_resp resp = {};
|
struct rmtfs_iovec_resp resp = {};
|
||||||
struct rmtfs_iovec_req req = {};
|
struct rmtfs_iovec_req req = {};
|
||||||
DEFINE_QRTR_PACKET(resp_buf, 256);
|
DEFINE_QRTR_PACKET(resp_buf, 256);
|
||||||
struct rmtfd *rmtfd;
|
struct rmtfd *rmtfd = NULL;
|
||||||
uint32_t caller_id = 0;
|
uint32_t caller_id = 0;
|
||||||
size_t num_entries = 0;
|
size_t num_entries = 0;
|
||||||
off_t sector_base;
|
off_t sector_base;
|
||||||
uint8_t is_write;
|
uint8_t is_write = 0;
|
||||||
off_t phys_base;
|
off_t phys_base;
|
||||||
uint8_t force = 0;
|
uint8_t force = 0;
|
||||||
unsigned txn;
|
unsigned txn;
|
||||||
@@ -504,7 +505,7 @@ int main(int argc, char **argv)
|
|||||||
int option;
|
int option;
|
||||||
const char *storage_root = NULL;
|
const char *storage_root = NULL;
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, "o:Prsv")) != -1) {
|
while ((option = getopt(argc, argv, "o:S:Prsv")) != -1) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
/*
|
/*
|
||||||
* -o sets the directory where EFS images are stored,
|
* -o sets the directory where EFS images are stored,
|
||||||
@@ -535,6 +536,20 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Partlabel slot suffix on A/B devices */
|
||||||
|
case 'S':
|
||||||
|
if (strnlen(optarg, 1 + 1) != 1) {
|
||||||
|
fprintf(stderr, "Couldn't parse slot name (too long?)\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = snprintf(slot_suffix, SLOT_SUFFIX_LEN, "_%s", optarg);
|
||||||
|
if (ret != SLOT_SUFFIX_LEN - 1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dbgprintf("Using slot %s\n", slot_suffix);
|
||||||
|
break;
|
||||||
|
|
||||||
/* -v is for verbose */
|
/* -v is for verbose */
|
||||||
case 'v':
|
case 'v':
|
||||||
dbgprintf_enabled = 1;
|
dbgprintf_enabled = 1;
|
||||||
|
|||||||
3
rmtfs.h
3
rmtfs.h
@@ -26,7 +26,8 @@ ssize_t rmtfs_mem_write(struct rmtfs_mem *rmem, unsigned long phys_address, cons
|
|||||||
struct rmtfd;
|
struct rmtfd;
|
||||||
|
|
||||||
int storage_init(const char *storage_root, bool read_only, bool use_partitions);
|
int storage_init(const char *storage_root, bool read_only, bool use_partitions);
|
||||||
struct rmtfd *storage_open(unsigned node, const char *path);
|
#define SLOT_SUFFIX_LEN (2 + 1) /* "_a" or "_b", null-terminated */
|
||||||
|
struct rmtfd *storage_open(unsigned node, const char *path, const char *slot_suffix);
|
||||||
struct rmtfd *storage_get(unsigned node, int caller_id);
|
struct rmtfd *storage_get(unsigned node, int caller_id);
|
||||||
void storage_close(struct rmtfd *rmtfd);
|
void storage_close(struct rmtfd *rmtfd);
|
||||||
int storage_get_caller_id(const struct rmtfd *rmtfd);
|
int storage_get_caller_id(const struct rmtfd *rmtfd);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Qualcomm remotefs service
|
Description=Qualcomm remotefs service
|
||||||
Requires=qrtr-ns.service
|
Before=NetworkManager.service
|
||||||
After=qrtr-ns.service
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=RMTFS_PATH/rmtfs -r -P -s
|
ExecStart=RMTFS_PATH/rmtfs -r -P -s
|
||||||
|
|||||||
11
sharedmem.c
11
sharedmem.c
@@ -4,6 +4,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
#else
|
#else
|
||||||
@@ -322,7 +323,7 @@ int64_t rmtfs_mem_alloc(struct rmtfs_mem *rmem, size_t alloc_size)
|
|||||||
{
|
{
|
||||||
if (alloc_size > rmem->size) {
|
if (alloc_size > rmem->size) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"[RMTFS] rmtfs shared memory not large enough for allocation request 0x%zx vs 0x%lx\n",
|
"[RMTFS] rmtfs shared memory not large enough for allocation request 0x%zx vs %" PRIu64 "\n",
|
||||||
alloc_size, rmem->size);
|
alloc_size, rmem->size);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@@ -418,7 +419,7 @@ static int rmtfs_mem_enumerate(struct rmtfs_mem *rmem)
|
|||||||
if (!dir) {
|
if (!dir) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Unable to open reserved-memory device tree node: %s\n",
|
"Unable to open reserved-memory device tree node: %s\n",
|
||||||
strerror(-errno));
|
strerror(errno));
|
||||||
close(basefd);
|
close(basefd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -430,7 +431,7 @@ static int rmtfs_mem_enumerate(struct rmtfs_mem *rmem)
|
|||||||
dirfd = openat(basefd, de->d_name, O_DIRECTORY);
|
dirfd = openat(basefd, de->d_name, O_DIRECTORY);
|
||||||
if (dirfd < 0) {
|
if (dirfd < 0) {
|
||||||
fprintf(stderr, "failed to open %s: %s\n",
|
fprintf(stderr, "failed to open %s: %s\n",
|
||||||
de->d_name, strerror(-errno));
|
de->d_name, strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -438,7 +439,7 @@ static int rmtfs_mem_enumerate(struct rmtfs_mem *rmem)
|
|||||||
regfd = openat(dirfd, "reg", O_RDONLY);
|
regfd = openat(dirfd, "reg", O_RDONLY);
|
||||||
if (regfd < 0) {
|
if (regfd < 0) {
|
||||||
fprintf(stderr, "failed to open reg of %s: %s\n",
|
fprintf(stderr, "failed to open reg of %s: %s\n",
|
||||||
de->d_name, strerror(-errno));
|
de->d_name, strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -452,7 +453,7 @@ static int rmtfs_mem_enumerate(struct rmtfs_mem *rmem)
|
|||||||
rmem->size = be64toh(reg.qw[1]);
|
rmem->size = be64toh(reg.qw[1]);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "failed to read reg of %s: %s\n",
|
fprintf(stderr, "failed to read reg of %s: %s\n",
|
||||||
de->d_name, strerror(-errno));
|
de->d_name, strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
storage.c
63
storage.c
@@ -41,7 +41,9 @@ static const struct partition partition_table[] = {
|
|||||||
{ "/boot/modem_fs2", "modem_fs2", "modemst2" },
|
{ "/boot/modem_fs2", "modem_fs2", "modemst2" },
|
||||||
{ "/boot/modem_fsc", "modem_fsc", "fsc" },
|
{ "/boot/modem_fsc", "modem_fsc", "fsc" },
|
||||||
{ "/boot/modem_fsg", "modem_fsg", "fsg" },
|
{ "/boot/modem_fsg", "modem_fsg", "fsg" },
|
||||||
|
{ "/boot/modem_study", "modem_study", "study" },
|
||||||
{ "/boot/modem_tunning", "modem_tunning", "tunning" },
|
{ "/boot/modem_tunning", "modem_tunning", "tunning" },
|
||||||
|
{ "/boot/modem_tng", "modem_tng", "tunning" },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,16 +75,43 @@ int storage_init(const char *storage_root, bool read_only, bool use_partitions)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct rmtfd *storage_open(unsigned node, const char *path)
|
static int fd_open(struct rmtfd *rmtfd, const char *fspath, const struct partition *part)
|
||||||
|
{
|
||||||
|
int saved_errno;
|
||||||
|
int ret;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (!storage_read_only) {
|
||||||
|
fd = open(fspath, O_RDWR);
|
||||||
|
if (fd < 0) {
|
||||||
|
saved_errno = errno;
|
||||||
|
fprintf(stderr, "[storage] failed to open '%s' (requested '%s'): %s\n",
|
||||||
|
fspath, part->path, strerror(saved_errno));
|
||||||
|
return saved_errno;
|
||||||
|
}
|
||||||
|
rmtfd->fd = fd;
|
||||||
|
rmtfd->shadow_len = 0;
|
||||||
|
} else {
|
||||||
|
ret = storage_populate_shadow_buf(rmtfd, fspath);
|
||||||
|
if (ret < 0) {
|
||||||
|
saved_errno = errno;
|
||||||
|
fprintf(stderr, "[storage] failed to open '%s' (requested '%s'): %s\n",
|
||||||
|
fspath, part->path, strerror(saved_errno));
|
||||||
|
return saved_errno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct rmtfd *storage_open(unsigned node, const char *path, const char *slot_suffix)
|
||||||
{
|
{
|
||||||
char *fspath;
|
char *fspath;
|
||||||
const struct partition *part;
|
const struct partition *part;
|
||||||
struct rmtfd *rmtfd = NULL;
|
struct rmtfd *rmtfd = NULL;
|
||||||
const char *file;
|
const char *file;
|
||||||
size_t pathlen;
|
size_t pathlen;
|
||||||
int saved_errno;
|
|
||||||
int ret;
|
int ret;
|
||||||
int fd;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (part = partition_table; part->path; part++) {
|
for (part = partition_table; part->path; part++) {
|
||||||
@@ -118,29 +147,19 @@ found:
|
|||||||
else
|
else
|
||||||
file = part->actual;
|
file = part->actual;
|
||||||
|
|
||||||
pathlen = strlen(storage_dir) + strlen(file) + 2;
|
pathlen = strlen(storage_dir) + strlen(file) + 2 + strnlen(slot_suffix, SLOT_SUFFIX_LEN);
|
||||||
fspath = alloca(pathlen);
|
fspath = alloca(pathlen);
|
||||||
snprintf(fspath, pathlen, "%s/%s", storage_dir, file);
|
snprintf(fspath, pathlen, "%s/%s", storage_dir, file);
|
||||||
if (!storage_read_only) {
|
ret = fd_open(rmtfd, fspath, part);
|
||||||
fd = open(fspath, O_RDWR);
|
if (ret) {
|
||||||
if (fd < 0) {
|
/* Try again with the slot suffix before giving up */
|
||||||
saved_errno = errno;
|
if (!slot_suffix)
|
||||||
fprintf(stderr, "[storage] failed to open '%s' (requested '%s'): %s\n",
|
|
||||||
fspath, part->path, strerror(saved_errno));
|
|
||||||
errno = saved_errno;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
rmtfd->fd = fd;
|
snprintf(fspath, pathlen, "%s/%s%s", storage_dir, file, slot_suffix);
|
||||||
rmtfd->shadow_len = 0;
|
ret = fd_open(rmtfd, fspath, part);
|
||||||
} else {
|
if (ret)
|
||||||
ret = storage_populate_shadow_buf(rmtfd, fspath);
|
|
||||||
if (ret < 0) {
|
|
||||||
saved_errno = errno;
|
|
||||||
fprintf(stderr, "[storage] failed to open '%s' (requested '%s'): %s\n",
|
|
||||||
fspath, part->path, strerror(saved_errno));
|
|
||||||
errno = saved_errno;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rmtfd->node = node;
|
rmtfd->node = node;
|
||||||
|
|||||||
Reference in New Issue
Block a user