本文整理汇总了C++中path_equal函数的典型用法代码示例。如果您正苦于以下问题:C++ path_equal函数的具体用法?C++ path_equal怎么用?C++ path_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:kcomkar,项目名称:pluginfs,代码行数:30,代码来源:plgfs.c
示例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;
}
开发者ID:aulanov,项目名称:systemd,代码行数:28,代码来源:user-util.c
示例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;
}
开发者ID:dbuch,项目名称:systemd,代码行数:60,代码来源:rm-rf.c
示例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;
}
开发者ID:ariscop,项目名称:systemd,代码行数:27,代码来源:automount.c
示例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
开发者ID:felipec,项目名称:udev-fc,代码行数:30,代码来源:device.c
示例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;
}
开发者ID:heftig,项目名称:systemd,代码行数:26,代码来源:namespace.c
示例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;
}
开发者ID:aulanov,项目名称:systemd,代码行数:25,代码来源:automount.c
示例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));
}
开发者ID:faizalpribadi,项目名称:systemd,代码行数:8,代码来源:test-copy.c
示例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));
}
开发者ID:iamyooon,项目名称:systemd,代码行数:9,代码来源:test-copy.c
示例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;
}
开发者ID:banada,项目名称:systemd,代码行数:9,代码来源:mount-setup.c
示例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));
}
开发者ID:GuillaumeSeren,项目名称:systemd,代码行数:9,代码来源:test-copy.c
示例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;
}
开发者ID:tonytcl,项目名称:betrfs,代码行数:15,代码来源:ftfs_southbound.c
示例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;
}
开发者ID:kevlund,项目名称:ufoai,代码行数:11,代码来源:FileSystem.cpp
示例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;
}
开发者ID:tblume,项目名称:systemd-testsuite-suse,代码行数:41,代码来源:stat-util.c
示例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;
}
开发者ID:clbr,项目名称:netradiant,代码行数:12,代码来源:vfs.cpp
示例16: mount_point_is_api
bool mount_point_is_api(const char *path) {
unsigned i;
/* Checks if this mount point is considered "API", and hence
* should be ignored */
for (i = 0; i < ELEMENTSOF(mount_table); i ++)
if (path_equal(path, mount_table[i].where))
return true;
return path_startswith(path, "/sys/fs/cgroup/");
}
开发者ID:banada,项目名称:systemd,代码行数:12,代码来源:mount-setup.c
示例17: equivalent
static int equivalent(const char *a, const char *b) {
_cleanup_free_ char *x = NULL, *y = NULL;
x = canonicalize_file_name(a);
if (!x)
return -errno;
y = canonicalize_file_name(b);
if (!y)
return -errno;
return path_equal(x, y);
}
开发者ID:RoadRunnr,项目名称:systemd,代码行数:13,代码来源:delta.c
示例18: equivalent
static int equivalent(const char *a, const char *b) {
_cleanup_free_ char *x = NULL, *y = NULL;
int r;
r = chase_symlinks(a, NULL, 0, &x);
if (r < 0)
return r;
r = chase_symlinks(b, NULL, 0, &y);
if (r < 0)
return r;
return path_equal(x, y);
}
开发者ID:OpenDZ,项目名称:systemd,代码行数:14,代码来源:delta.c
示例19: test_u_n_f_p_one
static void test_u_n_f_p_one(const char *path, const char *suffix, const char *expected, int ret) {
_cleanup_free_ char *t = NULL;
assert_se(unit_name_from_path(path, suffix, &t) == ret);
puts(strna(t));
assert_se(streq_ptr(t, expected));
if (t) {
_cleanup_free_ char *k = NULL;
assert_se(unit_name_to_path(t, &k) == 0);
puts(strna(k));
assert_se(path_equal(k, isempty(path) ? "/" : path));
}
}
开发者ID:michich,项目名称:systemd,代码行数:14,代码来源:test-unit-name.c
示例20: test_mnt_id
static void test_mnt_id(void) {
_cleanup_fclose_ FILE *f = NULL;
Hashmap *h;
Iterator i;
char *p;
void *k;
int r;
log_info("/* %s */", __func__);
assert_se(f = fopen("/proc/self/mountinfo", "re"));
assert_se(h = hashmap_new(&trivial_hash_ops));
for (;;) {
_cleanup_free_ char *line = NULL, *path = NULL;
int mnt_id;
r = read_line(f, LONG_LINE_MAX, &line);
if (r == 0)
break;
assert_se(r > 0);
assert_se(sscanf(line, "%i %*s %*s %*s %ms", &mnt_id, &path) == 2);
log_debug("mountinfo: %s → %i", path, mnt_id);
assert_se(hashmap_put(h, INT_TO_PTR(mnt_id), path) >= 0);
path = NULL;
}
HASHMAP_FOREACH_KEY(p, k, h, i) {
int mnt_id = PTR_TO_INT(k), mnt_id2;
r = path_get_mnt_id(p, &mnt_id2);
if (r < 0) {
log_debug_errno(r, "Failed to get the mnt id of %s: %m\n", p);
continue;
}
log_debug("mnt ids of %s are %i, %i\n", p, mnt_id, mnt_id2);
if (mnt_id == mnt_id2)
continue;
/* The ids don't match? If so, then there are two mounts on the same path, let's check if
* that's really the case */
char *t = hashmap_get(h, INT_TO_PTR(mnt_id2));
log_debug("the other path for mnt id %i is %s\n", mnt_id2, t);
assert_se(path_equal(p, t));
}
开发者ID:Keruspe,项目名称:systemd,代码行数:50,代码来源:test-mountpoint-util.c
注:本文中的path_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论