Skip to content

Commit 81317d0

Browse files
Cemil Azizoglumartinpitt
authored andcommitted
Call open(.., .., mode) when O_TMPFILE is specified
Test case by Martin Pitt.
1 parent 7e1ac80 commit 81317d0

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
------------------
33
- /umockdev-run/integration/input-evtest-evemu test: Be more liberal in parsing
44
evtest's SYN event output, as it changed in 1.32.
5+
- preload: Properly wrap open() with O_TMPFILE. Thanks Cemil Azizoglu.
56

67
0.8.6 (2014-09-01)
78
------------------

src/libumockdev-preload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ int prefix ## open ## suffix (const char *path, int flags, ...) \
10821082
return -1; \
10831083
} \
10841084
DBG(DBG_PATH, "testbed wrapped " #prefix "open" #suffix "(%s) -> %s\n", path, p); \
1085-
if (flags & O_CREAT) { \
1085+
if (flags & (O_CREAT | O_TMPFILE)) { \
10861086
mode_t mode; \
10871087
va_list ap; \
10881088
va_start(ap, flags); \

tests/test-umockdev.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* along with this program; If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21+
/* for O_TMPFILE */
22+
#define _GNU_SOURCE
23+
2124
#include <glib.h>
2225
#include <glib/gstdio.h>
2326
#include <string.h>
@@ -1064,6 +1067,14 @@ t_testbed_dev_access(UMockdevTestbedFixture * fixture, gconstpointer data)
10641067
close(fd);
10651068
}
10661069

1070+
/* open() with O_TMPFILE */
1071+
errno = 0;
1072+
fd = g_open("/dev", O_TMPFILE|O_RDWR, 0644);
1073+
g_assert_cmpint(errno, ==, 0);
1074+
g_assert_cmpint(fd, >, 0);
1075+
g_assert_cmpint(write(fd, "hello", 5), ==, 5);
1076+
close(fd);
1077+
10671078
g_free(devdir);
10681079
}
10691080

0 commit comments

Comments
 (0)