2001-11-05 Theodore Tso <tytso@valinux.com>
+ * mkjournal.c (ext2fs_add_journal_inode): When creating a .journal
+ file on adding a journal to an already-mounted filesystem,
+ try to clear the ext2 file attributes on an already
+ existing .journal file so that we don't fail if on a
+ partially added journal to the filesystem.
+
* ext2_fs.h: Define a new ext2 file attribute, EXT2_NOTAIL_FL,
which signals that a particular inode should not have the
last bits of data (the "tail") be merged with another
if (mount_flags & EXT2_MF_MOUNTED) {
strcat(jfile, "/.journal");
+ /*
+ * If .../.journal already exists, make sure any
+ * immutable or append-only flags are cleared.
+ */
+#if defined(HAVE_CHFLAGS) && defined(UF_NODUMP)
+ (void) chflags (jfile, 0);
+#else
+#if HAVE_EXT2_IOCTLS
+ fd = open(jfile, O_RDONLY);
+ if (fd >= 0) {
+ f = 0;
+ ioctl(fd, EXT2_IOC_SETFLAGS, &f);
+ close(fd);
+ }
+#endif
+#endif
+
/* Create the journal file */
if ((fd = open(jfile, O_CREAT|O_WRONLY, 0600)) < 0)
return errno;
retval = fchflags (fd, UF_NODUMP|UF_IMMUTABLE);
#else
#if HAVE_EXT2_IOCTLS
- f = EXT2_NODUMP_FL | EXT2_IMMUTABLE_FL;;
+ f = EXT2_NODUMP_FL | EXT2_IMMUTABLE_FL;
retval = ioctl(fd, EXT2_IOC_SETFLAGS, &f);
#endif
#endif