debugfs.c (do_write): Check to see if the filename exists before
creating it, and give an error if so. Addresses
Sourceforge bug #478195.
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index e2f59c5..2294104 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -1097,6 +1097,13 @@
return;
}
+ retval = ext2fs_namei(current_fs, root, cwd, argv[2], &newfile);
+ if (retval == 0) {
+ com_err(argv[0], 0, "The file '%s' already exists\n", argv[2]);
+ close(fd);
+ return;
+ }
+
retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
if (retval) {
com_err(argv[0], retval, "");