ovl_entry.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. int xino;
  21. bool metacopy;
  22. };
  23. struct ovl_sb {
  24. struct super_block *sb;
  25. dev_t pseudo_dev;
  26. };
  27. struct ovl_layer {
  28. struct vfsmount *mnt;
  29. struct ovl_sb *fs;
  30. /* Index of this layer in fs root (upper idx == 0) */
  31. int idx;
  32. /* One fsid per unique underlying sb (upper fsid == 0) */
  33. int fsid;
  34. };
  35. struct ovl_path {
  36. struct ovl_layer *layer;
  37. struct dentry *dentry;
  38. };
  39. /* private information held for overlayfs's superblock */
  40. struct ovl_fs {
  41. struct vfsmount *upper_mnt;
  42. unsigned int numlower;
  43. /* Number of unique lower sb that differ from upper sb */
  44. unsigned int numlowerfs;
  45. struct ovl_layer *lower_layers;
  46. struct ovl_sb *lower_fs;
  47. /* workbasedir is the path at workdir= mount option */
  48. struct dentry *workbasedir;
  49. /* workdir is the 'work' directory under workbasedir */
  50. struct dentry *workdir;
  51. /* index directory listing overlay inodes by origin file handle */
  52. struct dentry *indexdir;
  53. long namelen;
  54. /* pathnames of lower and upper dirs, for show_options */
  55. struct ovl_config config;
  56. /* creds of process who forced instantiation of super block */
  57. const struct cred *creator_cred;
  58. bool tmpfile;
  59. bool noxattr;
  60. /* Did we take the inuse lock? */
  61. bool upperdir_locked;
  62. bool workdir_locked;
  63. /* Inode numbers in all layers do not use the high xino_bits */
  64. unsigned int xino_bits;
  65. };
  66. /* private information held for every overlayfs dentry */
  67. struct ovl_entry {
  68. union {
  69. struct {
  70. unsigned long flags;
  71. };
  72. struct rcu_head rcu;
  73. };
  74. unsigned numlower;
  75. struct ovl_path lowerstack[];
  76. };
  77. struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
  78. static inline struct ovl_entry *OVL_E(struct dentry *dentry)
  79. {
  80. return (struct ovl_entry *) dentry->d_fsdata;
  81. }
  82. struct ovl_inode {
  83. union {
  84. struct ovl_dir_cache *cache; /* directory */
  85. struct inode *lowerdata; /* regular file */
  86. };
  87. const char *redirect;
  88. u64 version;
  89. unsigned long flags;
  90. struct inode vfs_inode;
  91. struct dentry *__upperdentry;
  92. struct inode *lower;
  93. /* synchronize copy up and more */
  94. struct mutex lock;
  95. };
  96. static inline struct ovl_inode *OVL_I(struct inode *inode)
  97. {
  98. return container_of(inode, struct ovl_inode, vfs_inode);
  99. }
  100. static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
  101. {
  102. return READ_ONCE(oi->__upperdentry);
  103. }