[ovs-dev] [PATCH] socket-util: Add symlink based workaround for long pathnames.

YAMAMOTO Takashi yamamoto at valinux.co.jp
Fri Oct 18 02:31:37 UTC 2013


> +/* Attempts to shorten 'name' by creating a symlink for the directory part of
> + * the name and indirecting through <symlink>/<basename>.  This works on
> + * systems that support symlinks, as long as <basename> isn't too long.
> + *
> + * On success, returns 0 and stores the short name in 'short_name' and the
> + * symbolic link to eventually delete in 'linkname'. */
> +static int
> +shorten_name_via_symlink(const char *name, char short_name[MAX_UN_LEN + 1],
> +                         char linkname[MAX_UN_LEN + 1])
> +{
> +    char *abs, *dir, *base;
> +    const char *tmpdir;
> +    int error;
> +    int i;
> +
> +    abs = abs_file_name(NULL, name);
> +    dir = dir_name(abs);
> +    base = base_name(abs);
> +    free(abs);
> +
> +    tmpdir = getenv("TMPDIR");
> +    if (tmpdir == NULL) {
> +        tmpdir = "/tmp";
> +    }
> +
> +    for (i = 0; i < 10; i++) {

i feel that 10 is too small as number of unix sockets ovs can use
is larger in magnitude.  while simultaneous use of this should be
typically much smaller, it shouldn't be a problem to waste cycles
here either.  IMO safer is better.

>              VLOG_WARN_RL(&rl, "Unix socket name %s is longer than maximum "
> -                         "%d bytes (even shortened)", name, MAX_UN_LEN);
> -        } else {
> -            /* 'name' is too long and we have no workaround. */
> -            VLOG_WARN_RL(&rl, "Unix socket name %s is longer than maximum "
>                           "%d bytes", name, MAX_UN_LEN);

with your new definition of MAX_UN_LEN, this should be %zu.

otherwise looks good to me and worked for me.  thanks!

YAMAMOTO Takashi



More information about the dev mailing list