chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
getty: simplify things a bit
[elogind.git]
/
src
/
util.c
diff --git
a/src/util.c
b/src/util.c
index ecfe450dcac5dd3c8bf33497ec8759b7f2d80cb8..6033aa05b271b4f55f361d31d576ba13c979de76 100644
(file)
--- a/
src/util.c
+++ b/
src/util.c
@@
-2895,19
+2895,25
@@
ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
return n;
}
return n;
}
-int path_is_mount_point(const char *t) {
+int path_is_mount_point(const char *t
, bool allow_symlink
) {
struct stat a, b;
char *parent;
int r;
struct stat a, b;
char *parent;
int r;
- if (lstat(t, &a) < 0) {
+ if (allow_symlink)
+ r = stat(t, &a);
+ else
+ r = lstat(t, &a);
+
+ if (r < 0) {
if (errno == ENOENT)
return 0;
return -errno;
}
if (errno == ENOENT)
return 0;
return -errno;
}
- if ((r = parent_of_path(t, &parent)) < 0)
+ r = parent_of_path(t, &parent);
+ if (r < 0)
return r;
r = lstat(parent, &b);
return r;
r = lstat(parent, &b);
@@
-3475,7
+3481,7
@@
int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky
if (honour_sticky && file_is_sticky(path) > 0)
return r;
if (honour_sticky && file_is_sticky(path) > 0)
return r;
- if (rmdir(path) < 0) {
+ if (rmdir(path) < 0
&& errno != ENOENT
) {
if (r == 0)
r = -errno;
}
if (r == 0)
r = -errno;
}
@@
-5846,3
+5852,15
@@
static const char *const signal_table[] = {
};
DEFINE_STRING_TABLE_LOOKUP(signal, int);
};
DEFINE_STRING_TABLE_LOOKUP(signal, int);
+
+bool kexec_loaded(void) {
+ bool loaded = false;
+ char *s;
+
+ if (read_one_line_file("/sys/kernel/kexec_loaded", &s) >= 0) {
+ if (s[0] == '1')
+ loaded = true;
+ free(s);
+ }
+ return loaded;
+}