libfs.c (5632a9fbcd451892332d45553ce8b831d5143691) libfs.c (3767e255b390d72f9a33c08d9e86c5f21f25860f)
1/*
2 * fs/libfs.c
3 * Library for filesystems writers.
4 */
5
6#include <linux/blkdev.h>
7#include <linux/export.h>
8#include <linux/pagemap.h>

--- 75 unchanged lines hidden (view full) ---

84 dput(file->private_data);
85 return 0;
86}
87EXPORT_SYMBOL(dcache_dir_close);
88
89loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
90{
91 struct dentry *dentry = file->f_path.dentry;
1/*
2 * fs/libfs.c
3 * Library for filesystems writers.
4 */
5
6#include <linux/blkdev.h>
7#include <linux/export.h>
8#include <linux/pagemap.h>

--- 75 unchanged lines hidden (view full) ---

84 dput(file->private_data);
85 return 0;
86}
87EXPORT_SYMBOL(dcache_dir_close);
88
89loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
90{
91 struct dentry *dentry = file->f_path.dentry;
92 inode_lock(d_inode(dentry));
93 switch (whence) {
94 case 1:
95 offset += file->f_pos;
96 case 0:
97 if (offset >= 0)
98 break;
99 default:
92 switch (whence) {
93 case 1:
94 offset += file->f_pos;
95 case 0:
96 if (offset >= 0)
97 break;
98 default:
100 inode_unlock(d_inode(dentry));
101 return -EINVAL;
102 }
103 if (offset != file->f_pos) {
104 file->f_pos = offset;
105 if (file->f_pos >= 2) {
106 struct list_head *p;
107 struct dentry *cursor = file->private_data;
108 loff_t n = file->f_pos - 2;

--- 10 unchanged lines hidden (view full) ---

119 n--;
120 spin_unlock(&next->d_lock);
121 p = p->next;
122 }
123 list_add_tail(&cursor->d_child, p);
124 spin_unlock(&dentry->d_lock);
125 }
126 }
99 return -EINVAL;
100 }
101 if (offset != file->f_pos) {
102 file->f_pos = offset;
103 if (file->f_pos >= 2) {
104 struct list_head *p;
105 struct dentry *cursor = file->private_data;
106 loff_t n = file->f_pos - 2;

--- 10 unchanged lines hidden (view full) ---

117 n--;
118 spin_unlock(&next->d_lock);
119 p = p->next;
120 }
121 list_add_tail(&cursor->d_child, p);
122 spin_unlock(&dentry->d_lock);
123 }
124 }
127 inode_unlock(d_inode(dentry));
128 return offset;
129}
130EXPORT_SYMBOL(dcache_dir_lseek);
131
132/* Relationship between i_mode and the DT_xxx types */
133static inline unsigned char dt_type(struct inode *inode)
134{
135 return (inode->i_mode >> 12) & 15;

--- 49 unchanged lines hidden (view full) ---

185}
186EXPORT_SYMBOL(generic_read_dir);
187
188const struct file_operations simple_dir_operations = {
189 .open = dcache_dir_open,
190 .release = dcache_dir_close,
191 .llseek = dcache_dir_lseek,
192 .read = generic_read_dir,
125 return offset;
126}
127EXPORT_SYMBOL(dcache_dir_lseek);
128
129/* Relationship between i_mode and the DT_xxx types */
130static inline unsigned char dt_type(struct inode *inode)
131{
132 return (inode->i_mode >> 12) & 15;

--- 49 unchanged lines hidden (view full) ---

182}
183EXPORT_SYMBOL(generic_read_dir);
184
185const struct file_operations simple_dir_operations = {
186 .open = dcache_dir_open,
187 .release = dcache_dir_close,
188 .llseek = dcache_dir_lseek,
189 .read = generic_read_dir,
193 .iterate = dcache_readdir,
190 .iterate_shared = dcache_readdir,
194 .fsync = noop_fsync,
195};
196EXPORT_SYMBOL(simple_dir_operations);
197
198const struct inode_operations simple_dir_inode_operations = {
199 .lookup = simple_lookup,
200};
201EXPORT_SYMBOL(simple_dir_inode_operations);

--- 914 unchanged lines hidden (view full) ---

1116 return 0;
1117}
1118
1119static int empty_dir_setattr(struct dentry *dentry, struct iattr *attr)
1120{
1121 return -EPERM;
1122}
1123
191 .fsync = noop_fsync,
192};
193EXPORT_SYMBOL(simple_dir_operations);
194
195const struct inode_operations simple_dir_inode_operations = {
196 .lookup = simple_lookup,
197};
198EXPORT_SYMBOL(simple_dir_inode_operations);

--- 914 unchanged lines hidden (view full) ---

1113 return 0;
1114}
1115
1116static int empty_dir_setattr(struct dentry *dentry, struct iattr *attr)
1117{
1118 return -EPERM;
1119}
1120
1124static int empty_dir_setxattr(struct dentry *dentry, const char *name,
1125 const void *value, size_t size, int flags)
1121static int empty_dir_setxattr(struct dentry *dentry, struct inode *inode,
1122 const char *name, const void *value,
1123 size_t size, int flags)
1126{
1127 return -EOPNOTSUPP;
1128}
1129
1124{
1125 return -EOPNOTSUPP;
1126}
1127
1130static ssize_t empty_dir_getxattr(struct dentry *dentry, const char *name,
1131 void *value, size_t size)
1128static ssize_t empty_dir_getxattr(struct dentry *dentry, struct inode *inode,
1129 const char *name, void *value, size_t size)
1132{
1133 return -EOPNOTSUPP;
1134}
1135
1136static int empty_dir_removexattr(struct dentry *dentry, const char *name)
1137{
1138 return -EOPNOTSUPP;
1139}

--- 24 unchanged lines hidden (view full) ---

1164{
1165 dir_emit_dots(file, ctx);
1166 return 0;
1167}
1168
1169static const struct file_operations empty_dir_operations = {
1170 .llseek = empty_dir_llseek,
1171 .read = generic_read_dir,
1130{
1131 return -EOPNOTSUPP;
1132}
1133
1134static int empty_dir_removexattr(struct dentry *dentry, const char *name)
1135{
1136 return -EOPNOTSUPP;
1137}

--- 24 unchanged lines hidden (view full) ---

1162{
1163 dir_emit_dots(file, ctx);
1164 return 0;
1165}
1166
1167static const struct file_operations empty_dir_operations = {
1168 .llseek = empty_dir_llseek,
1169 .read = generic_read_dir,
1172 .iterate = empty_dir_readdir,
1170 .iterate_shared = empty_dir_readdir,
1173 .fsync = noop_fsync,
1174};
1175
1176
1177void make_empty_dir_inode(struct inode *inode)
1178{
1179 set_nlink(inode, 2);
1180 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;

--- 16 unchanged lines hidden ---
1171 .fsync = noop_fsync,
1172};
1173
1174
1175void make_empty_dir_inode(struct inode *inode)
1176{
1177 set_nlink(inode, 2);
1178 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;

--- 16 unchanged lines hidden ---