2
* Author: Colin King <colin.king@canonical.com>
4
* Copyright (C) 2012 Canonical, Ltd.
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28
#include <sys/types.h>
32
#define TEST_PASSED (0)
33
#define TEST_FAILED (1)
34
#define TEST_ERROR (2)
36
#define BUFF_SIZE (4096)
39
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/719691
41
* read() on a directory should return EISDIR, but bug LP: #719691
42
* ecryptfs returns EINVAL in contradiction to SUSv2.
44
int main(int argc, char **argv)
52
fprintf(stderr, "Usage: path\n");
55
snprintf(path, sizeof(path), "%s/.", argv[1]);
57
if ((fd = open(path, O_RDONLY)) < 0) {
58
fprintf(stderr, "Cannot open ./. : %s\n", strerror(errno));
62
ret = read(fd, buff, sizeof(buff));
64
/* Should not be abled to read a directory */
65
fprintf(stderr, "read() on a directory should fail, but did not\n");
70
if (errno != EISDIR) {
71
fprintf(stderr, "read() on a directory should set errno to EISDIR, "
72
"instead got: %d - %s\n", errno, strerror(errno));