inotify_user.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. * fs/inotify_user.c - inotify support for userspace
  3. *
  4. * Authors:
  5. * John McCutchan <ttb@tentacle.dhs.org>
  6. * Robert Love <rml@novell.com>
  7. *
  8. * Copyright (C) 2005 John McCutchan
  9. * Copyright 2006 Hewlett-Packard Development Company, L.P.
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2, or (at your option) any
  14. * later version.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/sched.h>
  23. #include <linux/slab.h>
  24. #include <linux/fs.h>
  25. #include <linux/file.h>
  26. #include <linux/mount.h>
  27. #include <linux/namei.h>
  28. #include <linux/poll.h>
  29. #include <linux/init.h>
  30. #include <linux/list.h>
  31. #include <linux/inotify.h>
  32. #include <linux/syscalls.h>
  33. #include <linux/magic.h>
  34. #include <asm/ioctls.h>
  35. static struct kmem_cache *watch_cachep __read_mostly;
  36. static struct kmem_cache *event_cachep __read_mostly;
  37. static struct vfsmount *inotify_mnt __read_mostly;
  38. /* these are configurable via /proc/sys/fs/inotify/ */
  39. int inotify_max_user_instances __read_mostly;
  40. int inotify_max_user_watches __read_mostly;
  41. int inotify_max_queued_events __read_mostly;
  42. /*
  43. * Lock ordering:
  44. *
  45. * inotify_dev->up_mutex (ensures we don't re-add the same watch)
  46. * inode->inotify_mutex (protects inode's watch list)
  47. * inotify_handle->mutex (protects inotify_handle's watch list)
  48. * inotify_dev->ev_mutex (protects device's event queue)
  49. */
  50. /*
  51. * Lifetimes of the main data structures:
  52. *
  53. * inotify_device: Lifetime is managed by reference count, from
  54. * sys_inotify_init() until release. Additional references can bump the count
  55. * via get_inotify_dev() and drop the count via put_inotify_dev().
  56. *
  57. * inotify_user_watch: Lifetime is from create_watch() to the receipt of an
  58. * IN_IGNORED event from inotify, or when using IN_ONESHOT, to receipt of the
  59. * first event, or to inotify_destroy().
  60. */
  61. /*
  62. * struct inotify_device - represents an inotify instance
  63. *
  64. * This structure is protected by the mutex 'mutex'.
  65. */
  66. struct inotify_device {
  67. wait_queue_head_t wq; /* wait queue for i/o */
  68. struct mutex ev_mutex; /* protects event queue */
  69. struct mutex up_mutex; /* synchronizes watch updates */
  70. struct list_head events; /* list of queued events */
  71. atomic_t count; /* reference count */
  72. struct user_struct *user; /* user who opened this dev */
  73. struct inotify_handle *ih; /* inotify handle */
  74. unsigned int queue_size; /* size of the queue (bytes) */
  75. unsigned int event_count; /* number of pending events */
  76. unsigned int max_events; /* maximum number of events */
  77. };
  78. /*
  79. * struct inotify_kernel_event - An inotify event, originating from a watch and
  80. * queued for user-space. A list of these is attached to each instance of the
  81. * device. In read(), this list is walked and all events that can fit in the
  82. * buffer are returned.
  83. *
  84. * Protected by dev->ev_mutex of the device in which we are queued.
  85. */
  86. struct inotify_kernel_event {
  87. struct inotify_event event; /* the user-space event */
  88. struct list_head list; /* entry in inotify_device's list */
  89. char *name; /* filename, if any */
  90. };
  91. /*
  92. * struct inotify_user_watch - our version of an inotify_watch, we add
  93. * a reference to the associated inotify_device.
  94. */
  95. struct inotify_user_watch {
  96. struct inotify_device *dev; /* associated device */
  97. struct inotify_watch wdata; /* inotify watch data */
  98. };
  99. #ifdef CONFIG_SYSCTL
  100. #include <linux/sysctl.h>
  101. static int zero;
  102. ctl_table inotify_table[] = {
  103. {
  104. .ctl_name = INOTIFY_MAX_USER_INSTANCES,
  105. .procname = "max_user_instances",
  106. .data = &inotify_max_user_instances,
  107. .maxlen = sizeof(int),
  108. .mode = 0644,
  109. .proc_handler = &proc_dointvec_minmax,
  110. .strategy = &sysctl_intvec,
  111. .extra1 = &zero,
  112. },
  113. {
  114. .ctl_name = INOTIFY_MAX_USER_WATCHES,
  115. .procname = "max_user_watches",
  116. .data = &inotify_max_user_watches,
  117. .maxlen = sizeof(int),
  118. .mode = 0644,
  119. .proc_handler = &proc_dointvec_minmax,
  120. .strategy = &sysctl_intvec,
  121. .extra1 = &zero,
  122. },
  123. {
  124. .ctl_name = INOTIFY_MAX_QUEUED_EVENTS,
  125. .procname = "max_queued_events",
  126. .data = &inotify_max_queued_events,
  127. .maxlen = sizeof(int),
  128. .mode = 0644,
  129. .proc_handler = &proc_dointvec_minmax,
  130. .strategy = &sysctl_intvec,
  131. .extra1 = &zero
  132. },
  133. { .ctl_name = 0 }
  134. };
  135. #endif /* CONFIG_SYSCTL */
  136. static inline void get_inotify_dev(struct inotify_device *dev)
  137. {
  138. atomic_inc(&dev->count);
  139. }
  140. static inline void put_inotify_dev(struct inotify_device *dev)
  141. {
  142. if (atomic_dec_and_test(&dev->count)) {
  143. atomic_dec(&dev->user->inotify_devs);
  144. free_uid(dev->user);
  145. kfree(dev);
  146. }
  147. }
  148. /*
  149. * free_inotify_user_watch - cleans up the watch and its references
  150. */
  151. static void free_inotify_user_watch(struct inotify_watch *w)
  152. {
  153. struct inotify_user_watch *watch;
  154. struct inotify_device *dev;
  155. watch = container_of(w, struct inotify_user_watch, wdata);
  156. dev = watch->dev;
  157. atomic_dec(&dev->user->inotify_watches);
  158. put_inotify_dev(dev);
  159. kmem_cache_free(watch_cachep, watch);
  160. }
  161. /*
  162. * kernel_event - create a new kernel event with the given parameters
  163. *
  164. * This function can sleep.
  165. */
  166. static struct inotify_kernel_event * kernel_event(s32 wd, u32 mask, u32 cookie,
  167. const char *name)
  168. {
  169. struct inotify_kernel_event *kevent;
  170. kevent = kmem_cache_alloc(event_cachep, GFP_NOFS);
  171. if (unlikely(!kevent))
  172. return NULL;
  173. /* we hand this out to user-space, so zero it just in case */
  174. memset(&kevent->event, 0, sizeof(struct inotify_event));
  175. kevent->event.wd = wd;
  176. kevent->event.mask = mask;
  177. kevent->event.cookie = cookie;
  178. INIT_LIST_HEAD(&kevent->list);
  179. if (name) {
  180. size_t len, rem, event_size = sizeof(struct inotify_event);
  181. /*
  182. * We need to pad the filename so as to properly align an
  183. * array of inotify_event structures. Because the structure is
  184. * small and the common case is a small filename, we just round
  185. * up to the next multiple of the structure's sizeof. This is
  186. * simple and safe for all architectures.
  187. */
  188. len = strlen(name) + 1;
  189. rem = event_size - len;
  190. if (len > event_size) {
  191. rem = event_size - (len % event_size);
  192. if (len % event_size == 0)
  193. rem = 0;
  194. }
  195. kevent->name = kmalloc(len + rem, GFP_KERNEL);
  196. if (unlikely(!kevent->name)) {
  197. kmem_cache_free(event_cachep, kevent);
  198. return NULL;
  199. }
  200. memcpy(kevent->name, name, len);
  201. if (rem)
  202. memset(kevent->name + len, 0, rem);
  203. kevent->event.len = len + rem;
  204. } else {
  205. kevent->event.len = 0;
  206. kevent->name = NULL;
  207. }
  208. return kevent;
  209. }
  210. /*
  211. * inotify_dev_get_event - return the next event in the given dev's queue
  212. *
  213. * Caller must hold dev->ev_mutex.
  214. */
  215. static inline struct inotify_kernel_event *
  216. inotify_dev_get_event(struct inotify_device *dev)
  217. {
  218. return list_entry(dev->events.next, struct inotify_kernel_event, list);
  219. }
  220. /*
  221. * inotify_dev_queue_event - event handler registered with core inotify, adds
  222. * a new event to the given device
  223. *
  224. * Can sleep (calls kernel_event()).
  225. */
  226. static void inotify_dev_queue_event(struct inotify_watch *w, u32 wd, u32 mask,
  227. u32 cookie, const char *name,
  228. struct inode *ignored)
  229. {
  230. struct inotify_user_watch *watch;
  231. struct inotify_device *dev;
  232. struct inotify_kernel_event *kevent, *last;
  233. watch = container_of(w, struct inotify_user_watch, wdata);
  234. dev = watch->dev;
  235. mutex_lock(&dev->ev_mutex);
  236. /* we can safely put the watch as we don't reference it while
  237. * generating the event
  238. */
  239. if (mask & IN_IGNORED || mask & IN_ONESHOT)
  240. put_inotify_watch(w); /* final put */
  241. /* coalescing: drop this event if it is a dupe of the previous */
  242. last = inotify_dev_get_event(dev);
  243. if (last && last->event.mask == mask && last->event.wd == wd &&
  244. last->event.cookie == cookie) {
  245. const char *lastname = last->name;
  246. if (!name && !lastname)
  247. goto out;
  248. if (name && lastname && !strcmp(lastname, name))
  249. goto out;
  250. }
  251. /* the queue overflowed and we already sent the Q_OVERFLOW event */
  252. if (unlikely(dev->event_count > dev->max_events))
  253. goto out;
  254. /* if the queue overflows, we need to notify user space */
  255. if (unlikely(dev->event_count == dev->max_events))
  256. kevent = kernel_event(-1, IN_Q_OVERFLOW, cookie, NULL);
  257. else
  258. kevent = kernel_event(wd, mask, cookie, name);
  259. if (unlikely(!kevent))
  260. goto out;
  261. /* queue the event and wake up anyone waiting */
  262. dev->event_count++;
  263. dev->queue_size += sizeof(struct inotify_event) + kevent->event.len;
  264. list_add_tail(&kevent->list, &dev->events);
  265. wake_up_interruptible(&dev->wq);
  266. out:
  267. mutex_unlock(&dev->ev_mutex);
  268. }
  269. /*
  270. * remove_kevent - cleans up and ultimately frees the given kevent
  271. *
  272. * Caller must hold dev->ev_mutex.
  273. */
  274. static void remove_kevent(struct inotify_device *dev,
  275. struct inotify_kernel_event *kevent)
  276. {
  277. list_del(&kevent->list);
  278. dev->event_count--;
  279. dev->queue_size -= sizeof(struct inotify_event) + kevent->event.len;
  280. kfree(kevent->name);
  281. kmem_cache_free(event_cachep, kevent);
  282. }
  283. /*
  284. * inotify_dev_event_dequeue - destroy an event on the given device
  285. *
  286. * Caller must hold dev->ev_mutex.
  287. */
  288. static void inotify_dev_event_dequeue(struct inotify_device *dev)
  289. {
  290. if (!list_empty(&dev->events)) {
  291. struct inotify_kernel_event *kevent;
  292. kevent = inotify_dev_get_event(dev);
  293. remove_kevent(dev, kevent);
  294. }
  295. }
  296. /*
  297. * find_inode - resolve a user-given path to a specific inode and return a nd
  298. */
  299. static int find_inode(const char __user *dirname, struct nameidata *nd,
  300. unsigned flags)
  301. {
  302. int error;
  303. error = __user_walk(dirname, flags, nd);
  304. if (error)
  305. return error;
  306. /* you can only watch an inode if you have read permissions on it */
  307. error = vfs_permission(nd, MAY_READ);
  308. if (error)
  309. path_release(nd);
  310. return error;
  311. }
  312. /*
  313. * create_watch - creates a watch on the given device.
  314. *
  315. * Callers must hold dev->up_mutex.
  316. */
  317. static int create_watch(struct inotify_device *dev, struct inode *inode,
  318. u32 mask)
  319. {
  320. struct inotify_user_watch *watch;
  321. int ret;
  322. if (atomic_read(&dev->user->inotify_watches) >=
  323. inotify_max_user_watches)
  324. return -ENOSPC;
  325. watch = kmem_cache_alloc(watch_cachep, GFP_KERNEL);
  326. if (unlikely(!watch))
  327. return -ENOMEM;
  328. /* save a reference to device and bump the count to make it official */
  329. get_inotify_dev(dev);
  330. watch->dev = dev;
  331. atomic_inc(&dev->user->inotify_watches);
  332. inotify_init_watch(&watch->wdata);
  333. ret = inotify_add_watch(dev->ih, &watch->wdata, inode, mask);
  334. if (ret < 0)
  335. free_inotify_user_watch(&watch->wdata);
  336. return ret;
  337. }
  338. /* Device Interface */
  339. static unsigned int inotify_poll(struct file *file, poll_table *wait)
  340. {
  341. struct inotify_device *dev = file->private_data;
  342. int ret = 0;
  343. poll_wait(file, &dev->wq, wait);
  344. mutex_lock(&dev->ev_mutex);
  345. if (!list_empty(&dev->events))
  346. ret = POLLIN | POLLRDNORM;
  347. mutex_unlock(&dev->ev_mutex);
  348. return ret;
  349. }
  350. static ssize_t inotify_read(struct file *file, char __user *buf,
  351. size_t count, loff_t *pos)
  352. {
  353. size_t event_size = sizeof (struct inotify_event);
  354. struct inotify_device *dev;
  355. char __user *start;
  356. int ret;
  357. DEFINE_WAIT(wait);
  358. start = buf;
  359. dev = file->private_data;
  360. while (1) {
  361. int events;
  362. prepare_to_wait(&dev->wq, &wait, TASK_INTERRUPTIBLE);
  363. mutex_lock(&dev->ev_mutex);
  364. events = !list_empty(&dev->events);
  365. mutex_unlock(&dev->ev_mutex);
  366. if (events) {
  367. ret = 0;
  368. break;
  369. }
  370. if (file->f_flags & O_NONBLOCK) {
  371. ret = -EAGAIN;
  372. break;
  373. }
  374. if (signal_pending(current)) {
  375. ret = -EINTR;
  376. break;
  377. }
  378. schedule();
  379. }
  380. finish_wait(&dev->wq, &wait);
  381. if (ret)
  382. return ret;
  383. mutex_lock(&dev->ev_mutex);
  384. while (1) {
  385. struct inotify_kernel_event *kevent;
  386. ret = buf - start;
  387. if (list_empty(&dev->events))
  388. break;
  389. kevent = inotify_dev_get_event(dev);
  390. if (event_size + kevent->event.len > count) {
  391. if (ret == 0 && count > 0) {
  392. /*
  393. * could not get a single event because we
  394. * didn't have enough buffer space.
  395. */
  396. ret = -EINVAL;
  397. }
  398. break;
  399. }
  400. if (copy_to_user(buf, &kevent->event, event_size)) {
  401. ret = -EFAULT;
  402. break;
  403. }
  404. buf += event_size;
  405. count -= event_size;
  406. if (kevent->name) {
  407. if (copy_to_user(buf, kevent->name, kevent->event.len)){
  408. ret = -EFAULT;
  409. break;
  410. }
  411. buf += kevent->event.len;
  412. count -= kevent->event.len;
  413. }
  414. remove_kevent(dev, kevent);
  415. }
  416. mutex_unlock(&dev->ev_mutex);
  417. return ret;
  418. }
  419. static int inotify_release(struct inode *ignored, struct file *file)
  420. {
  421. struct inotify_device *dev = file->private_data;
  422. inotify_destroy(dev->ih);
  423. /* destroy all of the events on this device */
  424. mutex_lock(&dev->ev_mutex);
  425. while (!list_empty(&dev->events))
  426. inotify_dev_event_dequeue(dev);
  427. mutex_unlock(&dev->ev_mutex);
  428. /* free this device: the put matching the get in inotify_init() */
  429. put_inotify_dev(dev);
  430. return 0;
  431. }
  432. static long inotify_ioctl(struct file *file, unsigned int cmd,
  433. unsigned long arg)
  434. {
  435. struct inotify_device *dev;
  436. void __user *p;
  437. int ret = -ENOTTY;
  438. dev = file->private_data;
  439. p = (void __user *) arg;
  440. switch (cmd) {
  441. case FIONREAD:
  442. ret = put_user(dev->queue_size, (int __user *) p);
  443. break;
  444. }
  445. return ret;
  446. }
  447. static const struct file_operations inotify_fops = {
  448. .poll = inotify_poll,
  449. .read = inotify_read,
  450. .release = inotify_release,
  451. .unlocked_ioctl = inotify_ioctl,
  452. .compat_ioctl = inotify_ioctl,
  453. };
  454. static const struct inotify_operations inotify_user_ops = {
  455. .handle_event = inotify_dev_queue_event,
  456. .destroy_watch = free_inotify_user_watch,
  457. };
  458. asmlinkage long sys_inotify_init(void)
  459. {
  460. struct inotify_device *dev;
  461. struct inotify_handle *ih;
  462. struct user_struct *user;
  463. struct file *filp;
  464. int fd, ret;
  465. fd = get_unused_fd();
  466. if (fd < 0)
  467. return fd;
  468. filp = get_empty_filp();
  469. if (!filp) {
  470. ret = -ENFILE;
  471. goto out_put_fd;
  472. }
  473. user = get_uid(current->user);
  474. if (unlikely(atomic_read(&user->inotify_devs) >=
  475. inotify_max_user_instances)) {
  476. ret = -EMFILE;
  477. goto out_free_uid;
  478. }
  479. dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL);
  480. if (unlikely(!dev)) {
  481. ret = -ENOMEM;
  482. goto out_free_uid;
  483. }
  484. ih = inotify_init(&inotify_user_ops);
  485. if (unlikely(IS_ERR(ih))) {
  486. ret = PTR_ERR(ih);
  487. goto out_free_dev;
  488. }
  489. dev->ih = ih;
  490. filp->f_op = &inotify_fops;
  491. filp->f_path.mnt = mntget(inotify_mnt);
  492. filp->f_path.dentry = dget(inotify_mnt->mnt_root);
  493. filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping;
  494. filp->f_mode = FMODE_READ;
  495. filp->f_flags = O_RDONLY;
  496. filp->private_data = dev;
  497. INIT_LIST_HEAD(&dev->events);
  498. init_waitqueue_head(&dev->wq);
  499. mutex_init(&dev->ev_mutex);
  500. mutex_init(&dev->up_mutex);
  501. dev->event_count = 0;
  502. dev->queue_size = 0;
  503. dev->max_events = inotify_max_queued_events;
  504. dev->user = user;
  505. atomic_set(&dev->count, 0);
  506. get_inotify_dev(dev);
  507. atomic_inc(&user->inotify_devs);
  508. fd_install(fd, filp);
  509. return fd;
  510. out_free_dev:
  511. kfree(dev);
  512. out_free_uid:
  513. free_uid(user);
  514. put_filp(filp);
  515. out_put_fd:
  516. put_unused_fd(fd);
  517. return ret;
  518. }
  519. asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
  520. {
  521. struct inode *inode;
  522. struct inotify_device *dev;
  523. struct nameidata nd;
  524. struct file *filp;
  525. int ret, fput_needed;
  526. unsigned flags = 0;
  527. filp = fget_light(fd, &fput_needed);
  528. if (unlikely(!filp))
  529. return -EBADF;
  530. /* verify that this is indeed an inotify instance */
  531. if (unlikely(filp->f_op != &inotify_fops)) {
  532. ret = -EINVAL;
  533. goto fput_and_out;
  534. }
  535. if (!(mask & IN_DONT_FOLLOW))
  536. flags |= LOOKUP_FOLLOW;
  537. if (mask & IN_ONLYDIR)
  538. flags |= LOOKUP_DIRECTORY;
  539. ret = find_inode(path, &nd, flags);
  540. if (unlikely(ret))
  541. goto fput_and_out;
  542. /* inode held in place by reference to nd; dev by fget on fd */
  543. inode = nd.dentry->d_inode;
  544. dev = filp->private_data;
  545. mutex_lock(&dev->up_mutex);
  546. ret = inotify_find_update_watch(dev->ih, inode, mask);
  547. if (ret == -ENOENT)
  548. ret = create_watch(dev, inode, mask);
  549. mutex_unlock(&dev->up_mutex);
  550. path_release(&nd);
  551. fput_and_out:
  552. fput_light(filp, fput_needed);
  553. return ret;
  554. }
  555. asmlinkage long sys_inotify_rm_watch(int fd, u32 wd)
  556. {
  557. struct file *filp;
  558. struct inotify_device *dev;
  559. int ret, fput_needed;
  560. filp = fget_light(fd, &fput_needed);
  561. if (unlikely(!filp))
  562. return -EBADF;
  563. /* verify that this is indeed an inotify instance */
  564. if (unlikely(filp->f_op != &inotify_fops)) {
  565. ret = -EINVAL;
  566. goto out;
  567. }
  568. dev = filp->private_data;
  569. /* we free our watch data when we get IN_IGNORED */
  570. ret = inotify_rm_wd(dev->ih, wd);
  571. out:
  572. fput_light(filp, fput_needed);
  573. return ret;
  574. }
  575. static int
  576. inotify_get_sb(struct file_system_type *fs_type, int flags,
  577. const char *dev_name, void *data, struct vfsmount *mnt)
  578. {
  579. return get_sb_pseudo(fs_type, "inotify", NULL,
  580. INOTIFYFS_SUPER_MAGIC, mnt);
  581. }
  582. static struct file_system_type inotify_fs_type = {
  583. .name = "inotifyfs",
  584. .get_sb = inotify_get_sb,
  585. .kill_sb = kill_anon_super,
  586. };
  587. /*
  588. * inotify_user_setup - Our initialization function. Note that we cannnot return
  589. * error because we have compiled-in VFS hooks. So an (unlikely) failure here
  590. * must result in panic().
  591. */
  592. static int __init inotify_user_setup(void)
  593. {
  594. int ret;
  595. ret = register_filesystem(&inotify_fs_type);
  596. if (unlikely(ret))
  597. panic("inotify: register_filesystem returned %d!\n", ret);
  598. inotify_mnt = kern_mount(&inotify_fs_type);
  599. if (IS_ERR(inotify_mnt))
  600. panic("inotify: kern_mount ret %ld!\n", PTR_ERR(inotify_mnt));
  601. inotify_max_queued_events = 16384;
  602. inotify_max_user_instances = 128;
  603. inotify_max_user_watches = 8192;
  604. watch_cachep = kmem_cache_create("inotify_watch_cache",
  605. sizeof(struct inotify_user_watch),
  606. 0, SLAB_PANIC, NULL);
  607. event_cachep = kmem_cache_create("inotify_event_cache",
  608. sizeof(struct inotify_kernel_event),
  609. 0, SLAB_PANIC, NULL);
  610. return 0;
  611. }
  612. module_init(inotify_user_setup);