[PATCH v2] tests: add fchmod.test

Dmitry V. Levin ldv at altlinux.org
Thu Mar 10 01:05:25 UTC 2016


On Thu, Mar 10, 2016 at 12:59:25AM +0000, Fabien Siron wrote:
[...]
> +	int fchmod_res = syscall(__NR_fchmod, fd, 0600);
> +
> +	if (fchmod_res == 0) {
> +		printf("fchmod(%d, 0600) = 0\n", fd);
> +	} else {
> +		if (errno == ENOSYS) {
> +			printf("fchmod(%d, 0600) = -1 ENOSYS (%m)\n", fd);
> +		} else {
> +			perror_msg_and_fail("fchmod");
> +		}
> +	}
> +
> +	close(fd);
> +
> +	if (fchmod_res == 0) {
> +		if (syscall(__NR_fchmod, fd, 0600) != -1)
> +			perror_msg_and_fail("fchmod");
> +
> +		printf("fchmod(%d, 0600) = -1 EBADF (Bad file descriptor)\n",
> +		       fd);
> +	}

Right.  I bet the code cited above could be made simpler.
Could you try to rewrite it without additional hints?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160310/848b5656/attachment.bin>


More information about the Strace-devel mailing list