[systemd-devel] [PATCH 4/4] Adding unmount functions to be used in shutdown

Lennart Poettering lennart at poettering.net
Tue Oct 5 13:38:40 PDT 2010


On Tue, 05.10.10 08:41, fidencio at profusion.mobi (fidencio at profusion.mobi) wrote:

> +static int swap_list_get(MountPoint **swap_list_head) {
> +        FILE *proc_swaps;
> +
> +        if (!(proc_swaps = fopen("/proc/swaps", "re")))
> +                return -errno;
> +
> +        (void) fscanf(proc_swaps, "%*s %*s %*s %*s %*s\n");
> +
> +        for (;;) {
> +                MountPoint *swap;
> +                char *dev = NULL, *d;
> +                int k;
> +
> +                if ((k = fscanf(proc_swaps,
> +                                "%ms " /* device/file */
> +                                "%*s " /* type of swap */
> +                                "%*s " /* swap size */
> +                                "%*s " /* used */
> +                                "%*s\n", /* priority */
> +                                &dev)) != 1) {
> +
> +                        if (k == EOF)
> +                                break;
> +
> +                        free(dev);
> +                        return -EBADMSG;

Please just "continue" in this error case, too, much like you handle
mountinfo.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list