diff options
author | Christoph Hellwig <hch@tuxera.com> | 2010-10-14 09:54:39 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2010-10-14 09:54:39 -0400 |
commit | 90e616905a423126805186cb5754e10a704b30c8 (patch) | |
tree | f3b142b0414462ae9f267689c965d91c784760d4 /fs/hfsplus/inode.c | |
parent | 722c55d13e7296cc62ed8a38f926a915ff32e4ea (diff) |
hfsplus: create correct initial catalog entries for device files
Make sure the initial insertation of the catalog entry already contains
the device number by calling init_special_inode early and setting writing
out the dev field of the on-disk permission structure. The latter is
facilitated by sharing the almost identical hfsplus_set_perms helpers
between initial catalog entry creating and ->write_inode.
Unless we crashed just after mknod this bug was harmless as the inode
is marked dirty at the end of hfsplus_mknod, and hfsplus_write_inode
will update the catalog entry to contain the correct value.
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus/inode.c')
-rw-r--r-- | fs/hfsplus/inode.c | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index df57ea1f3a71..78449280dae0 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c | |||
@@ -252,29 +252,6 @@ static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, i | |||
252 | inode->i_flags &= ~S_APPEND; | 252 | inode->i_flags &= ~S_APPEND; |
253 | } | 253 | } |
254 | 254 | ||
255 | static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms) | ||
256 | { | ||
257 | if (inode->i_flags & S_IMMUTABLE) | ||
258 | perms->rootflags |= HFSPLUS_FLG_IMMUTABLE; | ||
259 | else | ||
260 | perms->rootflags &= ~HFSPLUS_FLG_IMMUTABLE; | ||
261 | if (inode->i_flags & S_APPEND) | ||
262 | perms->rootflags |= HFSPLUS_FLG_APPEND; | ||
263 | else | ||
264 | perms->rootflags &= ~HFSPLUS_FLG_APPEND; | ||
265 | perms->userflags = HFSPLUS_I(inode)->userflags; | ||
266 | perms->mode = cpu_to_be16(inode->i_mode); | ||
267 | perms->owner = cpu_to_be32(inode->i_uid); | ||
268 | perms->group = cpu_to_be32(inode->i_gid); | ||
269 | |||
270 | if (S_ISREG(inode->i_mode)) | ||
271 | perms->dev = cpu_to_be32(inode->i_nlink); | ||
272 | else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) | ||
273 | perms->dev = cpu_to_be32(inode->i_rdev); | ||
274 | else | ||
275 | perms->dev = 0; | ||
276 | } | ||
277 | |||
278 | static int hfsplus_file_open(struct inode *inode, struct file *file) | 255 | static int hfsplus_file_open(struct inode *inode, struct file *file) |
279 | { | 256 | { |
280 | if (HFSPLUS_IS_RSRC(inode)) | 257 | if (HFSPLUS_IS_RSRC(inode)) |
@@ -578,7 +555,7 @@ int hfsplus_cat_write_inode(struct inode *inode) | |||
578 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, | 555 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
579 | sizeof(struct hfsplus_cat_folder)); | 556 | sizeof(struct hfsplus_cat_folder)); |
580 | /* simple node checks? */ | 557 | /* simple node checks? */ |
581 | hfsplus_set_perms(inode, &folder->permissions); | 558 | hfsplus_cat_set_perms(inode, &folder->permissions); |
582 | folder->access_date = hfsp_ut2mt(inode->i_atime); | 559 | folder->access_date = hfsp_ut2mt(inode->i_atime); |
583 | folder->content_mod_date = hfsp_ut2mt(inode->i_mtime); | 560 | folder->content_mod_date = hfsp_ut2mt(inode->i_mtime); |
584 | folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime); | 561 | folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime); |
@@ -600,7 +577,7 @@ int hfsplus_cat_write_inode(struct inode *inode) | |||
600 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, | 577 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
601 | sizeof(struct hfsplus_cat_file)); | 578 | sizeof(struct hfsplus_cat_file)); |
602 | hfsplus_inode_write_fork(inode, &file->data_fork); | 579 | hfsplus_inode_write_fork(inode, &file->data_fork); |
603 | hfsplus_set_perms(inode, &file->permissions); | 580 | hfsplus_cat_set_perms(inode, &file->permissions); |
604 | if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE) | 581 | if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE) |
605 | file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED); | 582 | file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED); |
606 | else | 583 | else |