On Sat, 19.07.14 16:15, Timofey Titovets (nefelim...@gmail.com) wrote:

Heya,

> +int fail_if_symlink(const char *unit, const char* where) {
> +        assert(where);
> +
> +        if (!is_symlink(where))
> +                return 0;
> +
> +        log_warning_unit(unit,
> +                         "%s Refuse mount on symlink: %s",
> +                         unit, strerror(1));

strerror(1)? Where does the "1" come from?

> +
> +        return -1;

We strictly follow the logic to return "errno"-style negative error
numbers, we never make up numeric ones, like "-1".

In this case "return -ELOOP" sounds appropriate, I'd say..."

> +
> +bool is_symlink(const char *path) {
> +        struct stat info;
> +
> +        lstat(path, &info);

You need to handle the case whether the path doesn't exist at all, or
the lstat() fails for other reasons. I think it would be a good idea to
change is_symlink() to return an "int", and then simply return the
negative errno on failure, and 0 or 1 otherwise:

if (lstat(path, &info) < 0)
        return -errno;

That would follow our usual coding style very closely...

Thanks,

Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to