Lines Matching refs:path

40 static int fs_prepare_path_impl(const char* path, mode_t mode, uid_t uid, gid_t gid,
42 // Check if path needs to be created
45 if (TEMP_FAILURE_RETRY(lstat(path, &sb)) == -1) {
49 ALOGE("Failed to lstat(%s): %s", path, strerror(errno));
57 ALOGE("Not a %s: %s", (prepare_as_dir ? "directory" : "regular file"), path);
69 ALOGE("Expected path %s with owner %d:%d but found %d:%d",
70 path, uid, gid, sb.st_uid, sb.st_gid);
73 ALOGW("Expected path %s with mode %o but found %o",
74 path, mode, (sb.st_mode & ALL_PERMS));
81 ? TEMP_FAILURE_RETRY(mkdir(path, mode))
82 : TEMP_FAILURE_RETRY(open(path, O_CREAT | O_CLOEXEC | O_NOFOLLOW | O_RDONLY));
86 (prepare_as_dir ? "mkdir" : "open"), path, strerror(errno));
92 ALOGW("Failed to close file after create %s: %s", path, strerror(errno));
96 if (TEMP_FAILURE_RETRY(chmod(path, mode)) == -1) {
97 ALOGE("Failed to chmod(%s, %d): %s", path, mode, strerror(errno));
100 if (TEMP_FAILURE_RETRY(chown(path, uid, gid)) == -1) {
101 ALOGE("Failed to chown(%s, %d, %d): %s", path, uid, gid, strerror(errno));
108 int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid) {
109 return fs_prepare_path_impl(path, mode, uid, gid, /*allow_fixup*/ 1, /*prepare_as_dir*/ 1);
112 int fs_prepare_dir_strict(const char* path, mode_t mode, uid_t uid, gid_t gid) {
113 return fs_prepare_path_impl(path, mode, uid, gid, /*allow_fixup*/ 0, /*prepare_as_dir*/ 1);
116 int fs_prepare_file_strict(const char* path, mode_t mode, uid_t uid, gid_t gid) {
117 return fs_prepare_path_impl(path, mode, uid, gid, /*allow_fixup*/ 0, /*prepare_as_dir*/ 0);
120 int fs_read_atomic_int(const char* path, int* out_value) {
121 int fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY));
123 ALOGE("Failed to read %s: %s", path, strerror(errno));
129 ALOGE("Failed to read %s: %s", path, strerror(errno));
133 ALOGE("Failed to parse %s: %s", path, strerror(errno));
145 int fs_write_atomic_int(const char* path, int value) {
147 if (snprintf(temp, PATH_MAX, "%s.XXXXXX", path) >= PATH_MAX) {
173 if (rename(temp, path) == -1) {
174 ALOGE("Failed to rename %s to %s: %s", temp, path, strerror(errno));
189 int fs_mkdirs(const char* path, mode_t mode) {
193 char* buf = strdup(path);
214 ALOGE("Invalid path: %s", buf);