patch-2.0.1 linux/fs/minix/namei.c

Next file: linux/fs/msdos/namei.c
Previous file: linux/fs/locks.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.0/linux/fs/minix/namei.c linux/fs/minix/namei.c
@@ -672,7 +672,7 @@
  * higher-level routines.
  */
 static int do_minix_rename(struct inode * old_dir, const char * old_name, int old_len,
-	struct inode * new_dir, const char * new_name, int new_len)
+	struct inode * new_dir, const char * new_name, int new_len, int must_be_dir)
 {
 	struct inode * old_inode, * new_inode;
 	struct buffer_head * old_bh, * new_bh, * dir_bh;
@@ -700,6 +700,8 @@
 	old_inode = __iget(old_dir->i_sb, old_de->inode,0); /* don't cross mnt-points */
 	if (!old_inode)
 		goto end_rename;
+	if (must_be_dir && !S_ISDIR(old_inode->i_mode))
+		goto end_rename;
 	retval = -EPERM;
 	if ((old_dir->i_mode & S_ISVTX) && 
 	    current->fsuid != old_inode->i_uid &&
@@ -816,7 +818,8 @@
  * as they are on different partitions.
  */
 int minix_rename(struct inode * old_dir, const char * old_name, int old_len,
-	struct inode * new_dir, const char * new_name, int new_len)
+	struct inode * new_dir, const char * new_name, int new_len,
+	int must_be_dir)
 {
 	static struct wait_queue * wait = NULL;
 	static int lock = 0;
@@ -826,7 +829,7 @@
 		sleep_on(&wait);
 	lock = 1;
 	result = do_minix_rename(old_dir, old_name, old_len,
-		new_dir, new_name, new_len);
+		new_dir, new_name, new_len, must_be_dir);
 	lock = 0;
 	wake_up(&wait);
 	return result;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov