path.h revision 18c78fb1af5415bb6f87d9c7cae1f9c60e14ae24
71092d70af35567dd154d3de2ce04ce62e157a7cLennart Poettering/*-*- Mode: C; c-basic-offset: 8 -*-*/
7c66aeba0f28cb82027d6015405ed71afa3b6059Kay Sievers
7c66aeba0f28cb82027d6015405ed71afa3b6059Kay Sievers#ifndef foopathhfoo
c904f64d84db8c4eebedf210ba10893f19ba05edLennart Poettering#define foopathhfoo
c904f64d84db8c4eebedf210ba10893f19ba05edLennart Poettering
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers/***
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers This file is part of systemd.
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers Copyright 2010 Lennart Poettering
9a36607584bbd1d78775353e022a51794b4e27b1Lennart Poettering
9a36607584bbd1d78775353e022a51794b4e27b1Lennart Poettering systemd is free software; you can redistribute it and/or modify it
a40593a0d0d740efa387e35411e1e456a6c5aba7Lennart Poettering under the terms of the GNU General Public License as published by
20ffc4c4a9226b0e45cc02ad9c0108981626c0bbKay Sievers the Free Software Foundation; either version 2 of the License, or
7bcd865d386d96caac83cb1c589fdb8f9ce3b081Zbigniew Jędrzejewski-Szmek (at your option) any later version.
7bcd865d386d96caac83cb1c589fdb8f9ce3b081Zbigniew Jędrzejewski-Szmek
7bcd865d386d96caac83cb1c589fdb8f9ce3b081Zbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
2f8d077ece024b985f2501dc8c904c2d29967acbKay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
2f8d077ece024b985f2501dc8c904c2d29967acbKay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d19f95caef8668aeb5c05a18b39c6b79f710856Kay Sievers General Public License for more details.
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
2f8d077ece024b985f2501dc8c904c2d29967acbKay Sievers You should have received a copy of the GNU General Public License
81d112a8f0522a09fcfe317f420363a2b728137cLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
2d19f95caef8668aeb5c05a18b39c6b79f710856Kay Sievers***/
2d19f95caef8668aeb5c05a18b39c6b79f710856Kay Sievers
a4cc3e5ccc0a3033d764a9eb3ae5ee90db560682Lennart Poetteringtypedef struct Path Path;
a4cc3e5ccc0a3033d764a9eb3ae5ee90db560682Lennart Poettering
a4cc3e5ccc0a3033d764a9eb3ae5ee90db560682Lennart Poettering#include "unit.h"
0028da22f194f7c0ca7169a48cf32e1bc0f9138aLennart Poettering#include "mount.h"
a4cc3e5ccc0a3033d764a9eb3ae5ee90db560682Lennart Poettering
7e2c2bcf1285d124c9c656ff46cafa4db0a987c9Lennart Poetteringtypedef enum PathState {
f0c15f288513aa4da012db7497a4aec3f7763ebbLennart Poettering PATH_DEAD,
7b4da18c1717f811bae67ea3d39290495857c03eLennart Poettering PATH_WAITING,
7b4da18c1717f811bae67ea3d39290495857c03eLennart Poettering PATH_RUNNING,
788f75a0e766738c052086e856b7c1b1b676de6bLennart Poettering PATH_MAINTENANCE,
b44be3ecf6326c27aa2c6c6d1fe34e22e22592a0Lennart Poettering _PATH_STATE_MAX,
205b7fa46594b38901636b167b02a8725d915b79Lennart Poettering _PATH_STATE_INVALID = -1
81d112a8f0522a09fcfe317f420363a2b728137cLennart Poettering} PathState;
81d112a8f0522a09fcfe317f420363a2b728137cLennart Poettering
81d112a8f0522a09fcfe317f420363a2b728137cLennart Poetteringtypedef enum PathType {
81d112a8f0522a09fcfe317f420363a2b728137cLennart Poettering PATH_EXISTS,
eb124a97fb72d076014253b1acde69d428f15ecfLennart Poettering PATH_DIRECTORY_NOT_EMPTY,
990ffbe5cffe7f11a8d3ab2258a85fc52b97bf60Lennart Poettering PATH_CHANGED,
dd359de89b1fbabf6f4eb5003d2b5a806b6185c1Lennart Poettering _PATH_TYPE_MAX,
dd359de89b1fbabf6f4eb5003d2b5a806b6185c1Lennart Poettering _PATH_TYPE_INVALID = -1
dd359de89b1fbabf6f4eb5003d2b5a806b6185c1Lennart Poettering} PathType;
eb124a97fb72d076014253b1acde69d428f15ecfLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringtypedef struct PathSpec {
6bc80e94b66e6b008cdc21101fc7409ebcb279dbLennart Poettering PathType type;
6bc80e94b66e6b008cdc21101fc7409ebcb279dbLennart Poettering char *path;
487060c2394b7703e59650ef332053645ffae2a3Lennart Poettering
487060c2394b7703e59650ef332053645ffae2a3Lennart Poettering int inotify_fd;
54c31a79f72ff57ac8eba089acacc4ab482b745dLennart Poettering int primary_wd;
54c31a79f72ff57ac8eba089acacc4ab482b745dLennart Poettering bool previous_exists;
826872b61e4857dfffe63ba84e2b005623baecd6Lennart Poettering
826872b61e4857dfffe63ba84e2b005623baecd6Lennart Poettering Watch watch;
54c31a79f72ff57ac8eba089acacc4ab482b745dLennart Poettering
826872b61e4857dfffe63ba84e2b005623baecd6Lennart Poettering LIST_FIELDS(struct PathSpec, spec);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering} PathSpec;
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringstruct Path {
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering Meta meta;
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering LIST_HEAD(PathSpec, specs);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering PathState state, deserialized_state;
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering Unit *unit;
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering bool failure;
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering};
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringvoid path_unit_notify(Unit *u, UnitActiveState new_state);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering/* Called from the mount code figure out if a mount is a dependency of
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering * any of the paths of this path object */
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringint path_add_one_mount_link(Path *p, Mount *m);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringextern const UnitVTable path_vtable;
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringconst char* path_state_to_string(PathState i);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart PoetteringPathState path_state_from_string(const char *s);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poetteringconst char* path_type_to_string(PathType i);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart PoetteringPathType path_type_from_string(const char *s);
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering#endif
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering