modem/*: upgrade, modernize, clean up (!549)

Thanks to z3ntu and scintill for additional patches, that have been
squashed into this one (see MR for details).
This commit is contained in:
Danct12 2019-07-17 22:03:58 +07:00 committed by Oliver Smith
parent 292e742220
commit fc839c2ea6
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
8 changed files with 33 additions and 277 deletions

View file

@ -1,30 +1,25 @@
pkgname=msmipc-dev
pkgver=0.1
pkgrel=0
pkgrel=1
pkgdesc="Headers for Qualcomm MSM IPC (AF_MSM_IPC and AF_QRTR)"
url="https://android.googlesource.com/kernel/msm/+/e63c5a50c9379ccbee4c7f0e6ba43394e9d89db4/include/linux/msm_ipc.h"
arch="noarch"
depends="linux-headers"
license="GPL-2.0 WITH Linux-syscall-note"
source="
https://github.com/torvalds/linux/raw/0573fed92b671bfe6a302c67bb66471b18a5004d/include/uapi/linux/qrtr.h
msm_ipc.h.base64::https://android.googlesource.com/kernel/msm/+/e63c5a50c9379ccbee4c7f0e6ba43394e9d89db4/include/linux/msm_ipc.h?format=TEXT
"
"
builddir="$srcdir"
options="!check"
unpack() {
default_unpack
cd $srcdir
base64 -d msm_ipc.h.base64 > msm_ipc.h
}
package() {
cd "$srcdir"
for f in qrtr.h msm_ipc.h; do
install -Dm644 $f "$pkgdir"/usr/src/msmipc-dev/include/linux/$f
done
install -Dm644 msm_ipc.h "$pkgdir"/usr/src/msmipc-dev/include/linux/msm_ipc.h
}
sha512sums="1d424b43806930df079041c97db734572b48848b38b37852c3376a5e69e5257f24684f29381891f164d36cac7fbce2746f9580c0aab4ef4d92b8c72cadcb888c qrtr.h
c626c03b567b3e12ca0e7d7d89f7c308f1ca3782c163112a04076060a79a91c1192ffb695ab99b28a952021449657b0fdf1912873b7ca05a16a9848f896ea8d0 msm_ipc.h.base64"
sha512sums="c626c03b567b3e12ca0e7d7d89f7c308f1ca3782c163112a04076060a79a91c1192ffb695ab99b28a952021449657b0fdf1912873b7ca05a16a9848f896ea8d0 msm_ipc.h.base64"

View file

@ -1,40 +1,33 @@
pkgname=qcom_rmtfs
pkgver=0.0_git20180131
pkgver=0.2_git20190729
_commit="df6c19d0330d251af0a7c812bf5ddb847962ce2c"
pkgrel=3
pkgdesc="Qualcomm Remote Filesystem Service Implementation"
url="https://github.com/andersson/rmtfs"
arch="all"
license="BSD-3-Clause"
depends="qrtr"
makedepends="eudev-dev qrtr-dev msmipc-dev"
makedepends="eudev-dev qrtr-dev"
install="$pkgname.post-install"
subpackages="$pkgname-doc"
_commit="0f800fa4334b03a47941ce1b577f51a69552e414"
source="
rmtfs.tgz::https://github.com/andersson/rmtfs/archive/"$_commit".tar.gz
support-uio.patch
update-storage-paths.patch
rmtfs-$_commit.tar.gz::https://github.com/andersson/rmtfs/archive/$_commit.tar.gz
qcom_rmtfs.initd
udev.rules
"
builddir="$srcdir""/rmtfs-"$_commit
"
builddir="$srcdir/rmtfs-$_commit"
options="!check"
install="$pkgname.post-install"
build() {
cd "$builddir"
make C_INCLUDE_PATH=/usr/src/msmipc-dev/include rmtfs
make rmtfs
}
package() {
cd "$builddir"
install -D -m 755 rmtfs "$pkgdir"/usr/sbin/"$pkgname"
install -Dm755 rmtfs "$pkgdir"/usr/sbin/"$pkgname"
install -Dm755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
install -Dm644 "$srcdir/udev.rules" "$pkgdir/usr/lib/udev/rules.d/65-qcom_rmtfs.rules"
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
sha512sums="4b49cdf9d778bf6ae5e838c1da48e76b1004786a0dafefb0097fe3a73e4652c13ed1b011c051a712017f10b43ffc96b2fa133809715577b65fa4ca30cbdc191b rmtfs.tgz
a216dc36a7f12bbc125120ac7cc3e3030f3718f7d894c9e6d5e586375cbd76eae897160fdf780da8e3089dbfc0a31f1631dca4a2e850e193135ab825aa8d05cf support-uio.patch
877bdc84fdb4a851d94f29e2c6dd391afdb7812d19d0b10dc4449a6a7d0ed86fb3c01fd315bef7bfe24a644b3af102fc1e24194cb76c4e8966b8044a110ed639 update-storage-paths.patch
5ca3428b540c14a921a6a158833c39c2ac6bea33fd82172fb014cb8aa96684f31cc853b4a3b4359a764583f8da21a56aee617bd36fa1d6ca90a2827204c1ef9a qcom_rmtfs.initd
190db2ac5d0850f135738b4bfa9b14a0d0ec6ee66328ba704e4402c9ff76d60d330022f1f74ba96868491a0048fd3c4edb5a44cfc7574aca44afba5a3e4f5754 udev.rules"
sha512sums="16cdc2f1173246d1ef83f12aa1f14f5f2aba9e3cbf2c632353bd42b3d64888b1fe6a87df4d6c2d3648028195bfb359ede600162854d42905ca88b79ce5eae940 rmtfs-df6c19d0330d251af0a7c812bf5ddb847962ce2c.tar.gz
be32903df67af0ae2f6ea8c96f7c2bb003407258047622427097e3e867a6115a69e3ad2ad073a4182977f8d4d99c0283e9272f128ef7836a1d4365a24f7fd7ae qcom_rmtfs.initd
b27621462f9e176a6805a1cb5909e88bdc5bbde6fb879634cfd0e2d08ed4964b26e55586863e415c5f7aea5b03ce3430f38c90e57b46b1925b1d324eebd5eca2 udev.rules"

View file

@ -8,7 +8,7 @@ depend() {
export LD_PRELOAD=/usr/lib/preload/libqipcrtr4msmipc.so
command="/bin/sh"
command_args="-c 'exec /usr/sbin/qcom_rmtfs -v 2>&1 | logger -t qcom_rmtfs'"
command_args="-c 'exec /usr/sbin/qcom_rmtfs -o /dev/disk/qcom_rmtfs -v 2>&1 | logger -t qcom_rmtfs'"
command_background="yes"
pidfile="/var/run/${SVCNAME}.pid"

View file

@ -1,186 +0,0 @@
From b98442bbfaa0b61963c23c6079055c94515e38dd Mon Sep 17 00:00:00 2001
From: Joey Hewitt <joey@joeyhewitt.com>
Date: Mon, 9 Oct 2017 21:41:43 -0700
Subject: [PATCH] add uio dev support
diff --git a/sharedmem.c b/sharedmem.c
index f788b8a..eead258 100644
--- a/sharedmem.c
+++ b/sharedmem.c
@@ -44,6 +44,37 @@ static int parse_hex_sysattr(struct udev_device *dev, const char *name,
return 0;
}
+static int parse_hex_sysfsfile(int dir_fd, const char *name,
+ unsigned long *value)
+{
+ unsigned long val;
+ char buf[32];
+ char *endptr;
+ int fd;
+
+ fd = openat(dir_fd, name, O_RDONLY);
+ if (fd < 0) {
+ return -errno;
+ }
+
+ if (read(fd, buf, sizeof(buf)) < 0) {
+ close(fd);
+ return -errno;
+ }
+
+ close(fd);
+
+ errno = 0;
+ val = strtoul(buf, &endptr, 16);
+ if ((val == LONG_MAX && errno == ERANGE) || endptr == buf) {
+ return -errno;
+ }
+
+ *value = val;
+
+ return 0;
+}
+
static int rmtfs_mem_open_rfsa(struct rmtfs_mem *rmem, int client_id)
{
struct udev_device *dev;
@@ -114,6 +145,88 @@ err_close_fd:
return -saved_errno;
}
+static int rmtfs_mem_open_uio(struct rmtfs_mem *rmem)
+{
+ int saved_errno;
+ char path[64];
+ char buf[32];
+ int ret;
+ int dir_fd;
+ int fd;
+
+ for (int uio_index = 0; uio_index < 8; uio_index++) {
+ snprintf(path, sizeof(path), "/sys/class/uio/uio%d", uio_index);
+ dir_fd = open(path, O_DIRECTORY);
+ if (dir_fd < 0) {
+ saved_errno = errno;
+ if (errno != ENOENT) {
+ fprintf(stderr, "failed to open %s: %s\n", path, strerror(errno));
+ }
+ goto ret;
+ }
+
+ fd = openat(dir_fd, "name", O_RDONLY);
+ if (fd < 0) {
+ saved_errno = errno;
+ fprintf(stderr, "failed to open %s/name: %s\n", path, strerror(errno));
+ goto close_dirfd;
+ }
+
+ if (read(fd, buf, sizeof(buf)) < 0) {
+ saved_errno = errno;
+ fprintf(stderr, "failed to read %s/name: %s\n", path, strerror(errno));
+ close(fd);
+ goto close_dirfd;
+ }
+
+ close(fd);
+
+ if (strncmp(buf, "rmtfs\n", 6)) {
+ continue;
+ }
+
+ ret = parse_hex_sysfsfile(dir_fd, "maps/map0/addr", &rmem->address);
+ if (ret < 0) {
+ fprintf(stderr, "failed to parse addr of %s\n", path);
+ saved_errno = -ret;
+ goto close_dirfd;
+ }
+
+ ret = parse_hex_sysfsfile(dir_fd, "maps/map0/size", &rmem->size);
+ if (ret < 0) {
+ fprintf(stderr, "failed to parse size of %s\n", path);
+ saved_errno = -ret;
+ goto close_dirfd;
+ }
+
+ snprintf(path, sizeof(path), "/dev/uio%d", uio_index);
+ rmem->fd = open(path, O_RDWR);
+ if (rmem->fd < 0) {
+ saved_errno = errno;
+ fprintf(stderr, "failed to open %s: %s\n", path, strerror(errno));
+ goto close_dirfd;
+ }
+
+ rmem->base = mmap(0, rmem->size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ if (rmem->base == MAP_FAILED) {
+ saved_errno = errno;
+ fprintf(stderr, "failed to mmap: %s\n", strerror(errno));
+ close(rmem->fd);
+ goto close_dirfd;
+ }
+
+ saved_errno = 0;
+ goto close_dirfd;
+ }
+
+ saved_errno = ENOENT;
+
+close_dirfd:
+ close(dir_fd);
+ret:
+ return -saved_errno;
+}
+
struct rmtfs_mem *rmtfs_mem_open(void)
{
struct rmtfs_mem *rmem;
@@ -131,26 +244,31 @@ struct rmtfs_mem *rmtfs_mem_open(void)
if (ret < 0 && ret != -ENOENT) {
goto err;
} else if (ret < 0) {
- fprintf(stderr, "falling back to /dev/mem access\n");
-
- ret = rmtfs_mem_enumerate(rmem);
- if (ret < 0)
- goto err;
-
- fd = open("/dev/mem", O_RDWR|O_SYNC);
- if (fd < 0) {
- fprintf(stderr, "failed to open /dev/mem\n");
+ ret = rmtfs_mem_open_uio(rmem);
+ if (ret < 0 && ret != -ENOENT) {
goto err;
+ } else if (ret < 0) {
+ fprintf(stderr, "falling back to /dev/mem access\n");
+
+ ret = rmtfs_mem_enumerate(rmem);
+ if (ret < 0)
+ goto err;
+
+ fd = open("/dev/mem", O_RDWR|O_SYNC);
+ if (fd < 0) {
+ fprintf(stderr, "failed to open /dev/mem\n");
+ goto err;
+ }
+
+ base = mmap(0, rmem->size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, rmem->address);
+ if (base == MAP_FAILED) {
+ fprintf(stderr, "failed to mmap: %s\n", strerror(errno));
+ goto err_close_fd;
+ }
+
+ rmem->base = base;
+ rmem->fd = fd;
}
-
- base = mmap(0, rmem->size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, rmem->address);
- if (base == MAP_FAILED) {
- fprintf(stderr, "failed to mmap: %s\n", strerror(errno));
- goto err_close_fd;
- }
-
- rmem->base = base;
- rmem->fd = fd;
}
return rmem;

View file

@ -6,3 +6,5 @@ ENV{ID_PART_ENTRY_NAME}=="fsc", SYMLINK+="disk/qcom_rmtfs/modem_fsc"
ENV{ID_PART_ENTRY_NAME}=="fsg", SYMLINK+="disk/qcom_rmtfs/modem_fsg"
LABEL="qcom_rmtfs_end"
SUBSYSTEM=="uio", ATTR{name}=="rmtfs", SYMLINK+="qcom_rmtfs_uio1"

View file

@ -1,32 +0,0 @@
From c8af1ceccfa1c69845a0afb0068917cb16a4ef5b Mon Sep 17 00:00:00 2001
From: Joey Hewitt <joey@joeyhewitt.com>
Date: Sat, 2 Apr 2018 17:38:00 -0700
Subject: [PATCH] point storage to udev-linked paths
udev rules in this package create symlinks the daemon opens
---
storage.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/storage.c b/storage.c
index 997b428..8754b98 100644
--- a/storage.c
+++ b/storage.c
@@ -23,10 +23,10 @@ struct caller {
};
static const struct partition partition_table[] = {
- { "/boot/modem_fs1", "/boot/modem_fs1" },
- { "/boot/modem_fs2", "/boot/modem_fs2" },
- { "/boot/modem_fsc", "/boot/modem_fsc" },
- { "/boot/modem_fsg", "/boot/modem_fsg" },
+ { "/boot/modem_fs1", "/dev/disk/qcom_rmtfs/modem_fs1" },
+ { "/boot/modem_fs2", "/dev/disk/qcom_rmtfs/modem_fs2" },
+ { "/boot/modem_fsc", "/dev/disk/qcom_rmtfs/modem_fsc" },
+ { "/boot/modem_fsg", "/dev/disk/qcom_rmtfs/modem_fsg" },
{}
};
--
2.7.4

View file

@ -1,34 +1,31 @@
pkgname=qrtr
pkgver=1.0_git20180131
pkgver=1.1.0.3_git20190725
_commit="cd6bedd5d00f211e6c1e3803ff2f9f53c246435e"
pkgrel=1
pkgdesc="Userspace reference for net/qrtr in the Linux kernel"
url="https://github.com/andersson/qrtr"
arch="all"
license="BSD-3-Clause"
makedepends="msmipc-dev"
subpackages="$pkgname-doc $pkgname-dev"
_commit="dbffdd0193996723fdc9456e09736a30a32daf25"
source="
qrtr.tgz::https://github.com/andersson/qrtr/archive/"$_commit".tar.gz
fix-cfg-include.patch
qrtr.initd
"
builddir="$srcdir""/qrtr-"$_commit
options="!check"
depends_dev="linux-headers"
makedepends="$depends_dev"
install="$pkgname.post-install"
subpackages="$pkgname-doc $pkgname-dev"
source="
qrtr-$_commit.tar.gz::https://github.com/andersson/qrtr/archive/$_commit.tar.gz
qrtr.initd
"
builddir="$srcdir/qrtr-$_commit"
options="!check"
build() {
cd "$builddir"
make prefix=/usr libdir=/usr/lib/ C_INCLUDE_PATH=/usr/src/msmipc-dev/include all
make prefix=/usr all
}
package() {
cd "$builddir"
make prefix=/usr DESTDIR="$pkgdir" install
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/COPYING
install -Dm755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
}
sha512sums="4fbf9bcb26794a54e9784bafd0ee46a0c628327d6b31a438ca6d907185260cf590fc90a2e22139ebf3b939750277f434d67096396192d1ee3b0542c2feb39075 qrtr.tgz
fca4a8b886b7bb6a53a83f3a69e3ae03b8fc462f6f6bf6c812af1a1036aa5a8c1f40b6cabf921e91c55423c37309d4e56ac8ccf0d4c5f7db41c1005afaf19382 fix-cfg-include.patch
sha512sums="f606b38d94aa440d1efc071eaf0a9e85319765196844e4b62520fddfea98a70fb73ffd3825e54a0f3c66ef4591e404fba1291c1fa134b4c66460efe414f5756a qrtr-cd6bedd5d00f211e6c1e3803ff2f9f53c246435e.tar.gz
fcd9b8e4c4df9236ec778f1ffb231e547e0d65c718e0caf351bee821b1549aecafbfdb21b4c1d1e3d049d541d87b6bf98746414e88e5d70d05131e0496e1ef37 qrtr.initd"

View file

@ -1,13 +0,0 @@
diff --git a/Makefile b/Makefile
index 2fa026f..200fb92 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,8 @@ $(proj)-ns-srcs := \
$(proj)-ns-cflags := -Ilib
+$(proj)-cfg-cflags := -Ilib
+
$(proj)-lookup-srcs := \
src/lookup.c \
src/util.c \