/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
Copyright 2014 Tom Gundersen
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <poll.h>
#include <string.h>
#include "sd-network.h"
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "macro.h"
#include "parse-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
_cleanup_free_ char *s = NULL;
int r;
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
if (isempty(s))
return -ENODATA;
*state = s;
s = NULL;
return 0;
}
_cleanup_strv_free_ char **a = NULL;
_cleanup_free_ char *s = NULL;
int r;
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
if (isempty(s)) {
return 0;
}
a = strv_split(s, " ");
if (!a)
return -ENOMEM;
strv_uniq(a);
r = strv_length(a);
*ret = a;
a = NULL;
return r;
}
}
}
}
}
int r;
return -ENOMEM;
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
if (isempty(s))
return -ENODATA;
*ret = s;
s = NULL;
return 0;
}
_cleanup_strv_free_ char **a = NULL;
int r;
return -ENOMEM;
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
if (isempty(s)) {
return 0;
}
a = strv_split(s, " ");
if (!a)
return -ENOMEM;
strv_uniq(a);
r = strv_length(a);
*ret = a;
a = NULL;
return r;
}
}
}
}
}
}
}
}
int r;
return -ENOMEM;
r = read_full_file(p, &s, &size);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
if (size <= 0)
return -ENODATA;
*lldp = s;
s = NULL;
return 0;
}
}
}
}
}
}
}
}
return (int) (unsigned long) m - 1;
}
}
int k;
if (k >= 0)
return 0;
return -errno;
if (k >= 0)
return 0;
return -errno;
if (k < 0)
return -errno;
return 0;
}
int k;
bool good = false;
assert_return(m, -EINVAL);
if (fd < 0)
return -errno;
k = monitor_add_inotify_watch(fd);
if (k < 0)
return k;
good = true;
}
if (!good)
return -EINVAL;
*m = FD_TO_MONITOR(fd);
fd = -1;
return 0;
}
int fd;
if (m) {
fd = MONITOR_TO_FD(m);
}
return NULL;
}
struct inotify_event *e;
ssize_t l;
int fd, k;
assert_return(m, -EINVAL);
fd = MONITOR_TO_FD(m);
if (l < 0) {
return 0;
return -errno;
}
k = monitor_add_inotify_watch(fd);
if (k < 0)
return k;
if (k < 0)
return -errno;
}
}
return 0;
}
assert_return(m, -EINVAL);
return MONITOR_TO_FD(m);
}
assert_return(m, -EINVAL);
/* For now we will only return POLLIN here, since we don't
* need anything else ever for inotify. However, let's have
* this API to keep our options open should we later on need
* it. */
return POLLIN;
}
assert_return(m, -EINVAL);
/* For now we will only return (uint64_t) -1, since we don't
* need any timeout. However, let's have this API to keep our
* options open should we later on need it. */
return 0;
}