Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

View: New views
17 Messages — Rating Filter:   Alert me  

Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by aputerguy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For backup, I am trying to dump a list of the acl's for the files being backed up since my backup program doesn't handle the acls.

When I use something like:
   find /c -exec getfacl {} \; > mysavefile

It is slow, in part at least because it has to fork a call to getfacl on each file found.
Is there a faster way to do this (hopefully without having to go write C-code)?

Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Larry Hall (Cygwin) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/05/2009 05:00 PM, aputerguy wrote:

>
> For backup, I am trying to dump a list of the acl's for the files being
> backed up since my backup program doesn't handle the acls.
>
> When I use something like:
>     find /c -exec getfacl {} \;>  mysavefile
>
> It is slow, in part at least because it has to fork a call to getfacl on
> each file found.
> Is there a faster way to do this (hopefully without having to go write
> C-code)?

find /c -exec getfacl {} \+>  mysavefile

?

--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Dave Korn-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

aputerguy wrote:
> For backup, I am trying to dump a list of the acl's for the files being
> backed up since my backup program doesn't handle the acls.
>
> When I use something like:
>    find /c -exec getfacl {} \; > mysavefile
>
> It is slow, in part at least because it has to fork a call to getfacl on
> each file found.

  Don't use -exec; use -print0 and pipe the output to "xargs -0 getfacl".

    cheers,
      DaveK

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Andrew Schulman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> For backup, I am trying to dump a list of the acl's for the files being
> backed up since my backup program doesn't handle the acls.
>
> When I use something like:
>    find /c -exec getfacl {} \; > mysavefile
>
> It is slow, in part at least because it has to fork a call to getfacl on
> each file found.
> Is there a faster way to do this (hopefully without having to go write
> C-code)?

getfacl -R?


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Dave Korn-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew Schulman wrote:

>> For backup, I am trying to dump a list of the acl's for the files being
>> backed up since my backup program doesn't handle the acls.
>>
>> When I use something like:
>>    find /c -exec getfacl {} \; > mysavefile
>>
>> It is slow, in part at least because it has to fork a call to getfacl on
>> each file found.
>> Is there a faster way to do this (hopefully without having to go write
>> C-code)?
>
> getfacl -R?

  I think you're guessing.  There's no -R option in the "getfacl --help"
output and it got rejected when I tried it just in case.

    cheers,
      DaveK


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by aputerguy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Andrew Schulman-3 wrote:
> getfacl -R?

Unfortunately, no '-R' at least on my updated version.

The "-exec ... \+" and the "-print0 | xargs -0" tricks both worked!!! Thanks.

Timing and comparing the two approaches, it seems like they both use the same 'user' time but the xargs approach uses only about half the 'system' time.

Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by aputerguy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK... one small problem.
Every ~4500 lines and (70-80K characters), both of these methods omit the empty line between the getfacl stanzas. The skipped lines however don't occur at the same places in the two different methods.

I assume it must be due to buffering of the long line input or something, but I would like to correct for it.
Preferably correct it before it occurs rather than having to use some sed or perl magic to clean up the file afterward.

Any suggestions?

Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Larry Hall (Cygwin) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 11/05/2009 11:05 PM, aputerguy wrote:

>
> OK... one small problem.
> Every ~4500 lines and (70-80K characters), both of these methods omit the
> empty line between the getfacl stanzas. The skipped lines however don't
> occur at the same places in the two different methods.
>
> I assume it must be due to buffering of the long line input or something,
> but I would like to correct for it.
> Preferably correct it before it occurs rather than having to use some sed or
> perl magic to clean up the file afterward.
>
> Any suggestions?

$ getfacl ~/.vim/colors/mine.vim; getfacl ~/.bash_history; getfacl.exe /tmp/tt
# file: /home/lhall/.vim/colors/mine.vim
# owner: lhall
# group: None
user::rwx
group::---
mask:rwx
other:---
# file: /home/lhall/.bash_history
# owner: lhall
# group: None
user::rw-
group::---
mask:rwx
other:---
# file: /tmp/tt
# owner: lhall
# group: None
user::rw-
group::r--
mask:rwx
other:r--

What "empty line between the getfacls stanzas"?

--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Eric Blake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Larry Hall (Cygwin) on 11/5/2009 9:13 PM:
> What "empty line between the getfacls stanzas"?

The blank line that is output after one getfacl process ends.  Try
'getfacl . .; getfacl .' vs. 'getfacl .; getfacl . .' to see it.

The number of command line arguments pieced together without exceeding
exec() limits is dependent on the sum of the command line length and the
size of the current environment; but since the 'find -exec {} +' and 'find
- -print0 | xargs -0' approaches see a slightly different environment
variables (in particular, $_ will be a different length between the two
invocations), the wraparound point for creating new processes differs.

But if you WANT to guarantee a newline between processes, just ask for it.
 Here's one way:

find -print0 | xargs -0 sh -c 'getfacl "$@"; echo' sh

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@...
volunteer cygwin findutils maintainer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrzsOYACgkQ84KuGfSFAYBtygCfdRcDiCdFIruAygjweoT6OOM0
c08An1Vi3xPHMP9Y6ID+0O7WITkmPn7H
=5Svy
-----END PGP SIGNATURE-----

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Andrew Schulman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Andrew Schulman wrote:
> >> For backup, I am trying to dump a list of the acl's for the files being
> >> backed up since my backup program doesn't handle the acls.
> >>
> >> When I use something like:
> >>    find /c -exec getfacl {} \; > mysavefile
> >>
> >> It is slow, in part at least because it has to fork a call to getfacl on
> >> each file found.
> >> Is there a faster way to do this (hopefully without having to go write
> >> C-code)?
> >
> > getfacl -R?
>
>   I think you're guessing.  There's no -R option in the "getfacl --help"
> output and it got rejected when I tried it just in case.

Well, only partly.  I was looking at getfacl on my Debian box at home, and it
does have an -R option for recursive retrieval.  Strange that Cygwin doesn't
have it.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Corinna Vinschen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov  6 01:58, Andrew Schulman wrote:

> > Andrew Schulman wrote:
> > >> For backup, I am trying to dump a list of the acl's for the files being
> > >> backed up since my backup program doesn't handle the acls.
> > >>
> > >> When I use something like:
> > >>    find /c -exec getfacl {} \; > mysavefile
> > >>
> > >> It is slow, in part at least because it has to fork a call to getfacl on
> > >> each file found.
> > >> Is there a faster way to do this (hopefully without having to go write
> > >> C-code)?
> > >
> > > getfacl -R?
> >
> >   I think you're guessing.  There's no -R option in the "getfacl --help"
> > output and it got rejected when I tried it just in case.
>
> Well, only partly.  I was looking at getfacl on my Debian box at home, and it
> does have an -R option for recursive retrieval.  Strange that Cygwin doesn't
> have it.

Cygwin provides the Solaris ACL API, not the POSIX ACL API, and the
getfacl/setfacl tools are designed after their Solaris counterparts
which don't have the -R option.

Anyway, if somebody feels inclined to add the -R option, I'll not
refuse it again.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by aputerguy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Corinna Vinschen writes...
> Cygwin provides the Solaris ACL API, not the POSIX ACL API, and the
> getfacl/setfacl tools are designed after their Solaris counterparts
> which don't have the -R option.

Maybe this is a dumb or provocative question, but why does Cygwin provide the Solaris API rather than the POSIX one. Particularly, since Linux (and Fedora/RehHat in particular) seem to provide the POSIX one (or at least provide '-R' along with many other options)?

Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by aputerguy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Eric Blake writes...
> But if you WANT to guarantee a newline between processes, just ask for it.
>  Here's one way:
>
> find -print0 | xargs -0 sh -c 'getfacl "$@"; echo' sh

That works!
But it is more than a third slower, presumably because of the extra shell overhead.
Is there any way to "ask for the newline" without incurring that overhead?

Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Corinna Vinschen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov  6 10:21, aputerguy wrote:

>
> Corinna Vinschen writes...
> > Cygwin provides the Solaris ACL API, not the POSIX ACL API, and the
> > getfacl/setfacl tools are designed after their Solaris counterparts
> > which don't have the -R option.
>
> Maybe this is a dumb or provocative question, but why does Cygwin provide
> the Solaris API rather than the POSIX one. Particularly, since Linux (and
> Fedora/RehHat in particular) seem to provide the POSIX one (or at least
> provide '-R' along with many other options)?

History.  I knew the Solaris ACL API much earlier than I learned about
the POSIX ACL API, and the fact that POSIX 1003.1e was never really
finalized as a standard, but rather withdrawn while still being a draft
back in 1999 didn't give me any confidence that it's worth to implement.
Above all, the Solaris API is much simpler than the POSIX draft.

Having said that, I have no problems if somebody implements the POSIX
API in Cygwin additionally to the Solaris API, but personally I don't
see any advantage.  ACL-aware applications most often support both APIs
on the source level.


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Andrew Schulman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> History.  I knew the Solaris ACL API much earlier than I learned about
> the POSIX ACL API, and the fact that POSIX 1003.1e was never really
> finalized as a standard, but rather withdrawn while still being a draft
> back in 1999 didn't give me any confidence that it's worth to implement.
> Above all, the Solaris API is much simpler than the POSIX draft.

Doesn't seem worth changing the API just to get a "free" getfacl -R.  That
should be straightforward to implement... for someone else :|


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Corinna Vinschen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov  6 20:39, Corinna Vinschen wrote:

> On Nov  6 10:21, aputerguy wrote:
> >
> > Corinna Vinschen writes...
> > > Cygwin provides the Solaris ACL API, not the POSIX ACL API, and the
> > > getfacl/setfacl tools are designed after their Solaris counterparts
> > > which don't have the -R option.
> >
> > Maybe this is a dumb or provocative question, but why does Cygwin provide
> > the Solaris API rather than the POSIX one. Particularly, since Linux (and
> > Fedora/RehHat in particular) seem to provide the POSIX one (or at least
> > provide '-R' along with many other options)?
>
> History.  I knew the Solaris ACL API much earlier than I learned about
> the POSIX ACL API, [...]

Oh and, btw., I added Solaris ACL support to Cygwin back in 2000, while
Linux started to support POSIX ACLs first in kernel 2.6.1, back in 2003.
Unfortunately they didn't follow Cygwin's lead back then ;)


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Re: Is there a fast way to get acl's for the whole filesystem (or chunk thereof)

by Steven Monai-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

aputerguy wrote:

> Eric Blake writes...
>> But if you WANT to guarantee a newline between processes, just ask for it.
>>  Here's one way:
>>
>> find -print0 | xargs -0 sh -c 'getfacl "$@"; echo' sh
>
> That works!
> But it is more than a third slower, presumably because of the extra shell
> overhead.
> Is there any way to "ask for the newline" without incurring that overhead?

If eliminating the extra shell overhead is really that important to you,
you could build a custom getfacl that emits that extra newline just
before it exits.

I haven't looked at the getfacl source code, but I don't imagine it
would be very difficult. Probably as simple as adding a 'printf("\n");'
line to the appropriate place(s).

-SM
--

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple