diff --git a/bsp/buildroot-dl/.gitkeep b/bsp/buildroot-dl/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/bsp/buildroot/Makefile b/bsp/buildroot/Makefile index bd6f17be..2bf55fcd 100644 --- a/bsp/buildroot/Makefile +++ b/bsp/buildroot/Makefile @@ -498,9 +498,12 @@ prepare: $(BUILD_DIR)/buildroot-config/auto.conf world: target-post-image +rebuild: $(foreach pkg,$(PACKAGES),$(pkg)-clean-for-rebuild) world + .PHONY: all world toolchain dirs clean distclean source outputmakefile \ legal-info legal-info-prepare legal-info-clean printvars help \ - list-defconfigs target-finalize target-post-image source-check + list-defconfigs target-finalize target-post-image source-check \ + rebuild ################################################################################ # diff --git a/bsp/buildroot/package/pkg-cmake.mk b/bsp/buildroot/package/pkg-cmake.mk index 8d5b955f..13206dd9 100644 --- a/bsp/buildroot/package/pkg-cmake.mk +++ b/bsp/buildroot/package/pkg-cmake.mk @@ -110,7 +110,7 @@ define $(2)_CONFIGURE_CMDS cd $$($$(PKG)_BUILDDIR) && \ rm -f CMakeCache.txt && \ PATH=$$(BR_PATH) \ - $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \ + $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \ -DCMAKE_INSTALL_SO_NO_EXE=0 \ -DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="BOTH" \ diff --git a/bsp/buildroot_external/Config.in b/bsp/buildroot_external/Config.in index 4c041b32..5574d337 100644 --- a/bsp/buildroot_external/Config.in +++ b/bsp/buildroot_external/Config.in @@ -23,3 +23,9 @@ endmenu # Third parties menu "Domo" endmenu # Domo + +menu "Host tools" + +source "$BR2_EXTERNAL/package/virtfs-xattr/Config.in" + +endmenu # Host tools diff --git a/bsp/buildroot_external/package/virtfs-xattr/Config.in b/bsp/buildroot_external/package/virtfs-xattr/Config.in new file mode 100644 index 00000000..6c9c683e --- /dev/null +++ b/bsp/buildroot_external/package/virtfs-xattr/Config.in @@ -0,0 +1,6 @@ +config BR2_PACKAGE_HOST_VIRTFS_XATTR + bool "host virtfs-xattr" + default n + help + Utililty used to alter metadata of file in the target + directory, for sharing with 9p fsdev in qemu. diff --git a/bsp/buildroot_external/package/virtfs-xattr/virtfs-xattr.mk b/bsp/buildroot_external/package/virtfs-xattr/virtfs-xattr.mk new file mode 100644 index 00000000..9969d2a1 --- /dev/null +++ b/bsp/buildroot_external/package/virtfs-xattr/virtfs-xattr.mk @@ -0,0 +1,20 @@ +################################################################################ +# +# VIRTFS_XATTR +# +################################################################################ + +HOST_VIRTFS_XATTR_VERSION:= 1.0.0 + +HOST_VIRTFS_XATTR_SITE = $(TOPDIR)/../../src/tools/virtfs-xattr/builders/cmake +HOST_VIRTFS_XATTR_SITE_METHOD = local + +HOST_VIRTFS_XATTR_DEPENDENCIES = host-attr + +HOST_VIRTFS_XATTR_CONF = SRC_DIR=$(TOPDIR)/../.. + +HOST_VIRTFS_XATTR_CONF_ENV = $(HOST_VIRTFS_XATTR_CONF) +HOST_VIRTFS_XATTR_MAKE_ENV = $(HOST_VIRTFS_XATTR_CONF) +HOST_VIRTFS_XATTR_CONF_OPTS += -DMODULE_PATH=$(TOPDIR)/../../bsp/cmake-modules -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) + +$(eval $(host-cmake-package)) diff --git a/bsp/include/buildroot.mk b/bsp/include/buildroot.mk index c84372d6..7383bdea 100644 --- a/bsp/include/buildroot.mk +++ b/bsp/include/buildroot.mk @@ -12,9 +12,10 @@ buildroot.menuconfig: buildroot.config fi buildroot: buildroot.config - $(MAKE) LD_LIBRARY_PATH=$(BR_STAGING)/cross/opt/ext-toolchain/lib/ $(BR_ENV) -C $(BR_PROJECT)/../../bsp/buildroot/ + $(MAKE) $(BR_ENV) -C $(BR_PROJECT)/../../bsp/buildroot/ $(BR_TARGET) buildroot.shell: buildroot.config + $(MAKE) $(BR_ENV) -C $(BR_PROJECT)/../../bsp/buildroot/ dirs outputmakefile $(eval export $(BR_ENV)) cd $(BR_STAGING)/buildroot/; $(BR_ENV) bash diff --git a/bsp/include/dev.mk b/bsp/include/dev.mk new file mode 100644 index 00000000..a681a158 --- /dev/null +++ b/bsp/include/dev.mk @@ -0,0 +1,3 @@ + +dev.gdbscript: + BR_STAGING=$(BR_STAGING) BR_PROJECT=$(BR_PROJECT) $(BR_BOARD)/../../../scripts/gen_gdb_script.sh diff --git a/bsp/scripts/gen_gdb_script.sh b/bsp/scripts/gen_gdb_script.sh new file mode 100755 index 00000000..a14814f8 --- /dev/null +++ b/bsp/scripts/gen_gdb_script.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "===> Generate GDB script" +echo " AW_STAGING=${AW_STAGING}" +echo " AW_PROJECT=${AW_PROJECT}" + +echo "add-auto-load-safe-path ${AW_STAGING}" > ${AW_STAGING}/gdb.script +echo "set solib-absolute-prefix ${AW_STAGING}/buildroot/staging" >> ${AW_STAGING}/gdb.script +echo "dir ${AW_PROJECT}/../../../.." >> ${AW_STAGING}/gdb.script + + +echo "The gdb script : ${AW_STAGING}/gdb.script" + diff --git a/projects/x86_64_domo/configs/buildroot.config b/projects/x86_64_domo/configs/buildroot.config index bf7e424b..75d6a4a6 100644 --- a/projects/x86_64_domo/configs/buildroot.config +++ b/projects/x86_64_domo/configs/buildroot.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Buildroot 2016.08.1-gb9e31fc-dirty Configuration +# Buildroot 2016.08.1-gda13f66-dirty Configuration # BR2_HAVE_DOT_CONFIG=y BR2_HOST_GCC_AT_LEAST_4_6=y @@ -811,12 +811,6 @@ BR2_PACKAGE_GAUCHE_ARCH_SUPPORTS=y # BR2_PACKAGE_JAMVM is not set # BR2_PACKAGE_JIMTCL is not set # BR2_PACKAGE_LUA is not set -# BR2_PACKAGE_LUA_5_1 is not set -# BR2_PACKAGE_LUA_5_2 is not set -# BR2_PACKAGE_LUA_5_3 is not set -# BR2_PACKAGE_LUA_EDITING_NONE is not set -# BR2_PACKAGE_LUA_READLINE is not set -# BR2_PACKAGE_LUA_LINENOISE is not set BR2_PACKAGE_LUAJIT_ARCH_SUPPORTS=y # BR2_PACKAGE_LUAJIT is not set # BR2_PACKAGE_MICROPYTHON is not set @@ -2258,3 +2252,8 @@ BR2_PACKAGE_UCI=y # # Domo # + +# +# Host tools +# +BR2_PACKAGE_HOST_VIRTFS_XATTR=y diff --git a/projects/x86_64_domo/post-build.sh b/projects/x86_64_domo/post-build.sh index fb809169..af383af7 100755 --- a/projects/x86_64_domo/post-build.sh +++ b/projects/x86_64_domo/post-build.sh @@ -12,33 +12,10 @@ trap error ERR echo "==> POSTBUILD:" -echo "AW_STAGING: ${AW_STAGING}" -echo "AW_PROJECT: ${AW_PROJECT}" +echo "BR_STAGING: ${BR_STAGING}" +echo "BR_PROJECT: ${BR_PROJECT}" -ROOT_DIR=${AW_STAGING}/buildroot/target - -# USERNAME=$(id -n -u) -# GROUPNAME=$(id -n -g) -# USERID=$(id -u) -# GROUPID=$(id -g) -# -# if [ ! -f "${ROOT_DIR}/usr/share/acl.d/all_yes.json" ]; then -# mkdir -p "${ROOT_DIR}/usr/share/acl.d" -# cat > "${ROOT_DIR}/usr/share/acl.d/all_yes.json" << EOF -# { -# "user": "${USERNAME}", -# "access": { "*" : { "methods": [" "] } }, -# "publish": ["*"], -# "subscribe": ["*"] -# } -# EOF -# fi -# -# if [ -z "$(grep ${USERNAME} ${ROOT_DIR}/etc/passwd)" ]; then -# echo "Adding user '${USERNAME}' to target" -# echo "${USERNAME}:x:${USERID}:${GROUPID}::/:/bin/sh" >> ${ROOT_DIR}/etc/passwd -# echo "${GROUPNAME}:x:${GROUPID}:${USERNAME}" >> ${ROOT_DIR}/etc/group -# fi +ROOT_DIR=${BR_STAGING}/buildroot/target echo " => Setting-up the target rootfs to be used by qemu" -PATH="${PATH}:${AW_STAGING}/cross/usr/bin" "${AW_PROJECT}/map-all-xattr.sh" "${ROOT_DIR}" +PATH="${PATH}:${BR_STAGING}/cross/usr/bin" "${BR_PROJECT}/map-all-xattr.sh" "${ROOT_DIR}" diff --git a/src/tools/virtfs-xattr/builders/cmake/CMakeLists.txt b/src/tools/virtfs-xattr/builders/cmake/CMakeLists.txt new file mode 100644 index 00000000..e2ffbed8 --- /dev/null +++ b/src/tools/virtfs-xattr/builders/cmake/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required (VERSION 3.0) + +project (virtfs-xattr) + +set (CMAKE_MODULE_PATH "${MODULE_PATH}") + +include (br) + +include_directories (../../) + +file ( + GLOB_RECURSE + source_files + + $ENV{SRC_DIR}/src/tools/virtfs-xattr/virtfs-xattr.c +) + +add_executable (virtfs-xattr ${source_files}) + +target_link_libraries (virtfs-xattr + LINK_PUBLIC + attr) + +install (TARGETS virtfs-xattr DESTINATION bin) diff --git a/src/tools/virtfs-xattr/virtfs-xattr.c b/src/tools/virtfs-xattr/virtfs-xattr.c new file mode 100644 index 00000000..f72ff4e0 --- /dev/null +++ b/src/tools/virtfs-xattr/virtfs-xattr.c @@ -0,0 +1,157 @@ +/*! + * (C) Copyright 2017 Awox SA. All rights reserved. + * This work contains confidential trade secrets of Awox. + * Use, examination, copying, transfer and disclosure to others + * are prohibited, except with the express written agreement of Awox. + * + * virtfs-xattr.c + + * \author Awox + * \date Jan 25, 2017 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void usage(const char* progName) +{ + fprintf(stderr, "%s \tdisplay attributes\n", progName); + fprintf(stderr, + "%s { -u | -g | -l } \tset/change attribute value (uid, gid, is-symlink)\n", + progName); + fprintf(stderr, "%s -l \ttag file as a symlink\n", progName); + fprintf(stderr, "%s -c \tclear all attributes\n", progName); +} + +int main(int argc, char** argv) +{ + int rc; + uid_t uid; + int set_uid; + gid_t gid; + int set_gid; + mode_t mode; + int tag_symlink; + int clear; + int display; + + const char* filePath; + + set_uid = 0; + set_gid = 0; + tag_symlink = 0; + clear = 0; + display = 0; + + while ((rc = getopt(argc, argv, "u:g:lch")) != -1) + { + switch (rc) + { + case 'u': + uid = (uid_t) htole32(atoi(optarg)); + set_uid = 1; + break; + case 'g': + gid = (gid_t) htole32(atoi(optarg)); + set_gid = 1; + break; + case 'l': + tag_symlink = 1; + break; + case 'c': + clear = 1; + break; + case '?': + usage(argv[0]); + return EXIT_FAILURE; + break; + case 'h': + usage(argv[0]); + return EXIT_SUCCESS; + } + } + + if (optind >= argc) + { + usage(argv[0]); + return EXIT_FAILURE; + } + + filePath = argv[optind]; + + if (clear && (set_uid || set_gid || tag_symlink)) + { + usage(argv[0]); + return EXIT_FAILURE; + } + + if (!clear && !set_uid && !set_gid && !tag_symlink) + { + display = 1; + } + + if (set_uid && lsetxattr(filePath, "user.virtfs.uid", &uid, sizeof(uid), 0)) + { + perror("setxattr(user.virtfs.uid)"); + return EXIT_FAILURE; + } + + if (set_gid && lsetxattr(filePath, "user.virtfs.gid", &gid, sizeof(gid), 0)) + { + perror("setxattr(user.virtfs.gid)"); + return EXIT_FAILURE; + } + + if (tag_symlink) + { + mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; + + mode = htole32(mode); + + if (lsetxattr(filePath, "user.virtfs.mode", &mode, sizeof(mode), 0)) + { + perror("setxattr(user.virtfs.mode)"); + return EXIT_FAILURE; + } + } + + if (display) + { + if (lgetxattr(filePath, "user.virtfs.uid", &uid, sizeof(uid)) == sizeof(uid)) + { + printf("uid: %d\n", (int) le32toh(uid)); + } + if (lgetxattr(filePath, "user.virtfs.gid", &gid, sizeof(gid)) == sizeof(gid)) + { + printf("gid: %d\n", (int) le32toh(gid)); + } + if (lgetxattr(filePath, "user.virtfs.mode", &mode, sizeof(mode)) == sizeof(mode)) + { + mode = le32toh(mode); + if (mode & S_IFLNK) + printf("symlink\n"); + } + } + + if (clear) + { + if (lremovexattr(filePath, "user.virtfs.uid") && errno != ENOATTR) + { + perror("removexattr(user.virtfs.uid)"); + return EXIT_FAILURE; + } + if (lremovexattr(filePath, "user.virtfs.gid") && errno != ENOATTR) + { + perror("removexattr(user.virtfs.gid)"); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +}