@@ -594,6 +594,26 @@ int simple_write_end(struct file *file, struct address_space *mapping,
}
EXPORT_SYMBOL(simple_write_end);
+/**
+ * new_inode_current_time - create new inode by initializing the
+ * time to the current time and the inode to get_next_ino()
+ * @sb: pointer to super block of the file system
+ *
+ * Returns an inode pointer on success, NULL on failure.
+ */
+struct inode *new_inode_current_time(struct super_block *sb)
+{
+ struct inode *inode = new_inode(sb);
+
+ if (inode) {
+ inode->i_ino = get_next_ino();
+ inode->i_atime = inode->i_mtime =
+ inode->i_ctime = current_time(inode);
+ }
+ return inode;
+}
+EXPORT_SYMBOL(new_inode_current_time);
+
/*
* the inodes created here are not hashed. If you use iunique to generate
* unique inode values later for this filesystem, then you must take care
@@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *);
extern void __destroy_inode(struct inode *);
extern struct inode *new_inode_pseudo(struct super_block *sb);
extern struct inode *new_inode(struct super_block *sb);
+extern struct inode *new_inode_current_time(struct super_block *sb);
extern void free_inode_nonrcu(struct inode *inode);
extern int should_remove_suid(struct dentry *);
extern int file_remove_privs(struct file *);
It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> --- fs/libfs.c | 20 ++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 21 insertions(+)