Home | History | Annotate | Download | only in ext4_utils

Lines Matching refs:dentries

105 	struct dentry dentries = {
113 root_inode = make_directory(0, 1, &dentries, 1);
115 *dentries.inode = inode;
116 inode_set_permissions(inode, dentries.mode,
117 dentries.uid, dentries.gid, dentries.mtime);
151 struct dentry *dentries;
188 dentries = calloc(entries, sizeof(struct dentry));
189 if (dentries == NULL)
193 dentries[i].filename = strdup(namelist[i]->d_name);
194 if (dentries[i].filename == NULL)
197 asprintf(&dentries[i].path, "%s%s", dir_path, namelist[i]->d_name);
198 asprintf(&dentries[i].full_path, "%s%s", full_path, namelist[i]->d_name);
202 ret = lstat(dentries[i].full_path, &stat);
210 dentries[i].size = stat.st_size;
211 dentries[i].mode = stat.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO);
213 dentries[i].mtime = stat.st_mtime;
215 dentries[i].mtime = fixed_time;
224 fs_config_func(dentries[i].path, dir, target_out_path, &uid, &gid, &mode, &capabilities);
225 dentries[i].mode = mode;
226 dentries[i].uid = uid;
227 dentries[i].gid = gid;
228 dentries[i].capabilities = capabilities;
235 if (selabel_lookup(sehnd, &dentries[i].secon, dentries[i].path, stat.st_mode) < 0) {
236 error("cannot lookup security context for %s", dentries[i].path);
239 if (dentries[i].secon && verbose)
240 printf("Labeling %s as %s\n", dentries[i].path, dentries[i].secon);
245 dentries[i].file_type = EXT4_FT_REG_FILE;
247 dentries[i].file_type = EXT4_FT_DIR;
250 dentries[i].file_type = EXT4_FT_CHRDEV;
252 dentries[i].file_type = EXT4_FT_BLKDEV;
254 dentries[i].file_type = EXT4_FT_FIFO;
256 dentries[i].file_type = EXT4_FT_SOCK;
258 dentries[i].file_type = EXT4_FT_SYMLINK;
259 dentries[i].link = calloc(info.block_size, 1);
260 readlink(dentries[i].full_path, dentries[i].link, info.block_size - 1);
262 error("unknown file type on %s", dentries[i].path);
270 /* insert a lost+found directory at the beginning of the dentries */
273 memcpy(tmp + 1, dentries, entries * sizeof(struct dentry));
274 dentries = tmp;
276 dentries[0].filename = strdup("lost+found");
277 asprintf(&dentries[0].path, "%slost+found", dir_path);
278 dentries[0].full_path = NULL;
279 dentries[0].size = 0;
280 dentries[0].mode = S_IRWXU;
281 dentries[0].file_type = EXT4_FT_DIR;
282 dentries[0].uid = 0;
283 dentries[0].gid = 0;
285 if (selabel_lookup(sehnd, &dentries[0].secon, dentries[0].path, dentries[0].mode) < 0)
286 error("cannot lookup security context for %s", dentries[0].path);
292 inode = make_directory(dir_inode, entries, dentries, dirs);
295 if (dentries[i].file_type == EXT4_FT_REG_FILE) {
296 entry_inode = make_file(dentries[i].full_path, dentries[i].size);
297 } else if (dentries[i].file_type == EXT4_FT_DIR) {
300 if (dentries[i].full_path) {
301 ret = asprintf(&subdir_full_path, "%s/", dentries[i].full_path);
305 ret = asprintf(&subdir_dir_path, "%s/", dentries[i].path);
312 } else if (dentries[i].file_type == EXT4_FT_SYMLINK) {
313 entry_inode = make_link(dentries[i].link);
315 error("unknown file type on %s", dentries[i].path);
318 *dentries[i].inode = entry_inode;
320 ret = inode_set_permissions(entry_inode, dentries[i].mode,
321 dentries[i].uid, dentries[i].gid,
322 dentries[i].mtime);
324 error("failed to set permissions on %s\n", dentries[i].path);
333 ret = inode_set_selinux(entry_inode, dentries[i].secon);
335 error("failed to set SELinux context on %s\n", dentries[i].path);
336 ret = inode_set_capabilities(entry_inode, dentries[i].capabilities);
338 error("failed to set capability on %s\n", dentries[i].path);
340 free(dentries[i].path);
341 free(dentries[i].full_path);
342 free(dentries[i].link);
343 free((void *)dentries[i].filename);
344 free(dentries[i].secon);
347 free(dentries);