[PATCH v2] Modify mtd-utils intgck utility to test extended attribute set/get for UBIFS

Artem Bityutskiy dedekind1 at gmail.com
Mon May 14 08:18:19 EDT 2012


On Thu, 2012-05-10 at 16:05 -0700, Subodh Nijsure wrote:
> + * Verify security.selinux extendend attribute for given path
> + */
> +void xattr_check(char *path, char *xattr_value)
> +{
> +	int ret;
> +	char buf[255];
> +	int attrLen;
> +	/* Check if path actually exists */
> +	if (access(path, F_OK) != 0)
> +		return;
> +	if (xattr_value == NULL)
> +		return;
> +	attrLen = strlen(xattr_value) + 1;
> +	v("retrieve extended attribute for  %s", path);
> +	getxattr(path, "security.selinux", buf, attrLen);
> +	CHECK(ret == 0);
> +	ret = strncmp(buf, xattr_value, attrLen);
> +	if (ret != 0) {
> +		printf("ret != 0 PATH %s\n", path);
> +		printf("Expected value %s and retrived val %s\n",
> +			xattr_value, buf);
> +		CHECK(ret == 0);
> +	} else {
> +		CHECK(ret == 0);
> +	}

If the file-system does not support xattrs and returns ENOTSUPP, you
should not fail. Instead, you should set a "xattrs_supported" variable,
set it to zero, and have "fi (!xattrs_supported) return" check at the
top level of this function. Or something like this which handles the
situation gracefully.

-- 
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120514/49ec1f7a/attachment.sig>


More information about the linux-mtd mailing list