subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2007 SWSoft. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of version 2 of the GNU General Public License as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it would be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 11 | * |
| 12 | * Further, this software is distributed without any warranty that it is |
| 13 | * free of the rightful claim of any third person regarding infringement |
| 14 | * or the like. Any license provided herein, whether implied or |
| 15 | * otherwise, applies only to this software file. Patent licenses, if |
| 16 | * any, provided herein do not apply to combinations of this program with |
| 17 | * other software, or any other product whatsoever. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 20 | * with this program; if not, write the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 22 | * |
| 23 | * Started by Andrew Vagin <avagin@sw.ru> |
| 24 | * |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 25 | * DESCRIPTION |
| 26 | * Check that inotify work for a file |
| 27 | * |
| 28 | * ALGORITHM |
| 29 | * Execute sequence file's operation and check return events |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 30 | */ |
subrata_modak | 86faed4 | 2008-12-29 12:11:50 +0000 | [diff] [blame] | 31 | #include "config.h" |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 32 | |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 33 | #include <stdio.h> |
| 34 | #include <sys/stat.h> |
| 35 | #include <sys/types.h> |
| 36 | #include <sys/fcntl.h> |
| 37 | #include <errno.h> |
| 38 | #include <string.h> |
subrata_modak | c59422e | 2007-06-04 10:39:59 +0000 | [diff] [blame] | 39 | #include <sys/syscall.h> |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 40 | #include "test.h" |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 41 | #include "linux_syscall_numbers.h" |
Garrett Cooper | 3bf3cb1 | 2012-05-20 10:51:55 -0700 | [diff] [blame] | 42 | #include "inotify.h" |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 43 | |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 44 | #if defined(HAVE_SYS_INOTIFY_H) |
subrata_modak | 3e9f094 | 2008-08-22 21:32:50 +0000 | [diff] [blame] | 45 | #include <sys/inotify.h> |
subrata_modak | c59422e | 2007-06-04 10:39:59 +0000 | [diff] [blame] | 46 | |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 47 | #define EVENT_MAX 1024 |
| 48 | /* size of the event structure, not counting name */ |
| 49 | #define EVENT_SIZE (sizeof (struct inotify_event)) |
| 50 | /* reasonable guess as to size of 1024 events */ |
| 51 | #define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16)) |
| 52 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 53 | char *TCID = "inotify01"; |
| 54 | int TST_TOTAL = 7; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 55 | |
Cyril Hrubis | 26aa0a8 | 2013-08-08 14:58:42 +0200 | [diff] [blame] | 56 | static void setup(void); |
| 57 | static void cleanup(void); |
| 58 | |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 59 | #define BUF_SIZE 256 |
Cyril Hrubis | 26aa0a8 | 2013-08-08 14:58:42 +0200 | [diff] [blame] | 60 | static char fname[BUF_SIZE]; |
| 61 | static char buf[BUF_SIZE]; |
| 62 | static int fd, fd_notify; |
Cyril Hrubis | 04f2177 | 2014-12-09 14:26:23 +0100 | [diff] [blame] | 63 | static int wd, reap_wd; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 64 | |
Cyril Hrubis | 26aa0a8 | 2013-08-08 14:58:42 +0200 | [diff] [blame] | 65 | static int event_set[EVENT_MAX]; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 66 | |
Cyril Hrubis | 26aa0a8 | 2013-08-08 14:58:42 +0200 | [diff] [blame] | 67 | static char event_buf[EVENT_BUF_LEN]; |
vapier | 03b05a0 | 2008-04-07 18:33:46 +0000 | [diff] [blame] | 68 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 69 | int main(int ac, char **av) |
| 70 | { |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 71 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 72 | const char *msg; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 73 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 74 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 75 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 76 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 77 | setup(); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 78 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 79 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 80 | tst_count = 0; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 81 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 82 | /* |
| 83 | * generate sequence of events |
| 84 | */ |
| 85 | if (chmod(fname, 0755) < 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 86 | tst_brkm(TBROK | TERRNO, cleanup, |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 87 | "chmod(%s, 0755) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 88 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 89 | event_set[tst_count] = IN_ATTRIB; |
| 90 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 91 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 92 | if ((fd = open(fname, O_RDONLY)) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 93 | tst_brkm(TBROK | TERRNO, cleanup, |
| 94 | "open(%s, O_RDWR|O_CREAT,0700) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 95 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 96 | event_set[tst_count] = IN_OPEN; |
| 97 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 98 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 99 | if (read(fd, buf, BUF_SIZE) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 100 | tst_brkm(TBROK | TERRNO, cleanup, |
| 101 | "read(%d, buf, %d) failed", fd, BUF_SIZE); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 102 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 103 | event_set[tst_count] = IN_ACCESS; |
| 104 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 105 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 106 | if (close(fd) == -1) { |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 107 | tst_brkm(TBROK, cleanup, "close(%s) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 108 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 109 | event_set[tst_count] = IN_CLOSE_NOWRITE; |
| 110 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 111 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 112 | if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) { |
| 113 | tst_brkm(TBROK, cleanup, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 114 | "open(%s, O_RDWR|O_CREAT,0700) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 115 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 116 | event_set[tst_count] = IN_OPEN; |
| 117 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 118 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 119 | if (write(fd, buf, BUF_SIZE) == -1) { |
| 120 | tst_brkm(TBROK, cleanup, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 121 | "write(%d, %s, 1) failed", fd, fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 122 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 123 | event_set[tst_count] = IN_MODIFY; |
| 124 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 125 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 126 | if (close(fd) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 127 | tst_brkm(TBROK, cleanup, "close(%s) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 128 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 129 | event_set[tst_count] = IN_CLOSE_WRITE; |
| 130 | tst_count++; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 131 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 132 | if (TST_TOTAL != tst_count) { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 133 | tst_brkm(TBROK, cleanup, |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 134 | "TST_TOTAL and tst_count are not equal"); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 135 | } |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 136 | tst_count = 0; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 137 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 138 | /* |
| 139 | * get list on events |
| 140 | */ |
| 141 | int len, i = 0, test_num = 0; |
| 142 | if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) < 0) { |
| 143 | tst_brkm(TBROK, cleanup, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 144 | "read(%d, buf, %zu) failed", |
| 145 | fd_notify, EVENT_BUF_LEN); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 146 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 147 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 148 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 149 | /* |
| 150 | * check events |
| 151 | */ |
| 152 | while (i < len) { |
| 153 | struct inotify_event *event; |
| 154 | event = (struct inotify_event *)&event_buf[i]; |
| 155 | if (test_num >= TST_TOTAL) { |
| 156 | tst_resm(TFAIL, |
| 157 | "get unnecessary event: wd=%d mask=%x " |
| 158 | "cookie=%u len=%u", |
| 159 | event->wd, event->mask, |
| 160 | event->cookie, event->len); |
| 161 | } else if (event_set[test_num] == event->mask) { |
Jan Kara | 1ea2821 | 2014-02-20 18:16:17 +0100 | [diff] [blame] | 162 | if (event->cookie != 0) { |
| 163 | tst_resm(TFAIL, |
| 164 | "get event: wd=%d mask=%x " |
| 165 | "cookie=%u (expected 0) len=%u", |
| 166 | event->wd, event->mask, |
| 167 | event->cookie, event->len); |
| 168 | } else { |
| 169 | tst_resm(TPASS, "get event: wd=%d " |
| 170 | "mask=%x cookie=%u len=%u", |
| 171 | event->wd, event->mask, |
| 172 | event->cookie, event->len); |
| 173 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 174 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 175 | } else { |
| 176 | tst_resm(TFAIL, "get event: wd=%d mask=%x " |
| 177 | "(expected %x) cookie=%u len=%u", |
| 178 | event->wd, event->mask, |
| 179 | event_set[test_num], |
| 180 | event->cookie, event->len); |
| 181 | } |
| 182 | test_num++; |
| 183 | i += EVENT_SIZE + event->len; |
| 184 | } |
| 185 | for (; test_num < TST_TOTAL; test_num++) { |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 186 | tst_resm(TFAIL, "didn't get event: mask=%x", |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 187 | event_set[test_num]); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 188 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 189 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 190 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 191 | } |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 192 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 193 | cleanup(); |
Garrett Cooper | 766f33c | 2010-11-22 14:53:00 -0800 | [diff] [blame] | 194 | tst_exit(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 195 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 196 | |
Cyril Hrubis | 26aa0a8 | 2013-08-08 14:58:42 +0200 | [diff] [blame] | 197 | static void setup(void) |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 198 | { |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 199 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 200 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 201 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 202 | TEST_PAUSE; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 203 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 204 | tst_tmpdir(); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 205 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 206 | sprintf(fname, "tfile_%d", getpid()); |
| 207 | if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 208 | tst_brkm(TBROK | TERRNO, cleanup, |
| 209 | "open(%s, O_RDWR|O_CREAT,0700) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 210 | } |
| 211 | if ((write(fd, fname, 1)) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 212 | tst_brkm(TBROK | TERRNO, cleanup, "write(%d, %s, 1) failed", |
| 213 | fd, fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 214 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 215 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 216 | /* close the file we have open */ |
| 217 | if (close(fd) == -1) { |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 218 | tst_brkm(TBROK, cleanup, "close(%s) failed", fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 219 | } |
| 220 | if ((fd_notify = myinotify_init()) < 0) { |
| 221 | if (errno == ENOSYS) { |
Garrett Cooper | 766f33c | 2010-11-22 14:53:00 -0800 | [diff] [blame] | 222 | tst_brkm(TCONF, cleanup, |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 223 | "inotify is not configured in this kernel."); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 224 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 225 | tst_brkm(TBROK | TERRNO, cleanup, |
| 226 | "inotify_init failed"); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 227 | } |
| 228 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 229 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 230 | if ((wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS)) < 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 231 | tst_brkm(TBROK | TERRNO, cleanup, |
| 232 | "inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed", |
| 233 | fd_notify, fname); |
Cyril Hrubis | 04f2177 | 2014-12-09 14:26:23 +0100 | [diff] [blame] | 234 | reap_wd = 1; |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 235 | }; |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 236 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 237 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 238 | |
Cyril Hrubis | 26aa0a8 | 2013-08-08 14:58:42 +0200 | [diff] [blame] | 239 | static void cleanup(void) |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 240 | { |
Cyril Hrubis | 04f2177 | 2014-12-09 14:26:23 +0100 | [diff] [blame] | 241 | if (reap_wd && myinotify_rm_watch(fd_notify, wd) < 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 242 | tst_resm(TWARN | TERRNO, "inotify_rm_watch (%d, %d) failed", |
Garrett Cooper | 766f33c | 2010-11-22 14:53:00 -0800 | [diff] [blame] | 243 | fd_notify, wd); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 244 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 245 | } |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 246 | |
Cyril Hrubis | 04f2177 | 2014-12-09 14:26:23 +0100 | [diff] [blame] | 247 | if (fd_notify > 0 && close(fd_notify)) |
Garrett Cooper | 766f33c | 2010-11-22 14:53:00 -0800 | [diff] [blame] | 248 | tst_resm(TWARN, "close(%d) failed", fd_notify); |
subrata_modak | 73e6ce7 | 2007-05-24 10:00:45 +0000 | [diff] [blame] | 249 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 250 | tst_rmdir(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 251 | } |
subrata_modak | c59422e | 2007-06-04 10:39:59 +0000 | [diff] [blame] | 252 | |
| 253 | #else |
| 254 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 255 | char *TCID = "inotify01"; |
| 256 | int TST_TOTAL = 0; |
subrata_modak | c59422e | 2007-06-04 10:39:59 +0000 | [diff] [blame] | 257 | |
Garrett Cooper | 766f33c | 2010-11-22 14:53:00 -0800 | [diff] [blame] | 258 | int main(void) |
subrata_modak | c59422e | 2007-06-04 10:39:59 +0000 | [diff] [blame] | 259 | { |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 260 | tst_brkm(TCONF, NULL, "system doesn't have required inotify support"); |
subrata_modak | c59422e | 2007-06-04 10:39:59 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Markos Chandras | f4539c6 | 2012-01-03 09:41:10 +0000 | [diff] [blame] | 263 | #endif |