Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cp and extended attributes stupidity

538 views
Skip to first unread message

M. Strobel

unread,
Dec 31, 2014, 1:14:51 PM12/31/14
to
By default cp does not copy extended attributes - test with:

$F=yourfile.ext
setfattr -n user.info -v "in principle usable" $F
getfattr -d $F

The man page says use option --preserve ...

Fine.

Now why is this not configured by default?

More important: how could one configure this as default? alias?

/Str.

M. Strobel

unread,
Dec 31, 2014, 1:17:00 PM12/31/14
to
On 31.12.2014 19:14, M. Strobel wrote:
> By default cp does not copy extended attributes - test with:
>
> $F=yourfile.ext
> setfattr -n user.info -v "in principle usable" $F
> getfattr -d $F
>

oh, copy the file and do a getfattr -d on the copy.

William Unruh

unread,
Dec 31, 2014, 3:03:59 PM12/31/14
to
On 2014-12-31, M. Strobel <sorry_no_...@nowhere.dee> wrote:
> By default cp does not copy extended attributes - test with:
>
> $F=yourfile.ext

What shell? Usually it is F=yourfile.ext

> setfattr -n user.info -v "in principle usable" $F

Never hear of setfattr. Have heard of chattr. Also, never heard of
either the name nor the value of that you apply.

What filesystem?


> getfattr -d $F
>
> The man page says use option --preserve ...
>
> Fine.
>
> Now why is this not configured by default?

Why?

>
> More important: how could one configure this as default? alias?

Sure.
Under bash
alias cpa= "/bin/cp -preserve=all"
or even
alias cp="/bin/cp --preserve=all"
but that could be a bit dangerous. You would have to remember to use
/bin/cp if you wanted to not have the --preserve=all argument.



>
> /Str.

Luuk

unread,
Dec 31, 2014, 3:46:55 PM12/31/14
to
On 31-12-2014 21:03, William Unruh wrote:
>
> Never hear of setfattr. Have heard of chattr. Also, never heard of
> either the name nor the value of that you apply.
>

luuk@opensuse:~> setfattr --help
setfattr 2.4.47 -- set extended attributes
Usage: setfattr {-n name} [-v value] [-h] file...
setfattr {-x name} [-h] file...
-n, --name=name set the value of the named extended attribute
-x, --remove=name remove the named extended attribute
-v, --value=value use value as the attribute value
-h, --no-dereference do not dereference symbolic links
--restore=file restore extended attributes
--version print version and exit
--help this help text


(This is on an OpenSUSE 13.1 system.)

Luuk

unread,
Dec 31, 2014, 3:49:18 PM12/31/14
to
On 31-12-2014 21:03, William Unruh wrote:
> On 2014-12-31, M. Strobel <sorry_no_...@nowhere.dee> wrote:
>> By default cp does not copy extended attributes - test with:
>>
>> $F=yourfile.ext
>
> What shell? Usually it is F=yourfile.ext
>
>> setfattr -n user.info -v "in principle usable" $F
>
> Never hear of setfattr. Have heard of chattr. Also, never heard of
> either the name nor the value of that you apply.
>

*man setfattr*
SETFATTR(1) File Utilities
SETFATTR(1)



NAME
setfattr - set extended attributes of filesystem objects

SYNOPSIS
setfattr [-h] -n name [-v value] pathname...
setfattr [-h] -x name pathname...
setfattr [-h] --restore=file

DESCRIPTION
The setfattr command associates a new value with an extended
attribute name for each specified file.

......



*man chattr*
CHATTR(1) General Commands
Manual CHATTR(1)



NAME
chattr - change file attributes on a Linux file system

SYNOPSIS
chattr [ -RVf ] [ -v version ] [ mode ] files...

DESCRIPTION
chattr changes the file attributes on a Linux file system.

The format of a symbolic mode is +-=[acdeijstuACDST].

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.

The letters `acdeijstuACDST' select the new attributes for the
files: append only (a), compressed (c), no dump (d),
extent format (e), immutable (i), data journalling (j),
secure deletion (s), no tail-merging (t), undeletable (u), no
atime updates (A), no copy on write (C), synchronous directory
updates (D), synchronous updates (S), and top of directory
hierarchy (T).

The following attributes are read-only, and may be listed by
lsattr(1) but not modified by chattr: huge file (h), com-
pression error (E), indexed directory (I), compression raw
access (X), and compressed dirty file (Z).

.....

William Unruh

unread,
Dec 31, 2014, 4:24:50 PM12/31/14
to
On 2014-12-31, Luuk <lu...@invalid.lan> wrote:
> On 31-12-2014 21:03, William Unruh wrote:
>> On 2014-12-31, M. Strobel <sorry_no_...@nowhere.dee> wrote:
>>> By default cp does not copy extended attributes - test with:
>>>
>>> $F=yourfile.ext
>>
>> What shell? Usually it is F=yourfile.ext
>>
>>> setfattr -n user.info -v "in principle usable" $F
>>
>> Never hear of setfattr. Have heard of chattr. Also, never heard of
>> either the name nor the value of that you apply.
>>
>
> *man setfattr*
> SETFATTR(1) File Utilities

The setfattr and the chattr are clearly very very different extended
attributes. What is the relation between them, if any? Where are the
extended attributes of setfattr stored?


> SETFATTR(1)

Str

unread,
Jan 3, 2015, 12:32:46 PM1/3/15
to
On 31.12.2014 22:24, William Unruh wrote:
> On 2014-12-31, Luuk <lu...@invalid.lan> wrote:
>> On 31-12-2014 21:03, William Unruh wrote:
>>> On 2014-12-31, M. Strobel <sorry_no_...@nowhere.dee> wrote:
>>>> By default cp does not copy extended attributes - test with:
>>>>
>>>> $F=yourfile.ext
>>>
>>> What shell? Usually it is F=yourfile.ext
default shell, we are on opensuse. Yes, this is a typo
>>>
>>>> setfattr -n user.info -v "in principle usable" $F
>>>
>>> Never hear of setfattr. Have heard of chattr. Also, never heard of
>>> either the name nor the value of that you apply.
>>>
>>
>> *man setfattr*
>> SETFATTR(1) File Utilities
>
> The setfattr and the chattr are clearly very very different extended
> attributes. What is the relation between them, if any? Where are the
> extended attributes of setfattr stored?
>
>
>> SETFATTR(1)
>>
>>
>>
>>
>>
>> *man chattr*
>> CHATTR(1) General Commands

sorry for the delay, my provider shut down his news server.

The data is stored in the file system itself. This is not a new principle, I think
HPFS started it. It associates text with files, so you can tag files in the file itself.

I think this is a largely underestimated and unused feature. Of course unused if not
supported by default.

/Str.

M. Strobel

unread,
Jan 3, 2015, 12:53:50 PM1/3/15
to
Thank you. Now definitely I will have to extend my update scripts to manage aliases
in my servers ...

I thought the specialists find something more basic, working with cp called by other
programs.

There does not seem to be an environment var doing this for cp.

/Str.

M. Strobel

unread,
Jan 3, 2015, 12:56:09 PM1/3/15
to
Thank you luuk. I thought my example would get them going ;-)

/Str
0 new messages