.B chattr
changes the file attributes on a Linux second extended file system.
.PP
-The format of a symbolic mode is +-=[ASacDdIijsTtu].
+The format of a symbolic mode is +-=[ASacDdeIijsTtu].
.PP
The operator `+' causes the selected attributes to be added to the
existing attributes of the files; `-' causes them to be removed; and
.BR lsattr (1).
.PP
The 'e' attribute indicates that the file is using extents for mapping
-the blocks on disk. It may not be set or reset using
-.BR chattr (1),
-although it can be displayed by
-.BR lsattr (1).
+the blocks on disk. It may not be removed using
+.BR chattr (1).
.PP
The 'I' attribute is used by the htree code to indicate that a directory
is being indexed using hashed trees. It may not be set or reset using
static void usage(void)
{
fprintf(stderr,
- _("Usage: %s [-RVf] [-+=AacDdijsSu] [-v version] files...\n"),
+ _("Usage: %s [-RVf] [-+=AacDdeijsSu] [-v version] files...\n"),
program_name);
exit(1);
}
{ EXT2_APPEND_FL, 'a' },
{ EXT2_COMPR_FL, 'c' },
{ EXT2_NODUMP_FL, 'd' },
+ { EXT4_EXTENTS_FL, 'e'},
{ EXT2_IMMUTABLE_FL, 'i' },
{ EXT3_JOURNAL_DATA_FL, 'j' },
{ EXT2_SECRM_FL, 's' },
{
unsigned long flags;
STRUCT_STAT st;
+ int extent_file = 0;
if (LSTAT (name, &st) == -1) {
if (!silent)
return -1;
}
+ if (fgetflags(name, &flags) == -1) {
+ if (!silent)
+ com_err(program_name, errno,
+ _("while reading flags on %s"), name);
+ return -1;
+ }
+ if (flags & EXT4_EXTENTS_FL)
+ extent_file = 1;
if (set) {
+ if (extent_file && !(sf & EXT4_EXTENTS_FL)) {
+ if (!silent)
+ com_err(program_name, 0,
+ _("Clearing extent flag not supported on %s"),
+ name);
+ return -1;
+ }
if (verbose) {
printf (_("Flags of %s set as "), name);
print_flags (stdout, sf, 0);
if (fsetflags (name, sf) == -1)
perror (name);
} else {
- if (fgetflags (name, &flags) == -1) {
+ if (rem)
+ flags &= ~rf;
+ if (add)
+ flags |= af;
+ if (extent_file && !(flags & EXT4_EXTENTS_FL)) {
if (!silent)
- com_err (program_name, errno,
- _("while reading flags on %s"), name);
+ com_err(program_name, 0,
+ _("Clearing extent flag not supported on %s"),
+ name);
return -1;
- } else {
- if (rem)
- flags &= ~rf;
- if (add)
- flags |= af;
- if (verbose) {
- printf (_("Flags of %s set as "), name);
- print_flags (stdout, flags, 0);
- printf ("\n");
- }
- if (!S_ISDIR(st.st_mode))
- flags &= ~EXT2_DIRSYNC_FL;
- if (fsetflags (name, flags) == -1) {
- if (!silent)
- com_err(program_name, errno,
+ }
+ if (verbose) {
+ printf(_("Flags of %s set as "), name);
+ print_flags(stdout, flags, 0);
+ printf("\n");
+ }
+ if (!S_ISDIR(st.st_mode))
+ flags &= ~EXT2_DIRSYNC_FL;
+ if (fsetflags(name, flags) == -1) {
+ if (!silent) {
+ com_err(program_name, errno,
_("while setting flags on %s"),
name);
- return -1;
}
+ return -1;
}
}
if (set_version) {