本文整理汇总了C++中path_equal函数的典型用法代码示例。如果您正苦于以下问题:C++ path_equal函数的具体用法?C++ path_equal怎么用?C++ path_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plgfs_test_super
static int plgfs_test_super(struct super_block *sb, void *data)
{
struct plgfs_mnt_cfg *cfg;
struct plgfs_sb_info *sbi;
int i;
cfg = (struct plgfs_mnt_cfg *)data;
sbi = plgfs_sbi(sb);
if (sbi->pdev) {
if (sbi->pdev->bdev_hidden != cfg->bdev)
return 0;
} else if (!path_equal(&sbi->path_hidden, &cfg->path))
return 0;
cfg->flags |= PLGFS_OPT_DIFF_PLGS;
if (sbi->plgs_nr != cfg->plgs_nr)
return 0;
for (i = 0; i < cfg->plgs_nr; i++) {
if (sbi->plgs[i] != cfg->plgs[i])
return 0;
}
cfg->flags &= ~PLGFS_OPT_DIFF_PLGS;
return 1;
}
示例2: get_user_creds_clean
int get_user_creds_clean(
const char **username,
uid_t *uid, gid_t *gid,
const char **home,
const char **shell) {
int r;
/* Like get_user_creds(), but resets home/shell to NULL if they don't contain anything relevant. */
r = get_user_creds(username, uid, gid, home, shell);
if (r < 0)
return r;
if (shell &&
(isempty(*shell) || PATH_IN_SET(*shell,
"/bin/nologin",
"/sbin/nologin",
"/usr/bin/nologin",
"/usr/sbin/nologin")))
*shell = NULL;
if (home &&
(isempty(*home) || path_equal(*home, "/")))
*home = NULL;
return 0;
}
示例3: rm_rf
int rm_rf(const char *path, RemoveFlags flags) {
int fd, r;
struct statfs s;
assert(path);
/* We refuse to clean the root file system with this
* call. This is extra paranoia to never cause a really
* seriously broken system. */
if (path_equal(path, "/")) {
log_error("Attempted to remove entire root file system, and we can't allow that.");
return -EPERM;
}
if ((flags & (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) == (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) {
/* Try to remove as subvolume first */
r = btrfs_subvol_remove(path, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);
if (r >= 0)
return r;
if (r != -ENOTTY && r != -EINVAL && r != -ENOTDIR)
return r;
/* Not btrfs or not a subvolume */
}
fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
if (fd < 0) {
if (errno != ENOTDIR && errno != ELOOP)
return -errno;
if (!(flags & REMOVE_PHYSICAL)) {
if (statfs(path, &s) < 0)
return -errno;
if (is_physical_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
return -EPERM;
}
}
if ((flags & REMOVE_ROOT) && !(flags & REMOVE_ONLY_DIRECTORIES))
if (unlink(path) < 0 && errno != ENOENT)
return -errno;
return 0;
}
r = rm_rf_children(fd, flags, NULL);
if (flags & REMOVE_ROOT) {
if (rmdir(path) < 0) {
if (r == 0 && errno != ENOENT)
r = -errno;
}
}
return r;
}
示例4: automount_verify
static int automount_verify(Automount *a) {
bool b;
char *e;
assert(a);
if (UNIT(a)->load_state != UNIT_LOADED)
return 0;
if (path_equal(a->where, "/")) {
log_error_unit(UNIT(a)->id, "Cannot have an automount unit for the root directory. Refusing.");
return -EINVAL;
}
e = unit_name_from_path(a->where, ".automount");
if (!e)
return -ENOMEM;
b = unit_has_name(UNIT(a), e);
free(e);
if (!b) {
log_error_unit(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
return -EINVAL;
}
return 0;
}
示例5: device_update_unit
static int device_update_unit(Manager *m, struct udev_device *dev, const char *path, bool main) {
const char *sysfs, *model;
Unit *u = NULL;
int r;
bool delete;
assert(m);
if (!(sysfs = udev_device_get_syspath(dev)))
return -ENOMEM;
if ((r = device_find_escape_name(m, path, &u)) < 0)
return r;
if (u && DEVICE(u)->sysfs && !path_equal(DEVICE(u)->sysfs, sysfs))
return -EEXIST;
if (!u) {
delete = true;
u = unit_new(m, sizeof(Device));
if (!u)
return -ENOMEM;
r = device_add_escaped_name(u, path);
if (r < 0)
goto fail;
unit_add_to_load_queue(u);
} else
示例6: drop_duplicates
static void drop_duplicates(MountEntry *m, unsigned *n) {
MountEntry *f, *t, *previous;
assert(m);
assert(n);
/* Drops duplicate entries. Expects that the array is properly ordered already. */
for (f = m, t = m, previous = NULL; f < m + *n; f++) {
/* The first one wins (which is the one with the more restrictive mode), see mount_path_compare()
* above. */
if (previous && path_equal(mount_entry_path(f), mount_entry_path(previous))) {
log_debug("%s is duplicate.", mount_entry_path(f));
previous->read_only = previous->read_only || mount_entry_read_only(f); /* Propagate the read-only flag to the remaining entry */
mount_entry_done(f);
continue;
}
*t = *f;
previous = t;
t++;
}
*n = t - m;
}
示例7: automount_verify
static int automount_verify(Automount *a) {
_cleanup_free_ char *e = NULL;
int r;
assert(a);
if (UNIT(a)->load_state != UNIT_LOADED)
return 0;
if (path_equal(a->where, "/")) {
log_unit_error(UNIT(a), "Cannot have an automount unit for the root directory. Refusing.");
return -EINVAL;
}
r = unit_name_from_path(a->where, ".automount", &e);
if (r < 0)
return log_unit_error(UNIT(a), "Failed to generate unit name from path: %m");
if (!unit_has_name(UNIT(a), e)) {
log_unit_error(UNIT(a), "Where= setting doesn't match unit name. Refusing.");
return -EINVAL;
}
return 0;
}
示例8: STRV_FOREACH_PAIR
STRV_FOREACH_PAIR(link, p, links) {
_cleanup_free_ char *target = NULL;
char *f = strappenda(original_dir, *p);
char *l = strappenda(copy_dir, *link);
assert_se(readlink_and_canonicalize(l, &target) == 0);
assert_se(path_equal(f, target));
}
示例9: STRV_FOREACH_PAIR
STRV_FOREACH_PAIR(link, p, links) {
_cleanup_free_ char *target, *f, *l;
assert_se(f = strjoin(original_dir, *p));
assert_se(l = strjoin(copy_dir, *link));
assert_se(chase_symlinks(l, NULL, 0, &target) == 1);
assert_se(path_equal(f, target));
}
示例10: mount_point_ignore
bool mount_point_ignore(const char *path) {
const char *i;
NULSTR_FOREACH(i, ignore_paths)
if (path_equal(path, i))
return true;
return false;
}
示例11: STRV_FOREACH_PAIR
STRV_FOREACH_PAIR(link, p, links) {
_cleanup_free_ char *target = NULL, *f, *l;
assert_se((f = strjoin(original_dir, *p)));
assert_se((l = strjoin(copy_dir, *link)));
assert_se(readlink_and_canonicalize(l, NULL, &target) == 0);
assert_se(path_equal(f, target));
}
示例12: in_southbound_context
/*
* Whenever we do any sort of path lookup, we must make sure we are in
* the namespace of our southbound fs. This is a simple check that our
* task struct has the right context.
*/
int in_southbound_context(struct task_struct *tsk)
{
int err;
mutex_lock(&ftfs_southbound_lock);
task_lock(tsk);
err = path_equal(&tsk->fs->root, &ftfs_fs->root);
task_unlock(tsk);
mutex_unlock(&ftfs_southbound_lock);
return err;
}
示例13: getArchive
Archive* FileSystem::getArchive (const std::string& archiveName)
{
for (ArchiveEntryList::iterator i = g_archives.begin(); i != g_archives.end(); ++i) {
if (i->is_pakfile) {
if (path_equal(i->name, archiveName)) {
return i->archive;
}
}
}
return 0;
}
示例14: device_path_parse_major_minor
int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devno) {
mode_t mode;
dev_t devno;
int r;
/* Tries to extract the major/minor directly from the device path if we can. Handles /dev/block/ and /dev/char/
* paths, as well out synthetic inaccessible device nodes. Never goes to disk. Returns -ENODEV if the device
* path cannot be parsed like this. */
if (path_equal(path, "/run/systemd/inaccessible/chr")) {
mode = S_IFCHR;
devno = makedev(0, 0);
} else if (path_equal(path, "/run/systemd/inaccessible/blk")) {
mode = S_IFBLK;
devno = makedev(0, 0);
} else {
const char *w;
w = path_startswith(path, "/dev/block/");
if (w)
mode = S_IFBLK;
else {
w = path_startswith(path, "/dev/char/");
if (!w)
return -ENODEV;
mode = S_IFCHR;
}
r = parse_dev(w, &devno);
if (r < 0)
return r;
}
if (ret_mode)
*ret_mode = mode;
if (ret_devno)
*ret_devno = devno;
return 0;
}
示例15: getArchive
Archive* getArchive(const char* archiveName, bool pakonly)
{
for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
{
if(pakonly && !(*i).is_pakfile)
continue;
if(path_equal((*i).name.c_str(), archiveName))
return (*i).archive;
}
return 0;
}