]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit - io/open.c
xfs_io: test for invalid -Tr flag combination before open
authorEric Sandeen <sandeen@sandeen.net>
Mon, 3 Mar 2014 01:29:32 +0000 (12:29 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 3 Mar 2014 01:29:32 +0000 (12:29 +1100)
commitade06f83f18b0801935de8925bb5117557627f4c
tree2b2f69700d156a648381dc2081eb5de38392e316
parent617c3c2a0349859ddd65d48b6abc38a479baf08f
xfs_io: test for invalid -Tr flag combination before open

Coverity spotted this.

It complained that we didn't close the fd before returning in
the error case of incompatible options, but in reality, we wouldn't
have gotten that far because open(O_RDONLY|O_TMPFILE) would be
rejected with EINVAL.

So the error handling test would never actually be true.

Fix this by moving the error checking prior to the open so
the user gets a more useful error message than "Invalid Argument."

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
io/open.c