* [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option
@ 2015-04-11 13:40 Angelo Compagnucci
2015-04-11 13:40 ` [Buildroot] [PATCH v2 1/2] package/makedevs: " Angelo Compagnucci
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Angelo Compagnucci @ 2015-04-11 13:40 UTC (permalink / raw)
To: buildroot
This patch series add the recursive option to makedevs.
With recursive option will be possible to apply owner/permission
recursively to folders.
Angelo Compagnucci (2):
package/makedevs: add recursive option
docs/manual: documentation for recursive makedevs syntax
docs/manual/makedev-syntax.txt | 10 +++++++++-
package/makedevs/makedevs.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/2] package/makedevs: add recursive option
2015-04-11 13:40 [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Angelo Compagnucci
@ 2015-04-11 13:40 ` Angelo Compagnucci
2015-04-11 15:07 ` Yann E. MORIN
2015-04-11 13:40 ` [Buildroot] [PATCH v2 2/2] docs/manual: documentation for recursive makedevs syntax Angelo Compagnucci
2015-04-11 16:04 ` [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Thomas Petazzoni
2 siblings, 1 reply; 7+ messages in thread
From: Angelo Compagnucci @ 2015-04-11 13:40 UTC (permalink / raw)
To: buildroot
This patch adds the option to change owner/permission
of a folder recursively.
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changelog:
v1 -> v2:
- Code refactoring to avoid nested functions as suggested
by Peter Korsgaard
package/makedevs/makedevs.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/package/makedevs/makedevs.c b/package/makedevs/makedevs.c
index ab90b93..ee0f9fb 100644
--- a/package/makedevs/makedevs.c
+++ b/package/makedevs/makedevs.c
@@ -34,8 +34,12 @@
#ifndef __APPLE__
#include <sys/sysmacros.h> /* major() and minor() */
#endif
+#include <ftw.h>
const char *bb_applet_name;
+uid_t recursive_uid;
+gid_t recursive_gid;
+unsigned int recursive_mode;
void bb_verror_msg(const char *s, va_list p)
{
@@ -332,6 +336,7 @@ void bb_show_usage(void)
fprintf(stderr, "Where name is the file name, type can be one of:\n");
fprintf(stderr, " f A regular file\n");
fprintf(stderr, " d Directory\n");
+ fprintf(stderr, " r Directory recursively\n");
fprintf(stderr, " c Character special device file\n");
fprintf(stderr, " b Block special device file\n");
fprintf(stderr, " p Fifo (named pipe)\n");
@@ -364,6 +369,23 @@ void bb_show_usage(void)
exit(1);
}
+bb_recursive(const char *fpath, const struct stat *sb,
+ int tflag, struct FTW *ftwbuf){
+
+ if (chown(fpath, recursive_uid, recursive_gid) == -1) {
+ bb_perror_msg("chown failed for %s", fpath);
+ return -1;
+ }
+ if (recursive_mode != -1) {
+ if (chmod(fpath, recursive_mode) < 0) {
+ bb_perror_msg("chmod failed for %s", fpath);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
int main(int argc, char **argv)
{
int opt;
@@ -474,6 +496,15 @@ int main(int argc, char **argv)
ret = EXIT_FAILURE;
goto loop;
}
+ } else if (type == 'r') {
+ recursive_uid = uid;
+ recursive_gid = gid;
+ recursive_mode = mode;
+ if (nftw(full_name, bb_recursive, 20, FTW_MOUNT | FTW_PHYS) < 0) {
+ bb_perror_msg("line %d: recursive failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
} else
{
dev_t rdev;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 2/2] docs/manual: documentation for recursive makedevs syntax
2015-04-11 13:40 [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Angelo Compagnucci
2015-04-11 13:40 ` [Buildroot] [PATCH v2 1/2] package/makedevs: " Angelo Compagnucci
@ 2015-04-11 13:40 ` Angelo Compagnucci
2015-04-11 15:08 ` Yann E. MORIN
2015-04-11 16:04 ` [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Thomas Petazzoni
2 siblings, 1 reply; 7+ messages in thread
From: Angelo Compagnucci @ 2015-04-11 13:40 UTC (permalink / raw)
To: buildroot
This patch adds the documentation for the new makedevs
recursive syntax.
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
docs/manual/makedev-syntax.txt | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/docs/manual/makedev-syntax.txt b/docs/manual/makedev-syntax.txt
index e02b79d..afb4ae2 100644
--- a/docs/manual/makedev-syntax.txt
+++ b/docs/manual/makedev-syntax.txt
@@ -24,6 +24,7 @@ There are a few non-trivial blocks:
- +type+ is the type of the file, being one of:
* f: a regular file
* d: a directory
+ * r: a directory recursively
* c: a character device file
* b: a block device file
* p: a named pipe
@@ -38,7 +39,14 @@ Let's say you want to change the permissions of a given file; using
this syntax, you will need to put:
----
-/usr/bin/foobar f 644 0 0 - - - - -
+/usr/bin/foobar f 644 0 0 - - - - -
+----
+
+Alternatively, if you want to change owner/permission of a folder
+recursively, you can put:
+
+----
+/usr/share/myapp r 750 myuser myuser - - - - -
----
On the other hand, if you want to create the device file +/dev/hda+
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/2] package/makedevs: add recursive option
2015-04-11 13:40 ` [Buildroot] [PATCH v2 1/2] package/makedevs: " Angelo Compagnucci
@ 2015-04-11 15:07 ` Yann E. MORIN
0 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2015-04-11 15:07 UTC (permalink / raw)
To: buildroot
Angelo, All,
On 2015-04-11 15:40 +0200, Angelo Compagnucci spake thusly:
> This patch adds the option to change owner/permission
> of a folder recursively.
In *nix terminology, we usually refer to a 'directory' not a 'folder'.
'Folder' is a Windows-ism. ;-)
> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested with a simple dirtectory tree, and manually running through
fakeroot that saved its internal DB, then manually inspected the DB
dump to contain what was expected.
Thanks! :-)
Regards,
Yann E. MORIN.
> ---
> Changelog:
>
> v1 -> v2:
> - Code refactoring to avoid nested functions as suggested
> by Peter Korsgaard
>
> package/makedevs/makedevs.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/package/makedevs/makedevs.c b/package/makedevs/makedevs.c
> index ab90b93..ee0f9fb 100644
> --- a/package/makedevs/makedevs.c
> +++ b/package/makedevs/makedevs.c
> @@ -34,8 +34,12 @@
> #ifndef __APPLE__
> #include <sys/sysmacros.h> /* major() and minor() */
> #endif
> +#include <ftw.h>
>
> const char *bb_applet_name;
> +uid_t recursive_uid;
> +gid_t recursive_gid;
> +unsigned int recursive_mode;
>
> void bb_verror_msg(const char *s, va_list p)
> {
> @@ -332,6 +336,7 @@ void bb_show_usage(void)
> fprintf(stderr, "Where name is the file name, type can be one of:\n");
> fprintf(stderr, " f A regular file\n");
> fprintf(stderr, " d Directory\n");
> + fprintf(stderr, " r Directory recursively\n");
> fprintf(stderr, " c Character special device file\n");
> fprintf(stderr, " b Block special device file\n");
> fprintf(stderr, " p Fifo (named pipe)\n");
> @@ -364,6 +369,23 @@ void bb_show_usage(void)
> exit(1);
> }
>
> +bb_recursive(const char *fpath, const struct stat *sb,
> + int tflag, struct FTW *ftwbuf){
> +
> + if (chown(fpath, recursive_uid, recursive_gid) == -1) {
> + bb_perror_msg("chown failed for %s", fpath);
> + return -1;
> + }
> + if (recursive_mode != -1) {
> + if (chmod(fpath, recursive_mode) < 0) {
> + bb_perror_msg("chmod failed for %s", fpath);
> + return -1;
> + }
> + }
> +
> + return 0;
> +}
> +
> int main(int argc, char **argv)
> {
> int opt;
> @@ -474,6 +496,15 @@ int main(int argc, char **argv)
> ret = EXIT_FAILURE;
> goto loop;
> }
> + } else if (type == 'r') {
> + recursive_uid = uid;
> + recursive_gid = gid;
> + recursive_mode = mode;
> + if (nftw(full_name, bb_recursive, 20, FTW_MOUNT | FTW_PHYS) < 0) {
> + bb_perror_msg("line %d: recursive failed for %s", linenum, full_name);
> + ret = EXIT_FAILURE;
> + goto loop;
> + }
> } else
> {
> dev_t rdev;
> --
> 1.9.1
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 2/2] docs/manual: documentation for recursive makedevs syntax
2015-04-11 13:40 ` [Buildroot] [PATCH v2 2/2] docs/manual: documentation for recursive makedevs syntax Angelo Compagnucci
@ 2015-04-11 15:08 ` Yann E. MORIN
0 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2015-04-11 15:08 UTC (permalink / raw)
To: buildroot
Angelo, All,
On 2015-04-11 15:40 +0200, Angelo Compagnucci spake thusly:
> This patch adds the documentation for the new makedevs
> recursive syntax.
>
> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
> ---
> docs/manual/makedev-syntax.txt | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/docs/manual/makedev-syntax.txt b/docs/manual/makedev-syntax.txt
> index e02b79d..afb4ae2 100644
> --- a/docs/manual/makedev-syntax.txt
> +++ b/docs/manual/makedev-syntax.txt
> @@ -24,6 +24,7 @@ There are a few non-trivial blocks:
> - +type+ is the type of the file, being one of:
> * f: a regular file
> * d: a directory
> + * r: a directory recursively
> * c: a character device file
> * b: a block device file
> * p: a named pipe
> @@ -38,7 +39,14 @@ Let's say you want to change the permissions of a given file; using
> this syntax, you will need to put:
>
> ----
> -/usr/bin/foobar f 644 0 0 - - - - -
> +/usr/bin/foobar f 644 0 0 - - - - -
> +----
> +
> +Alternatively, if you want to change owner/permission of a folder
s/folder/directory/
Otherwise:
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Regards,
Yann E. MORIN.
> +recursively, you can put:
> +
> +----
> +/usr/share/myapp r 750 myuser myuser - - - - -
> ----
>
> On the other hand, if you want to create the device file +/dev/hda+
> --
> 1.9.1
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option
2015-04-11 13:40 [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Angelo Compagnucci
2015-04-11 13:40 ` [Buildroot] [PATCH v2 1/2] package/makedevs: " Angelo Compagnucci
2015-04-11 13:40 ` [Buildroot] [PATCH v2 2/2] docs/manual: documentation for recursive makedevs syntax Angelo Compagnucci
@ 2015-04-11 16:04 ` Thomas Petazzoni
2015-04-11 16:56 ` Angelo Compagnucci
2 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2015-04-11 16:04 UTC (permalink / raw)
To: buildroot
Dear Angelo Compagnucci,
On Sat, 11 Apr 2015 15:40:30 +0200, Angelo Compagnucci wrote:
> This patch series add the recursive option to makedevs.
>
> With recursive option will be possible to apply owner/permission
> recursively to folders.
>
> Angelo Compagnucci (2):
> package/makedevs: add recursive option
> docs/manual: documentation for recursive makedevs syntax
>
> docs/manual/makedev-syntax.txt | 10 +++++++++-
> package/makedevs/makedevs.c | 31 +++++++++++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 1 deletion(-)
Both patches applied, after s/folder/directory/, as suggested by Yann.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option
2015-04-11 16:04 ` [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Thomas Petazzoni
@ 2015-04-11 16:56 ` Angelo Compagnucci
0 siblings, 0 replies; 7+ messages in thread
From: Angelo Compagnucci @ 2015-04-11 16:56 UTC (permalink / raw)
To: buildroot
Dear Thoma Petazzoni,
Il 11/apr/2015 18:04, "Thomas Petazzoni" <
thomas.petazzoni@free-electrons.com> ha scritto:
>
> Dear Angelo Compagnucci,
>
> On Sat, 11 Apr 2015 15:40:30 +0200, Angelo Compagnucci wrote:
> > This patch series add the recursive option to makedevs.
> >
> > With recursive option will be possible to apply owner/permission
> > recursively to folders.
> >
> > Angelo Compagnucci (2):
> > package/makedevs: add recursive option
> > docs/manual: documentation for recursive makedevs syntax
> >
> > docs/manual/makedev-syntax.txt | 10 +++++++++-
> > package/makedevs/makedevs.c | 31 +++++++++++++++++++++++++++++++
> > 2 files changed, 40 insertions(+), 1 deletion(-)
>
> Both patches applied, after s/folder/directory/, as suggested by Yann.
Kawabonga! Fantastic news!
Thank you all for your support!
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150411/bdcf94ff/attachment.html>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-04-11 16:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-11 13:40 [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Angelo Compagnucci
2015-04-11 13:40 ` [Buildroot] [PATCH v2 1/2] package/makedevs: " Angelo Compagnucci
2015-04-11 15:07 ` Yann E. MORIN
2015-04-11 13:40 ` [Buildroot] [PATCH v2 2/2] docs/manual: documentation for recursive makedevs syntax Angelo Compagnucci
2015-04-11 15:08 ` Yann E. MORIN
2015-04-11 16:04 ` [Buildroot] [PATCH v2 0/2] Makedevs: add recursive option Thomas Petazzoni
2015-04-11 16:56 ` Angelo Compagnucci
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.