-static int mount_find_pri(char *options) {
- char *end, *pri;
- unsigned long r;
-
- if (!(pri = mount_test_option(options, "pri")))
- return 0;
-
- pri += 4;
-
- errno = 0;
- r = strtoul(pri, &end, 10);
-
- if (errno != 0)
- return -errno;
-
- if (end == pri || (*end != ',' && *end != 0))
- return -EINVAL;
-
- return (int) r;
-}
-
-static int mount_load_etc_fstab(Manager *m) {
- FILE *f;
- int r = 0;
- struct mntent* me;
-
- assert(m);
-
- errno = 0;
- f = setmntent("/etc/fstab", "r");
- if (!f)
- return errno == ENOENT ? 0 : -errno;
-
- while ((me = getmntent(f))) {
- char *where, *what;
- int k;
-
- if (!(what = fstab_node_to_udev_node(me->mnt_fsname))) {
- r = -ENOMEM;
- goto finish;
- }
-
- if (!(where = strdup(me->mnt_dir))) {
- free(what);
- r = -ENOMEM;
- goto finish;
- }
-
- if (what[0] == '/')
- path_kill_slashes(what);
-
- if (where[0] == '/')
- path_kill_slashes(where);
-
- if (streq(me->mnt_type, "swap")) {
- int pri;
-
- if ((pri = mount_find_pri(me->mnt_opts)) < 0)
- k = pri;
- else
- k = swap_add_one(m,
- what,
- NULL,
- pri,
- !!mount_test_option(me->mnt_opts, "noauto"),
- !!mount_test_option(me->mnt_opts, "nofail"),
- false);
- } else
- k = mount_add_one(m, what, where, me->mnt_opts, me->mnt_type, me->mnt_passno, false, false);
-
- free(what);
- free(where);
-
- if (k < 0)
- r = k;
- }
-
-finish:
-
- endmntent(f);
- return r;
-}
-