Lines Matching +full:non +full:- +full:zero
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2018-2019 SUSE LLC.
64 /* TODO: Once expanded, check zero-padding. */ in test_openat2_struct()
66 /* Smaller than version-0 struct. */ in test_openat2_struct()
67 { .name = "zero-sized 'struct'", in test_openat2_struct()
68 .arg.inner.flags = O_RDONLY, .size = 0, .err = -EINVAL }, in test_openat2_struct()
69 { .name = "smaller-than-v0 struct", in test_openat2_struct()
71 .size = OPEN_HOW_SIZE_VER0 - 1, .err = -EINVAL }, in test_openat2_struct()
73 /* Bigger struct, with non-zero trailing bytes. */ in test_openat2_struct()
74 { .name = "bigger struct (non-zero data in first 'future field')", in test_openat2_struct()
76 .size = sizeof(struct open_how_ext), .err = -E2BIG }, in test_openat2_struct()
77 { .name = "bigger struct (non-zero data in middle of 'future fields')", in test_openat2_struct()
79 .size = sizeof(struct open_how_ext), .err = -E2BIG }, in test_openat2_struct()
80 { .name = "bigger struct (non-zero data at end of 'future fields')", in test_openat2_struct()
82 .size = sizeof(struct open_how_ext), .err = -E2BIG }, in test_openat2_struct()
90 struct open_how_ext how_ext = test->arg; in test_openat2_struct()
109 * (mis)alignment offset. The other data is set to be non-zero to in test_openat2_struct()
110 * make sure that non-zero bytes outside the struct aren't checked in test_openat2_struct()
120 fd = raw_openat2(AT_FDCWD, ".", how_copy, test->size); in test_openat2_struct()
121 if (test->err >= 0) in test_openat2_struct()
124 failed = (fd != test->err); in test_openat2_struct()
137 ksft_print_msg("%d (%s)\n", fd, strerror(-fd)); in test_openat2_struct()
141 if (test->err >= 0) in test_openat2_struct()
143 test->name, misalign); in test_openat2_struct()
146 test->name, misalign, test->err, in test_openat2_struct()
147 strerror(-test->err)); in test_openat2_struct()
169 .how.flags = O_TMPFILE | O_PATH | O_RDWR, .err = -EINVAL }, in test_openat2_flags()
171 .how.flags = O_TMPFILE | O_CREAT | O_RDWR, .err = -EINVAL }, in test_openat2_flags()
182 .how.flags = O_PATH | O_RDWR, .err = -EINVAL }, in test_openat2_flags()
184 .how.flags = O_PATH | O_CREAT, .err = -EINVAL }, in test_openat2_flags()
186 .how.flags = O_PATH | O_EXCL, .err = -EINVAL }, in test_openat2_flags()
188 .how.flags = O_PATH | O_NOCTTY, .err = -EINVAL }, in test_openat2_flags()
190 .how.flags = O_PATH | O_DIRECT, .err = -EINVAL }, in test_openat2_flags()
192 .how.flags = O_PATH | O_LARGEFILE, .err = -EINVAL }, in test_openat2_flags()
194 /* ->mode must only be set with O_{CREAT,TMPFILE}. */ in test_openat2_flags()
195 { .name = "non-zero how.mode and O_RDONLY", in test_openat2_flags()
196 .how.flags = O_RDONLY, .how.mode = 0600, .err = -EINVAL }, in test_openat2_flags()
197 { .name = "non-zero how.mode and O_PATH", in test_openat2_flags()
198 .how.flags = O_PATH, .how.mode = 0600, .err = -EINVAL }, in test_openat2_flags()
203 /* ->mode must only contain 0777 bits. */ in test_openat2_flags()
206 .how.mode = 0xFFFF, .err = -EINVAL }, in test_openat2_flags()
209 .how.mode = 0xC000000000000000ULL, .err = -EINVAL }, in test_openat2_flags()
212 .how.mode = 0x1337, .err = -EINVAL }, in test_openat2_flags()
215 .how.mode = 0x0000A00000000000ULL, .err = -EINVAL }, in test_openat2_flags()
217 /* ->resolve flags must not conflict. */ in test_openat2_flags()
221 .err = -EINVAL }, in test_openat2_flags()
223 /* ->resolve must only contain RESOLVE_* flags. */ in test_openat2_flags()
226 .how.resolve = 0x1337, .err = -EINVAL }, in test_openat2_flags()
229 .how.resolve = 0x1337, .err = -EINVAL }, in test_openat2_flags()
232 .how.resolve = 0x1337, .err = -EINVAL }, in test_openat2_flags()
235 .how.resolve = 0x1337, .err = -EINVAL }, in test_openat2_flags()
240 .how.resolve = 0, .err = -EINVAL }, in test_openat2_flags()
246 int fd, fdflags = -1; in test_openat2_flags()
258 path = (test->how.flags & O_CREAT) ? "/tmp/ksft.openat2_tmpfile" : "."; in test_openat2_flags()
261 fd = sys_openat2(AT_FDCWD, path, &test->how); in test_openat2_flags()
262 if (fd < 0 && fd == -EOPNOTSUPP) { in test_openat2_flags()
268 test->name, fd, strerror(-fd)); in test_openat2_flags()
272 if (test->err >= 0) in test_openat2_flags()
275 failed = (fd != test->err); in test_openat2_flags()
291 if (test->how.flags & O_CREAT) in test_openat2_flags()
293 if (!(test->how.flags & O_LARGEFILE)) in test_openat2_flags()
295 failed |= (fdflags != test->how.flags); in test_openat2_flags()
305 test->how.flags); in test_openat2_flags()
307 ksft_print_msg("%d (%s)\n", fd, strerror(-fd)); in test_openat2_flags()
311 if (test->err >= 0) in test_openat2_flags()
312 resultfn("openat2 with %s succeeds\n", test->name); in test_openat2_flags()
315 test->name, test->err, strerror(-test->err)); in test_openat2_flags()