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

Next file: linux/include/asm-alpha/byteorder.h
Previous file: linux/fs/vfat/namei.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.0/linux/fs/xiafs/namei.c linux/fs/xiafs/namei.c
@@ -713,7 +713,8 @@
  */
 static int do_xiafs_rename(struct inode * old_dir, const char * old_name, 
 			 int old_len, struct inode * new_dir, 
-			 const char * new_name, int new_len)
+			 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;
@@ -730,6 +731,8 @@
     old_inode = __iget(old_dir->i_sb, old_de->d_ino, 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 &&
@@ -832,7 +835,8 @@
  * as they are on different partitions.
  */
 int xiafs_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;
@@ -842,7 +846,8 @@
         sleep_on(&wait);
     lock = 1;
     result = do_xiafs_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