lkml.org 
[lkml]   [1996]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Drawbacks of implementing undelete entirely in user space

<snip>
> them. I think I've got things right. Anybody care to comment?

Looks good to me, and works fine, well done.

I've modified it a bit so that instead of calling fsuser() it checks to
see if the ext2 undeletable flag is set on the file. It then moves the
file to .wastebasket and removes the flag so that some user process can
then delete it to free up space. Since the u flag is inherited from the
parent directory setting it on user dirs and important system dirs is easy
without having a hole partition setup for it, so that tmp files created by
compilers et al don't get stuffed in .wastebasket

I've also polished of the patch by adding a config option and help text.

Maybe something better should be done about files in .wastebasket with
duplicate names, I've left your solution of adding a version no.

It also might be worth adding a mount option for setting the name of the
undel dir, at the moment I've stuck it in a #define in <linux/ext2_fs.h>


- --- PatchAfter here ---------------------------------------------------

diff -cdHwPrX /tmp/nopatch linux/Documentation/Configure.help linux-undelete/Documentation/Configure.help
*** linux/Documentation/Configure.help Fri Jun 7 14:28:46 1996
--- linux-undelete/Documentation/Configure.help Sun Jun 23 22:18:27 1996
***************
*** 2720,2725 ****
--- 2720,2735 ----
sunsite.unc.edu:/pub/Linux/docs/faqs. This option will enlarge your
kernel by about 41 kB. Default is Y.

+ Undelete for second extended fs
+ CONFIG_EXT2_UNDELETE
+ Files marked with the ext2 attribute 'u' for undeletable will be moved
+ to a .wastebasket directory at the top of the fs, similar to lost+found.
+ If no .wastebasket directory exists then undeletion is not active on that
+ partition.
+ At present if a file in the .wastebasket directory already exists then _1
+ is appened to the next file of that name and so on.
+
+
xiafs filesystem support
CONFIG_XIA_FS
This is an old filesystem (= method to organize files on a harddisk
diff -cdHwPrX /tmp/nopatch linux/fs/Config.in linux-undelete/fs/Config.in
*** linux/fs/Config.in Wed Jun 5 11:24:45 1996
--- linux-undelete/fs/Config.in Sun Jun 23 22:21:10 1996
***************
*** 9,14 ****
--- 9,17 ----
tristate 'Minix fs support' CONFIG_MINIX_FS
tristate 'Extended fs support' CONFIG_EXT_FS
tristate 'Second extended fs support' CONFIG_EXT2_FS
+ if [ "$CONFIG_EXT2_FS" != "n" -a "$CONFIG_EXPERIMENTAL" = "y" ]; then
+ bool 'Undelete for Second extended fs (EXPERIMENTAL)' CONFIG_EXT2_UNDELETE
+ fi
tristate 'xiafs filesystem support' CONFIG_XIA_FS

# msdos filesystems
diff -cdHwPrX /tmp/nopatch linux/fs/ext2/namei.c linux-undelete/fs/ext2/namei.c
*** linux/fs/ext2/namei.c Mon Dec 11 04:56:35 1995
--- linux-undelete/fs/ext2/namei.c Mon Jun 24 00:17:56 1996
***************
*** 728,733 ****
--- 728,784 ----
inode->i_ino, inode->i_nlink);
inode->i_nlink = 1;
}
+ #ifdef CONFIG_EXT2_UNDELETE
+ if (inode->u.ext2_i.i_flags & EXT2_UNRM_FL) {/* Only move if attr set */
+ if (inode->i_sb) {
+ struct inode *wb,*tmp;
+ const char *new_name;
+ char buf[EXT2_NAME_LEN];
+ int new_len;
+ int version;
+
+ inode->i_sb->s_mounted->i_count++;
+ if (ext2_lookup (inode->i_sb->s_mounted,
+ EXT2_UNDEL_DIR_NAME,12,&wb) == 0) {
+ ext2_debug ("inode_c=%d, dir_c=%d,wb_c=%d\n",
+ inode->i_count,dir->i_count,wb->i_count);
+ new_name=name;
+ new_len = len;
+ version = 0;
+ wb->i_count++;
+ while (ext2_lookup (wb,new_name,new_len,&tmp) == 0) {
+ iput (tmp);
+ sprintf (buf,"%s_%d",name,version++);
+ new_name = buf;
+ new_len = strlen (buf);
+ wb->i_count++;
+ }
+
+ printk ("EXT2-fs: moveing %s to wastebasket as %s.\n",
+ name,new_name);
+ while (dir->i_sb->u.ext2_sb.s_rename_lock)
+ sleep_on (&dir->i_sb->u.ext2_sb.s_rename_wait);
+ dir->i_sb->u.ext2_sb.s_rename_lock = 1;
+
+ retval = do_ext2_rename (dir, name, len, wb, new_name, new_len);
+
+ dir->i_sb->u.ext2_sb.s_rename_lock = 0;
+ wake_up (&dir->i_sb->u.ext2_sb.s_rename_wait);
+ ext2_debug("inode_c=%d, dir_c=%d,wb_c=%d\n",
+ inode->i_count,dir->i_count,wb->i_count);
+ brelse (bh);
+ inode->u.ext2_i.i_flags &= ~EXT2_UNRM_FL;
+ iput (inode);
+ return retval;
+ } else {
+ ext2_debug ("No wastebasket. Old unlink for %s....\n",name);
+ }
+ } else {
+ printk ("EXT2-fs Warning: Undelete can't find a superblock for inode %ld\n"
+ "Deleting file normally.\n",inode->i_ino);
+ }
+ }
+ #endif /* CONFIG_EXT2_DELETE */
retval = ext2_delete_entry (de, bh);
if (retval)
goto end_unlink;
diff -cdHwPrX /tmp/nopatch linux/include/linux/ext2_fs.h linux-undelete/include/linux/ext2_fs.h
*** linux/include/linux/ext2_fs.h Fri Jun 7 13:45:21 1996
--- linux-undelete/include/linux/ext2_fs.h Sun Jun 23 22:20:21 1996
***************
*** 61,66 ****
--- 61,68 ----
#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */

+ #define EXT2_UNDEL_DIR_NAME ".wastebasket"
+
/* First non-reserved inode for old ext2 filesystems */
#define EXT2_GOOD_OLD_FIRST_INO 11


--
Darren J Moffat



\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.087 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site