From 4ba172b2baedfbf19c1591b522514ff3c42c1d1c Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Thu, 17 Oct 2019 19:51:43 -0700 Subject: [PATCH 1/4] luci-app-ssr-plus: copy dns files to memory --- package/lean/luci-app-ssr-plus/Makefile | 2 +- .../luci-app-ssr-plus/root/etc/init.d/shadowsocksr | 13 +++++++------ .../root/usr/share/shadowsocksr/gfw2ipset.sh | 11 ++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package/lean/luci-app-ssr-plus/Makefile b/package/lean/luci-app-ssr-plus/Makefile index ee930af7c7..97cbe3f136 100644 --- a/package/lean/luci-app-ssr-plus/Makefile +++ b/package/lean/luci-app-ssr-plus/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=1 -PKG_RELEASE:=116 +PKG_RELEASE:=117 PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ diff --git a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 3079e369e0..d45d4578a9 100755 --- a/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/package/lean/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -484,19 +484,20 @@ start() { if rules ;then start_redir - - /usr/share/shadowsocksr/gfw2ipset.sh - - mkdir -p /tmp/dnsmasq.d + + mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/ if ! [ "$run_mode" = "oversea" ] ;then cat > /tmp/dnsmasq.d/dnsmasq-ssr.conf < /tmp/dnsmasq.d/dnsmasq-ssr.conf </dev/null 2>&1 fi diff --git a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gfw2ipset.sh b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gfw2ipset.sh index 536f679e01..a9249ceed1 100755 --- a/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gfw2ipset.sh +++ b/package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/gfw2ipset.sh @@ -1,11 +1,12 @@ #!/bin/sh -awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"gfwlist"'\n",$0)}' /etc/config/gfw.list > /etc/dnsmasq.ssr/custom_forward.conf -awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/gfw.list >> /etc/dnsmasq.ssr/custom_forward.conf +mkdir -p /tmp/dnsmasq.ssr -awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/config/black.list > /etc/dnsmasq.ssr/blacklist_forward.conf -awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/black.list >> /etc/dnsmasq.ssr/blacklist_forward.conf +awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"gfwlist"'\n",$0)}' /etc/config/gfw.list > /tmp/dnsmasq.ssr/custom_forward.conf +awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/gfw.list >> /tmp/dnsmasq.ssr/custom_forward.conf -awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/config/white.list > /etc/dnsmasq.ssr/whitelist_forward.conf +awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"blacklist"'\n",$0)}' /etc/config/black.list > /tmp/dnsmasq.ssr/blacklist_forward.conf +awk '!/^$/&&!/^#/{printf("server=/.%s/'"127.0.0.1#5335"'\n",$0)}' /etc/config/black.list >> /tmp/dnsmasq.ssr/blacklist_forward.conf +awk '!/^$/&&!/^#/{printf("ipset=/.%s/'"whitelist"'\n",$0)}' /etc/config/white.list > /tmp/dnsmasq.ssr/whitelist_forward.conf From bca9c232333001b34648adc54183a429118cf1f7 Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Thu, 17 Oct 2019 19:56:08 -0700 Subject: [PATCH 2/4] luci-app-docker: readme pdf link --- package/lean/luci-app-docker/Makefile | 2 +- .../luasrc/model/cbi/docker.lua | 27 ++----------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/package/lean/luci-app-docker/Makefile b/package/lean/luci-app-docker/Makefile index 19ea282eda..34979a90be 100755 --- a/package/lean/luci-app-docker/Makefile +++ b/package/lean/luci-app-docker/Makefile @@ -10,7 +10,7 @@ LUCI_TITLE:=Luci for Docker-CE LUCI_DEPENDS:=+docker-ce LUCI_PKGARCH:=all PKG_VERSION:=1 -PKG_RELEASE:=8 +PKG_RELEASE:=9 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-docker/luasrc/model/cbi/docker.lua b/package/lean/luci-app-docker/luasrc/model/cbi/docker.lua index 750418b762..270fecbbc7 100644 --- a/package/lean/luci-app-docker/luasrc/model/cbi/docker.lua +++ b/package/lean/luci-app-docker/luasrc/model/cbi/docker.lua @@ -17,30 +17,7 @@ wan_mode = s:option(Flag, "wan_mode", translate("Enable WAN access Dokcer"), tra wan_mode.default = 0 wan_mode.rmempty = false - -o = s:option(Button,"readme",translate("Docker Readme First")) -o.inputtitle = translate("Download DockerReadme.pdf") -o.description = translate("Please download DockerReadme.pdf to read when first-running") -o.inputstyle = "reload" -o.write = function() - Download() -end - -function Download() - local t,e - t=nixio.open("/www/DockerReadme.pdf","r") - luci.http.header('Content-Disposition','attachment; filename="DockerReadme.pdf"') - luci.http.prepare_content("application/octet-stream") - while true do - e=t:read(nixio.const.buffersize) - if(not e)or(#e==0)then - break - else - luci.http.write(e) - end - end - t:close() - luci.http.close() -end +o=s:option(DummyValue,"readme",translate(" ")) +o.description=translate(""..translate("Download DockerReadme.pdf").."") return m \ No newline at end of file From 1bfbd38e5208c03db5573bc5a4f70112b3a7030b Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Thu, 17 Oct 2019 19:58:07 -0700 Subject: [PATCH 3/4] Revert "fstools: bugs fixed and add support for exfat filesystem" This reverts commit 609a241000524a221d54b517bedc8f93aaa4c3cf. --- package/system/fstools/Makefile | 12 +- package/system/fstools/files/fstab.init | 6 +- .../patches/0001-add-exfat-support.patch | 315 ------------------ .../0002-fix-potential-memory-leak.patch | 11 - ...fix-lost-mount-point-when-first-boot.patch | 27 -- 5 files changed, 7 insertions(+), 364 deletions(-) delete mode 100644 package/system/fstools/patches/0001-add-exfat-support.patch delete mode 100644 package/system/fstools/patches/0002-fix-potential-memory-leak.patch delete mode 100644 package/system/fstools/patches/0003-fix-lost-mount-point-when-first-boot.patch diff --git a/package/system/fstools/Makefile b/package/system/fstools/Makefile index 218195a554..3c318df511 100644 --- a/package/system/fstools/Makefile +++ b/package/system/fstools/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fstools -PKG_RELEASE:=1 +PKG_RELEASE:=4 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git -PKG_SOURCE_DATE:=2019-09-21 -PKG_SOURCE_VERSION:=4327ed40d96c95803b2d4d09ddf997c895eea071 -PKG_MIRROR_HASH:=34e4510fbf8eb01571e4af632754c2f6799719e1f743037b998ca7fc838e6288 +PKG_SOURCE_DATE:=2019-03-28 +PKG_SOURCE_VERSION:=ff1ded63c51e84e239fb422ac8b9d15251d1221f +PKG_MIRROR_HASH:=2731bbca42c0eafda557d545ebeca243fa4048c433c3b27d31256aca356886bc CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 @@ -79,14 +79,14 @@ define Package/block-mount SECTION:=base CATEGORY:=Base system TITLE:=Block device mounting and checking - DEPENDS:=+ubox +libubox +libuci +libblobmsg-json +libjson-c + DEPENDS:=+ubox +libubox +libuci endef define Package/blockd SECTION:=base CATEGORY:=Base system TITLE:=Block device automounting - DEPENDS:=+block-mount +fstools +libubus +kmod-fs-autofs4 +libblobmsg-json +libjson-c + DEPENDS:=+block-mount +fstools +libubus +kmod-fs-autofs4 endef define Package/fstools/install diff --git a/package/system/fstools/files/fstab.init b/package/system/fstools/files/fstab.init index 08d5601bee..5faa8ecbb9 100644 --- a/package/system/fstools/files/fstab.init +++ b/package/system/fstools/files/fstab.init @@ -8,11 +8,7 @@ boot() { } start() { - return 0 -} - -restart() { - return 0 + echo "this file has been obsoleted. please call \"/sbin/block mount\" directly" } stop() { diff --git a/package/system/fstools/patches/0001-add-exfat-support.patch b/package/system/fstools/patches/0001-add-exfat-support.patch deleted file mode 100644 index f2325d0f17..0000000000 --- a/package/system/fstools/patches/0001-add-exfat-support.patch +++ /dev/null @@ -1,315 +0,0 @@ ---- a/libblkid-tiny/blkidP.h -+++ b/libblkid-tiny/blkidP.h -@@ -557,4 +557,16 @@ extern size_t blkid_encode_to_utf8(int e - #define BLKID_ENC_UTF16BE 0 - #define BLKID_ENC_UTF16LE 1 - -+enum uuid_format { -+ UUID_DOS = 0, /* 4 bytes */ -+ UUID_NTFS = 1, /* 8 bytes */ -+ UUID_DCE = 2, /* 16 bytes */ -+ UUID_DCE_STRING = 3, /* 36 bytes (VOLUME_ID_UUID_SIZE) */ -+}; -+ -+enum endian { -+ LE = 0, -+ BE = 1 -+}; -+ - #endif /* _BLKID_BLKIDP_H */ ---- /dev/null -+++ b/libblkid-tiny/exfat.c -@@ -0,0 +1,155 @@ -+ /* -+ * Copyright (C) 1999 by Andries Brouwer -+ * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o -+ * Copyright (C) 2001 by Andreas Dilger -+ * Copyright (C) 2004 Kay Sievers -+ * Copyright (C) 2008 Karel Zak -+ * Copyright (C) 2012 S-G Bergh -+ * Copyright (C) 2018 rosysong -+ * -+ * This file may be redistributed under the terms of the -+ * GNU Lesser General Public License. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#if 0 -+#include "pt-mbr.h" -+#endif -+ -+#include "superblocks.h" -+ -+#define EXFAT_SB_OFFSET 0 -+#define EXFAT_DIR_ENTRY_SZ 32 -+#define EXFAT_MAX_DIR_ENTRIES 100 -+ -+struct exfat_super_block { -+/* 0x00 */ uint8_t boot_jump[3]; -+/* 0x03 */ uint8_t fs_name[8]; -+/* 0x0B */ uint8_t must_be_zero[53]; -+/* 0x40 */ uint64_t partition_offset; -+/* 0x48 */ uint64_t volume_length; -+/* 0x50 */ uint32_t fat_offset; // Sector address of 1st FAT -+/* 0x54 */ uint32_t fat_size; // In sectors -+/* 0x58 */ uint32_t cluster_heap_offset; // Sector address of Data Region -+/* 0x5C */ uint32_t cluster_count; -+/* 0x60 */ uint32_t root_dir; // Cluster address of Root Directory -+/* 0x64 */ uint8_t vol_serial_nr[4]; // Volume ID -+/* 0x68 */ uint16_t fs_revision; // VV.MM -+/* 0x6A */ uint16_t vol_flags; -+/* 0x6C */ uint8_t bytes_per_sector; // Power of 2: 9 => 512, 12 => 4096 -+/* 0x6D */ uint8_t sectors_per_cluster; // Power of 2 -+/* 0x6E */ uint8_t nr_of_fats; // 2 for TexFAT -+/* 0x6F */ // ... -+} __attribute__((packed)); -+ -+struct exfat_dir_entry { -+/* 0x00 */ uint8_t entry_type; -+ union { -+ struct volume_label { -+/* 0x01 */ uint8_t char_count; // Length of label -+/* 0x02 */ uint16_t vol_label[11]; // UTF16 string without null termination -+/* 0x18 */ uint8_t reserved[8]; -+/* 0x20 */ } __attribute__((packed)) label; -+ struct volume_guid { -+/* 0x01 */ uint8_t sec_count; -+/* 0x02 */ uint16_t set_checksum; -+/* 0x04 */ uint16_t flags; -+/* 0x06 */ uint8_t vol_guid[16]; -+/* 0x16 */ uint8_t reserved[10]; -+/* 0x20 */ } __attribute__((packed)) guid; -+ } __attribute__((packed)) type; -+} __attribute__((packed)); -+ -+static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag) -+{ -+ struct exfat_super_block *sb; -+ struct exfat_dir_entry *de; -+ unsigned char *vol_label = 0; -+ unsigned char *vol_serno = NULL; -+ unsigned sector_sz; -+ unsigned cluster_sz; -+ uint64_t root_dir_off; -+ unsigned count; -+ unsigned need_lbl_guid; -+ const char *version = "EXFAT"; -+ -+ // Primary super block -+ DBG(LOWPROBE, ul_debug("exFAT: probing at offset 0x%x", EXFAT_SB_OFFSET)); -+ sb = blkid_probe_get_sb(pr, mag, struct exfat_super_block); -+ if (!sb) -+ return errno ? -errno : 1; -+ -+ if (memcmp(sb->fs_name, "EXFAT ", 8) != 0) -+ return -1; -+ -+ sector_sz = 1 << sb->bytes_per_sector; -+ cluster_sz = sector_sz << sb->sectors_per_cluster; -+ // There are no clusters 0 and 1, so the first cluster is 2. -+ root_dir_off = (uint64_t)EXFAT_SB_OFFSET + -+ // Hmm... should we cast sector_sz/cluster_sz to uint64_t? -+ (le32_to_cpu(sb->cluster_heap_offset)) * sector_sz + -+ (le32_to_cpu(sb->root_dir) - 2) * cluster_sz; -+ DBG(LOWPROBE, ul_debug("exFAT: sector size 0x%x bytes", sector_sz)); -+ DBG(LOWPROBE, ul_debug("exFAT: cluster size 0x%x bytes", cluster_sz)); -+ DBG(LOWPROBE, ul_debug("exFAT: root dir is at 0x%llx", (long long)root_dir_off)); -+ -+ // Use DOS uuid(UUID_DOS) as fallback, if no GUID set -+ vol_serno = sb->vol_serial_nr; -+ blkid_probe_sprintf_uuid_exfat(pr, vol_serno, UUID_DOS); -+ -+ // EXFAT_MAX_DIR_ENTRIES is used as a safety belt. -+ // The Root Directory may hold an unlimited number of entries, -+ // so we do not want to check all. Usually label and GUID -+ // are in the beginning, but there are no guarantees. -+ need_lbl_guid = (1 << 0) | (1 << 1); -+ for (count = 0; count < EXFAT_MAX_DIR_ENTRIES; count++) { -+ de = (struct exfat_dir_entry *) -+ blkid_probe_get_buffer(pr, root_dir_off + (count * EXFAT_DIR_ENTRY_SZ), EXFAT_DIR_ENTRY_SZ); -+ if (de == NULL) -+ break; -+ if (de->entry_type == 0x00) { -+ // End of Directory Marker -+ DBG(LOWPROBE, ul_debug("exFAT: End of root directory reached after %u entries", count)); -+ break; -+ } -+ if (de->entry_type == 0x83) { -+ // Volume Label Directory Entry -+ vol_label = (unsigned char *)de->type.label.vol_label; -+ blkid_probe_set_unicode16label(pr, vol_label, LE, 2 * de->type.label.char_count); -+ need_lbl_guid &= ~(1 << 0); -+ } -+ if (de->entry_type == 0xA0) { -+ // Volume GUID Directory Entry (UUID_DCE) -+ vol_serno = de->type.guid.vol_guid; -+ blkid_probe_sprintf_uuid_exfat(pr, vol_serno, UUID_DCE); -+ need_lbl_guid &= ~(1 << 1); -+ } -+ if (!need_lbl_guid) -+ break; -+ } -+ -+ if (version) -+ blkid_probe_set_version(pr, version); -+ -+ return 0; -+} -+ -+const struct blkid_idinfo exfat_idinfo = -+{ -+ .name = "exfat", -+ .usage = BLKID_USAGE_FILESYSTEM, -+ .probefunc = probe_exfat, -+ .magics = -+ { -+ { .magic = "EXFAT ", .len = 8, .sboff = 0x03 }, -+ { NULL } -+ } -+}; -+ ---- a/libblkid-tiny/libblkid-tiny.c -+++ b/libblkid-tiny/libblkid-tiny.c -@@ -121,6 +121,51 @@ int blkid_probe_set_label(blkid_probe pr - return 0; - } - -+int blkid_probe_set_unicode16(char *str, size_t len, const unsigned char *buf, enum endian endianess, size_t count) -+{ -+ unsigned i, j; -+ unsigned c; -+ -+ j = 0; -+ for (i = 0; i + 2 <= count; i += 2) { -+ if (endianess == LE) -+ c = (buf[i+1] << 8) | buf[i]; -+ else -+ c = (buf[i] << 8) | buf[i+1]; -+ if (c == 0) -+ break; -+ if (j+1 >= len) -+ break; -+ if (c < 0x80) { -+ /* 0xxxxxxx */ -+ } else { -+ unsigned char topbits = 0xc0; -+ if (j+2 >= len) -+ break; -+ if (c < 0x800) { -+ /* 110yyyxx 10xxxxxx */ -+ } else { -+ if (j+3 >= len) -+ break; -+ /* 1110yyyy 10yyyyxx 10xxxxxx */ -+ str[j++] = (unsigned char) (0xe0 | (c >> 12)); -+ topbits = 0x80; -+ } -+ str[j++] = (unsigned char) (topbits | ((c >> 6) & 0x3f)); -+ c = 0x80 | (c & 0x3f); -+ } -+ str[j++] = (unsigned char) c; -+ } -+ str[j] = '\0'; -+ -+ return j; -+} -+ -+int blkid_probe_set_unicode16label(blkid_probe pr, unsigned char *label, enum endian endianess, size_t len) -+{ -+ return blkid_probe_set_unicode16(pr->label, sizeof(pr->label), label, endianess, len); -+} -+ - int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const char *name) - { - short unsigned int*u = (short unsigned int*) uuid; -@@ -135,6 +180,47 @@ int blkid_probe_set_uuid_as(blkid_probe - return 0; - } - -+int blkid_probe_sprintf_uuid_exfat(blkid_probe pr, unsigned char *buf, enum uuid_format format) -+{ -+ unsigned i; -+ unsigned count = 4 << format; -+ -+ /* if set, create string in the same format, the native platform uses */ -+ for (i = 0; i < count; i++) -+ if (buf[i] != 0) -+ goto set; -+ -+ /* all bytes are zero, leave it empty ("") */ -+ return 0; -+ -+set: -+ switch (format) { -+ case UUID_DOS: -+ blkid_probe_sprintf_uuid(pr, buf, count, "%02X%02X-%02X%02X", -+ buf[3], buf[2], buf[1], buf[0]); -+ break; -+ case UUID_NTFS: -+ blkid_probe_sprintf_uuid(pr, buf, count, "%02X%02X%02X%02X%02X%02X%02X%02X", -+ buf[7], buf[6], buf[5], buf[4], -+ buf[3], buf[2], buf[1], buf[0]); -+ break; -+ case UUID_DCE: -+ blkid_probe_sprintf_uuid(pr, buf, count, -+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", -+ buf[0], buf[1], buf[2], buf[3], -+ buf[4], buf[5], buf[6], buf[7], -+ buf[8], buf[9], buf[10], buf[11], -+ buf[12], buf[13], buf[14], buf[15]); -+ break; -+ case UUID_DCE_STRING: -+ memcpy(pr->uuid, buf, count); -+ pr->uuid[count] = '\0'; -+ break; -+ } -+ -+ return count; -+} -+ - int blkid_probe_set_uuid(blkid_probe pr, unsigned char *uuid) - { - return blkid_probe_set_uuid_as(pr, uuid, NULL); -@@ -155,6 +241,7 @@ int blkid_probe_sprintf_uuid(blkid_probe - static const struct blkid_idinfo *idinfos[] = - { - &vfat_idinfo, -+ &exfat_idinfo, - &swsuspend_idinfo, - &swap_idinfo, - &ext4dev_idinfo, ---- a/libblkid-tiny/superblocks.h -+++ b/libblkid-tiny/superblocks.h -@@ -88,9 +88,15 @@ extern int blkid_probe_sprintf_version(b - extern int blkid_probe_set_label(blkid_probe pr, unsigned char *label, size_t len); - extern int blkid_probe_set_utf8label(blkid_probe pr, unsigned char *label, - size_t len, int enc); -+extern int blkid_probe_set_unicode16(char *str, size_t len, const unsigned char *buf, -+ enum endian endianess, size_t count); -+extern int blkid_probe_set_unicode16label(blkid_probe pr, unsigned char *label, -+ enum endian endianess, size_t len); - extern int blkid_probe_sprintf_uuid(blkid_probe pr, unsigned char *uuid, - size_t len, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 4, 5))); -+extern int blkid_probe_sprintf_uuid_exfat(blkid_probe pr, unsigned char *buf, -+ enum uuid_format format); - extern int blkid_probe_strncpy_uuid(blkid_probe pr, unsigned char *str, size_t len); - - extern int blkid_probe_set_uuid(blkid_probe pr, unsigned char *uuid); ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -24,6 +24,7 @@ ADD_LIBRARY(blkid-tiny SHARED - libblkid-tiny/ext.c - libblkid-tiny/jffs2.c - libblkid-tiny/vfat.c -+ libblkid-tiny/exfat.c - libblkid-tiny/ntfs.c - libblkid-tiny/hfs.c - libblkid-tiny/swap.c diff --git a/package/system/fstools/patches/0002-fix-potential-memory-leak.patch b/package/system/fstools/patches/0002-fix-potential-memory-leak.patch deleted file mode 100644 index 868df15a25..0000000000 --- a/package/system/fstools/patches/0002-fix-potential-memory-leak.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/libblkid-tiny/libblkid-tiny.c -+++ b/libblkid-tiny/libblkid-tiny.c -@@ -282,7 +282,7 @@ int probe_block(char *block, struct blki - - mag = &idinfos[i]->magics[0]; - -- while (mag->magic) { -+ while (mag && mag->magic) { - int off = (mag->kboff * 1024) + mag->sboff; - char magic[32] = { 0 }; - diff --git a/package/system/fstools/patches/0003-fix-lost-mount-point-when-first-boot.patch b/package/system/fstools/patches/0003-fix-lost-mount-point-when-first-boot.patch deleted file mode 100644 index bdc866ec6a..0000000000 --- a/package/system/fstools/patches/0003-fix-lost-mount-point-when-first-boot.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/mount_root.c -+++ b/mount_root.c -@@ -101,6 +101,7 @@ stop(int argc, char *argv[1]) - static int - done(int argc, char *argv[1]) - { -+ int ret; - struct volume *v = volume_find("rootfs_data"); - - if (!v) -@@ -109,7 +110,15 @@ done(int argc, char *argv[1]) - switch (volume_identify(v)) { - case FS_NONE: - case FS_DEADCODE: -- return jffs2_switch(v); -+ ret = jffs2_switch(v); -+ /* -+ * Devices mounted under /mnt will lost their mount point(see switch2jffs()) -+ * if the filesystem's(/overlay) state is not FS_STATE_READY, -+ * this action can fix it. -+ */ -+ if (!access("/sbin/block", X_OK)) -+ system("/sbin/block mount"); -+ return ret; - - case FS_EXT4: - case FS_F2FS: From 3ef73178d12fed2ecacfef5e856aa8cd34895f01 Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Thu, 17 Oct 2019 20:10:09 -0700 Subject: [PATCH 4/4] fstools: add exfat automount support --- .../patches/0001-add-exfat-support.patch | 315 ++++++++++++++++++ ...nit.patch => 0005-disable-lazy-init.patch} | 0 2 files changed, 315 insertions(+) create mode 100644 package/system/fstools/patches/0001-add-exfat-support.patch rename package/system/fstools/patches/{100-disable-lazy-init.patch => 0005-disable-lazy-init.patch} (100%) diff --git a/package/system/fstools/patches/0001-add-exfat-support.patch b/package/system/fstools/patches/0001-add-exfat-support.patch new file mode 100644 index 0000000000..f2325d0f17 --- /dev/null +++ b/package/system/fstools/patches/0001-add-exfat-support.patch @@ -0,0 +1,315 @@ +--- a/libblkid-tiny/blkidP.h ++++ b/libblkid-tiny/blkidP.h +@@ -557,4 +557,16 @@ extern size_t blkid_encode_to_utf8(int e + #define BLKID_ENC_UTF16BE 0 + #define BLKID_ENC_UTF16LE 1 + ++enum uuid_format { ++ UUID_DOS = 0, /* 4 bytes */ ++ UUID_NTFS = 1, /* 8 bytes */ ++ UUID_DCE = 2, /* 16 bytes */ ++ UUID_DCE_STRING = 3, /* 36 bytes (VOLUME_ID_UUID_SIZE) */ ++}; ++ ++enum endian { ++ LE = 0, ++ BE = 1 ++}; ++ + #endif /* _BLKID_BLKIDP_H */ +--- /dev/null ++++ b/libblkid-tiny/exfat.c +@@ -0,0 +1,155 @@ ++ /* ++ * Copyright (C) 1999 by Andries Brouwer ++ * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o ++ * Copyright (C) 2001 by Andreas Dilger ++ * Copyright (C) 2004 Kay Sievers ++ * Copyright (C) 2008 Karel Zak ++ * Copyright (C) 2012 S-G Bergh ++ * Copyright (C) 2018 rosysong ++ * ++ * This file may be redistributed under the terms of the ++ * GNU Lesser General Public License. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#if 0 ++#include "pt-mbr.h" ++#endif ++ ++#include "superblocks.h" ++ ++#define EXFAT_SB_OFFSET 0 ++#define EXFAT_DIR_ENTRY_SZ 32 ++#define EXFAT_MAX_DIR_ENTRIES 100 ++ ++struct exfat_super_block { ++/* 0x00 */ uint8_t boot_jump[3]; ++/* 0x03 */ uint8_t fs_name[8]; ++/* 0x0B */ uint8_t must_be_zero[53]; ++/* 0x40 */ uint64_t partition_offset; ++/* 0x48 */ uint64_t volume_length; ++/* 0x50 */ uint32_t fat_offset; // Sector address of 1st FAT ++/* 0x54 */ uint32_t fat_size; // In sectors ++/* 0x58 */ uint32_t cluster_heap_offset; // Sector address of Data Region ++/* 0x5C */ uint32_t cluster_count; ++/* 0x60 */ uint32_t root_dir; // Cluster address of Root Directory ++/* 0x64 */ uint8_t vol_serial_nr[4]; // Volume ID ++/* 0x68 */ uint16_t fs_revision; // VV.MM ++/* 0x6A */ uint16_t vol_flags; ++/* 0x6C */ uint8_t bytes_per_sector; // Power of 2: 9 => 512, 12 => 4096 ++/* 0x6D */ uint8_t sectors_per_cluster; // Power of 2 ++/* 0x6E */ uint8_t nr_of_fats; // 2 for TexFAT ++/* 0x6F */ // ... ++} __attribute__((packed)); ++ ++struct exfat_dir_entry { ++/* 0x00 */ uint8_t entry_type; ++ union { ++ struct volume_label { ++/* 0x01 */ uint8_t char_count; // Length of label ++/* 0x02 */ uint16_t vol_label[11]; // UTF16 string without null termination ++/* 0x18 */ uint8_t reserved[8]; ++/* 0x20 */ } __attribute__((packed)) label; ++ struct volume_guid { ++/* 0x01 */ uint8_t sec_count; ++/* 0x02 */ uint16_t set_checksum; ++/* 0x04 */ uint16_t flags; ++/* 0x06 */ uint8_t vol_guid[16]; ++/* 0x16 */ uint8_t reserved[10]; ++/* 0x20 */ } __attribute__((packed)) guid; ++ } __attribute__((packed)) type; ++} __attribute__((packed)); ++ ++static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag) ++{ ++ struct exfat_super_block *sb; ++ struct exfat_dir_entry *de; ++ unsigned char *vol_label = 0; ++ unsigned char *vol_serno = NULL; ++ unsigned sector_sz; ++ unsigned cluster_sz; ++ uint64_t root_dir_off; ++ unsigned count; ++ unsigned need_lbl_guid; ++ const char *version = "EXFAT"; ++ ++ // Primary super block ++ DBG(LOWPROBE, ul_debug("exFAT: probing at offset 0x%x", EXFAT_SB_OFFSET)); ++ sb = blkid_probe_get_sb(pr, mag, struct exfat_super_block); ++ if (!sb) ++ return errno ? -errno : 1; ++ ++ if (memcmp(sb->fs_name, "EXFAT ", 8) != 0) ++ return -1; ++ ++ sector_sz = 1 << sb->bytes_per_sector; ++ cluster_sz = sector_sz << sb->sectors_per_cluster; ++ // There are no clusters 0 and 1, so the first cluster is 2. ++ root_dir_off = (uint64_t)EXFAT_SB_OFFSET + ++ // Hmm... should we cast sector_sz/cluster_sz to uint64_t? ++ (le32_to_cpu(sb->cluster_heap_offset)) * sector_sz + ++ (le32_to_cpu(sb->root_dir) - 2) * cluster_sz; ++ DBG(LOWPROBE, ul_debug("exFAT: sector size 0x%x bytes", sector_sz)); ++ DBG(LOWPROBE, ul_debug("exFAT: cluster size 0x%x bytes", cluster_sz)); ++ DBG(LOWPROBE, ul_debug("exFAT: root dir is at 0x%llx", (long long)root_dir_off)); ++ ++ // Use DOS uuid(UUID_DOS) as fallback, if no GUID set ++ vol_serno = sb->vol_serial_nr; ++ blkid_probe_sprintf_uuid_exfat(pr, vol_serno, UUID_DOS); ++ ++ // EXFAT_MAX_DIR_ENTRIES is used as a safety belt. ++ // The Root Directory may hold an unlimited number of entries, ++ // so we do not want to check all. Usually label and GUID ++ // are in the beginning, but there are no guarantees. ++ need_lbl_guid = (1 << 0) | (1 << 1); ++ for (count = 0; count < EXFAT_MAX_DIR_ENTRIES; count++) { ++ de = (struct exfat_dir_entry *) ++ blkid_probe_get_buffer(pr, root_dir_off + (count * EXFAT_DIR_ENTRY_SZ), EXFAT_DIR_ENTRY_SZ); ++ if (de == NULL) ++ break; ++ if (de->entry_type == 0x00) { ++ // End of Directory Marker ++ DBG(LOWPROBE, ul_debug("exFAT: End of root directory reached after %u entries", count)); ++ break; ++ } ++ if (de->entry_type == 0x83) { ++ // Volume Label Directory Entry ++ vol_label = (unsigned char *)de->type.label.vol_label; ++ blkid_probe_set_unicode16label(pr, vol_label, LE, 2 * de->type.label.char_count); ++ need_lbl_guid &= ~(1 << 0); ++ } ++ if (de->entry_type == 0xA0) { ++ // Volume GUID Directory Entry (UUID_DCE) ++ vol_serno = de->type.guid.vol_guid; ++ blkid_probe_sprintf_uuid_exfat(pr, vol_serno, UUID_DCE); ++ need_lbl_guid &= ~(1 << 1); ++ } ++ if (!need_lbl_guid) ++ break; ++ } ++ ++ if (version) ++ blkid_probe_set_version(pr, version); ++ ++ return 0; ++} ++ ++const struct blkid_idinfo exfat_idinfo = ++{ ++ .name = "exfat", ++ .usage = BLKID_USAGE_FILESYSTEM, ++ .probefunc = probe_exfat, ++ .magics = ++ { ++ { .magic = "EXFAT ", .len = 8, .sboff = 0x03 }, ++ { NULL } ++ } ++}; ++ +--- a/libblkid-tiny/libblkid-tiny.c ++++ b/libblkid-tiny/libblkid-tiny.c +@@ -121,6 +121,51 @@ int blkid_probe_set_label(blkid_probe pr + return 0; + } + ++int blkid_probe_set_unicode16(char *str, size_t len, const unsigned char *buf, enum endian endianess, size_t count) ++{ ++ unsigned i, j; ++ unsigned c; ++ ++ j = 0; ++ for (i = 0; i + 2 <= count; i += 2) { ++ if (endianess == LE) ++ c = (buf[i+1] << 8) | buf[i]; ++ else ++ c = (buf[i] << 8) | buf[i+1]; ++ if (c == 0) ++ break; ++ if (j+1 >= len) ++ break; ++ if (c < 0x80) { ++ /* 0xxxxxxx */ ++ } else { ++ unsigned char topbits = 0xc0; ++ if (j+2 >= len) ++ break; ++ if (c < 0x800) { ++ /* 110yyyxx 10xxxxxx */ ++ } else { ++ if (j+3 >= len) ++ break; ++ /* 1110yyyy 10yyyyxx 10xxxxxx */ ++ str[j++] = (unsigned char) (0xe0 | (c >> 12)); ++ topbits = 0x80; ++ } ++ str[j++] = (unsigned char) (topbits | ((c >> 6) & 0x3f)); ++ c = 0x80 | (c & 0x3f); ++ } ++ str[j++] = (unsigned char) c; ++ } ++ str[j] = '\0'; ++ ++ return j; ++} ++ ++int blkid_probe_set_unicode16label(blkid_probe pr, unsigned char *label, enum endian endianess, size_t len) ++{ ++ return blkid_probe_set_unicode16(pr->label, sizeof(pr->label), label, endianess, len); ++} ++ + int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const char *name) + { + short unsigned int*u = (short unsigned int*) uuid; +@@ -135,6 +180,47 @@ int blkid_probe_set_uuid_as(blkid_probe + return 0; + } + ++int blkid_probe_sprintf_uuid_exfat(blkid_probe pr, unsigned char *buf, enum uuid_format format) ++{ ++ unsigned i; ++ unsigned count = 4 << format; ++ ++ /* if set, create string in the same format, the native platform uses */ ++ for (i = 0; i < count; i++) ++ if (buf[i] != 0) ++ goto set; ++ ++ /* all bytes are zero, leave it empty ("") */ ++ return 0; ++ ++set: ++ switch (format) { ++ case UUID_DOS: ++ blkid_probe_sprintf_uuid(pr, buf, count, "%02X%02X-%02X%02X", ++ buf[3], buf[2], buf[1], buf[0]); ++ break; ++ case UUID_NTFS: ++ blkid_probe_sprintf_uuid(pr, buf, count, "%02X%02X%02X%02X%02X%02X%02X%02X", ++ buf[7], buf[6], buf[5], buf[4], ++ buf[3], buf[2], buf[1], buf[0]); ++ break; ++ case UUID_DCE: ++ blkid_probe_sprintf_uuid(pr, buf, count, ++ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", ++ buf[0], buf[1], buf[2], buf[3], ++ buf[4], buf[5], buf[6], buf[7], ++ buf[8], buf[9], buf[10], buf[11], ++ buf[12], buf[13], buf[14], buf[15]); ++ break; ++ case UUID_DCE_STRING: ++ memcpy(pr->uuid, buf, count); ++ pr->uuid[count] = '\0'; ++ break; ++ } ++ ++ return count; ++} ++ + int blkid_probe_set_uuid(blkid_probe pr, unsigned char *uuid) + { + return blkid_probe_set_uuid_as(pr, uuid, NULL); +@@ -155,6 +241,7 @@ int blkid_probe_sprintf_uuid(blkid_probe + static const struct blkid_idinfo *idinfos[] = + { + &vfat_idinfo, ++ &exfat_idinfo, + &swsuspend_idinfo, + &swap_idinfo, + &ext4dev_idinfo, +--- a/libblkid-tiny/superblocks.h ++++ b/libblkid-tiny/superblocks.h +@@ -88,9 +88,15 @@ extern int blkid_probe_sprintf_version(b + extern int blkid_probe_set_label(blkid_probe pr, unsigned char *label, size_t len); + extern int blkid_probe_set_utf8label(blkid_probe pr, unsigned char *label, + size_t len, int enc); ++extern int blkid_probe_set_unicode16(char *str, size_t len, const unsigned char *buf, ++ enum endian endianess, size_t count); ++extern int blkid_probe_set_unicode16label(blkid_probe pr, unsigned char *label, ++ enum endian endianess, size_t len); + extern int blkid_probe_sprintf_uuid(blkid_probe pr, unsigned char *uuid, + size_t len, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 4, 5))); ++extern int blkid_probe_sprintf_uuid_exfat(blkid_probe pr, unsigned char *buf, ++ enum uuid_format format); + extern int blkid_probe_strncpy_uuid(blkid_probe pr, unsigned char *str, size_t len); + + extern int blkid_probe_set_uuid(blkid_probe pr, unsigned char *uuid); +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -24,6 +24,7 @@ ADD_LIBRARY(blkid-tiny SHARED + libblkid-tiny/ext.c + libblkid-tiny/jffs2.c + libblkid-tiny/vfat.c ++ libblkid-tiny/exfat.c + libblkid-tiny/ntfs.c + libblkid-tiny/hfs.c + libblkid-tiny/swap.c diff --git a/package/system/fstools/patches/100-disable-lazy-init.patch b/package/system/fstools/patches/0005-disable-lazy-init.patch similarity index 100% rename from package/system/fstools/patches/100-disable-lazy-init.patch rename to package/system/fstools/patches/0005-disable-lazy-init.patch