From f03b8ad8d38634d13e802165cc15917481b47835 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Sep 2016 11:03:57 +0200 Subject: fs: support RENAME_NOREPLACE for local filesystems This is trivial to do: - add flags argument to foo_rename() - check if flags doesn't have any other than RENAME_NOREPLACE - assign foo_rename() to .rename2 instead of .rename Filesystems converted: affs, bfs, exofs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos, nilfs2, omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat. Signed-off-by: Miklos Szeredi Acked-by: Boaz Harrosh Acked-by: Richard Weinberger Acked-by: Bob Copeland Acked-by: Jan Kara Cc: Theodore Ts'o Cc: Jaegeuk Kim Cc: OGAWA Hirofumi Cc: Mikulas Patocka Cc: David Woodhouse Cc: Dave Kleikamp Cc: Ryusuke Konishi Cc: Christoph Hellwig --- fs/hfsplus/dir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fs/hfsplus/dir.c') diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 42e128661dc1..ca64a75f12b3 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -530,10 +530,14 @@ static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) } static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir, struct dentry *new_dentry) + struct inode *new_dir, struct dentry *new_dentry, + unsigned int flags) { int res; + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; + /* Unlink destination if it already exists */ if (d_really_is_positive(new_dentry)) { if (d_is_dir(new_dentry)) @@ -561,7 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = { .rmdir = hfsplus_rmdir, .symlink = hfsplus_symlink, .mknod = hfsplus_mknod, - .rename = hfsplus_rename, + .rename2 = hfsplus_rename, .setxattr = generic_setxattr, .getxattr = generic_getxattr, .listxattr = hfsplus_listxattr, -- cgit From 2773bf00aeb9bf39e022463272a61dd0ec9f55f4 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 27 Sep 2016 11:03:58 +0200 Subject: fs: rename "rename2" i_op to "rename" Generated patch: sed -i "s/\.rename2\t/\.rename\t\t/" `git grep -wl rename2` sed -i "s/\brename2\b/rename/g" `git grep -wl rename2` Signed-off-by: Miklos Szeredi --- fs/hfsplus/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/hfsplus/dir.c') diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index ca64a75f12b3..063577958126 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -565,7 +565,7 @@ const struct inode_operations hfsplus_dir_inode_operations = { .rmdir = hfsplus_rmdir, .symlink = hfsplus_symlink, .mknod = hfsplus_mknod, - .rename2 = hfsplus_rename, + .rename = hfsplus_rename, .setxattr = generic_setxattr, .getxattr = generic_getxattr, .listxattr = hfsplus_listxattr, -- cgit From 02027d42c3f747945f19111d3da2092ed2148ac8 Mon Sep 17 00:00:00 2001 From: Deepa Dinamani Date: Wed, 14 Sep 2016 07:48:05 -0700 Subject: fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps CURRENT_TIME_SEC is not y2038 safe. current_time() will be transitioned to use 64 bit time along with vfs in a separate patch. There is no plan to transistion CURRENT_TIME_SEC to use y2038 safe time interfaces. current_time() will also be extended to use superblock range checking parameters when range checking is introduced. This works because alloc_super() fills in the the s_time_gran in super block to NSEC_PER_SEC. Signed-off-by: Deepa Dinamani Acked-by: Jan Kara Signed-off-by: Al Viro --- fs/hfsplus/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/hfsplus/dir.c') diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 42e128661dc1..69c66c21113b 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -347,7 +347,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir, inc_nlink(inode); hfsplus_instantiate(dst_dentry, inode, cnid); ihold(inode); - inode->i_ctime = CURRENT_TIME_SEC; + inode->i_ctime = current_time(inode); mark_inode_dirty(inode); sbi->file_count++; hfsplus_mark_mdb_dirty(dst_dir->i_sb); @@ -406,7 +406,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry) hfsplus_delete_inode(inode); } else sbi->file_count--; - inode->i_ctime = CURRENT_TIME_SEC; + inode->i_ctime = current_time(inode); mark_inode_dirty(inode); out: mutex_unlock(&sbi->vh_mutex); @@ -427,7 +427,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry) if (res) goto out; clear_nlink(inode); - inode->i_ctime = CURRENT_TIME_SEC; + inode->i_ctime = current_time(inode); hfsplus_delete_inode(inode); mark_inode_dirty(inode); out: -- cgit