stat-util.c revision b26fa1a2fbcfee7d03b0c8fd15ec3aa64ae70b9f
/***
This file is part of systemd.
Copyright 2010-2012 Lennart Poettering
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 <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include "dirent-util.h"
#include "fd-util.h"
#include "macro.h"
#include "missing.h"
#include "stat-util.h"
#include "string-util.h"
int is_symlink(const char *path) {
return -errno;
}
int r;
if (follow)
else
if (r < 0)
return -errno;
}
int is_device_node(const char *path) {
return -errno;
}
int dir_is_empty(const char *path) {
if (!d)
return -errno;
return 0;
return 1;
}
return true;
* hence we do a simpler "is this a device node?" check. */
return true;
return false;
}
int null_or_empty_path(const char *fn) {
return -errno;
return null_or_empty(&st);
}
int null_or_empty_fd(int fd) {
return -errno;
return null_or_empty(&st);
}
int path_is_read_only_fs(const char *path) {
return -errno;
return true;
/* On NFS, statvfs() might not reflect whether we can actually
* write to the remote share. Let's try again with
* access(W_OK) which is more reliable, at least sometimes. */
return true;
return false;
}
int path_is_os_tree(const char *path) {
char *p;
int r;
/* We use /usr/lib/os-release as flag file if something is an OS */
if (r >= 0)
return 1;
/* Also check for the old location in /etc, just in case. */
return r >= 0;
}
struct stat a, b;
return -errno;
return -errno;
}
assert(s);
}
struct statfs s;
return -errno;
return is_fs_type(&s, magic_value);
}
if (fd < 0)
return -errno;
}
bool is_temporary_fs(const struct statfs *s) {
return is_fs_type(s, TMPFS_MAGIC) ||
is_fs_type(s, RAMFS_MAGIC);
}
int fd_is_temporary_fs(int fd) {
struct statfs s;
return -errno;
return is_temporary_fs(&s);
}