[OpenWrt-Devel] [PATCH] zram-swap: support swap priority

2020-01-09 Thread Maxim Storchak
If zram-backed swap is added after an existing swap, it gets a lower
priority. Assiming that usually all other swaps are slower, there should
be a way to assign a higher priority to zram swap.

Signed-off-by: Maxim Storchak 
---
 package/system/zram-swap/Makefile| 2 +-
 package/system/zram-swap/files/zram.init | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/package/system/zram-swap/Makefile 
b/package/system/zram-swap/Makefile
index bcada98a81..ee5e85927f 100644
--- a/package/system/zram-swap/Makefile
+++ b/package/system/zram-swap/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=zram-swap
 PKG_VERSION:=1.1
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
diff --git a/package/system/zram-swap/files/zram.init 
b/package/system/zram-swap/files/zram.init
index ae432f3b00..49140ad406 100755
--- a/package/system/zram-swap/files/zram.init
+++ b/package/system/zram-swap/files/zram.init
@@ -172,6 +172,8 @@ start()
local zram_size="$( zram_getsize )"
local zram_dev="$( zram_getdev )"
zram_applicable "$zram_dev" || return 1
+   local zram_priority="$( uci -q get system.@system[0].zram_priority )"
+   zram_priority=${zram_priority:+-p $zram_priority}
 
logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for 
swapping ($zram_size MegaBytes)"
 
@@ -180,7 +182,7 @@ start()
zram_comp_streams "$zram_dev"
echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename 
"$zram_dev" )/disksize"
mkswap "$zram_dev"
-   swapon "$zram_dev"
+   swapon $zram_priority "$zram_dev"
 }
 
 stop()
-- 
2.24.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 19.07] ca-certificates: provide ca-certs by both ca-certificates and ca-bundle

2019-12-25 Thread Maxim Storchak
- both packages provide ca-certs
- make ca-bundle the default provider

This should allow easy transition between these two forms of CA certificates 
storage

Signed-off-by: Maxim Storchak 
(cherry picked from commit dd299805ad18472a8245b4524a25e4381e166057)
---
 package/system/ca-certificates/Makefile | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/package/system/ca-certificates/Makefile 
b/package/system/ca-certificates/Makefile
index f449645c77..ea7d253fa2 100644
--- a/package/system/ca-certificates/Makefile
+++ b/package/system/ca-certificates/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ca-certificates
 PKG_VERSION:=20190110
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_MAINTAINER:=
 
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.xz
@@ -24,6 +24,7 @@ define Package/ca-certificates
   CATEGORY:=Base system
   TITLE:=System CA certificates
   PKGARCH:=all
+  PROVIDES:=ca-certs
 endef
 
 define Package/ca-bundle
@@ -31,6 +32,7 @@ define Package/ca-bundle
   CATEGORY:=Base system
   TITLE:=System CA certificates as a bundle
   PKGARCH:=all
+  PROVIDES:=ca-certs
 endef
 
 define Build/Install
@@ -59,5 +61,5 @@ define Package/ca-bundle/install
cat $(PKG_INSTALL_DIR)/usr/share/ca-certificates/*/*.crt 
>$(1)/etc/ssl/certs/ca-certificates.crt
$(LN) /etc/ssl/certs/ca-certificates.crt $(1)/etc/ssl/cert.pem
 endef
-$(eval $(call BuildPackage,ca-certificates))
 $(eval $(call BuildPackage,ca-bundle))
+$(eval $(call BuildPackage,ca-certificates))
-- 
2.24.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ca-certificates: provide ca-certs by both ca-certificates and ca-bundle

2019-12-12 Thread Maxim Storchak
- both packages provide ca-certs
- make ca-bundle the default provider

This should allow easy transition between these two forms of CA certificates 
storage

Signed-off-by: Maxim Storchak 
---
 package/system/ca-certificates/Makefile | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/package/system/ca-certificates/Makefile 
b/package/system/ca-certificates/Makefile
index f449645c77..ea7d253fa2 100644
--- a/package/system/ca-certificates/Makefile
+++ b/package/system/ca-certificates/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ca-certificates
 PKG_VERSION:=20190110
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_MAINTAINER:=
 
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.xz
@@ -24,6 +24,7 @@ define Package/ca-certificates
   CATEGORY:=Base system
   TITLE:=System CA certificates
   PKGARCH:=all
+  PROVIDES:=ca-certs
 endef
 
 define Package/ca-bundle
@@ -31,6 +32,7 @@ define Package/ca-bundle
   CATEGORY:=Base system
   TITLE:=System CA certificates as a bundle
   PKGARCH:=all
+  PROVIDES:=ca-certs
 endef
 
 define Build/Install
@@ -59,5 +61,5 @@ define Package/ca-bundle/install
cat $(PKG_INSTALL_DIR)/usr/share/ca-certificates/*/*.crt 
>$(1)/etc/ssl/certs/ca-certificates.crt
$(LN) /etc/ssl/certs/ca-certificates.crt $(1)/etc/ssl/cert.pem
 endef
-$(eval $(call BuildPackage,ca-certificates))
 $(eval $(call BuildPackage,ca-bundle))
+$(eval $(call BuildPackage,ca-certificates))
-- 
2.24.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] procd: patch to support busybox mkfs.ext2

2016-07-03 Thread Maxim Storchak
On 7/3/16 00:26, Luke McKee wrote:
> For some further background...
> 
> the original procd zram patch uses ext2 :)
> 
> https://dev.openwrt.org/ticket/19586#comment:9
> https://lists.openwrt.org/pipermail/openwrt-devel/2014-December/029587.html
> 
> It shows you what happens when someone enables this option from make 
> menuconfig.
> There needs to be some dependency testing. I suggest apply the patch
> and make it dependent on busybox mkfs.ext2 only.
> Leave mkfs.ext4 e2fsprogs in /usr/sbin and let users choose which they
> want from a fully qualified path in scripts.

Is there a reason to use full path specification? Why can't
mkfs.ext{2|4} be called and whichever is found first in PATH gets
executed? In this case only one of e2fsprogs and busybox implementations
should be required. Let busybox be default, but please leave an option
to use full e2fsprogs and disable mkfs.ext* in busybox.
Something like DEPENDS:= ... +!BUSYBOX_CONFIG_MKFS_EXT2:e2fsprogs

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Why default of XATTR in kernel but not userspace?

2015-12-23 Thread Maxim Storchak
Hi Daniel,

When I added attr and acl initially, I enabled xattr and acl support for
filesystems, but then that part was removed, possibly because dependency
logic didn't conform standards (just in case, I'm not blaming anyone,
that was one of my first patches submitted), see
https://github.com/openwrt/packages/commit/c43ecd25564391d518039971a86cd692e5a685fb.
I like your idea of having single place to control ACL and XATTR
support, but that may mean that attr and acl have to become core
components, not packages.

On 12/20/15 10:18, Daniel Dickinson wrote:
> Hi all,
> 
> I've been working on a patch for making POSIX ACL support and userspace
> support of POSIX ACL and XATTR (extended attributes) a configuration
> option at compile time and noticed something rather wonky:
> 
> While for POSIX ACL the default is disabled both at the kernel
> level and in userpace (i.e. filesystem modules by default do
> not support POSIX ACL and programs don't use libacl).
> 
> OTOH for XATTR support the default is for kernel modules and built-ins
> to support XATTR, but block mount does not support XATTR so I'm not sure
> any filesystems are actually mounted with xattr support enabled, and, in
> addition, no programs are compiled with xattr support (that is the
> default is not support xattr in userspace by default).
> 
> I'm a little puzzled as to why this is and what is acommplished by
> having XATTR support by filesystem modules, when it doesn't appear
> anything uses that support (unless overlayfs uses with jffs2 and/or
> tmpfs uses it via procd, but the support would fail for anything not
> mounted by procd).
> 
> What is exactly is logic/reason for this configuration and what is
> actually going on here?  Is xattr used at all?  If it is, why the mixed
> bag of support vs. lack of support depending on how a filesystem
> is mounted?
> 
> My plan is to make a config option that, when enabled, makes POSIX ACL
> support in both kernel and userpace the default (with certain exceptions
> like JFFS2 and TMPFS), along with userpace xattr support.
> In addition I add to the build options menu (if the above option is
> enabled), the ability to turn on and off POSIX ACL support for each
> filesystem.
> 
> (The option if enabled also manages (on by default) NFSv4 (and off by
> default) old NFS ACL support).
> 
> In addition I have a patch to fstools that lets block mount mount with
> posix acl and xattr support enabled.
> 
> (I make this an ifdef since it's pointless without the appropriate
> kernel support).
> 
> 
> Regards,
> 
> Daniel
> _______
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] uClibc: enable xattr support to make feature sets of libc implementations closer to each other

2015-10-21 Thread Maxim Storchak
Size increase is about 3-4k: this is how big xattr.os in uClibc after stripping 
is.

Signed-off-by: Maxim Storchak 
---
 toolchain/uClibc/config-0.9.33.2/common | 2 +-
 toolchain/uClibc/config-ng-1.0.6/common | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/toolchain/uClibc/config-0.9.33.2/common 
b/toolchain/uClibc/config-0.9.33.2/common
index b948d4b..c26d22b 100644
--- a/toolchain/uClibc/config-0.9.33.2/common
+++ b/toolchain/uClibc/config-0.9.33.2/common
@@ -187,7 +187,7 @@ UCLIBC_HAS_TZ_FILE_READ_MANY=y
 # UCLIBC_HAS_UTMPX is not set
 UCLIBC_HAS_WCHAR=y
 UCLIBC_HAS_WORDEXP=y
-# UCLIBC_HAS_XATTR is not set
+UCLIBC_HAS_XATTR=y
 # UCLIBC_HAS_XLOCALE is not set
 UCLIBC_HAS___PROGNAME=y
 # UCLIBC_LINUX_MODULE_24 is not set
diff --git a/toolchain/uClibc/config-ng-1.0.6/common 
b/toolchain/uClibc/config-ng-1.0.6/common
index ddaf600..fc43c6f 100644
--- a/toolchain/uClibc/config-ng-1.0.6/common
+++ b/toolchain/uClibc/config-ng-1.0.6/common
@@ -192,7 +192,7 @@ UCLIBC_HAS_UTMPX=y
 UCLIBC_HAS_UTMP=y
 UCLIBC_HAS_WCHAR=y
 UCLIBC_HAS_WORDEXP=y
-# UCLIBC_HAS_XATTR is not set
+UCLIBC_HAS_XATTR=y
 # UCLIBC_HAS_XLOCALE is not set
 UCLIBC_HAS___PROGNAME=y
 # UCLIBC_LINUX_MODULE_24 is not set
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] RFC: uClibc and xattr

2015-10-20 Thread Maxim Storchak
Hello,

I was trying to fix https://github.com/openwrt/packages/issues/1703
(lsof compilation on mips64) and discovered that a) mips64* were the
only targets using uCLibc; b) xattr was disabled in uClibc config.
I tried to add DEPENDS:=@(!(USE_UCLIBC)) to libattr, but that created
recursive dependencies for musl targets:
tmp/.config-package.in:55568:error: recursive dependency detected!
tmp/.config-package.in:55568:   symbol PACKAGE_rsnapshot depends on
RSYNC_xattr
tmp/.config-package.in:34393:   symbol RSYNC_xattr depends on PACKAGE_rsync
tmp/.config-package.in:34365:   symbol PACKAGE_rsync is selected by
PACKAGE_rsnapshot
I tried several approaches, but didn't get any further.

My questions are:
- is xattr disabled in uClibc for purpose?
- would it make sense to enable it to make feature sets of libc
implementations closer to each other?

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] musl: add upstream patch for open_[w]memstream

2015-10-13 Thread Maxim Storchak
This patch fixes corner case in open_memstrem, when stream is created,
but nothing is written.
This case is present in tgtadm, tgtd management tool.

Signed-off-by: Maxim Storchak 
---
 .../musl/patches/020-upstream_open_memstream.patch | 79 ++
 1 file changed, 79 insertions(+)
 create mode 100644 toolchain/musl/patches/020-upstream_open_memstream.patch

diff --git a/toolchain/musl/patches/020-upstream_open_memstream.patch 
b/toolchain/musl/patches/020-upstream_open_memstream.patch
new file mode 100644
index 000..3d14404
--- /dev/null
+++ b/toolchain/musl/patches/020-upstream_open_memstream.patch
@@ -0,0 +1,79 @@
+From 7b9f57f207b51132f188f750161953b7baf32154 Mon Sep 17 00:00:00 2001
+From: Rich Felker 
+Date: Thu, 8 Oct 2015 22:03:53 +
+Subject: fix open_[w]memstream behavior when no writes take place
+
+the specification for these functions requires that the buffer/size
+exposed to the caller be valid after any successful call to fflush or
+fclose on the stream. the implementation's approach is to update them
+only at flush time, but that misses the case where fflush or fclose is
+called without any writes having taken place, in which case the write
+flushing callback will not be called.
+
+to fix both the observable bug and the desired invariant, setup empty
+buffers at open time and fail the open operation if no memory is
+available.
+---
+ src/stdio/open_memstream.c  | 11 +--
+ src/stdio/open_wmemstream.c | 11 +--
+ 2 files changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c
+index 58504c9..eab024d 100644
+--- a/src/stdio/open_memstream.c
 b/src/stdio/open_memstream.c
+@@ -59,14 +59,21 @@ FILE *open_memstream(char **bufp, size_t *sizep)
+ {
+   FILE *f;
+   struct cookie *c;
++  char *buf;
++
+   if (!(f=malloc(sizeof *f + sizeof *c + BUFSIZ))) return 0;
++  if (!(buf=malloc(sizeof *buf))) {
++  free(f);
++  return 0;
++  }
+   memset(f, 0, sizeof *f + sizeof *c);
+   f->cookie = c = (void *)(f+1);
+ 
+   c->bufp = bufp;
+   c->sizep = sizep;
+-  c->pos = c->len = c->space = 0;
+-  c->buf = 0;
++  c->pos = c->len = c->space = *sizep = 0;
++  c->buf = *bufp = buf;
++  *buf = 0;
+ 
+   f->flags = F_NORD;
+   f->fd = -1;
+diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c
+index 7ab2c64..4d90cd9 100644
+--- a/src/stdio/open_wmemstream.c
 b/src/stdio/open_wmemstream.c
+@@ -61,14 +61,21 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep)
+ {
+   FILE *f;
+   struct cookie *c;
++  wchar_t *buf;
++
+   if (!(f=malloc(sizeof *f + sizeof *c))) return 0;
++  if (!(buf=malloc(sizeof *buf))) {
++  free(f);
++  return 0;
++  }
+   memset(f, 0, sizeof *f + sizeof *c);
+   f->cookie = c = (void *)(f+1);
+ 
+   c->bufp = bufp;
+   c->sizep = sizep;
+-  c->pos = c->len = c->space = 0;
+-  c->buf = 0;
++  c->pos = c->len = c->space = *sizep = 0;
++  c->buf = *bufp = buf;
++  *buf = 0;
+ 
+   f->flags = F_NORD;
+   f->fd = -1;
+-- 
+cgit v0.11.2
+
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] procd: add helper binaries to jail

2015-08-12 Thread Maxim Storchak
This allows to build jails with more than a single binary.
May be used to run main program with a wrapper, f.e. ionice,
or to add helper binaries for the main one (like gzip for tar with no
build-in compression support).

Usage:
directly:
ujail ... -b /usr/bin/main ... -- /bin/wrapper ... /usr/bin/main
ujail ... -b /usr/bin/helper1 -b /bin/helper2 ... -- /usr/bin/main
in init scripts:
procd_add_jail_mount_bin /usr/bin/something /bin/helper

Signed-off-by: Maxim Storchak 
---
 package/system/procd/files/procd.sh| 18 +++
 .../procd/patches/100-ujail-helper-binary.patch| 58 ++
 .../procd/patches/101-service-helper-binary.patch  | 15 ++
 3 files changed, 91 insertions(+)
 create mode 100644 package/system/procd/patches/100-ujail-helper-binary.patch
 create mode 100644 package/system/procd/patches/101-service-helper-binary.patch

diff --git a/package/system/procd/files/procd.sh 
b/package/system/procd/files/procd.sh
index e83e75c..bc9f78d 100644
--- a/package/system/procd/files/procd.sh
+++ b/package/system/procd/files/procd.sh
@@ -177,6 +177,23 @@ _procd_add_jail_mount_rw() {
json_select ..
 }
 
+_procd_add_jail_mount_bin() {
+   local _json_no_warning=1
+
+   json_select "jail"
+   [ $? = 0 ] || return
+   json_select "mount"
+   [ $? = 0 ] || {
+   json_select ..
+   return
+   }
+   for a in $@; do
+   json_add_string "$a" "2"
+   done
+   json_select ..
+   json_select ..
+}
+
 _procd_set_param() {
local type="$1"; shift
 
@@ -423,6 +440,7 @@ _procd_wrapper \
procd_add_jail \
procd_add_jail_mount \
procd_add_jail_mount_rw \
+   procd_add_jail_mount_bin \
procd_set_param \
procd_append_param \
procd_add_validation \
diff --git a/package/system/procd/patches/100-ujail-helper-binary.patch 
b/package/system/procd/patches/100-ujail-helper-binary.patch
new file mode 100644
index 000..dd7ab64
--- /dev/null
+++ b/package/system/procd/patches/100-ujail-helper-binary.patch
@@ -0,0 +1,58 @@
+diff --git a/jail/jail.c b/jail/jail.c
+index 2bba292..22fda87 100644
+--- a/jail/jail.c
 b/jail/jail.c
+@@ -43,7 +43,7 @@
+ #include 
+ 
+ #define STACK_SIZE(1024 * 1024)
+-#define OPT_ARGS  "P:S:n:r:w:psuldo"
++#define OPT_ARGS  "P:S:n:r:w:b:psuldo"
+ 
+ struct extra {
+   struct list_head list;
+@@ -260,6 +260,7 @@ static int usage(void)
+   fprintf(stderr, "  -n \tthe name of the jail\n");
+   fprintf(stderr, "  -r \treadonly files that should be staged\n");
+   fprintf(stderr, "  -w \twriteable files that should be staged\n");
++  fprintf(stderr, "  -b \tadditional binaries that should be 
staged\n");
+   fprintf(stderr, "  -p\t\tjail has /proc\t\n");
+   fprintf(stderr, "  -s\t\tjail has /sys\t\n");
+   fprintf(stderr, "  -l\t\tjail has /dev/log\t\n");
+@@ -433,6 +434,12 @@ int main(int argc, char **argv)
+ 
+   umask(022);
+ 
++  avl_init(&libraries, avl_strcmp, false, NULL);
++  alloc_library_path("/lib64");
++  alloc_library_path("/lib");
++  alloc_library_path("/usr/lib");
++  load_ldso_conf("/etc/ld.so.conf");
++
+   while ((ch = getopt(argc, argv, OPT_ARGS)) != -1) {
+   switch (ch) {
+   case 'd':
+@@ -457,6 +464,11 @@ int main(int argc, char **argv)
+   case 'l':
+   add_extra(log, 0);
+   break;
++  case 'b':
++  if (elf_load_deps(optarg)) {
++  ERROR("failed to load dependencies for %s\n", 
optarg);
++  return -1;
++  }
+   }
+   }
+ 
+@@ -476,11 +488,6 @@ int main(int argc, char **argv)
+   if (name)
+   prctl(PR_SET_NAME, name, NULL, NULL, NULL);
+ 
+-  avl_init(&libraries, avl_strcmp, false, NULL);
+-  alloc_library_path("/lib64");
+-  alloc_library_path("/lib");
+-  alloc_library_path("/usr/lib");
+-  load_ldso_conf("/etc/ld.so.conf");
+ 
+   if (elf_load_deps(argv[optind])) {
+   ERROR("failed to load dependencies\n");
diff --git a/package/system/procd/patches/101-service-helper-binary.patch 
b/package/system/procd/patches/101-service-helper-binary.patch
new file mode 100644
index 000..0b4a274
--- /dev/null
+++ b/package/system/procd/patches/101-service-helper-binary.patch
@@ -0,0 +1,15 @@
+diff --git a/service/instance.c b/service/instance.c
+index 40ff021..9fec647 100644
+--- a/service/instance.c
 b/service/instance.c
+@@ -208,7 +208,9 @@ jail_run(struct service_instance *in, char **argv)
+   blobmsg_list_

[OpenWrt-Devel] issues with service jailing

2015-08-11 Thread Maxim Storchak
Hi,

I'm trying to build latest trunk with CONFIG_PROCD_JAIL_SUPPORT=y, and
it appears that ujail can't run anything in jail. The reason is that
/lib/ld-musl-mips-sf.so.1 (I have ar71xx router) is not present in jail
root. As I understand, ujail parses ELF headers of the target binary and
bind-mounts all libs into jail. All but not that one. Unfortunately I
can't fix it myself, so I'd like core devs to take a look at this issue.

Reproduction:
root@OpenWrt:~# ldd /bin/busybox
/lib/ld-musl-mips-sf.so.1 (0x55c3)
librpc.so => /lib/librpc.so (0x77b8a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x77b66000)
libc.so => /lib/ld-musl-mips-sf.so.1 (0x55c3)
root@OpenWrt:~# ls -la /lib/ld-musl-mips-sf.so.1
lrwxrwxrwx 1 root root 7 Aug 10 20:43 /lib/ld-musl-mips-sf.so.1 -> libc.so

root@OpenWrt:~# /sbin/ujail -n busybox  -P /tmp/.jail/busybox --
/bin/busybox ash
jail: spawning /bin/busybox
jail: failed to spawn child /bin/busybox: No such file or directory
jail: child (2) exited: 65280
jail: namespace (3319) exited: 10

root@OpenWrt:~# /sbin/ujail -n busybox  -P /tmp/.jail/busybox -r
/lib/ld-musl-mips-sf.so.1  -- /bin/busybox ash
jail: spawning /bin/busybox
/ # /bin/busybox ls /
bin  lib  usr


One more request would be to add support for "helper" binaries. Consider
this case: I want to run transmission with idle IO priority. At the
moment procd doesn't support ionoce, so I try to run /bin/ionice -c3
/usr/bin/transmission-daemon. In this case ujail correctly creates jail
for ionice, but everything required to run transmission-daemon has to be
added by hands.
It would be nice to be able to pass single reference to a binary
(/usr/bin/transmission-daemon in this case) and have ujail automatically
pull all required libs. init subsystem should export this ability as
something like procd_add_jail_mount_bin.

Reproduction:
root@OpenWrt:~# /sbin/ujail -n busybox  -P /tmp/.jail/busybox -r
/lib/ld-musl-mips-sf.so.1  -- /bin/ionice -c3 /usr/bin/wget-ssl
jail: spawning /bin/ionice
ionice: can't execute '/usr/bin/wget-ssl': No such file or directory
jail: child (2) exited: 32512
jail: namespace (3375) exited: 10

root@OpenWrt:~# /sbin/ujail -n busybox  -P /tmp/.jail/busybox -r
/lib/ld-musl-mips-sf.so.1 -r /usr/lib/libpcre.so.1 -r
/usr/lib/libssl.so.1.0.0 -r /usr/lib/libcrypto.so.1.0.0 -r
/usr/lib/libz.so.1 -r /usr/bin/wget-ssl -- /bin/ionice -c3 /usr/bin/wget-ssl
jail: spawning /bin/ionice
wget-ssl: missing URL
Usage: wget-ssl [OPTION]... [URL]...

Try `wget-ssl --help' for more options.
jail: child (2) exited: 256
jail: namespace (3393) exited: 10


With patch applied:
root@OpenWrt:~# /tmp/ujail -n busybox -b /usr/bin/wget-ssl -b
/usr/bin/curl -b /usr/bin/tmux -P /tmp/.jail/busybox -r
/lib/ld-musl-mips-sf.so.1  -- /bin/busybox ls -1 /lib /usr/lib
jail: spawning /bin/busybox
/lib:
ld-musl-mips-sf.so.1
libblobmsg_json.so
libc.so
libgcc_s.so.1
libpreload-seccomp.so
librpc.so
libubox.so

/usr/lib:
libcrypto.so.1.0.0
libcurl.so.4
libevent-2.0.so.5
libjson-c.so.2
libncurses.so.5
libpcre.so.1
libssl.so.1.0.0
libz.so.1
jail: child (2) exited: 0
jail: namespace (4500) exited: 10


-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
Signed-off-by: Maxim Storchak 

diff --git a/jail/jail.c b/jail/jail.c
index 2bba292..22fda87 100644
--- a/jail/jail.c
+++ b/jail/jail.c
@@ -43,7 +43,7 @@
 #include 
 
 #define STACK_SIZE (1024 * 1024)
-#define OPT_ARGS   "P:S:n:r:w:psuldo"
+#define OPT_ARGS   "P:S:n:r:w:b:psuldo"
 
 struct extra {
struct list_head list;
@@ -260,6 +260,7 @@ static int usage(void)
fprintf(stderr, "  -n \tthe name of the jail\n");
fprintf(stderr, "  -r \treadonly files that should be staged\n");
fprintf(stderr, "  -w \twriteable files that should be staged\n");
+   fprintf(stderr, "  -b \tadditional binaries that should be 
staged\n");
fprintf(stderr, "  -p\t\tjail has /proc\t\n");
fprintf(stderr, "  -s\t\tjail has /sys\t\n");
fprintf(stderr, "  -l\t\tjail has /dev/log\t\n");
@@ -433,6 +434,12 @@ int main(int argc, char **argv)
 
umask(022);
 
+   avl_init(&libraries, avl_strcmp, false, NULL);
+   alloc_library_path("/lib64");
+   alloc_library_path("/lib");
+   alloc_library_path("/usr/lib");
+   load_ldso_conf("/etc/ld.so.conf");
+
while ((ch = getopt(argc, argv, OPT_ARGS)) != -1) {
switch (ch) {
case 'd':
@@ -457,6 +464,11 @@ int main(int argc, char **argv)
case 'l':
add_extra(log, 0);
break;
+   case 'b':
+   if (elf_load_deps(optarg)) {
+   ERROR("failed to load dependencies for %s

[OpenWrt-Devel] [PATCH 3/3] e2fsprogs: symlink e2fsck to fsck.ext{2, 3, 4}, and tune2fs to findfs

2014-12-29 Thread Maxim Storchak
Signed-off-by: Maxim Storchak 

diff --git a/package/utils/e2fsprogs/Makefile b/package/utils/e2fsprogs/Makefile
index 969f0d6..a2ce999 100644
--- a/package/utils/e2fsprogs/Makefile
+++ b/package/utils/e2fsprogs/Makefile
@@ -148,6 +148,9 @@ define Package/e2fsprogs/install
$(LN) mke2fs $(1)/usr/sbin/mkfs.ext2
$(LN) mke2fs $(1)/usr/sbin/mkfs.ext3
$(LN) mke2fs $(1)/usr/sbin/mkfs.ext4
+   $(LN) e2fsck $(1)/usr/sbin/fsck.ext2
+   $(LN) e2fsck $(1)/usr/sbin/fsck.ext3
+   $(LN) e2fsck $(1)/usr/sbin/fsck.ext4
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libe2p.so.* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/etc/init.d
@@ -175,6 +178,7 @@ endef
 define Package/tune2fs/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tune2fs $(1)/usr/sbin/
+   $(LN) tune2fs $(1)/usr/sbin/findfs
 endef
 
 define Package/resize2fs/install
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] e2fsprogs: package dumpe2fs, e2freefrag, filefrag, debugfs

2014-12-29 Thread Maxim Storchak
Signed-off-by: Maxim Storchak 

diff --git a/package/utils/e2fsprogs/Makefile b/package/utils/e2fsprogs/Makefile
index 09c4833..969f0d6 100644
--- a/package/utils/e2fsprogs/Makefile
+++ b/package/utils/e2fsprogs/Makefile
@@ -67,6 +67,30 @@ $(call Package/e2fsprogs)
   DEPENDS:= +e2fsprogs
 endef
 
+define Package/dumpe2fs
+$(call Package/e2fsprogs)
+  TITLE:=Ext2 Filesystem information dumping utility
+  DEPENDS:= +e2fsprogs
+endef
+
+define Package/e2freefrag
+$(call Package/e2fsprogs)
+  TITLE:=Ext2 Filesystem free space fragmentation information utility
+  DEPENDS:= +e2fsprogs
+endef
+
+define Package/filefrag
+$(call Package/e2fsprogs)
+  TITLE:=Ext2 Filesystem file fragmentation report utility
+  DEPENDS:= +e2fsprogs
+endef
+
+define Package/debugfs
+$(call Package/e2fsprogs)
+  TITLE:=Ext2 Filesystem debugger
+  DEPENDS:= +e2fsprogs
+endef
+
 TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections
 
 CONFIGURE_VARS += \
@@ -163,8 +187,34 @@ define Package/badblocks/install
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/badblocks $(1)/usr/sbin/
 endef
 
+define Package/dumpe2fs/install
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/dumpe2fs $(1)/usr/sbin/
+endef
+
+define Package/e2freefrag/install
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/e2freefrag $(1)/usr/sbin/
+endef
+
+define Package/filefrag/install
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/filefrag $(1)/usr/sbin/
+endef
+
+define Package/debugfs/install
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(INSTALL_DIR) $(1)/usr/lib
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/debugfs $(1)/usr/sbin/
+   $(CP) $(PKG_INSTALL_DIR)/usr/lib/libss.so.* $(1)/usr/lib/
+endef
+
 $(eval $(call BuildPackage,e2fsprogs))
 $(eval $(call BuildPackage,libext2fs))
 $(eval $(call BuildPackage,tune2fs))
 $(eval $(call BuildPackage,resize2fs))
 $(eval $(call BuildPackage,badblocks))
+$(eval $(call BuildPackage,dumpe2fs))
+$(eval $(call BuildPackage,e2freefrag))
+$(eval $(call BuildPackage,filefrag))
+$(eval $(call BuildPackage,debugfs))
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] e2fsprogs: bump release

2014-12-29 Thread Maxim Storchak
Signed-off-by: Maxim Storchak 

diff --git a/package/utils/e2fsprogs/Makefile b/package/utils/e2fsprogs/Makefile
index b91c957..09c4833 100644
--- a/package/utils/e2fsprogs/Makefile
+++ b/package/utils/e2fsprogs/Makefile
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=e2fsprogs
 PKG_VERSION:=1.42.4
 PKG_MD5SUM:=b6e296f210d642361b7394437ff0f318
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@SF/e2fsprogs
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/3] tgt: add more knobs to config, improve error handling

2014-06-04 Thread Maxim Storchak
- allow to select multiple addresses and ports to listent to
- support both address- and name-based ACLs
  (note: config option has been changed from "allow" to "allow_address", 
"allow_name")
- support more optionf for LUNs
- support various device types (disk, cd, sg passthrough)
- bind accounts to multiple targets
- use uci_validate_section in the init script
- improve error reporting, use logger instead of echo

Note: this patch depends on http://patchwork.openwrt.org/patch/5586/

Signed-off-by: Maxim Storchak 
---
 net/tgt/files/etc/config/tgt |   48 +++
 net/tgt/files/etc/init.d/tgt |  190 --
 2 files changed, 180 insertions(+), 58 deletions(-)

diff --git a/net/tgt/files/etc/config/tgt b/net/tgt/files/etc/config/tgt
index 98b2206..7686a13 100644
--- a/net/tgt/files/etc/config/tgt
+++ b/net/tgt/files/etc/config/tgt
@@ -2,40 +2,58 @@ config options 'tgt'
 # iothreads limits number of worker threads per rdwr target, default is 16
 # which seems to be too much for an avarage router
option iothreads '2'
-#  option portal '0.0.0.0:3260'
 #  option nop_count '3'
-#  option nop_interval '5'
+#  option nop_interval '1'
+#  list portal '[::1]'
+#  list portal '127.0.0.1:3261'
+#  list portal '0.0.0.0:3262'
+#  list portal '[::]:3263'
 
 config target 1
option name 'iqn.2012-06.org.openwrt:target1'
-   option allow ALL
+#  list allow_name 'iqn.1994-05.org.example:fedcba987654'
+#  list allow_address '192.168.1.0/27'
 
 #config target 2
 #  option name 'iqn.2012-06.org.openwrt:t2'
-#  option allow 192.168.1.0/24
-
 
 # all options are set to default, except for the device
-# for all type and bstype values see tgtd(8)
 # lun "name" is constructed as TGTID_LUN
 #config lun1_1
-#  option readonly 0
-#  option device /dev/sda
-#  option type disk
-#  option bstype rdwr
-#  option sync 0
-#  option direct 0
-
+#  option 'device' '/dev/sda'
+# type of scsi device. available options: disk, cd, pt (sg passthrough)
+#  option 'type' 'disk'
+# backing store access method: rdwr (read-write), aio (async IO), sg (for pt 
type only, device must be /dev/sgN)
+#  option 'bstype' 'aio'
+# set sync and/or direct flags when opening device, affect only rdwr
+#  option 'sync' '0'
+#  option 'direct' '0'
+# block size for lun, default is 512
+#  option 'blocksize' 4096
+# override SCSI mode page, see tgtadm man page for details
+#  option 'mode_page' 'string'
+# vendor, product, revision, SCSI ID and SCSI Serial number
+#  option 'vendor_id' 'string'
+#  option 'product_id' 'string'
+#  option 'product_rev' 'string'
+#  option 'scsi_id' 'string'
+#  option 'scsi_sn' 'string'
+# refuse write attempts. applies only to disk type
+#  option 'readonly' '0'
+# Disk devices default to non-removable, cd - to removable
+#  option 'removable' '0'
+#  0 = Clasic sense format, 1 = Support descriptor format.
+#  option 'sense_format' '0'
 
 #config lun 2_1
-#  option readonly 0
 #  option device /mnt/iscsi.img
 
 #config lun 2_2
 #  option device /dev/sdc
 
 #config account
-#  option target 1
+#  list target 1
+#  list target 2
 #  option user "username1"
 #  option password "pass1"
 
diff --git a/net/tgt/files/etc/init.d/tgt b/net/tgt/files/etc/init.d/tgt
index 82648b6..da03201 100755
--- a/net/tgt/files/etc/init.d/tgt
+++ b/net/tgt/files/etc/init.d/tgt
@@ -10,23 +10,45 @@ PROG=/usr/sbin/tgtd
 USE_PROCD=1
 
 tgtadm="/usr/sbin/tgtadm --lld iscsi"
+logger="logger -p daemon.err -s -t $NAME"
+
+validate_lun_section() {
+   uci_validate_section tgt lun $1 \
+   'device:file' \
+   'type:or("disk", "cd", "pt"):disk' \
+   'bstype:or("rdwr", "aio", "sg"):rdwr' \
+   'sync:bool:0' \
+   'direct:bool:0' \
+   'blocksize:uinteger' \
+   'mode_page:string' \
+   'product_id:string' \
+   'product_rev:string' \
+   'readonly:bool:0' \
+   'removable:bool' \
+   'scsi_id:string' \
+   'scsi_sn:string' \
+   'sense_format:range(0, 1)

[OpenWrt-Devel] [PATCH 3/3] tgt: update to 1.0.48, refresh patches

2014-06-04 Thread Maxim Storchak
Signed-off-by: Maxim Storchak 
---
 net/tgt/Makefile   |6 +++---
 net/tgt/patches/010-fallocate.patch|4 ++--
 net/tgt/patches/020-usr_Makefile.patch |   16 
 net/tgt/patches/030-Makefile.patch |6 +++---
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/net/tgt/Makefile b/net/tgt/Makefile
index 5f918d4..6d7fc96 100644
--- a/net/tgt/Makefile
+++ b/net/tgt/Makefile
@@ -7,9 +7,9 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=tgt
-PKG_VERSION:=1.0.46
-PKG_REV:=601a44d6c833f59d9d2472ad11d421481a25b2e7
-PKG_RELEASE:=2
+PKG_VERSION:=1.0.48
+PKG_REV:=22d9567f39e5eb8a794ce2cb5a2190abdbecaa1f
+PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/fujita/tgt.git
diff --git a/net/tgt/patches/010-fallocate.patch 
b/net/tgt/patches/010-fallocate.patch
index cb8ddb4..9d572d6 100644
--- a/net/tgt/patches/010-fallocate.patch
+++ b/net/tgt/patches/010-fallocate.patch
@@ -1,5 +1,5 @@
 tgt-1.0.42/usr/util.h.orig 2013-12-26 16:18:54.0 +0200
-+++ tgt-1.0.42/usr/util.h  2013-12-26 16:19:10.0 +0200
+--- tgt-1.0.48.orig/usr/util.h 2014-06-04 15:03:53.0 +0300
 tgt-1.0.48/usr/util.h  2014-06-04 15:17:48.548123039 +0300
 @@ -212,11 +212,6 @@
   */
  static inline int unmap_file_region(int fd, off_t offset, off_t length)
diff --git a/net/tgt/patches/020-usr_Makefile.patch 
b/net/tgt/patches/020-usr_Makefile.patch
index 33b235b..2deb305 100644
--- a/net/tgt/patches/020-usr_Makefile.patch
+++ b/net/tgt/patches/020-usr_Makefile.patch
@@ -1,5 +1,5 @@
 tgt-1.0.46.orig/usr/Makefile   2014-04-06 09:55:49.0 +0300
-+++ tgt-1.0.46/usr/Makefile2014-04-06 09:57:04.0 +0300
+--- tgt-1.0.48.orig/usr/Makefile   2014-06-04 15:03:53.0 +0300
 tgt-1.0.48/usr/Makefile2014-06-04 15:17:56.373670618 +0300
 @@ -1,13 +1,13 @@
  sbindir ?= $(PREFIX)/sbin
  libdir ?= $(PREFIX)/lib/tgt
@@ -18,8 +18,8 @@
  
  TGTD_OBJS += $(addprefix iscsi/, conn.o param.o session.o \
iscsid.o target.o chap.o sha1.o md5.o transport.o iscsi_tcp.o \
-@@ -21,8 +21,9 @@
- MODULES += bs_glfs.so
+@@ -25,8 +25,9 @@
+ CFLAGS += -DUSE_SYSTEMD
  endif
  
 -ifneq ($(shell test -e /usr/include/sys/eventfd.h && test -e 
/usr/include/libaio.h && echo 1),)
@@ -30,16 +30,16 @@
  TGTD_OBJS += bs_aio.o
  LIBS += -laio
  endif
-@@ -47,7 +48,7 @@
- 
- LIBS += -lpthread -ldl
+@@ -55,7 +56,7 @@
+ LIBS += -lsystemd-daemon
+ endif
  
 -PROGRAMS += tgtd tgtadm tgtimg
 +PROGRAMS += tgtd tgtadm
  TGTD_OBJS += tgtd.o mgmt.o target.o scsi.o log.o driver.o util.o work.o \
concat_buf.o parser.o spc.o sbc.o mmc.o osd.o scc.o smc.o \
ssc.o libssc.o bs_rdwr.o bs_ssc.o \
-@@ -74,14 +75,8 @@
+@@ -82,14 +83,8 @@
  
  -include $(TGTADM_DEP)
  
diff --git a/net/tgt/patches/030-Makefile.patch 
b/net/tgt/patches/030-Makefile.patch
index 5ef9b82..ab54f22 100644
--- a/net/tgt/patches/030-Makefile.patch
+++ b/net/tgt/patches/030-Makefile.patch
@@ -1,6 +1,6 @@
 tgt-1.0.46.orig/Makefile   2014-04-06 09:55:49.0 +0300
-+++ tgt-1.0.46/Makefile2014-04-06 09:57:04.0 +0300
-@@ -63,7 +63,7 @@
+--- tgt-1.0.48.orig/Makefile   2014-06-04 15:03:53.0 +0300
 tgt-1.0.48/Makefile2014-06-04 15:18:13.132963670 +0300
+@@ -64,7 +64,7 @@
$(MAKE) -C conf clean
  
  .PHONY: install
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] tgt: configure number of iothreads, allow to bind to specific address/port

2014-06-04 Thread Maxim Storchak
Default number of iothreads for rdwr target is 16. Setting it to 2 lowers
memory footprint dramatically.
By default tgtd binds to wildcard address. Now it's possible to specify
address and port to listen to.
New options have been added to configure keepalives.

Signed-off-by: Maxim Storchak 
---
 net/tgt/files/etc/config/tgt |8 
 net/tgt/files/etc/init.d/tgt |   21 +
 2 files changed, 29 insertions(+)

diff --git a/net/tgt/files/etc/config/tgt b/net/tgt/files/etc/config/tgt
index 250d12d..98b2206 100644
--- a/net/tgt/files/etc/config/tgt
+++ b/net/tgt/files/etc/config/tgt
@@ -1,3 +1,11 @@
+config options 'tgt'
+# iothreads limits number of worker threads per rdwr target, default is 16
+# which seems to be too much for an avarage router
+   option iothreads '2'
+#  option portal '0.0.0.0:3260'
+#  option nop_count '3'
+#  option nop_interval '5'
+
 config target 1
option name 'iqn.2012-06.org.openwrt:target1'
option allow ALL
diff --git a/net/tgt/files/etc/init.d/tgt b/net/tgt/files/etc/init.d/tgt
index 38efa2b..82648b6 100755
--- a/net/tgt/files/etc/init.d/tgt
+++ b/net/tgt/files/etc/init.d/tgt
@@ -85,9 +85,30 @@ configure() {
return 0
 }
 
+validate_tgt_section() {
+   uci_validate_section tgt options $1 \
+   'iothreads:uinteger' \
+   'portal:string' \
+   'nop_interval:uinteger' \
+   'nop_count:uinteger'
+}
+
 start_service() {
+   local iothreads portal nop_interval nop_count
+   validate_tgt_section tgt || {
+   echo "validation failed"
+   return 1
+   }
procd_open_instance
procd_set_param command $PROG -f
+   [ "$iothreads" ] && procd_append_param command -t $iothreads
+   [ "${portal}${nop_interval}${nop_count}" ] && {
+   local iscsi
+   [ "$portal" ] && iscsi="portal=$portal"
+   [ "$nop_interval" ] && iscsi="nop_interval=$nop_interval,$iscsi"
+   [ "$nop_count" ] && iscsi="nop_count=$nop_count,$iscsi"
+   procd_append_param command --iscsi $iscsi
+   }
procd_set_param respawn
procd_close_instance
logger -t $NAME -s "Configuration will be loaded in seconds"
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/1] procd: rename local variable in uci_validate_section

2014-06-04 Thread Maxim Storchak
Allow to use "package", "type", "name", "error" and "result"
as config option names:

package some_service
config section 'foo'
option name 'bar'
option type 'unknown'

Signed-off-by: Maxim Storchak 
---
 package/system/procd/files/procd.sh |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/package/system/procd/files/procd.sh 
b/package/system/procd/files/procd.sh
index c5dc3c6..d83c067 100644
--- a/package/system/procd/files/procd.sh
+++ b/package/system/procd/files/procd.sh
@@ -219,16 +219,16 @@ _procd_kill() {
 
 uci_validate_section()
 {
-   local package="$1"
-   local type="$2"
-   local name="$3"
-   local error
+   local _package="$1"
+   local _type="$2"
+   local _name="$3"
+   local _error
shift; shift; shift
-   local result=`/sbin/validate_data "$package" "$type" "$name" "$@" 2> 
/dev/null`
-   error=$?
-   eval "$result"
-   [ "$error" = "0" ] || `/sbin/validate_data "$package" "$type" "$name" 
"$@" 1> /dev/null`
-   return $error
+   local _result=`/sbin/validate_data "$_package" "$_type" "$_name" "$@" 
2> /dev/null`
+   _error=$?
+   eval "$_result"
+   [ "$_error" = "0" ] || `/sbin/validate_data "$_package" "$_type" 
"$_name" "$@" 1> /dev/null`
+   return $_error
 }
 
 _procd_wrapper \
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] [packages] new package tgt

2014-05-05 Thread Maxim Storchak
On 05.05.14 22:35, Florian Fainelli wrote:
> 2014-04-06 1:35 GMT-07:00 Maxim Storchak :
>> This patch provides userspace iSCSI target support.
>>
>> https://dev.openwrt.org/ticket/8798
>>
>> Signed-off-by: Maxim Storchak 
> 
> Applied in r40703, thanks!
> 
Thank you for merging it, but there is one issue I found after
submitting the patch: "Package/.../conffiles" doesn't like leading
spaces. Could you please remove it? Correct section should look like this:

define Package/tgt/conffiles
/etc/config/tgt
endef

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] haserl: uptate to 0.9.32, add optional lua support

2014-05-03 Thread Maxim Storchak
This patch updates haserl to version 0.9.32 and introduces optional lua support
See http://haserl.sourceforge.net/manpage.html#lbAM

Note: to implement lua support I had to change build process slightly to
get rid of host precompilation of lua script. I decided to patch existing
Makefile.in instead of patching Makefile.am and regenerating everything
from scratch.  If this approach is wrong and it's better to patch Makefile.am,
please let me know.

Signed-off-by: Maxim Storchak 
---
 utils/haserl/Config.in |   35 +
 utils/haserl/Makefile  |   21 -
 .../patches/100-replace-lua2c-with-sed.patch   |   80 
 utils/haserl/patches/101-adjust-script-size.patch  |   11 +++
 4 files changed, 145 insertions(+), 2 deletions(-)
 create mode 100644 utils/haserl/Config.in
 create mode 100644 utils/haserl/patches/100-replace-lua2c-with-sed.patch
 create mode 100644 utils/haserl/patches/101-adjust-script-size.patch

diff --git a/utils/haserl/Config.in b/utils/haserl/Config.in
new file mode 100644
index 000..e5fb90d
--- /dev/null
+++ b/utils/haserl/Config.in
@@ -0,0 +1,35 @@
+if PACKAGE_haserl
+
+   config HASERL_with_lua
+   bool
+   default n
+
+   comment "Lua support"
+
+   config HASERL_shell_luac
+   bool
+   prompt "Support --shell=luac"
+   select HASERL_with_lua
+   default n
+   help
+   haserl(1):
+   The luac "shell" is a precompiled lua chunk, so 
interactive
+   editing and testing of scripts is not possible. However,
+   haserl can be compiled with luac support only, and this
+   allows lua support even in a small memory environment. 
All
+   haserl lua features listed above are still available. 
(If
+   luac is the only shell built into haserl, the
+   haserl.loadfile is disabled, as the haserl parser is not
+   compiled in.)
+
+   config HASERL_shell_lua
+   bool
+   prompt "Support --shell=lua"
+   select HASERL_with_lua
+   default n
+   help
+   haserl(1):
+   If compiled with lua support, --shell=lua will enable 
lua as the
+   script language instead of bash shell.
+
+endif
diff --git a/utils/haserl/Makefile b/utils/haserl/Makefile
index 4d7164f..31e966f 100644
--- a/utils/haserl/Makefile
+++ b/utils/haserl/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=haserl
-PKG_VERSION:=0.9.29
+PKG_VERSION:=0.9.32
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@SF/haserl
-PKG_MD5SUM:=4cac9409530200b4a7a82a48ec174800
+PKG_MD5SUM:=18e2208aea6d772d1670c1a648bb6b77
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -22,8 +22,25 @@ define Package/haserl
   CATEGORY:=Utilities
   TITLE:=A CGI wrapper to embed shell scripts in HTML documents
   URL:=http://haserl.sourceforge.net/
+  MENU:=1
+  DEPENDS:= +HASERL_with_lua:liblua
 endef
 
+define Package/haserl/config
+   source "$(SOURCE)/Config.in
+endef
+
+ifeq ($(CONFIG_HASERL_with_lua),y)
+   CONFIGURE_ARGS+=--with-lua
+   TARGET_LDFLAGS += -ldl
+endif
+ifneq ($(CONFIG_HASERL_shell_lua),y)
+   CONFIGURE_ARGS+=--disable-luashell
+endif
+ifneq ($(CONFIG_HASERL_shell_luac),y)
+   CONFIGURE_ARGS+=--disable-luacshell
+endif
+
 define Package/haserl/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/haserl $(1)/usr/bin/
diff --git a/utils/haserl/patches/100-replace-lua2c-with-sed.patch 
b/utils/haserl/patches/100-replace-lua2c-with-sed.patch
new file mode 100644
index 000..5b19fc1
--- /dev/null
+++ b/utils/haserl/patches/100-replace-lua2c-with-sed.patch
@@ -0,0 +1,80 @@
+--- a/src/Makefile.in  2013-09-20 23:52:15.0 +0300
 b/src/Makefile.in  2014-05-03 23:06:17.0 +0300
+@@ -76,7 +76,6 @@
+ NORMAL_UNINSTALL = :
+ PRE_UNINSTALL = :
+ POST_UNINSTALL = :
+-@USE_LUA_TRUE@noinst_PROGRAMS = lua2c$(EXEEXT)
+ @INCLUDE_LUASHELL_TRUE@@USE_LUA_TRUE@am__append_1 = h_lua.c h_lua.h
+ @INCLUDE_LUACSHELL_TRUE@@USE_LUA_TRUE@am__append_2 = h_luac.c h_luac.h
+ bin_PROGRAMS = haserl$(EXEEXT)
+@@ -115,9 +114,6 @@
+ haserl_DEPENDENCIES = $(am__DEPENDENCIES_1)
+ haserl_LINK = $(CCLD) $(haserl_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+   $(LDFLAGS) -o $@
+-lua2c_SOURCES = lua2c.c
+-lua2c_OBJECTS = lua2c.$(OBJEXT)
+-lua2c_LDADD = $(LDADD)
+ AM_V_P = $(am__v_P_@AM_V@)
+ am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+ am__v_P_0 = false
+@@ -150,8 +146,8 @@
+ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+ am__v_CCLD_0 = @echo "  CCLD" $@;
+ am__v_CCLD_1 = 
+-SOURCES = $(haserl_SOURCES) $(nodist_haserl_SOURCES) lua2c.c
+-DIST_SOURCES = $(a

[OpenWrt-Devel] [PATCH try3 2/2] [luaposix]: update to v31

2014-05-02 Thread Maxim Storchak
v31 adds more interfaces to POSIX.
New compared to v5.1.11:
nanosleep, open, close, read, write, pipe, dup, dup2, setfl, getfl, fcntl,
poll, fnmatch, memrchr, strptime, statvfs, mkdtemp, isatty, openpt, ptsname,
grantpt, unlockpt, killpg, openpty, realpath, socket functions and constants,
fixes, optimizations, etc.
New dependency: luabitop (provided as a separate patch)

New in try3: PKG_BUILD_DEPENDS:=+lua/host. Should address
> I do not have Lua installed locally and it looks like it wants to check
> my local lua version.

Signed-off-by: Maxim Storchak 
---
 lang/luaposix/Makefile|   19 ++---
 lang/luaposix/patches/100-eglibc-compat.patch |   28 +
 2 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/lang/luaposix/Makefile b/lang/luaposix/Makefile
index 95e0135..0747c77 100644
--- a/lang/luaposix/Makefile
+++ b/lang/luaposix/Makefile
@@ -8,13 +8,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luaposix
-PKG_VERSION:=5.1.11
-PKG_RELEASE:=2
+PKG_VERSION:=v31
+PKG_RELEASE:=1
+_BASENAME:=release
 
-PKG_SOURCE:=v$(PKG_VERSION).tar.gz
+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/luaposix/luaposix/archive/
-PKG_MD5SUM:=8254576c52bd2d0e160353d24880bb89
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_MD5SUM:=a25ff76d54bbbebf7a1f3b20c9806ee3
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(_BASENAME)-$(PKG_VERSION)
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -24,7 +25,8 @@ define Package/luaposix
   CATEGORY:=Languages
   TITLE:=luaposix
   URL:=http://luaforge.net/projects/luaposix/
-  DEPENDS:=+lua +librt
+  DEPENDS:=+lua +librt +luabitop
+  PKG_BUILD_DEPENDS:=+lua/host
 endef
 
 define Package/luaposix/description
@@ -33,6 +35,8 @@ define Package/luaposix/description
 endef
 
 define Build/Configure
+   cd $(PKG_BUILD_DIR) && ./bootstrap
+   $(call Build/Configure/Default)
 endef
 
 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
@@ -46,7 +50,8 @@ endif
 
 define Package/luaposix/install
$(INSTALL_DIR) $(1)/usr/lib/lua
-   $(INSTALL_BIN) $(PKG_BUILD_DIR)/posix.so $(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/ext/posix/.libs/posix_c.so 
$(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/posix.lua $(1)/usr/lib/lua
 endef
 
 $(eval $(call BuildPackage,luaposix))
diff --git a/lang/luaposix/patches/100-eglibc-compat.patch 
b/lang/luaposix/patches/100-eglibc-compat.patch
index 96a6fce..10aad20 100644
--- a/lang/luaposix/patches/100-eglibc-compat.patch
+++ b/lang/luaposix/patches/100-eglibc-compat.patch
@@ -1,26 +1,28 @@
 a/lposix.c
-+++ b/lposix.c
-@@ -960,11 +960,13 @@ static int Pctermid(lua_State *L)/** c
+--- luaposix-release-v31/ext/posix/posix.c.orig2014-03-10 
14:22:45.0 +0200
 luaposix-release-v31/ext/posix/posix.c 2014-03-10 14:25:04.0 
+0200
+@@ -1970,6 +1970,7 @@
+   return 1;
  }
  
- 
 +#ifndef NO_GETLOGIN
- static int Pgetlogin(lua_State *L)/** getlogin() */
- {
+ /***
+ Current logged-in user.
+ @see getlogin(3)
+@@ -1980,6 +1981,7 @@
lua_pushstring(L, getlogin());
return 1;
  }
 +#endif
  
- 
  static void Fgetpasswd(lua_State *L, int i, const void *data)
-@@ -1778,7 +1780,9 @@ static const luaL_reg R[] =
+ {
+@@ -3786,7 +3788,9 @@
  #if _POSIX_VERSION >= 200112L
-   {"getgroups",   Pgetgroups},
+   MENTRY( Pgetgroups  ),
  #endif
 +#ifndef NO_GETLOGIN
-   {"getlogin",Pgetlogin},
+   MENTRY( Pgetlogin   ),
 +#endif
-   {"getopt_long", Pgetopt_long},
-   {"getpasswd",   Pgetpasswd},
-   {"getpid",  Pgetpid},
+   MENTRY( Pgetopt ),
+   MENTRY( Pgetpasswd  ),
+   MENTRY( Pgetpid ),
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH try3 1/2] [luabitop]: new package

2014-05-02 Thread Maxim Storchak
Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise
operations on numbers.
This is a requirement for the updated luaposix.

Note: nothing new compared to try2, repeating it just in case.

Signed-off-by: Maxim Storchak 
---
 lang/luabitop/Makefile |   51 
 1 file changed, 51 insertions(+)
 create mode 100644 lang/luabitop/Makefile

diff --git a/lang/luabitop/Makefile b/lang/luabitop/Makefile
new file mode 100644
index 000..1eccaa9
--- /dev/null
+++ b/lang/luabitop/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luabitop
+PKG_VERSION:=1.0.2
+PKG_RELEASE:=1
+
+_BASENAME:=LuaBitOp
+
+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://bitop.luajit.org/download/
+PKG_MD5SUM:=d0c1080fe0c844e8477279668e2d0d06
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(_BASENAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luabitop
+  SUBMENU:=Lua
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=luabitop
+  URL:=http://bitop.luajit.org/
+  DEPENDS:=+lua
+endef
+
+define Package/luabitop/description
+Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise 
operations on numbers.
+endef
+
+define Build/Configure
+endef
+
+
+TARGET_CFLAGS += $(FPIC) -DLUA_USE_LINUX -DLUA_NUMBER_DOUBLE
+
+define Build/Compile
+   $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CPPFLAGS) 
-std=gnu99 $(FPIC) -DLUA_USE_LINUX -shared -o $(PKG_BUILD_DIR)/bit.so 
$(PKG_BUILD_DIR)/bit.c
+endef
+
+define Package/luabitop/install
+   $(INSTALL_DIR) $(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/bit.so $(1)/usr/lib/lua
+endef
+
+$(eval $(call BuildPackage,luabitop))
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH try2 2/2] packages: update luaposix to v31

2014-04-30 Thread Maxim Storchak
On 01.05.14 01:00, Hauke Mehrtens wrote:
> On 03/30/2014 11:20 AM, Maxim Storchak wrote:
>> v31 adds more interfaces to POSIX.
>> New compared to v5.1.11:
>> nanosleep, open, close, read, write, pipe, dup, dup2, setfl, getfl, fcntl,
>> poll, fnmatch, memrchr, strptime, statvfs, mkdtemp, isatty, openpt, ptsname,
>> grantpt, unlockpt, killpg, openpty, realpath, socket functions and constants,
>> fixes, optimizations, etc.
>>
>> New dependency: luabitop (provided as a separate patch)
>>
>> Signed-off-by: Maxim Storchak 
>> ---
>>  lang/luaposix/Makefile|   20 +++---
>>  lang/luaposix/patches/100-eglibc-compat.patch |   28 
>> +
>>  2 files changed, 27 insertions(+), 21 deletions(-)
>>
> 
> Hi,
> 
> I am getting the following error with your patch.
> 
> I do not have Lua installed locally and it looks like it wants to check
> my local lua version.
> 
> Hauke
> 

I see. Thank you for the feedback, I'll fix the issue and resubmit.

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH try2 1/2] packages: new package luabitop

2014-04-16 Thread Maxim Storchak
On 30.03.14 02:20, Maxim Storchak wrote:
> Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise 
> operations on numbers.
> 

Ping.

Is there anything wrong with the patch?

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] [packages] new package tgt

2014-04-06 Thread Maxim Storchak
This patch provides userspace iSCSI target support.

https://dev.openwrt.org/ticket/8798

Signed-off-by: Maxim Storchak 
---
 net/tgt/Makefile   |   59 ++
 net/tgt/files/etc/config/tgt   |   38 
 net/tgt/files/etc/init.d/tgt   |  107 
 net/tgt/patches/010-fallocate.patch|   14 +
 net/tgt/patches/020-usr_Makefile.patch |   56 +
 net/tgt/patches/030-Makefile.patch |   11 
 6 files changed, 285 insertions(+)
 create mode 100644 net/tgt/Makefile
 create mode 100644 net/tgt/files/etc/config/tgt
 create mode 100755 net/tgt/files/etc/init.d/tgt
 create mode 100644 net/tgt/patches/010-fallocate.patch
 create mode 100644 net/tgt/patches/020-usr_Makefile.patch
 create mode 100644 net/tgt/patches/030-Makefile.patch

diff --git a/net/tgt/Makefile b/net/tgt/Makefile
new file mode 100644
index 000..676bdc2
--- /dev/null
+++ b/net/tgt/Makefile
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=tgt
+PKG_VERSION:=1.0.46
+PKG_REV:=601a44d6c833f59d9d2472ad11d421481a25b2e7
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/fujita/tgt.git
+
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_REV).tar.gz
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/tgt
+  SECTION:=net
+  CATEGORY:=Network
+  URL:=http://stgt.sourceforge.net/
+  TITLE:=userspace iSCSI target
+  DEPENDS:=+libpthread +libaio +@KERNEL_AIO +@KERNEL_DIRECT_IO
+endef
+
+define Package/tgt/description
+Linux SCSI target framework (tgt) aims to simplify various SCSI target driver 
(iSCSI, Fibre Channel, SRP, etc) creation and maintenance.
+Key goals of the project are the clean integration into the scsi-mid layer and 
implementing a great portion of tgt in user space.
+Tgt consists of kernel-space and user-space code. The kernel-space component 
is included in upstream as of 2.6.20.
+Note that if you are interested in only iSCSI (probably you are), you need 
only the user-space code (any kernel version is fine).
+endef
+
+define Build/Compile
+   CC=$(TARGET_CC) CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $(PKG_BUILD_DIR) \
+   DESTDIR="$(PKG_INSTALL_DIR)" \
+   LD="$(TARGET_CC)" \
+   install-programs
+endef
+
+define Package/tgt/conffiles
+   /etc/config/tgt
+endef
+
+define Package/tgt/install
+   $(INSTALL_DIR) $(1)/
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(CP) ./files/* $(1)/
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tgtd $(1)/usr/sbin/
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tgtadm $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,tgt))
diff --git a/net/tgt/files/etc/config/tgt b/net/tgt/files/etc/config/tgt
new file mode 100644
index 000..250d12d
--- /dev/null
+++ b/net/tgt/files/etc/config/tgt
@@ -0,0 +1,38 @@
+config target 1
+   option name 'iqn.2012-06.org.openwrt:target1'
+   option allow ALL
+
+#config target 2
+#  option name 'iqn.2012-06.org.openwrt:t2'
+#  option allow 192.168.1.0/24
+
+
+# all options are set to default, except for the device
+# for all type and bstype values see tgtd(8)
+# lun "name" is constructed as TGTID_LUN
+#config lun1_1
+#  option readonly 0
+#  option device /dev/sda
+#  option type disk
+#  option bstype rdwr
+#  option sync 0
+#  option direct 0
+
+
+#config lun 2_1
+#  option readonly 0
+#  option device /mnt/iscsi.img
+
+#config lun 2_2
+#  option device /dev/sdc
+
+#config account
+#  option target 1
+#  option user "username1"
+#  option password "pass1"
+
+#config account
+#  option target 2
+#  option user "user2"
+#  option password "pwd2"
+#  option outgoing 1
diff --git a/net/tgt/files/etc/init.d/tgt b/net/tgt/files/etc/init.d/tgt
new file mode 100755
index 000..38efa2b
--- /dev/null
+++ b/net/tgt/files/etc/init.d/tgt
@@ -0,0 +1,107 @@
+#!/bin/sh /etc/rc.common
+START=91
+STOP=10
+
+EXTRA_COMMANDS="show"
+EXTRA_HELP="   showShow current configuration of tgtd"
+
+NAME=tgt
+PROG=/usr/sbin/tgtd
+USE_PROCD=1
+
+tgtadm="/usr/sbin/tgtadm --lld iscsi"
+
+handle_lun() {
+   local tgt_lun=$1
+   local tgtid=$2
+   local ro device type bstype sync direct
+   local my_tgtid=${tgt_lun%_*}
+   local lun=${tgt_lun#*_}
+   [ $my_tgtid -eq $tgtid ] || return 0
+
+   config_get device $1 device ""
+   [ "$device" ] || return 1
+
+   config_get type $1 type disk
+   config_get bstype $1 bstype rdwr
+   config_get_b

[OpenWrt-Devel] [PATCH try2 1/2] packages: new package luabitop

2014-03-30 Thread Maxim Storchak
Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise operations 
on numbers.

Signed-off-by: Maxim Storchak 
---
 lang/luabitop/Makefile |   51 
 1 file changed, 51 insertions(+)
 create mode 100644 lang/luabitop/Makefile

diff --git a/lang/luabitop/Makefile b/lang/luabitop/Makefile
new file mode 100644
index 000..1eccaa9
--- /dev/null
+++ b/lang/luabitop/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luabitop
+PKG_VERSION:=1.0.2
+PKG_RELEASE:=1
+
+_BASENAME:=LuaBitOp
+
+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://bitop.luajit.org/download/
+PKG_MD5SUM:=d0c1080fe0c844e8477279668e2d0d06
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(_BASENAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luabitop
+  SUBMENU:=Lua
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=luabitop
+  URL:=http://bitop.luajit.org/
+  DEPENDS:=+lua
+endef
+
+define Package/luabitop/description
+Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise 
operations on numbers.
+endef
+
+define Build/Configure
+endef
+
+
+TARGET_CFLAGS += $(FPIC) -DLUA_USE_LINUX -DLUA_NUMBER_DOUBLE
+
+define Build/Compile
+   $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CPPFLAGS) 
-std=gnu99 $(FPIC) -DLUA_USE_LINUX -shared -o $(PKG_BUILD_DIR)/bit.so 
$(PKG_BUILD_DIR)/bit.c
+endef
+
+define Package/luabitop/install
+   $(INSTALL_DIR) $(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/bit.so $(1)/usr/lib/lua
+endef
+
+$(eval $(call BuildPackage,luabitop))
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH try2 2/2] packages: update luaposix to v31

2014-03-30 Thread Maxim Storchak
v31 adds more interfaces to POSIX.
New compared to v5.1.11:
nanosleep, open, close, read, write, pipe, dup, dup2, setfl, getfl, fcntl,
poll, fnmatch, memrchr, strptime, statvfs, mkdtemp, isatty, openpt, ptsname,
grantpt, unlockpt, killpg, openpty, realpath, socket functions and constants,
fixes, optimizations, etc.

New dependency: luabitop (provided as a separate patch)

Signed-off-by: Maxim Storchak 
---
 lang/luaposix/Makefile|   20 +++---
 lang/luaposix/patches/100-eglibc-compat.patch |   28 +
 2 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/lang/luaposix/Makefile b/lang/luaposix/Makefile
index 726921e..ed4d3d2 100644
--- a/lang/luaposix/Makefile
+++ b/lang/luaposix/Makefile
@@ -8,13 +8,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luaposix
-PKG_VERSION:=5.1.11
+PKG_VERSION:=v31
 PKG_RELEASE:=1
+_BASENAME:=release
 
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://luaforge.net/frs/download.php/4813
-PKG_MD5SUM:=edb76911dbdabe98dec49e3d8a126227
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/luaposix/luaposix/archive/
+PKG_MD5SUM:=a25ff76d54bbbebf7a1f3b20c9806ee3
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(_BASENAME)-$(PKG_VERSION)
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -23,8 +24,8 @@ define Package/luaposix
   SECTION:=lang
   CATEGORY:=Languages
   TITLE:=luaposix
-  URL:=http://luaposix.luaforge.net/
-  DEPENDS:=+lua +librt
+  URL:=http://luaforge.net/projects/luaposix/
+  DEPENDS:=+lua +librt +luabitop
 endef
 
 define Package/luaposix/description
@@ -33,6 +34,8 @@ define Package/luaposix/description
 endef
 
 define Build/Configure
+   cd $(PKG_BUILD_DIR) && ./bootstrap
+   $(call Build/Configure/Default)
 endef
 
 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
@@ -46,7 +49,8 @@ endif
 
 define Package/luaposix/install
$(INSTALL_DIR) $(1)/usr/lib/lua
-   $(INSTALL_BIN) $(PKG_BUILD_DIR)/posix.so $(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/ext/posix/.libs/posix_c.so 
$(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/posix.lua $(1)/usr/lib/lua
 endef
 
 $(eval $(call BuildPackage,luaposix))
diff --git a/lang/luaposix/patches/100-eglibc-compat.patch 
b/lang/luaposix/patches/100-eglibc-compat.patch
index 96a6fce..10aad20 100644
--- a/lang/luaposix/patches/100-eglibc-compat.patch
+++ b/lang/luaposix/patches/100-eglibc-compat.patch
@@ -1,26 +1,28 @@
 a/lposix.c
-+++ b/lposix.c
-@@ -960,11 +960,13 @@ static int Pctermid(lua_State *L)/** c
+--- luaposix-release-v31/ext/posix/posix.c.orig2014-03-10 
14:22:45.0 +0200
 luaposix-release-v31/ext/posix/posix.c 2014-03-10 14:25:04.0 
+0200
+@@ -1970,6 +1970,7 @@
+   return 1;
  }
  
- 
 +#ifndef NO_GETLOGIN
- static int Pgetlogin(lua_State *L)/** getlogin() */
- {
+ /***
+ Current logged-in user.
+ @see getlogin(3)
+@@ -1980,6 +1981,7 @@
lua_pushstring(L, getlogin());
return 1;
  }
 +#endif
  
- 
  static void Fgetpasswd(lua_State *L, int i, const void *data)
-@@ -1778,7 +1780,9 @@ static const luaL_reg R[] =
+ {
+@@ -3786,7 +3788,9 @@
  #if _POSIX_VERSION >= 200112L
-   {"getgroups",   Pgetgroups},
+   MENTRY( Pgetgroups  ),
  #endif
 +#ifndef NO_GETLOGIN
-   {"getlogin",Pgetlogin},
+   MENTRY( Pgetlogin   ),
 +#endif
-   {"getopt_long", Pgetopt_long},
-   {"getpasswd",   Pgetpasswd},
-   {"getpid",  Pgetpid},
+   MENTRY( Pgetopt ),
+   MENTRY( Pgetpasswd  ),
+   MENTRY( Pgetpid ),
-- 
1.7.10.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/2] [packages] luaposix, update to v31

2014-03-20 Thread Maxim Storchak
On 20.03.14 02:09, Karl P wrote:
> 
> Your patch didn't come inline?  I haven't tested this out explicitly,
I'm new to email based submission process, so I checked the mailing
list, made sure attached patches are accepted, and decided not to take a
risk with potentially misconfigured MUA :).
I have really no idea how patches get processed on the maintainers'
side. Could you please advise any good self-test for submission? I mean,
I can send patch to myself first, but how do I make sure it applies
cleanly? I use Mozilla Thunderbird.

> but just a note that this would supersede
> http://patchwork.openwrt.org/patch/4990/
Yes, but I tried to take into account your changes as well.

> Why do you need all the _BASENAME juggling? What is the difference
> between "release-v31" and "v31" ?
If I understand the author's idea, vN is the start of work on this
version, and release-vN is the release.
I do have a feeling that I'm reinventing the wheel with _BASENAME, but I
couldn't find any other DRY way around.

> 
> Sincerely,
> Karl P
> 
> 
> On 03/19/2014 05:05 PM, Maxim Storchak wrote:
>> Hi,
>>
>> This is an update for luaposix to v31. It provides more interfaces to
>> POSIX functions for Lua. There is also a new requirement, luabitop.
>>
>> Tested on Raspberry Pi in LXC container running OpenWRT.
>>
>> Signed-off-by: Maxim Storchak 
>>
>>
>>
>> ___
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/2] [packages] luaposix, update to v31

2014-03-19 Thread Maxim Storchak
Hi,

This is an update for luaposix to v31. It provides more interfaces to
POSIX functions for Lua. There is also a new requirement, luabitop.

Tested on Raspberry Pi in LXC container running OpenWRT.

Signed-off-by: Maxim Storchak 

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com

diff --git a/lang/luaposix/Makefile b/lang/luaposix/Makefile
index 46cb211..f821655 100644
--- a/lang/luaposix/Makefile
+++ b/lang/luaposix/Makefile
@@ -8,13 +8,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=luaposix
-PKG_VERSION:=5.1.11
+PKG_VERSION:=v31
 PKG_RELEASE:=1
+_BASENAME:=release
 
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=http://luaforge.net/frs/download.php/4813
-PKG_MD5SUM:=edb76911dbdabe98dec49e3d8a126227
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/luaposix/luaposix/archive/
+PKG_MD5SUM:=a25ff76d54bbbebf7a1f3b20c9806ee3
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(_BASENAME)-$(PKG_VERSION)
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -23,8 +24,8 @@ define Package/luaposix
   SECTION:=lang
   CATEGORY:=Languages
   TITLE:=luaposix
-  URL:=http://luaposix.luaforge.net/
-  DEPENDS:=+lua +librt
+  URL:=http://luaforge.net/projects/luaposix/
+  DEPENDS:=+lua +librt +luabitop
 endef
 
 define Package/luaposix/description
@@ -33,6 +34,8 @@ define Package/luaposix/description
 endef
 
 define Build/Configure
+   cd $(PKG_BUILD_DIR) && ./bootstrap
+   $(call Build/Configure/Default)
 endef
 
 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
@@ -46,7 +49,8 @@ endif
 
 define Package/luaposix/install
$(INSTALL_DIR) $(1)/usr/lib/lua
-   $(INSTALL_BIN) $(PKG_BUILD_DIR)/posix.so $(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/ext/posix/.libs/posix_c.so 
$(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/posix.lua $(1)/usr/lib/lua
 endef
 
 $(eval $(call BuildPackage,luaposix))
diff --git a/lang/luaposix/patches/100-eglibc-compat.patch 
b/lang/luaposix/patches/100-eglibc-compat.patch
index 96a6fce..10aad20 100644
--- a/lang/luaposix/patches/100-eglibc-compat.patch
+++ b/lang/luaposix/patches/100-eglibc-compat.patch
@@ -1,26 +1,28 @@
 a/lposix.c
-+++ b/lposix.c
-@@ -960,11 +960,13 @@ static int Pctermid(lua_State *L)/** c
+--- luaposix-release-v31/ext/posix/posix.c.orig2014-03-10 
14:22:45.0 +0200
 luaposix-release-v31/ext/posix/posix.c 2014-03-10 14:25:04.0 
+0200
+@@ -1970,6 +1970,7 @@
+   return 1;
  }
  
- 
 +#ifndef NO_GETLOGIN
- static int Pgetlogin(lua_State *L)/** getlogin() */
- {
+ /***
+ Current logged-in user.
+ @see getlogin(3)
+@@ -1980,6 +1981,7 @@
lua_pushstring(L, getlogin());
return 1;
  }
 +#endif
  
- 
  static void Fgetpasswd(lua_State *L, int i, const void *data)
-@@ -1778,7 +1780,9 @@ static const luaL_reg R[] =
+ {
+@@ -3786,7 +3788,9 @@
  #if _POSIX_VERSION >= 200112L
-   {"getgroups",   Pgetgroups},
+   MENTRY( Pgetgroups  ),
  #endif
 +#ifndef NO_GETLOGIN
-   {"getlogin",Pgetlogin},
+   MENTRY( Pgetlogin   ),
 +#endif
-   {"getopt_long", Pgetopt_long},
-   {"getpasswd",   Pgetpasswd},
-   {"getpid",  Pgetpid},
+   MENTRY( Pgetopt ),
+   MENTRY( Pgetpasswd  ),
+   MENTRY( Pgetpid ),
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/2] [packages] new package: luabitop

2014-03-19 Thread Maxim Storchak
Hi,

This is a new lua package providing bit operations. It's required for
new luaposix.

Signed-off-by: Maxim Storchak 

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
diff --git a/lang/luabitop/Makefile b/lang/luabitop/Makefile
new file mode 100644
index 000..1eccaa9
--- /dev/null
+++ b/lang/luabitop/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luabitop
+PKG_VERSION:=1.0.2
+PKG_RELEASE:=1
+
+_BASENAME:=LuaBitOp
+
+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://bitop.luajit.org/download/
+PKG_MD5SUM:=d0c1080fe0c844e8477279668e2d0d06
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(_BASENAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luabitop
+  SUBMENU:=Lua
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=luabitop
+  URL:=http://bitop.luajit.org/
+  DEPENDS:=+lua
+endef
+
+define Package/luabitop/description
+Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise 
operations on numbers.
+endef
+
+define Build/Configure
+endef
+
+
+TARGET_CFLAGS += $(FPIC) -DLUA_USE_LINUX -DLUA_NUMBER_DOUBLE
+
+define Build/Compile
+   $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_CPPFLAGS) 
-std=gnu99 $(FPIC) -DLUA_USE_LINUX -shared -o $(PKG_BUILD_DIR)/bit.so 
$(PKG_BUILD_DIR)/bit.c
+endef
+
+define Package/luabitop/install
+   $(INSTALL_DIR) $(1)/usr/lib/lua
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/bit.so $(1)/usr/lib/lua
+endef
+
+$(eval $(call BuildPackage,luabitop))
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] how to set busybox's some options now ?

2013-12-27 Thread Maxim Storchak
On 27.12.13 19:12, Maxim Storchak wrote:
> On 17.12.13 18:22, edgar.sol...@web.de wrote:
>> On 17.12.2013 16:14, Yousong Zhou wrote:
> 
>>> Does it deserve a "busybox_menuconfig" just like "kernel_menuconfig"?
>>
>> there should be at least one graphical way. so either busybox's menu_config 
>> or at least the old options presumably missing currently in trunk's 
>> menu_config.
> 
> Would the attached patch help?
> 
> If there is an old config around, env/busybox-config may be created with
> sed:
> sed -nre '/CONFIG_BUSYBOX_/s/CONFIG_BUSYBOX_//p' config.old >
> env/busybox-config
> 
oops, I'm sorry, I've lost another part of the patch. Please see this one.

Signed-off-by: Maxim Storchak 

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
Index: include/toplevel.mk
===
--- include/toplevel.mk (revision 39163)
+++ include/toplevel.mk (working copy)
@@ -131,6 +131,12 @@
 kernel_nconfig: prepare_kernel_conf
$(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
 
+prepare_busybox_conf:
+   $(_SINGLE)$(NO_TRACE_MAKE) -C package/utils/busybox prepare
+
+busybox_menuconfig: prepare_busybox_conf
+   $(_SINGLE)$(NO_TRACE_MAKE) -C package/utils/busybox -f 
Makefile.menuconfig menuconfig
+
 tmp/.prereq-build: include/prereq-build.mk
mkdir -p tmp
rm -f tmp/.host.mk
Index: package/utils/busybox/Makefile.menuconfig
===
--- package/utils/busybox/Makefile.menuconfig   (revision 0)
+++ package/utils/busybox/Makefile.menuconfig   (revision 0)
@@ -0,0 +1,11 @@
+include $(TOPDIR)/rules.mk
+include Makefile
+
+menuconfig:
+   mkdir -p $(TOPDIR)/env && \
+   [ -f $(TOPDIR)/env/busybox-config ] && \
+   cp $(TOPDIR)/env/busybox-config 
$(BUILD_DIR)/busybox-$(PKG_VERSION)/.config || \
+   cp $(TOPDIR)/package/utils/busybox/config/default 
$(BUILD_DIR)/busybox-$(PKG_VERSION)/.config && \
+   make -C $(BUILD_DIR)/busybox-$(PKG_VERSION) oldconfig && \
+   make -C $(BUILD_DIR)/busybox-$(PKG_VERSION) menuconfig && \
+   cp $(BUILD_DIR)/busybox-$(PKG_VERSION)/.config 
$(TOPDIR)/env/busybox-config
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] how to set busybox's some options now ?

2013-12-27 Thread Maxim Storchak
On 17.12.13 18:22, edgar.sol...@web.de wrote:
> On 17.12.2013 16:14, Yousong Zhou wrote:

>> Does it deserve a "busybox_menuconfig" just like "kernel_menuconfig"?
> 
> there should be at least one graphical way. so either busybox's menu_config 
> or at least the old options presumably missing currently in trunk's 
> menu_config.

Would the attached patch help?

If there is an old config around, env/busybox-config may be created with
sed:
sed -nre '/CONFIG_BUSYBOX_/s/CONFIG_BUSYBOX_//p' config.old >
env/busybox-config

-- 
Best regards,
Maxim Storchak
mailto:m.storc...@gmail.com
Index: package/utils/busybox/Makefile.menuconfig
===
--- package/utils/busybox/Makefile.menuconfig   (revision 0)
+++ package/utils/busybox/Makefile.menuconfig   (revision 0)
@@ -0,0 +1,11 @@
+include $(TOPDIR)/rules.mk
+include Makefile
+
+menuconfig:
+   mkdir -p $(TOPDIR)/env && \
+   [ -f $(TOPDIR)/env/busybox-config ] && \
+   cp $(TOPDIR)/env/busybox-config 
$(BUILD_DIR)/busybox-$(PKG_VERSION)/.config || \
+   cp $(TOPDIR)/package/utils/busybox/config/default 
$(BUILD_DIR)/busybox-$(PKG_VERSION)/.config && \
+   make -C $(BUILD_DIR)/busybox-$(PKG_VERSION) oldconfig && \
+   make -C $(BUILD_DIR)/busybox-$(PKG_VERSION) menuconfig && \
+   cp $(BUILD_DIR)/busybox-$(PKG_VERSION)/.config 
$(TOPDIR)/env/busybox-config
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] New package tgt, iscsi target

2012-08-27 Thread Maxim Storchak
iSCSI target 

This patch adds a user space iscsi implementation. It provides a daemon tgtd,
a control tool tgtadm, init script and an example uci config.

It has been tested with Scientific Linux 6 
iscsi-initiator-utils-6.2.0.872-34.el6.x86_64,
also worked with Microsoft iSCSI initiator and Global SAN 4 on Mac OS X.
The best performance was observed with an image file located on a local 
filesystem.
Raw device was much slower for some reason. Also, direct mode didn't work well 
for me -
I could not mount filesystem after creating it.
"Image indirect" mode worked perfectly.

Signed-off-by: Maxim Storchak 

 net/tgt/Makefile   |  57 +
 net/tgt/files/etc/config/tgt   |  38 +++
 net/tgt/files/etc/init.d/tgt   | 111 +
 net/tgt/patches/010-fallocate.patch|  14 +
 net/tgt/patches/020-usr_Makefile.patch |  26 
 net/tgt/patches/030-Makefile.patch |  11 
 6 files changed, 257 insertions(+)

diff --git a/net/tgt/Makefile b/net/tgt/Makefile
new file mode 100644
index 000..1e87be2
--- /dev/null
+++ b/net/tgt/Makefile
@@ -0,0 +1,57 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=tgt
+PKG_VERSION:=1.0.30
+PKG_RELEASE:=2
+GIT_SHORT_REV:=9dc30be
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/fujita/tgt/tarball/v$(PKG_VERSION)
+
+#PKG_MD5SUM:=
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/fujita-$(PKG_NAME)-$(GIT_SHORT_REV)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/tgt
+  SECTION:=net
+  CATEGORY:=Network
+  URL:=http://stgt.sourceforge.net/
+  TITLE:=userspace iSCSI target
+  DEPENDS:=+libpthread
+endef
+
+define Package/tgt/description
+Linux SCSI target framework (tgt) aims to simplify various SCSI target driver 
(iSCSI, Fibre Channel, SRP, etc) creation and maintenance.
+Key goals of the project are the clean integration into the scsi-mid layer and 
implementing a great portion of tgt in user space.
+Tgt consists of kernel-space and user-space code. The kernel-space component 
is included in upstream as of 2.6.20.
+Note that if you are interested in only iSCSI (probably you are), you need 
only the user-space code (any kernel version is fine).
+endef
+
+define Build/Compile
+   CC=$(TARGET_CC) $(MAKE) -C $(PKG_BUILD_DIR) \
+   DESTDIR="$(PKG_INSTALL_DIR)" \
+   LD="$(TARGET_CC)" \
+   install-programs
+endef
+
+define Package/tgt/conffiles
+   /etc/config/tgt
+endef
+
+define Package/tgt/install
+   $(INSTALL_DIR) $(1)/
+   $(INSTALL_DIR) $(1)/usr/sbin
+   $(CP) ./files/* $(1)/
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tgtd $(1)/usr/sbin/
+   $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tgtadm $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,tgt))
diff --git a/net/tgt/files/etc/config/tgt b/net/tgt/files/etc/config/tgt
new file mode 100644
index 000..250d12d
--- /dev/null
+++ b/net/tgt/files/etc/config/tgt
@@ -0,0 +1,38 @@
+config target 1
+   option name 'iqn.2012-06.org.openwrt:target1'
+   option allow ALL
+
+#config target 2
+#  option name 'iqn.2012-06.org.openwrt:t2'
+#  option allow 192.168.1.0/24
+
+
+# all options are set to default, except for the device
+# for all type and bstype values see tgtd(8)
+# lun "name" is constructed as TGTID_LUN
+#config lun1_1
+#  option readonly 0
+#  option device /dev/sda
+#  option type disk
+#  option bstype rdwr
+#  option sync 0
+#  option direct 0
+
+
+#config lun 2_1
+#  option readonly 0
+#  option device /mnt/iscsi.img
+
+#config lun 2_2
+#  option device /dev/sdc
+
+#config account
+#  option target 1
+#  option user "username1"
+#  option password "pass1"
+
+#config account
+#  option target 2
+#  option user "user2"
+#  option password "pwd2"
+#  option outgoing 1
diff --git a/net/tgt/files/etc/init.d/tgt b/net/tgt/files/etc/init.d/tgt
new file mode 100644
index 000..06496b1
--- /dev/null
+++ b/net/tgt/files/etc/init.d/tgt
@@ -0,0 +1,111 @@
+#!/bin/sh /etc/rc.common
+START=91
+STOP=10
+
+SERVICE_SIG_STOP=INT
+
+EXTRA_COMMANDS="show status"
+EXTRA_HELP="   showShow current configuration of tgtd
+   status  Check of tgtd is running"
+
+NAME=tgt
+EXEC=/usr/sbin/${NAME}d
+
+tgtadm="/usr/sbin/tgtadm --lld iscsi"
+
+handle_lun() {
+   local tgt_lun=$1
+   local tgtid=$2
+   local ro device type bstype sync direct
+   local my_tgtid=${tgt_lun%_*}
+   local lun=${tgt_lun#*_}
+   [ $my_tgtid -eq $tgtid ] || return 0
+
+   config_get device $1 device ""
+   [ "$device" ] || return 1
+
+