static int automount_add_mount_links(Automount *a) { _cleanup_free_ char *parent = NULL; int r; assert(a); r = path_get_parent(a->where, &parent); if (r < 0) return r; return unit_require_mounts_for(UNIT(a), parent); }
status_t BEntry::GetParent(BDirectory *dir) const { if (dir == NULL) return B_BAD_VALUE; if (fName == NULL) return B_NO_INIT; BString str; status_t status = path_get_parent(str, fName); if (status != B_OK) return status; return dir->SetTo(str.String()); }
status_t BEntry::GetParent(BPath *path) const { if (path == NULL) return B_BAD_VALUE; if (fName == NULL) return B_NO_INIT; BString str; status_t status = path_get_parent(str, fName); if (status != B_OK) return status; return path->SetTo(str.String(), NULL, false); }
int cg_delete(const char *controller, const char *path) { char *parent; int r; assert(controller); assert(path); if ((r = path_get_parent(path, &parent)) < 0) return r; r = cg_migrate_recursive(controller, path, controller, parent, false, true); free(parent); return r == -ENOENT ? 0 : r; }
static char *specifier_cgroup_root(char specifier, void *data, void *userdata) { Unit *u = userdata; char *p; assert(u); if (specifier == 'r') return strdup(u->manager->cgroup_hierarchy); if (path_get_parent(u->manager->cgroup_hierarchy, &p) < 0) return strdup(""); if (streq(p, "/")) { free(p); return strdup(""); } return p; }
status_t BEntry::SetTo(const char *dir, const char *leaf, bool traverse) { if (dir == NULL) return B_BAD_VALUE; BString str; if (path_expound(str, dir, leaf, NULL) != B_OK) return B_BAD_VALUE; BString parent; status_t status = path_get_parent(parent, str.String()); if (status == B_ENTRY_NOT_FOUND) parent = str; else if (status != B_OK) return B_BAD_VALUE; #ifdef _WIN32 parent.ReplaceAll("/", "\\"); #endif bool parentExists; #ifndef _WIN32 struct stat st; parentExists = (stat(parent.String(), &st) == 0); #else struct _stat st; parentExists = (_stat(parent.String(), &st) == 0); #endif if (!parentExists) return B_ENTRY_NOT_FOUND; // TODO: traverse char *name = EStrdup(str.String()); if (name == NULL) return B_NO_MEMORY; if (fName != NULL) delete[] fName; fName = name; return B_OK; }