From patchwork Wed Apr 11 18:24:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subodh Nijsure X-Patchwork-Id: 151850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 252C4B7030 for ; Thu, 12 Apr 2012 04:26:21 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SI2Dx-0002ai-7Q; Wed, 11 Apr 2012 18:24:57 +0000 Received: from mail-pz0-f43.google.com ([209.85.210.43]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SI2Du-0002a1-0Z for linux-mtd@lists.infradead.org; Wed, 11 Apr 2012 18:24:54 +0000 Received: by dadn15 with SMTP id n15so1852472dad.16 for ; Wed, 11 Apr 2012 11:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=dcKmUM1eXiVuHu+nu+EUlbZyWGJZzRC59dm1LtAjJOo=; b=sKVzD/MGAWzb8hYdMgoBqUrnI4oWAGgVGO8Lp6a6TRwlrsVWvGCFsFnuz+q++snE2V qIw0a4jteoVNwfhMXoA0bsmrA/cf++kpzGevEXe9kaidctpjvR8xtBODI8GoUkjuC4cQ mKMYh1F/r+Kcu9m89oRriA3obbIIU8TORtQlthI4CrbcwfXcgTe830FoCCEGyMzRMG2r rO+x8IcDn40qH81BGSrefHOvYWlP8K5+q5sWfbO8ElgWXQWOqQwwMeBICl2MwRzsjrgl AKaC5H87M+CRxxJgRFSWeXFzNcojKjg7+63Vko1JIiXSePisxFNdDPhwPeDTUfGN0a31 BJ3A== Received: by 10.68.194.1 with SMTP id hs1mr1040pbc.6.1334168686302; Wed, 11 Apr 2012 11:24:46 -0700 (PDT) Received: from localhost.localdomain ([97.65.115.1]) by mx.google.com with ESMTPS id h10sm3498719pbh.69.2012.04.11.11.24.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 11:24:39 -0700 (PDT) From: subodh.nijsure@gmail.com To: linux-mtd@lists.infradead.org Subject: [PATCH] Modify mtd-utils intgck utility to test extended attribute set/get for UBIFS Date: Wed, 11 Apr 2012 11:24:28 -0700 Message-Id: <1334168668-26218-1-git-send-email-snijsure@grid-net.com> X-Mailer: git-send-email 1.7.5.4 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.43 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (subodh.nijsure[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Subodh Nijsure X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Subodh Nijsure [ Assuming that linux-mtd is right place to send patches for mtd-utils] Need to compile the test target with option UBIFS_XATTR_TEST=1 run make as "UBIFS_XATTR_TEST=1 make tests" Signed-off-by: Subodh Nijsure --- tests/fs-tests/integrity/Makefile | 11 +++++++++++ tests/fs-tests/integrity/integck.c | 31 +++++++++++++++++++++++++++++++ tests/ubi-tests/Makefile | 3 ++- 3 files changed, 44 insertions(+), 1 deletions(-) diff --git a/tests/fs-tests/integrity/Makefile b/tests/fs-tests/integrity/Makefile index 4d6fc7d..2b1280f 100644 --- a/tests/fs-tests/integrity/Makefile +++ b/tests/fs-tests/integrity/Makefile @@ -3,6 +3,12 @@ ifeq ($(origin CC),default) CC = gcc endif +#To compile integck with XATTR test support +#invoke as UBIFS_XATTR_TEST=1 make tests from toplevel directory +ifeq ($(UBIFS_XATTR_TEST), 1) + CPPFLAGS += -DUBIFS_XATTR_TEST +endif + COMMON_HEADERS_DIR := ../../../include LIBUBI_PATH = ../../../ubi-utils/ LIBUBI_HEADER_PATH = $(LIBUBI_PATH)/include @@ -25,7 +31,12 @@ $(TARGETS): libubi.a # Disable optimizations to make it possible to use gdb comfortably # Use -rdynamic to have stack backtraces debug: libubi.a +ifeq ($(UBIFS_XATTR_TEST), 1) + @echo "Linking with -lattr...." + gcc $(CFLAGS) -O0 -D INTEGCK_DEBUG -rdynamic integck.c libubi.a -o integck -lattr +else gcc $(CFLAGS) -O0 -D INTEGCK_DEBUG -rdynamic integck.c libubi.a -o integck +endif clean: rm -f *.o $(TARGETS) libubi.a diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 30322cd..12f9ee9 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -38,6 +38,7 @@ #include #include + #define PROGRAM_VERSION "1.1" #define PROGRAM_NAME "integck" #include "common.h" @@ -543,6 +544,28 @@ static void remove_dir_entry(struct dir_entry_info *entry, int free_target) free(entry); } +/* Assign given path extended attribute security.selinx value + * root:object_t:bin_t then read it back and verify it correct + */ +#ifdef UBIFS_XATTR_TEST +void test_xattr(char *path) +{ + int ret; + char buf[255]; + char value[255]; + int attrLen; + strcpy(value,"root:object_r:bin_t"); + attrLen = strlen(value) + 1; + ret = setxattr (path, "security.selinux", value, attrLen, 0x0); + v("assign extended attribute to %s", path); + CHECK(ret == 0); + if ( ret == 0 ) { + v("retrieve extended attribute for %s", path); + ret = getxattr(path,"security.selinux",buf,attrLen); + CHECK(strncmp(buf,"root:object_r:bin_t", attrLen) == 0 ); + } +} +#endif /* * Create a new directory "name" in the parent directory described by "parent" * and add it to the in-memory list of directories. Returns zero in case of @@ -573,6 +596,9 @@ static int dir_new(struct dir_info *parent, const char *name) CHECK(lstat(path, &st) == 0); CHECK(S_ISDIR(st.st_mode)); } +#ifdef UBIFS_XATTR_TEST + test_xattr(path); +#endif free(path); add_dir_entry(parent, 'd', name, NULL); @@ -627,6 +653,8 @@ static int dir_remove(struct dir_info *dir) return 0; } + + static int file_new(struct dir_info *parent, const char *name) { char *path; @@ -660,6 +688,9 @@ static int file_new(struct dir_info *parent, const char *name) add_dir_entry(parent, 'f', name, NULL); close(fd); +#ifdef UBIFS_XATTR_TEST + test_xattr(path); +#endif free(path); return 0; } diff --git a/tests/ubi-tests/Makefile b/tests/ubi-tests/Makefile index 2c47a9f..ba8e7e0 100644 --- a/tests/ubi-tests/Makefile +++ b/tests/ubi-tests/Makefile @@ -8,7 +8,8 @@ LIBS = libubi TARGETS=io_update volrefcnt integ io_paral io_read io_basic \ mkvol_basic mkvol_bad mkvol_paral rsvol -CFLAGS += -I$(LIBUBI_HEADER_PATH) -I $(KERNELHDR) -lpthread +CFLAGS += -I$(LIBUBI_HEADER_PATH) -I$(KERNELHDR) -lpthread +LDFLAGS += -lpthread include ../../common.mk