Applied Andrew Morton's patch to support the dirsync option.
diff --git a/misc/ChangeLog b/misc/ChangeLog
index 0a972d0..e2dc6ad 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,7 @@
+2002-06-15 Theodore Ts'o <tytso@mit.edu>
+
+ * chattr.c: Applied patch from Andrew to support the dirsync flag.
+
2002-05-22 Andreas Dilger <adilger@clusterfs.com>
* mke2fs.c (set_fs_defaults): make the default inode ratio at most
diff --git a/misc/chattr.1.in b/misc/chattr.1.in
index 82f054b..be64575 100644
--- a/misc/chattr.1.in
+++ b/misc/chattr.1.in
@@ -19,16 +19,16 @@
.B chattr
changes the file attributes on a Linux second extended file system.
.PP
-The format of a symbolic mode is +-=[ASacdistu].
+The format of a symbolic mode is +-=[ASacDdistu].
.PP
The operator `+' causes the selected attributes to be added to the
existing attributes of the files; `-' causes them to be removed; and
`=' causes them to be the only attributes that the files have.
.PP
-The letters `ASacdijsu' select the new attributes for the files:
-don't update atime (A), synchronous updates (S), append only (a),
-compressed (c), no dump (d), immutable (i), data journalling (j),
-secure deletion (s), and undeletable (u).
+The letters `ASacDdijsu' select the new attributes for the files:
+don't update atime (A), synchronous updates (S), synchronous directory
+updates (D), append only (a), compressed (c), no dump (d), immutable (i),
+data journalling (j), secure deletion (s), and undeletable (u).
.SH OPTIONS
.TP
.B \-R
@@ -74,6 +74,10 @@
the changes are written synchronously on the disk; this is equivalent to
the `sync' mount option applied to a subset of the files.
.PP
+When a directory with the `D' attribute set is modified,
+the changes are written synchronously on the disk; this is equivalent to
+the `dirsync' mount option applied to a subset of the files.
+.PP
A file with the 't' attribute will not have a partial block fragment at
the of the file merged with other files (for those filesystems which
support tail-merging). This is necessary for applications such as LILO
@@ -92,6 +96,8 @@
in a future ext2 fs version.
.PP
The `j' option is only useful if the filesystem is mounted as ext3.
+.PP
+The `D' option is only useful on Linux kernel 2.5.19 and later.
.SH AVAILABILITY
.B chattr
is part of the e2fsprogs package and is available from
diff --git a/misc/chattr.c b/misc/chattr.c
index 96977e9..467e6ba 100644
--- a/misc/chattr.c
+++ b/misc/chattr.c
@@ -78,7 +78,7 @@
exit (errcode);
}
-#define usage() fatal_error(_("usage: %s [-RV] [-+=AacdijsSu] [-v version] files...\n"), \
+#define usage() fatal_error(_("usage: %s [-RV] [-+=AacDdijsSu] [-v version] files...\n"), \
1)
struct flags_char {
@@ -89,6 +89,7 @@
static const struct flags_char flags_array[] = {
{ EXT2_NOATIME_FL, 'A' },
{ EXT2_SYNC_FL, 'S' },
+ { EXT2_DIRSYNC_FL, 'D' },
{ EXT2_APPEND_FL, 'a' },
{ EXT2_COMPR_FL, 'c' },
{ EXT2_NODUMP_FL, 'd' },
@@ -218,6 +219,8 @@
print_flags (stdout, flags, 0);
printf ("\n");
}
+ if (!S_ISDIR(st.st_mode))
+ flags &= ~EXT2_DIRSYNC_FL;
if (fsetflags (name, flags) == -1)
com_err (program_name, errno,
_("while setting flags on %s"), name);