History

fsnotify(): switch to passing const struct qstr * for file_name

Note that in fnsotify_move() and fsnotify_link() we are guaranteed that dentry->d_name won't change during the fsnotify() evaluation (by having the parent directory locked exclusive), so we don't need to fetch dentry->d_name.name in the callers. In fsnotify_dirent() the same stability of dentry->d_name is also true, but it's a bit more convoluted - there is one callchain (devpts_pty_new() -> fsnotify_create() -> fsnotify_dirent()) where the parent is _not_ locked, but on devpts ->d_name of everything is unchanging; it has neither explicit nor implicit renames.

Al Viro committed 7 years ago

Commit 25b229d1 parent f4ec3a34 files · +15 −13Browse files

Showing the changes to include/linux (2 of 4 files). Show all

Unified · Split

2 files
  1. include/linux/fsnotify.h +5 −5
  2. include/linux/fsnotify_backend.h +2 −2
include/linux/fsnotify.h+5−5
@@ -27,7 +27,7 @@ static inline int fsnotify_dirent(struct inode *dir, struct dentry *dentry, · 26 unmodified lines
2727 __u32 mask)
2828 {
2929 return fsnotify(dir, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
30− dentry->d_name.name, 0);
30+ &dentry->d_name, 0);
3131 }
3232
3333 /* Notify this dentry's parent about a child's events. */
@@ -111,7 +111,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, · 77 unmodified lines
111111 __u32 old_dir_mask = FS_MOVED_FROM;
112112 __u32 new_dir_mask = FS_MOVED_TO;
113113 __u32 mask = FS_MOVE_SELF;
114− const unsigned char *new_name = moved->d_name.name;
114+ const struct qstr *new_name = &moved->d_name;
115115
116116 if (old_dir == new_dir)
117117 old_dir_mask |= FS_DN_RENAME;
@@ -122,7 +122,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, · 4 unmodified lines
122122 mask |= FS_ISDIR;
123123 }
124124
125− fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name->name,
125+ fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name,
126126 fs_cookie);
127127 fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name,
128128 fs_cookie);
@@ -178,7 +178,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir) · 49 unmodified lines
178178 take_dentry_name_snapshot(&name, dentry);
179179
180180 fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
181− name.name.name, 0);
181+ &name.name, 0);
182182
183183 release_dentry_name_snapshot(&name);
184184 dput(parent);
@@ -218,7 +218,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct · 33 unmodified lines
218218 fsnotify_link_count(inode);
219219 audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE);
220220
221− fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0);
221+ fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, &new_dentry->d_name, 0);
222222 }
223223
224224 /*
include/linux/fsnotify_backend.h+2−2
@@ -350,7 +350,7 @@ struct fsnotify_mark { · 349 unmodified lines
350350
351351 /* main fsnotify call to send events */
352352 extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
353− const unsigned char *name, u32 cookie);
353+ const struct qstr *name, u32 cookie);
354354 extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask);
355355 extern void __fsnotify_inode_delete(struct inode *inode);
356356 extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
@@ -505,7 +505,7 @@ static inline void fsnotify_init_event(struct fsnotify_event *event, · 148 unmodified lines
505505 #else
506506
507507 static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
508− const unsigned char *name, u32 cookie)
508+ const struct qstr *name, u32 cookie)
509509 {
510510 return 0;
511511 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t