diff --git a/fastrpc/hexagonrpcd/hexagonfs.c b/fastrpc/hexagonrpcd/hexagonfs.c index a139093..39b137c 100644 --- a/fastrpc/hexagonrpcd/hexagonfs.c +++ b/fastrpc/hexagonrpcd/hexagonfs.c @@ -45,11 +45,11 @@ .u.phys = path, \ } -#define DEFINE_SYSFILE(dirname, func) \ - (struct hexagonfs_dirent) { \ - .name = dirname, \ - .ops = &hexagonfs_sysfs_ops, \ - .u.func = func, \ +#define DEFINE_SYSFILE(dirname, path) \ + (struct hexagonfs_dirent) { \ + .name = dirname, \ + .ops = &hexagonfs_mapped_sysfs_ops, \ + .u.phys = path, \ } static struct hexagonfs_dirent root_dir = DEFINE_VIRT_DIR("/", @@ -70,21 +70,21 @@ static struct hexagonfs_dirent root_dir = DEFINE_VIRT_DIR("/", &DEFINE_VIRT_DIR("sys", &DEFINE_VIRT_DIR("devices", &DEFINE_VIRT_DIR("soc0", - &DEFINE_MAPPED("hw_platform", - "/sys/kernel/debug/qcom_socinfo/hardware_platform"), + &DEFINE_SYSFILE("hw_platform", + "/sys/kernel/debug/qcom_socinfo/hardware_platform"), &(struct hexagonfs_dirent) { .name = "platform_subtype", .ops = &hexagonfs_plat_subtype_name_ops, .u.phys = "/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype", }, - &DEFINE_MAPPED("platform_subtype_id", - "/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype"), - &DEFINE_MAPPED("platform_version", - "/sys/kernel/debug/qcom_socinfo/platform_version"), - &DEFINE_MAPPED("revision", - "/sys/devices/soc0/revision"), - &DEFINE_MAPPED("soc_id", - "/sys/devices/soc0/soc_id"), + &DEFINE_SYSFILE("platform_subtype_id", + "/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype"), + &DEFINE_SYSFILE("platform_version", + "/sys/kernel/debug/qcom_socinfo/platform_version"), + &DEFINE_SYSFILE("revision", + "/sys/devices/soc0/revision"), + &DEFINE_SYSFILE("soc_id", + "/sys/devices/soc0/soc_id"), NULL, ), NULL, diff --git a/fastrpc/hexagonrpcd/hexagonfs.h b/fastrpc/hexagonrpcd/hexagonfs.h index 0c0b368..0ae138d 100644 --- a/fastrpc/hexagonrpcd/hexagonfs.h +++ b/fastrpc/hexagonrpcd/hexagonfs.h @@ -63,6 +63,7 @@ struct hexagonfs_fd { }; extern struct hexagonfs_file_ops hexagonfs_mapped_ops; +extern struct hexagonfs_file_ops hexagonfs_mapped_sysfs_ops; extern struct hexagonfs_file_ops hexagonfs_plat_subtype_name_ops; extern struct hexagonfs_file_ops hexagonfs_virt_dir_ops; diff --git a/fastrpc/hexagonrpcd/hexagonfs_mapped.c b/fastrpc/hexagonrpcd/hexagonfs_mapped.c index 33b0414..44ca779 100644 --- a/fastrpc/hexagonrpcd/hexagonfs_mapped.c +++ b/fastrpc/hexagonrpcd/hexagonfs_mapped.c @@ -216,6 +216,29 @@ static int mapped_stat(struct hexagonfs_fd *fd, struct stat *stats) return 0; } +/* + * This is the sysfs variant of the stat function. + * + * The remote processor expects a non-zero size if the file is not empty, even + * if a size cannot be determined without reading. The size is 256 on + * downstream kernels, so set it to that. + * + * Otherwise, the existing stat() function can be used. + */ +static int mapped_sysfs_stat(struct hexagonfs_fd *fd, struct stat *stats) +{ + int ret; + + ret = mapped_stat(fd, stats); + if (ret) + return ret; + + if (!(stats->st_mode & S_IFDIR)) + stats->st_size = 256; + + return 0; +} + struct hexagonfs_file_ops hexagonfs_mapped_ops = { .close = mapped_close, .from_dirent = mapped_from_dirent, @@ -225,3 +248,13 @@ struct hexagonfs_file_ops hexagonfs_mapped_ops = { .seek = mapped_seek, .stat = mapped_stat, }; + +struct hexagonfs_file_ops hexagonfs_mapped_sysfs_ops = { + .close = mapped_close, + .from_dirent = mapped_from_dirent, + .openat = mapped_openat, + .read = mapped_read, + .readdir = mapped_readdir, + .seek = mapped_seek, + .stat = mapped_sysfs_stat, +};