~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/hpfs/inode.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/hpfs/inode.c (Version linux-6.12-rc7) and /fs/hpfs/inode.c (Version linux-4.10.17)


  1 // SPDX-License-Identifier: GPL-2.0            << 
  2 /*                                                  1 /*
  3  *  linux/fs/hpfs/inode.c                           2  *  linux/fs/hpfs/inode.c
  4  *                                                  3  *
  5  *  Mikulas Patocka (mikulas@artax.karlin.mff.      4  *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
  6  *                                                  5  *
  7  *  inode VFS functions                             6  *  inode VFS functions
  8  */                                                 7  */
  9                                                     8 
 10 #include <linux/slab.h>                             9 #include <linux/slab.h>
 11 #include <linux/user_namespace.h>                  10 #include <linux/user_namespace.h>
 12 #include "hpfs_fn.h"                               11 #include "hpfs_fn.h"
 13                                                    12 
 14 void hpfs_init_inode(struct inode *i)              13 void hpfs_init_inode(struct inode *i)
 15 {                                                  14 {
 16         struct super_block *sb = i->i_sb;          15         struct super_block *sb = i->i_sb;
 17         struct hpfs_inode_info *hpfs_inode = h     16         struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 18                                                    17 
 19         i->i_uid = hpfs_sb(sb)->sb_uid;            18         i->i_uid = hpfs_sb(sb)->sb_uid;
 20         i->i_gid = hpfs_sb(sb)->sb_gid;            19         i->i_gid = hpfs_sb(sb)->sb_gid;
 21         i->i_mode = hpfs_sb(sb)->sb_mode;          20         i->i_mode = hpfs_sb(sb)->sb_mode;
 22         i->i_size = -1;                            21         i->i_size = -1;
 23         i->i_blocks = -1;                          22         i->i_blocks = -1;
 24                                                    23         
 25         hpfs_inode->i_dno = 0;                     24         hpfs_inode->i_dno = 0;
 26         hpfs_inode->i_n_secs = 0;                  25         hpfs_inode->i_n_secs = 0;
 27         hpfs_inode->i_file_sec = 0;                26         hpfs_inode->i_file_sec = 0;
 28         hpfs_inode->i_disk_sec = 0;                27         hpfs_inode->i_disk_sec = 0;
 29         hpfs_inode->i_dpos = 0;                    28         hpfs_inode->i_dpos = 0;
 30         hpfs_inode->i_dsubdno = 0;                 29         hpfs_inode->i_dsubdno = 0;
 31         hpfs_inode->i_ea_mode = 0;                 30         hpfs_inode->i_ea_mode = 0;
 32         hpfs_inode->i_ea_uid = 0;                  31         hpfs_inode->i_ea_uid = 0;
 33         hpfs_inode->i_ea_gid = 0;                  32         hpfs_inode->i_ea_gid = 0;
 34         hpfs_inode->i_ea_size = 0;                 33         hpfs_inode->i_ea_size = 0;
 35                                                    34 
 36         hpfs_inode->i_rddir_off = NULL;            35         hpfs_inode->i_rddir_off = NULL;
 37         hpfs_inode->i_dirty = 0;                   36         hpfs_inode->i_dirty = 0;
 38                                                    37 
 39         inode_set_ctime(i, 0, 0);              !!  38         i->i_ctime.tv_sec = i->i_ctime.tv_nsec = 0;
 40         inode_set_mtime(i, 0, 0);              !!  39         i->i_mtime.tv_sec = i->i_mtime.tv_nsec = 0;
 41         inode_set_atime(i, 0, 0);              !!  40         i->i_atime.tv_sec = i->i_atime.tv_nsec = 0;
 42 }                                                  41 }
 43                                                    42 
 44 void hpfs_read_inode(struct inode *i)              43 void hpfs_read_inode(struct inode *i)
 45 {                                                  44 {
 46         struct buffer_head *bh;                    45         struct buffer_head *bh;
 47         struct fnode *fnode;                       46         struct fnode *fnode;
 48         struct super_block *sb = i->i_sb;          47         struct super_block *sb = i->i_sb;
 49         struct hpfs_inode_info *hpfs_inode = h     48         struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 50         void *ea;                                  49         void *ea;
 51         int ea_size;                               50         int ea_size;
 52                                                    51 
 53         if (!(fnode = hpfs_map_fnode(sb, i->i_     52         if (!(fnode = hpfs_map_fnode(sb, i->i_ino, &bh))) {
 54                 /*i->i_mode |= S_IFREG;            53                 /*i->i_mode |= S_IFREG;
 55                 i->i_mode &= ~0111;                54                 i->i_mode &= ~0111;
 56                 i->i_op = &hpfs_file_iops;         55                 i->i_op = &hpfs_file_iops;
 57                 i->i_fop = &hpfs_file_ops;         56                 i->i_fop = &hpfs_file_ops;
 58                 clear_nlink(i);*/                  57                 clear_nlink(i);*/
 59                 make_bad_inode(i);                 58                 make_bad_inode(i);
 60                 return;                            59                 return;
 61         }                                          60         }
 62         if (hpfs_sb(i->i_sb)->sb_eas) {            61         if (hpfs_sb(i->i_sb)->sb_eas) {
 63                 if ((ea = hpfs_get_ea(i->i_sb,     62                 if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) {
 64                         if (ea_size == 2) {        63                         if (ea_size == 2) {
 65                                 i_uid_write(i,     64                                 i_uid_write(i, le16_to_cpu(*(__le16*)ea));
 66                                 hpfs_inode->i_     65                                 hpfs_inode->i_ea_uid = 1;
 67                         }                          66                         }
 68                         kfree(ea);                 67                         kfree(ea);
 69                 }                                  68                 }
 70                 if ((ea = hpfs_get_ea(i->i_sb,     69                 if ((ea = hpfs_get_ea(i->i_sb, fnode, "GID", &ea_size))) {
 71                         if (ea_size == 2) {        70                         if (ea_size == 2) {
 72                                 i_gid_write(i,     71                                 i_gid_write(i, le16_to_cpu(*(__le16*)ea));
 73                                 hpfs_inode->i_     72                                 hpfs_inode->i_ea_gid = 1;
 74                         }                          73                         }
 75                         kfree(ea);                 74                         kfree(ea);
 76                 }                                  75                 }
 77                 if ((ea = hpfs_get_ea(i->i_sb,     76                 if ((ea = hpfs_get_ea(i->i_sb, fnode, "SYMLINK", &ea_size))) {
 78                         kfree(ea);                 77                         kfree(ea);
 79                         i->i_mode = S_IFLNK |      78                         i->i_mode = S_IFLNK | 0777;
 80                         i->i_op = &page_symlin     79                         i->i_op = &page_symlink_inode_operations;
 81                         inode_nohighmem(i);        80                         inode_nohighmem(i);
 82                         i->i_data.a_ops = &hpf     81                         i->i_data.a_ops = &hpfs_symlink_aops;
 83                         set_nlink(i, 1);           82                         set_nlink(i, 1);
 84                         i->i_size = ea_size;       83                         i->i_size = ea_size;
 85                         i->i_blocks = 1;           84                         i->i_blocks = 1;
 86                         brelse(bh);                85                         brelse(bh);
 87                         return;                    86                         return;
 88                 }                                  87                 }
 89                 if ((ea = hpfs_get_ea(i->i_sb,     88                 if ((ea = hpfs_get_ea(i->i_sb, fnode, "MODE", &ea_size))) {
 90                         int rdev = 0;              89                         int rdev = 0;
 91                         umode_t mode = hpfs_sb     90                         umode_t mode = hpfs_sb(sb)->sb_mode;
 92                         if (ea_size == 2) {        91                         if (ea_size == 2) {
 93                                 mode = le16_to     92                                 mode = le16_to_cpu(*(__le16*)ea);
 94                                 hpfs_inode->i_     93                                 hpfs_inode->i_ea_mode = 1;
 95                         }                          94                         }
 96                         kfree(ea);                 95                         kfree(ea);
 97                         i->i_mode = mode;          96                         i->i_mode = mode;
 98                         if (S_ISBLK(mode) || S     97                         if (S_ISBLK(mode) || S_ISCHR(mode)) {
 99                                 if ((ea = hpfs     98                                 if ((ea = hpfs_get_ea(i->i_sb, fnode, "DEV", &ea_size))) {
100                                         if (ea     99                                         if (ea_size == 4)
101                                                   100                                                 rdev = le32_to_cpu(*(__le32*)ea);
102                                         kfree(    101                                         kfree(ea);
103                                 }                 102                                 }
104                         }                         103                         }
105                         if (S_ISBLK(mode) || S    104                         if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
106                                 brelse(bh);       105                                 brelse(bh);
107                                 set_nlink(i, 1    106                                 set_nlink(i, 1);
108                                 i->i_size = 0;    107                                 i->i_size = 0;
109                                 i->i_blocks =     108                                 i->i_blocks = 1;
110                                 init_special_i    109                                 init_special_inode(i, mode,
111                                         new_de    110                                         new_decode_dev(rdev));
112                                 return;           111                                 return;
113                         }                         112                         }
114                 }                                 113                 }
115         }                                         114         }
116         if (fnode_is_dir(fnode)) {                115         if (fnode_is_dir(fnode)) {
117                 int n_dnodes, n_subdirs;          116                 int n_dnodes, n_subdirs;
118                 i->i_mode |= S_IFDIR;             117                 i->i_mode |= S_IFDIR;
119                 i->i_op = &hpfs_dir_iops;         118                 i->i_op = &hpfs_dir_iops;
120                 i->i_fop = &hpfs_dir_ops;         119                 i->i_fop = &hpfs_dir_ops;
121                 hpfs_inode->i_parent_dir = le3    120                 hpfs_inode->i_parent_dir = le32_to_cpu(fnode->up);
122                 hpfs_inode->i_dno = le32_to_cp    121                 hpfs_inode->i_dno = le32_to_cpu(fnode->u.external[0].disk_secno);
123                 if (hpfs_sb(sb)->sb_chk >= 2)     122                 if (hpfs_sb(sb)->sb_chk >= 2) {
124                         struct buffer_head *bh    123                         struct buffer_head *bh0;
125                         if (hpfs_map_fnode(sb,    124                         if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0);
126                 }                                 125                 }
127                 n_dnodes = 0; n_subdirs = 0;      126                 n_dnodes = 0; n_subdirs = 0;
128                 hpfs_count_dnodes(i->i_sb, hpf    127                 hpfs_count_dnodes(i->i_sb, hpfs_inode->i_dno, &n_dnodes, &n_subdirs, NULL);
129                 i->i_blocks = 4 * n_dnodes;       128                 i->i_blocks = 4 * n_dnodes;
130                 i->i_size = 2048 * n_dnodes;      129                 i->i_size = 2048 * n_dnodes;
131                 set_nlink(i, 2 + n_subdirs);      130                 set_nlink(i, 2 + n_subdirs);
132         } else {                                  131         } else {
133                 i->i_mode |= S_IFREG;             132                 i->i_mode |= S_IFREG;
134                 if (!hpfs_inode->i_ea_mode) i-    133                 if (!hpfs_inode->i_ea_mode) i->i_mode &= ~0111;
135                 i->i_op = &hpfs_file_iops;        134                 i->i_op = &hpfs_file_iops;
136                 i->i_fop = &hpfs_file_ops;        135                 i->i_fop = &hpfs_file_ops;
137                 set_nlink(i, 1);                  136                 set_nlink(i, 1);
138                 i->i_size = le32_to_cpu(fnode-    137                 i->i_size = le32_to_cpu(fnode->file_size);
139                 i->i_blocks = ((i->i_size + 51    138                 i->i_blocks = ((i->i_size + 511) >> 9) + 1;
140                 i->i_data.a_ops = &hpfs_aops;     139                 i->i_data.a_ops = &hpfs_aops;
141                 hpfs_i(i)->mmu_private = i->i_    140                 hpfs_i(i)->mmu_private = i->i_size;
142         }                                         141         }
143         brelse(bh);                               142         brelse(bh);
144 }                                                 143 }
145                                                   144 
146 static void hpfs_write_inode_ea(struct inode *    145 static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
147 {                                                 146 {
148         struct hpfs_inode_info *hpfs_inode = h    147         struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
149         /*if (le32_to_cpu(fnode->acl_size_l) |    148         /*if (le32_to_cpu(fnode->acl_size_l) || le16_to_cpu(fnode->acl_size_s)) {
150                    Some unknown structures lik    149                    Some unknown structures like ACL may be in fnode,
151                    we'd better not overwrite t    150                    we'd better not overwrite them
152                 hpfs_error(i->i_sb, "fnode %08    151                 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 structures", i->i_ino);
153         } else*/ if (hpfs_sb(i->i_sb)->sb_eas     152         } else*/ if (hpfs_sb(i->i_sb)->sb_eas >= 2) {
154                 __le32 ea;                        153                 __le32 ea;
155                 if (!uid_eq(i->i_uid, hpfs_sb(    154                 if (!uid_eq(i->i_uid, hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
156                         ea = cpu_to_le32(i_uid    155                         ea = cpu_to_le32(i_uid_read(i));
157                         hpfs_set_ea(i, fnode,     156                         hpfs_set_ea(i, fnode, "UID", (char*)&ea, 2);
158                         hpfs_inode->i_ea_uid =    157                         hpfs_inode->i_ea_uid = 1;
159                 }                                 158                 }
160                 if (!gid_eq(i->i_gid, hpfs_sb(    159                 if (!gid_eq(i->i_gid, hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) {
161                         ea = cpu_to_le32(i_gid    160                         ea = cpu_to_le32(i_gid_read(i));
162                         hpfs_set_ea(i, fnode,     161                         hpfs_set_ea(i, fnode, "GID", (char *)&ea, 2);
163                         hpfs_inode->i_ea_gid =    162                         hpfs_inode->i_ea_gid = 1;
164                 }                                 163                 }
165                 if (!S_ISLNK(i->i_mode))          164                 if (!S_ISLNK(i->i_mode))
166                         if ((i->i_mode != ((hp    165                         if ((i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0 : 0111))
167                           | (S_ISDIR(i->i_mode    166                           | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))
168                           && i->i_mode != ((hp    167                           && i->i_mode != ((hpfs_sb(i->i_sb)->sb_mode & ~(S_ISDIR(i->i_mode) ? 0222 : 0333))
169                           | (S_ISDIR(i->i_mode    168                           | (S_ISDIR(i->i_mode) ? S_IFDIR : S_IFREG))) || hpfs_inode->i_ea_mode) {
170                                 ea = cpu_to_le    169                                 ea = cpu_to_le32(i->i_mode);
171                                 /* sick, but l    170                                 /* sick, but legal */
172                                 hpfs_set_ea(i,    171                                 hpfs_set_ea(i, fnode, "MODE", (char *)&ea, 2);
173                                 hpfs_inode->i_    172                                 hpfs_inode->i_ea_mode = 1;
174                         }                         173                         }
175                 if (S_ISBLK(i->i_mode) || S_IS    174                 if (S_ISBLK(i->i_mode) || S_ISCHR(i->i_mode)) {
176                         ea = cpu_to_le32(new_e    175                         ea = cpu_to_le32(new_encode_dev(i->i_rdev));
177                         hpfs_set_ea(i, fnode,     176                         hpfs_set_ea(i, fnode, "DEV", (char *)&ea, 4);
178                 }                                 177                 }
179         }                                         178         }
180 }                                                 179 }
181                                                   180 
182 void hpfs_write_inode(struct inode *i)            181 void hpfs_write_inode(struct inode *i)
183 {                                                 182 {
184         struct hpfs_inode_info *hpfs_inode = h    183         struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
185         struct inode *parent;                     184         struct inode *parent;
186         if (i->i_ino == hpfs_sb(i->i_sb)->sb_r    185         if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
187         if (hpfs_inode->i_rddir_off && !atomic    186         if (hpfs_inode->i_rddir_off && !atomic_read(&i->i_count)) {
188                 if (*hpfs_inode->i_rddir_off)     187                 if (*hpfs_inode->i_rddir_off)
189                         pr_err("write_inode: s    188                         pr_err("write_inode: some position still there\n");
190                 kfree(hpfs_inode->i_rddir_off)    189                 kfree(hpfs_inode->i_rddir_off);
191                 hpfs_inode->i_rddir_off = NULL    190                 hpfs_inode->i_rddir_off = NULL;
192         }                                         191         }
193         if (!i->i_nlink) {                        192         if (!i->i_nlink) {
194                 return;                           193                 return;
195         }                                         194         }
196         parent = iget_locked(i->i_sb, hpfs_ino    195         parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
197         if (parent) {                             196         if (parent) {
198                 hpfs_inode->i_dirty = 0;          197                 hpfs_inode->i_dirty = 0;
199                 if (parent->i_state & I_NEW) {    198                 if (parent->i_state & I_NEW) {
200                         hpfs_init_inode(parent    199                         hpfs_init_inode(parent);
201                         hpfs_read_inode(parent    200                         hpfs_read_inode(parent);
202                         unlock_new_inode(paren    201                         unlock_new_inode(parent);
203                 }                                 202                 }
204                 hpfs_write_inode_nolock(i);       203                 hpfs_write_inode_nolock(i);
205                 iput(parent);                     204                 iput(parent);
206         }                                         205         }
207 }                                                 206 }
208                                                   207 
209 void hpfs_write_inode_nolock(struct inode *i)     208 void hpfs_write_inode_nolock(struct inode *i)
210 {                                                 209 {
211         struct hpfs_inode_info *hpfs_inode = h    210         struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
212         struct buffer_head *bh;                   211         struct buffer_head *bh;
213         struct fnode *fnode;                      212         struct fnode *fnode;
214         struct quad_buffer_head qbh;              213         struct quad_buffer_head qbh;
215         struct hpfs_dirent *de;                   214         struct hpfs_dirent *de;
216         if (i->i_ino == hpfs_sb(i->i_sb)->sb_r    215         if (i->i_ino == hpfs_sb(i->i_sb)->sb_root) return;
217         if (!(fnode = hpfs_map_fnode(i->i_sb,     216         if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) return;
218         if (i->i_ino != hpfs_sb(i->i_sb)->sb_r    217         if (i->i_ino != hpfs_sb(i->i_sb)->sb_root && i->i_nlink) {
219                 if (!(de = map_fnode_dirent(i-    218                 if (!(de = map_fnode_dirent(i->i_sb, i->i_ino, fnode, &qbh))) {
220                         brelse(bh);               219                         brelse(bh);
221                         return;                   220                         return;
222                 }                                 221                 }
223         } else de = NULL;                         222         } else de = NULL;
224         if (S_ISREG(i->i_mode)) {                 223         if (S_ISREG(i->i_mode)) {
225                 fnode->file_size = cpu_to_le32    224                 fnode->file_size = cpu_to_le32(i->i_size);
226                 if (de) de->file_size = cpu_to    225                 if (de) de->file_size = cpu_to_le32(i->i_size);
227         } else if (S_ISDIR(i->i_mode)) {          226         } else if (S_ISDIR(i->i_mode)) {
228                 fnode->file_size = cpu_to_le32    227                 fnode->file_size = cpu_to_le32(0);
229                 if (de) de->file_size = cpu_to    228                 if (de) de->file_size = cpu_to_le32(0);
230         }                                         229         }
231         hpfs_write_inode_ea(i, fnode);            230         hpfs_write_inode_ea(i, fnode);
232         if (de) {                                 231         if (de) {
233                 de->write_date = cpu_to_le32(g !! 232                 de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
234                 de->read_date = cpu_to_le32(gm !! 233                 de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
235                 de->creation_date = cpu_to_le3 !! 234                 de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
236                 de->read_only = !(i->i_mode &     235                 de->read_only = !(i->i_mode & 0222);
237                 de->ea_size = cpu_to_le32(hpfs    236                 de->ea_size = cpu_to_le32(hpfs_inode->i_ea_size);
238                 hpfs_mark_4buffers_dirty(&qbh)    237                 hpfs_mark_4buffers_dirty(&qbh);
239                 hpfs_brelse4(&qbh);               238                 hpfs_brelse4(&qbh);
240         }                                         239         }
241         if (S_ISDIR(i->i_mode)) {                 240         if (S_ISDIR(i->i_mode)) {
242                 if ((de = map_dirent(i, hpfs_i    241                 if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) {
243                         de->write_date = cpu_t !! 242                         de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
244                         de->read_date = cpu_to !! 243                         de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
245                         de->creation_date = cp !! 244                         de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
246                         de->read_only = !(i->i    245                         de->read_only = !(i->i_mode & 0222);
247                         de->ea_size = cpu_to_l    246                         de->ea_size = cpu_to_le32(/*hpfs_inode->i_ea_size*/0);
248                         de->file_size = cpu_to    247                         de->file_size = cpu_to_le32(0);
249                         hpfs_mark_4buffers_dir    248                         hpfs_mark_4buffers_dirty(&qbh);
250                         hpfs_brelse4(&qbh);       249                         hpfs_brelse4(&qbh);
251                 } else                            250                 } else
252                         hpfs_error(i->i_sb,       251                         hpfs_error(i->i_sb,
253                                 "directory %08    252                                 "directory %08lx doesn't have '.' entry",
254                                 (unsigned long    253                                 (unsigned long)i->i_ino);
255         }                                         254         }
256         mark_buffer_dirty(bh);                    255         mark_buffer_dirty(bh);
257         brelse(bh);                               256         brelse(bh);
258 }                                                 257 }
259                                                   258 
260 int hpfs_setattr(struct mnt_idmap *idmap, stru !! 259 int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
261                  struct iattr *attr)           << 
262 {                                                 260 {
263         struct inode *inode = d_inode(dentry);    261         struct inode *inode = d_inode(dentry);
264         int error = -EINVAL;                      262         int error = -EINVAL;
265                                                   263 
266         hpfs_lock(inode->i_sb);                   264         hpfs_lock(inode->i_sb);
267         if (inode->i_ino == hpfs_sb(inode->i_s    265         if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
268                 goto out_unlock;                  266                 goto out_unlock;
269         if ((attr->ia_valid & ATTR_UID) &&        267         if ((attr->ia_valid & ATTR_UID) &&
270             from_kuid(&init_user_ns, attr->ia_    268             from_kuid(&init_user_ns, attr->ia_uid) >= 0x10000)
271                 goto out_unlock;                  269                 goto out_unlock;
272         if ((attr->ia_valid & ATTR_GID) &&        270         if ((attr->ia_valid & ATTR_GID) &&
273             from_kgid(&init_user_ns, attr->ia_    271             from_kgid(&init_user_ns, attr->ia_gid) >= 0x10000)
274                 goto out_unlock;                  272                 goto out_unlock;
275         if ((attr->ia_valid & ATTR_SIZE) && at    273         if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
276                 goto out_unlock;                  274                 goto out_unlock;
277                                                   275 
278         error = setattr_prepare(&nop_mnt_idmap !! 276         error = setattr_prepare(dentry, attr);
279         if (error)                                277         if (error)
280                 goto out_unlock;                  278                 goto out_unlock;
281                                                   279 
282         if ((attr->ia_valid & ATTR_SIZE) &&       280         if ((attr->ia_valid & ATTR_SIZE) &&
283             attr->ia_size != i_size_read(inode    281             attr->ia_size != i_size_read(inode)) {
284                 error = inode_newsize_ok(inode    282                 error = inode_newsize_ok(inode, attr->ia_size);
285                 if (error)                        283                 if (error)
286                         goto out_unlock;          284                         goto out_unlock;
287                                                   285 
288                 truncate_setsize(inode, attr->    286                 truncate_setsize(inode, attr->ia_size);
289                 hpfs_truncate(inode);             287                 hpfs_truncate(inode);
290         }                                         288         }
291                                                   289 
292         setattr_copy(&nop_mnt_idmap, inode, at !! 290         setattr_copy(inode, attr);
293                                                   291 
294         hpfs_write_inode(inode);                  292         hpfs_write_inode(inode);
295                                                   293 
296  out_unlock:                                      294  out_unlock:
297         hpfs_unlock(inode->i_sb);                 295         hpfs_unlock(inode->i_sb);
298         return error;                             296         return error;
299 }                                                 297 }
300                                                   298 
301 void hpfs_write_if_changed(struct inode *inode    299 void hpfs_write_if_changed(struct inode *inode)
302 {                                                 300 {
303         struct hpfs_inode_info *hpfs_inode = h    301         struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
304                                                   302 
305         if (hpfs_inode->i_dirty)                  303         if (hpfs_inode->i_dirty)
306                 hpfs_write_inode(inode);          304                 hpfs_write_inode(inode);
307 }                                                 305 }
308                                                   306 
309 void hpfs_evict_inode(struct inode *inode)        307 void hpfs_evict_inode(struct inode *inode)
310 {                                                 308 {
311         truncate_inode_pages_final(&inode->i_d    309         truncate_inode_pages_final(&inode->i_data);
312         clear_inode(inode);                       310         clear_inode(inode);
313         if (!inode->i_nlink) {                    311         if (!inode->i_nlink) {
314                 hpfs_lock(inode->i_sb);           312                 hpfs_lock(inode->i_sb);
315                 hpfs_remove_fnode(inode->i_sb,    313                 hpfs_remove_fnode(inode->i_sb, inode->i_ino);
316                 hpfs_unlock(inode->i_sb);         314                 hpfs_unlock(inode->i_sb);
317         }                                         315         }
318 }                                                 316 }
319                                                   317 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php