Re: [PATCH v2] static-nodes: tmpfiles - also create parents directories of device nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 19, 2013 at 6:53 PM, Tom Gundersen <teg@xxxxxxx> wrote:
> Before:
>
> c /dev/cpu/microcode 0600 - - - 10:184
> c /dev/fuse 0600 - - - 10:229
> c /dev/btrfs-control 0600 - - - 10:234
> c /dev/loop-control 0600 - - - 10:237
> c /dev/snd/timer 0600 - - - 116:33
>
> After:
>
> d /dev/cpu 0755 - - -
> c /dev/cpu/microcode 0600 - - - 10:184
> c /dev/fuse 0600 - - - 10:229
> c /dev/btrfs-control 0600 - - - 10:234
> c /dev/loop-control 0600 - - - 10:237
> d /dev/snd 0755 - - -
> c /dev/snd/timer 0600 - - - 116:33
> ---
>
> v2: avoid using libgen.h as requested by Lucas
>
>  tools/static-nodes.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/tools/static-nodes.c b/tools/static-nodes.c
> index 65a36fc..2f9773a 100644
> --- a/tools/static-nodes.c
> +++ b/tools/static-nodes.c
> @@ -85,12 +85,20 @@ static const struct static_nodes_format static_nodes_format_human = {
>  static int write_tmpfiles(FILE *out, char modname[], char devname[], char type, unsigned int maj, unsigned int min)
>  {
>          int ret;
> +        char *dir;

missing const

> +
> +        dir = strrchr(devname, '/');
> +        if (dir) {
> +                ret = fprintf(out, "d /dev/%.*s 0755 - - -\n", (int)(dir - devname), devname);
> +                if (ret < 0)
> +                        return EXIT_FAILURE;
> +        }
>
>          ret = fprintf(out, "%c /dev/%s 0600 - - - %u:%u\n", type, devname, maj, min);
> -        if (ret >= 0)
> -                return EXIT_SUCCESS;
> -        else
> +        if (ret < 0)
>                  return EXIT_FAILURE;
> +
> +        return EXIT_SUCCESS;
>  }
>
>  static const struct static_nodes_format static_nodes_format_tmpfiles = {
> --

squashed the const and pushed. May I convince you to add a test case?



Thanks
Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux