Lines Matching refs:inode
47 struct inode *inode = page->mapping->host; in hfsplus_releasepage() local
48 struct super_block *sb = inode->i_sb; in hfsplus_releasepage()
54 switch (inode->i_ino) { in hfsplus_releasepage()
107 struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; in hfsplus_direct_IO() local
109 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, in hfsplus_direct_IO()
145 static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dentry, in hfsplus_file_lookup()
150 struct inode *inode = NULL; in hfsplus_file_lookup() local
156 inode = HFSPLUS_I(dir).rsrc_inode; in hfsplus_file_lookup()
157 if (inode) in hfsplus_file_lookup()
160 inode = new_inode(sb); in hfsplus_file_lookup()
161 if (!inode) in hfsplus_file_lookup()
164 inode->i_ino = dir->i_ino; in hfsplus_file_lookup()
165 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); in hfsplus_file_lookup()
166 mutex_init(&HFSPLUS_I(inode).extents_lock); in hfsplus_file_lookup()
167 HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC; in hfsplus_file_lookup()
172 err = hfsplus_cat_read_inode(inode, &fd); in hfsplus_file_lookup()
175 iput(inode); in hfsplus_file_lookup()
178 HFSPLUS_I(inode).rsrc_inode = dir; in hfsplus_file_lookup()
179 HFSPLUS_I(dir).rsrc_inode = inode; in hfsplus_file_lookup()
181 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb).rsrc_inodes); in hfsplus_file_lookup()
182 mark_inode_dirty(inode); in hfsplus_file_lookup()
184 d_add(dentry, inode); in hfsplus_file_lookup()
188 static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, int dir) in hfsplus_get_perms() argument
190 struct super_block *sb = inode->i_sb; in hfsplus_get_perms()
195 inode->i_uid = be32_to_cpu(perms->owner); in hfsplus_get_perms()
196 if (!inode->i_uid && !mode) in hfsplus_get_perms()
197 inode->i_uid = HFSPLUS_SB(sb).uid; in hfsplus_get_perms()
199 inode->i_gid = be32_to_cpu(perms->group); in hfsplus_get_perms()
200 if (!inode->i_gid && !mode) in hfsplus_get_perms()
201 inode->i_gid = HFSPLUS_SB(sb).gid; in hfsplus_get_perms()
210 inode->i_mode = mode; in hfsplus_get_perms()
212 HFSPLUS_I(inode).rootflags = perms->rootflags; in hfsplus_get_perms()
213 HFSPLUS_I(inode).userflags = perms->userflags; in hfsplus_get_perms()
215 inode->i_flags |= S_IMMUTABLE; in hfsplus_get_perms()
217 inode->i_flags &= ~S_IMMUTABLE; in hfsplus_get_perms()
219 inode->i_flags |= S_APPEND; in hfsplus_get_perms()
221 inode->i_flags &= ~S_APPEND; in hfsplus_get_perms()
224 static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms) in hfsplus_set_perms() argument
226 if (inode->i_flags & S_IMMUTABLE) in hfsplus_set_perms()
230 if (inode->i_flags & S_APPEND) in hfsplus_set_perms()
234 perms->userflags = HFSPLUS_I(inode).userflags; in hfsplus_set_perms()
235 perms->mode = cpu_to_be16(inode->i_mode); in hfsplus_set_perms()
236 perms->owner = cpu_to_be32(inode->i_uid); in hfsplus_set_perms()
237 perms->group = cpu_to_be32(inode->i_gid); in hfsplus_set_perms()
238 perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev); in hfsplus_set_perms()
241 static int hfsplus_file_open(struct inode *inode, struct file *file) in hfsplus_file_open() argument
243 if (HFSPLUS_IS_RSRC(inode)) in hfsplus_file_open()
244 inode = HFSPLUS_I(inode).rsrc_inode; in hfsplus_file_open()
245 if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) in hfsplus_file_open()
247 atomic_inc(&HFSPLUS_I(inode).opencnt); in hfsplus_file_open()
251 static int hfsplus_file_release(struct inode *inode, struct file *file) in hfsplus_file_release() argument
253 struct super_block *sb = inode->i_sb; in hfsplus_file_release()
255 if (HFSPLUS_IS_RSRC(inode)) in hfsplus_file_release()
256 inode = HFSPLUS_I(inode).rsrc_inode; in hfsplus_file_release()
257 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { in hfsplus_file_release()
258 mutex_lock(&inode->i_mutex); in hfsplus_file_release()
259 hfsplus_file_truncate(inode); in hfsplus_file_release()
260 if (inode->i_flags & S_DEAD) { in hfsplus_file_release()
261 hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL); in hfsplus_file_release()
262 hfsplus_delete_inode(inode); in hfsplus_file_release()
264 mutex_unlock(&inode->i_mutex); in hfsplus_file_release()
291 struct inode *hfsplus_new_inode(struct super_block *sb, int mode) in hfsplus_new_inode()
293 struct inode *inode = new_inode(sb); in hfsplus_new_inode() local
294 if (!inode) in hfsplus_new_inode()
297 inode->i_ino = HFSPLUS_SB(sb).next_cnid++; in hfsplus_new_inode()
298 inode->i_mode = mode; in hfsplus_new_inode()
299 inode->i_uid = current_fsuid(); in hfsplus_new_inode()
300 inode->i_gid = current_fsgid(); in hfsplus_new_inode()
301 inode->i_nlink = 1; in hfsplus_new_inode()
302 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; in hfsplus_new_inode()
303 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); in hfsplus_new_inode()
304 mutex_init(&HFSPLUS_I(inode).extents_lock); in hfsplus_new_inode()
305 atomic_set(&HFSPLUS_I(inode).opencnt, 0); in hfsplus_new_inode()
306 HFSPLUS_I(inode).flags = 0; in hfsplus_new_inode()
307 memset(HFSPLUS_I(inode).first_extents, 0, sizeof(hfsplus_extent_rec)); in hfsplus_new_inode()
308 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); in hfsplus_new_inode()
309 HFSPLUS_I(inode).alloc_blocks = 0; in hfsplus_new_inode()
310 HFSPLUS_I(inode).first_blocks = 0; in hfsplus_new_inode()
311 HFSPLUS_I(inode).cached_start = 0; in hfsplus_new_inode()
312 HFSPLUS_I(inode).cached_blocks = 0; in hfsplus_new_inode()
313 HFSPLUS_I(inode).phys_size = 0; in hfsplus_new_inode()
314 HFSPLUS_I(inode).fs_blocks = 0; in hfsplus_new_inode()
315 HFSPLUS_I(inode).rsrc_inode = NULL; in hfsplus_new_inode()
316 if (S_ISDIR(inode->i_mode)) { in hfsplus_new_inode()
317 inode->i_size = 2; in hfsplus_new_inode()
319 inode->i_op = &hfsplus_dir_inode_operations; in hfsplus_new_inode()
320 inode->i_fop = &hfsplus_dir_operations; in hfsplus_new_inode()
321 } else if (S_ISREG(inode->i_mode)) { in hfsplus_new_inode()
323 inode->i_op = &hfsplus_file_inode_operations; in hfsplus_new_inode()
324 inode->i_fop = &hfsplus_file_operations; in hfsplus_new_inode()
325 inode->i_mapping->a_ops = &hfsplus_aops; in hfsplus_new_inode()
326 HFSPLUS_I(inode).clump_blocks = HFSPLUS_SB(sb).data_clump_blocks; in hfsplus_new_inode()
327 } else if (S_ISLNK(inode->i_mode)) { in hfsplus_new_inode()
329 inode->i_op = &page_symlink_inode_operations; in hfsplus_new_inode()
330 inode->i_mapping->a_ops = &hfsplus_aops; in hfsplus_new_inode()
331 HFSPLUS_I(inode).clump_blocks = 1; in hfsplus_new_inode()
334 insert_inode_hash(inode); in hfsplus_new_inode()
335 mark_inode_dirty(inode); in hfsplus_new_inode()
338 return inode; in hfsplus_new_inode()
341 void hfsplus_delete_inode(struct inode *inode) in hfsplus_delete_inode() argument
343 struct super_block *sb = inode->i_sb; in hfsplus_delete_inode()
345 if (S_ISDIR(inode->i_mode)) { in hfsplus_delete_inode()
351 if (S_ISREG(inode->i_mode)) { in hfsplus_delete_inode()
352 if (!inode->i_nlink) { in hfsplus_delete_inode()
353 inode->i_size = 0; in hfsplus_delete_inode()
354 hfsplus_file_truncate(inode); in hfsplus_delete_inode()
356 } else if (S_ISLNK(inode->i_mode)) { in hfsplus_delete_inode()
357 inode->i_size = 0; in hfsplus_delete_inode()
358 hfsplus_file_truncate(inode); in hfsplus_delete_inode()
363 void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork) in hfsplus_inode_read_fork() argument
365 struct super_block *sb = inode->i_sb; in hfsplus_inode_read_fork()
369 memcpy(&HFSPLUS_I(inode).first_extents, &fork->extents, in hfsplus_inode_read_fork()
373 HFSPLUS_I(inode).first_blocks = count; in hfsplus_inode_read_fork()
374 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); in hfsplus_inode_read_fork()
375 HFSPLUS_I(inode).cached_start = 0; in hfsplus_inode_read_fork()
376 HFSPLUS_I(inode).cached_blocks = 0; in hfsplus_inode_read_fork()
378 HFSPLUS_I(inode).alloc_blocks = be32_to_cpu(fork->total_blocks); in hfsplus_inode_read_fork()
379 inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size); in hfsplus_inode_read_fork()
380 HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; in hfsplus_inode_read_fork()
381 inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits); in hfsplus_inode_read_fork()
382 HFSPLUS_I(inode).clump_blocks = be32_to_cpu(fork->clump_size) >> HFSPLUS_SB(sb).alloc_blksz_shift; in hfsplus_inode_read_fork()
383 if (!HFSPLUS_I(inode).clump_blocks) in hfsplus_inode_read_fork()
384 HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ? HFSPLUS_SB(sb).rsrc_clump_blocks : in hfsplus_inode_read_fork()
388 void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork) in hfsplus_inode_write_fork() argument
390 memcpy(&fork->extents, &HFSPLUS_I(inode).first_extents, in hfsplus_inode_write_fork()
392 fork->total_size = cpu_to_be64(inode->i_size); in hfsplus_inode_write_fork()
393 fork->total_blocks = cpu_to_be32(HFSPLUS_I(inode).alloc_blocks); in hfsplus_inode_write_fork()
396 int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd) in hfsplus_cat_read_inode() argument
404 HFSPLUS_I(inode).dev = 0; in hfsplus_cat_read_inode()
412 hfsplus_get_perms(inode, &folder->permissions, 1); in hfsplus_cat_read_inode()
413 inode->i_nlink = 1; in hfsplus_cat_read_inode()
414 inode->i_size = 2 + be32_to_cpu(folder->valence); in hfsplus_cat_read_inode()
415 inode->i_atime = hfsp_mt2ut(folder->access_date); in hfsplus_cat_read_inode()
416 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date); in hfsplus_cat_read_inode()
417 inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date); in hfsplus_cat_read_inode()
418 HFSPLUS_I(inode).create_date = folder->create_date; in hfsplus_cat_read_inode()
419 HFSPLUS_I(inode).fs_blocks = 0; in hfsplus_cat_read_inode()
420 inode->i_op = &hfsplus_dir_inode_operations; in hfsplus_cat_read_inode()
421 inode->i_fop = &hfsplus_dir_operations; in hfsplus_cat_read_inode()
430 hfsplus_inode_read_fork(inode, HFSPLUS_IS_DATA(inode) ? in hfsplus_cat_read_inode()
432 hfsplus_get_perms(inode, &file->permissions, 0); in hfsplus_cat_read_inode()
433 inode->i_nlink = 1; in hfsplus_cat_read_inode()
434 if (S_ISREG(inode->i_mode)) { in hfsplus_cat_read_inode()
436 inode->i_nlink = be32_to_cpu(file->permissions.dev); in hfsplus_cat_read_inode()
437 inode->i_op = &hfsplus_file_inode_operations; in hfsplus_cat_read_inode()
438 inode->i_fop = &hfsplus_file_operations; in hfsplus_cat_read_inode()
439 inode->i_mapping->a_ops = &hfsplus_aops; in hfsplus_cat_read_inode()
440 } else if (S_ISLNK(inode->i_mode)) { in hfsplus_cat_read_inode()
441 inode->i_op = &page_symlink_inode_operations; in hfsplus_cat_read_inode()
442 inode->i_mapping->a_ops = &hfsplus_aops; in hfsplus_cat_read_inode()
444 init_special_inode(inode, inode->i_mode, in hfsplus_cat_read_inode()
447 inode->i_atime = hfsp_mt2ut(file->access_date); in hfsplus_cat_read_inode()
448 inode->i_mtime = hfsp_mt2ut(file->content_mod_date); in hfsplus_cat_read_inode()
449 inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date); in hfsplus_cat_read_inode()
450 HFSPLUS_I(inode).create_date = file->create_date; in hfsplus_cat_read_inode()
458 int hfsplus_cat_write_inode(struct inode *inode) in hfsplus_cat_write_inode() argument
460 struct inode *main_inode = inode; in hfsplus_cat_write_inode()
464 if (HFSPLUS_IS_RSRC(inode)) in hfsplus_cat_write_inode()
465 main_inode = HFSPLUS_I(inode).rsrc_inode; in hfsplus_cat_write_inode()
486 hfsplus_set_perms(inode, &folder->permissions); in hfsplus_cat_write_inode()
487 folder->access_date = hfsp_ut2mt(inode->i_atime); in hfsplus_cat_write_inode()
488 folder->content_mod_date = hfsp_ut2mt(inode->i_mtime); in hfsplus_cat_write_inode()
489 folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime); in hfsplus_cat_write_inode()
490 folder->valence = cpu_to_be32(inode->i_size - 2); in hfsplus_cat_write_inode()
493 } else if (HFSPLUS_IS_RSRC(inode)) { in hfsplus_cat_write_inode()
497 hfsplus_inode_write_fork(inode, &file->rsrc_fork); in hfsplus_cat_write_inode()
507 hfsplus_inode_write_fork(inode, &file->data_fork); in hfsplus_cat_write_inode()
508 if (S_ISREG(inode->i_mode)) in hfsplus_cat_write_inode()
509 HFSPLUS_I(inode).dev = inode->i_nlink; in hfsplus_cat_write_inode()
510 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) in hfsplus_cat_write_inode()
511 HFSPLUS_I(inode).dev = kdev_t_to_nr(inode->i_rdev); in hfsplus_cat_write_inode()
512 hfsplus_set_perms(inode, &file->permissions); in hfsplus_cat_write_inode()
517 file->access_date = hfsp_ut2mt(inode->i_atime); in hfsplus_cat_write_inode()
518 file->content_mod_date = hfsp_ut2mt(inode->i_mtime); in hfsplus_cat_write_inode()
519 file->attribute_mod_date = hfsp_ut2mt(inode->i_ctime); in hfsplus_cat_write_inode()