ovl_entry.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. *
  3. * Copyright (C) 2011 Novell Inc.
  4. * Copyright (C) 2016 Red Hat, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. */
  10. struct ovl_config {
  11. char *lowerdir;
  12. char *upperdir;
  13. char *workdir;
  14. bool default_permissions;
  15. bool redirect_dir;
  16. bool redirect_follow;
  17. const char *redirect_mode;
  18. bool index;
  19. bool nfs_export;
  20. };
  21. struct ovl_layer {
  22. struct vfsmount *mnt;
  23. dev_t pseudo_dev;
  24. /* Index of this layer in fs root (upper == 0) */
  25. int idx;
  26. };
  27. struct ovl_path {
  28. struct ovl_layer *layer;
  29. struct dentry *dentry;
  30. };
  31. /* private information held for overlayfs's superblock */
  32. struct ovl_fs {
  33. struct vfsmount *upper_mnt;
  34. unsigned numlower;
  35. struct ovl_layer *lower_layers;
  36. /* workbasedir is the path at workdir= mount option */
  37. struct dentry *workbasedir;
  38. /* workdir is the 'work' directory under workbasedir */
  39. struct dentry *workdir;
  40. /* index directory listing overlay inodes by origin file handle */
  41. struct dentry *indexdir;
  42. long namelen;
  43. /* pathnames of lower and upper dirs, for show_options */
  44. struct ovl_config config;
  45. /* creds of process who forced instantiation of super block */
  46. const struct cred *creator_cred;
  47. bool tmpfile;
  48. bool noxattr;
  49. /* sb common to all layers */
  50. struct super_block *same_sb;
  51. /* Did we take the inuse lock? */
  52. bool upperdir_locked;
  53. bool workdir_locked;
  54. };
  55. /* private information held for every overlayfs dentry */
  56. struct ovl_entry {
  57. union {
  58. struct {
  59. unsigned long flags;
  60. };
  61. struct rcu_head rcu;
  62. };
  63. unsigned numlower;
  64. struct ovl_path lowerstack[];
  65. };
  66. struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
  67. static inline struct ovl_entry *OVL_E(struct dentry *dentry)
  68. {
  69. return (struct ovl_entry *) dentry->d_fsdata;
  70. }
  71. struct ovl_inode {
  72. struct ovl_dir_cache *cache;
  73. const char *redirect;
  74. u64 version;
  75. unsigned long flags;
  76. struct inode vfs_inode;
  77. struct dentry *__upperdentry;
  78. struct inode *lower;
  79. /* synchronize copy up and more */
  80. struct mutex lock;
  81. };
  82. static inline struct ovl_inode *OVL_I(struct inode *inode)
  83. {
  84. return container_of(inode, struct ovl_inode, vfs_inode);
  85. }
  86. static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
  87. {
  88. return READ_ONCE(oi->__upperdentry);
  89. }