--- linux-2.2.19-rsbac-1.1.1/fs/namei.c.sik	Wed Mar 28 11:48:38 2001
+++ linux-2.2.19-rsbac-1.1.1/fs/namei.c	Tue Jul  3 12:59:54 2001
@@ -1947,7 +1947,9 @@
         #ifdef CONFIG_RSBAC
         enum  rsbac_target_t          rsbac_target;
         union rsbac_target_id_t       rsbac_target_id;
+        union rsbac_target_id_t       rsbac_new_target_id;
         union rsbac_attribute_value_t rsbac_attribute_value;
+        boolean target_exists = FALSE;
         #endif
 
 	old_dentry = lookup_dentry(oldname, NULL, 0);
@@ -2021,6 +2023,34 @@
             dput(new_dentry);
             goto exit_old;
           }
+        if(new_dentry->d_inode)
+          {
+            target_exists = TRUE;
+            if (rsbac_debug_aef)
+              printk(KERN_DEBUG
+                     "do_rename() [sys_rename()]: calling ADF for DELETE on existing target\n");
+            rsbac_target = T_FILE;
+            if (S_ISDIR(new_dentry->d_inode->i_mode))
+              rsbac_target = T_DIR;
+            else if (S_ISFIFO (new_dentry->d_inode->i_mode))
+              rsbac_target = T_FIFO;
+            rsbac_target_id.file.device = new_dentry->d_inode->i_dev;
+            rsbac_target_id.file.inode  = new_dentry->d_inode->i_ino;
+            rsbac_target_id.file.dentry_p = new_dentry;
+            rsbac_attribute_value.nlink = new_dentry->d_inode->i_nlink;
+            if (!rsbac_adf_request(R_DELETE,
+                                   current->pid,
+                                   rsbac_target,
+                                   rsbac_target_id,
+                                   A_nlink,
+                                   rsbac_attribute_value))
+              {
+                error = -EPERM;
+                dput(new_dir);
+                dput(new_dentry);
+                goto exit_old;
+              }
+          }
         #endif /* CONFIG_RSBAC */
 
 	old_dir = get_parent(old_dentry);
@@ -2033,6 +2063,27 @@
 				   new_dir->d_inode, new_dentry);
 
 	double_unlock(new_dir, old_dir);
+
+        /* RSBAC: notify ADF of deleted file */
+        #ifdef CONFIG_RSBAC
+        if (target_exists && !error)
+          {
+            rsbac_new_target_id.dummy = 0;
+            if (rsbac_adf_set_attr(R_DELETE,
+                                   current->pid,
+                                   rsbac_target,
+                                   rsbac_target_id,
+                                   T_NONE,
+                                   rsbac_new_target_id,
+                                   A_nlink,
+                                   rsbac_attribute_value))
+              {
+                printk(KERN_WARNING
+                       "do_rename() [sys_rename()]: rsbac_adf_set_attr() returned error");
+              }
+          }
+        #endif
+
 	dput(new_dentry);
 exit_old:
 	dput(old_dentry);
