Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/hpfs/namei.c |
| 3 | * |
| 4 | * Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999 |
| 5 | * |
| 6 | * adding & removing files & directories |
| 7 | */ |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 8 | #include <linux/sched.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include "hpfs_fn.h" |
| 10 | |
| 11 | static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
| 12 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 13 | const unsigned char *name = dentry->d_name.name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | unsigned len = dentry->d_name.len; |
| 15 | struct quad_buffer_head qbh0; |
| 16 | struct buffer_head *bh; |
| 17 | struct hpfs_dirent *de; |
| 18 | struct fnode *fnode; |
| 19 | struct dnode *dnode; |
| 20 | struct inode *result; |
| 21 | fnode_secno fno; |
| 22 | dnode_secno dno; |
| 23 | int r; |
| 24 | struct hpfs_dirent dee; |
| 25 | int err; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 26 | if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 27 | hpfs_lock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | err = -ENOSPC; |
| 29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
| 30 | if (!fnode) |
| 31 | goto bail; |
| 32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0, 1); |
| 33 | if (!dnode) |
| 34 | goto bail1; |
| 35 | memset(&dee, 0, sizeof dee); |
| 36 | dee.directory = 1; |
| 37 | if (!(mode & 0222)) dee.read_only = 1; |
| 38 | /*dee.archive = 0;*/ |
| 39 | dee.hidden = name[0] == '.'; |
| 40 | dee.fnode = fno; |
| 41 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); |
| 42 | result = new_inode(dir->i_sb); |
| 43 | if (!result) |
| 44 | goto bail2; |
| 45 | hpfs_init_inode(result); |
| 46 | result->i_ino = fno; |
| 47 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
| 48 | hpfs_i(result)->i_dno = dno; |
| 49 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); |
| 50 | result->i_ctime.tv_nsec = 0; |
| 51 | result->i_mtime.tv_nsec = 0; |
| 52 | result->i_atime.tv_nsec = 0; |
| 53 | hpfs_i(result)->i_ea_size = 0; |
| 54 | result->i_mode |= S_IFDIR; |
| 55 | result->i_op = &hpfs_dir_iops; |
| 56 | result->i_fop = &hpfs_dir_ops; |
| 57 | result->i_blocks = 4; |
| 58 | result->i_size = 2048; |
| 59 | result->i_nlink = 2; |
| 60 | if (dee.read_only) |
| 61 | result->i_mode &= ~0222; |
| 62 | |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 63 | mutex_lock(&hpfs_i(dir)->i_mutex); |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 64 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | if (r == 1) |
| 66 | goto bail3; |
| 67 | if (r == -1) { |
| 68 | err = -EEXIST; |
| 69 | goto bail3; |
| 70 | } |
| 71 | fnode->len = len; |
| 72 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
| 73 | fnode->up = dir->i_ino; |
| 74 | fnode->dirflag = 1; |
| 75 | fnode->btree.n_free_nodes = 7; |
| 76 | fnode->btree.n_used_nodes = 1; |
| 77 | fnode->btree.first_free = 0x14; |
| 78 | fnode->u.external[0].disk_secno = dno; |
| 79 | fnode->u.external[0].file_secno = -1; |
| 80 | dnode->root_dnode = 1; |
| 81 | dnode->up = fno; |
| 82 | de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); |
| 83 | de->creation_date = de->write_date = de->read_date = gmt_to_local(dir->i_sb, get_seconds()); |
| 84 | if (!(mode & 0222)) de->read_only = 1; |
| 85 | de->first = de->directory = 1; |
| 86 | /*de->hidden = de->system = 0;*/ |
| 87 | de->fnode = fno; |
| 88 | mark_buffer_dirty(bh); |
| 89 | brelse(bh); |
| 90 | hpfs_mark_4buffers_dirty(&qbh0); |
| 91 | hpfs_brelse4(&qbh0); |
Dave Hansen | d8c76e6 | 2006-09-30 23:29:04 -0700 | [diff] [blame] | 92 | inc_nlink(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | insert_inode_hash(result); |
| 94 | |
David Howells | de395b8 | 2008-11-14 10:38:55 +1100 | [diff] [blame] | 95 | if (result->i_uid != current_fsuid() || |
| 96 | result->i_gid != current_fsgid() || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | result->i_mode != (mode | S_IFDIR)) { |
David Howells | de395b8 | 2008-11-14 10:38:55 +1100 | [diff] [blame] | 98 | result->i_uid = current_fsuid(); |
| 99 | result->i_gid = current_fsgid(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | result->i_mode = mode | S_IFDIR; |
| 101 | hpfs_write_inode_nolock(result); |
| 102 | } |
| 103 | d_instantiate(dentry, result); |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 104 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 105 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | return 0; |
| 107 | bail3: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 108 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | iput(result); |
| 110 | bail2: |
| 111 | hpfs_brelse4(&qbh0); |
| 112 | hpfs_free_dnode(dir->i_sb, dno); |
| 113 | bail1: |
| 114 | brelse(bh); |
| 115 | hpfs_free_sectors(dir->i_sb, fno, 1); |
| 116 | bail: |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 117 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | return err; |
| 119 | } |
| 120 | |
| 121 | static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) |
| 122 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 123 | const unsigned char *name = dentry->d_name.name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | unsigned len = dentry->d_name.len; |
| 125 | struct inode *result = NULL; |
| 126 | struct buffer_head *bh; |
| 127 | struct fnode *fnode; |
| 128 | fnode_secno fno; |
| 129 | int r; |
| 130 | struct hpfs_dirent dee; |
| 131 | int err; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 132 | if ((err = hpfs_chk_name(name, &len))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | return err==-ENOENT ? -EINVAL : err; |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 134 | hpfs_lock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | err = -ENOSPC; |
| 136 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
| 137 | if (!fnode) |
| 138 | goto bail; |
| 139 | memset(&dee, 0, sizeof dee); |
| 140 | if (!(mode & 0222)) dee.read_only = 1; |
| 141 | dee.archive = 1; |
| 142 | dee.hidden = name[0] == '.'; |
| 143 | dee.fnode = fno; |
| 144 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); |
| 145 | |
| 146 | result = new_inode(dir->i_sb); |
| 147 | if (!result) |
| 148 | goto bail1; |
| 149 | |
| 150 | hpfs_init_inode(result); |
| 151 | result->i_ino = fno; |
| 152 | result->i_mode |= S_IFREG; |
| 153 | result->i_mode &= ~0111; |
| 154 | result->i_op = &hpfs_file_iops; |
| 155 | result->i_fop = &hpfs_file_ops; |
| 156 | result->i_nlink = 1; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 157 | hpfs_decide_conv(result, name, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
| 159 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); |
| 160 | result->i_ctime.tv_nsec = 0; |
| 161 | result->i_mtime.tv_nsec = 0; |
| 162 | result->i_atime.tv_nsec = 0; |
| 163 | hpfs_i(result)->i_ea_size = 0; |
| 164 | if (dee.read_only) |
| 165 | result->i_mode &= ~0222; |
| 166 | result->i_blocks = 1; |
| 167 | result->i_size = 0; |
| 168 | result->i_data.a_ops = &hpfs_aops; |
| 169 | hpfs_i(result)->mmu_private = 0; |
| 170 | |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 171 | mutex_lock(&hpfs_i(dir)->i_mutex); |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 172 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | if (r == 1) |
| 174 | goto bail2; |
| 175 | if (r == -1) { |
| 176 | err = -EEXIST; |
| 177 | goto bail2; |
| 178 | } |
| 179 | fnode->len = len; |
| 180 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
| 181 | fnode->up = dir->i_ino; |
| 182 | mark_buffer_dirty(bh); |
| 183 | brelse(bh); |
| 184 | |
| 185 | insert_inode_hash(result); |
| 186 | |
David Howells | de395b8 | 2008-11-14 10:38:55 +1100 | [diff] [blame] | 187 | if (result->i_uid != current_fsuid() || |
| 188 | result->i_gid != current_fsgid() || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | result->i_mode != (mode | S_IFREG)) { |
David Howells | de395b8 | 2008-11-14 10:38:55 +1100 | [diff] [blame] | 190 | result->i_uid = current_fsuid(); |
| 191 | result->i_gid = current_fsgid(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | result->i_mode = mode | S_IFREG; |
| 193 | hpfs_write_inode_nolock(result); |
| 194 | } |
| 195 | d_instantiate(dentry, result); |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 196 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 197 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | return 0; |
| 199 | |
| 200 | bail2: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 201 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | iput(result); |
| 203 | bail1: |
| 204 | brelse(bh); |
| 205 | hpfs_free_sectors(dir->i_sb, fno, 1); |
| 206 | bail: |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 207 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | return err; |
| 209 | } |
| 210 | |
| 211 | static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) |
| 212 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 213 | const unsigned char *name = dentry->d_name.name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | unsigned len = dentry->d_name.len; |
| 215 | struct buffer_head *bh; |
| 216 | struct fnode *fnode; |
| 217 | fnode_secno fno; |
| 218 | int r; |
| 219 | struct hpfs_dirent dee; |
| 220 | struct inode *result = NULL; |
| 221 | int err; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 222 | if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM; |
| 224 | if (!new_valid_dev(rdev)) |
| 225 | return -EINVAL; |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 226 | hpfs_lock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | err = -ENOSPC; |
| 228 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
| 229 | if (!fnode) |
| 230 | goto bail; |
| 231 | memset(&dee, 0, sizeof dee); |
| 232 | if (!(mode & 0222)) dee.read_only = 1; |
| 233 | dee.archive = 1; |
| 234 | dee.hidden = name[0] == '.'; |
| 235 | dee.fnode = fno; |
| 236 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); |
| 237 | |
| 238 | result = new_inode(dir->i_sb); |
| 239 | if (!result) |
| 240 | goto bail1; |
| 241 | |
| 242 | hpfs_init_inode(result); |
| 243 | result->i_ino = fno; |
| 244 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
| 245 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); |
| 246 | result->i_ctime.tv_nsec = 0; |
| 247 | result->i_mtime.tv_nsec = 0; |
| 248 | result->i_atime.tv_nsec = 0; |
| 249 | hpfs_i(result)->i_ea_size = 0; |
David Howells | de395b8 | 2008-11-14 10:38:55 +1100 | [diff] [blame] | 250 | result->i_uid = current_fsuid(); |
| 251 | result->i_gid = current_fsgid(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | result->i_nlink = 1; |
| 253 | result->i_size = 0; |
| 254 | result->i_blocks = 1; |
| 255 | init_special_inode(result, mode, rdev); |
| 256 | |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 257 | mutex_lock(&hpfs_i(dir)->i_mutex); |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 258 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | if (r == 1) |
| 260 | goto bail2; |
| 261 | if (r == -1) { |
| 262 | err = -EEXIST; |
| 263 | goto bail2; |
| 264 | } |
| 265 | fnode->len = len; |
| 266 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
| 267 | fnode->up = dir->i_ino; |
| 268 | mark_buffer_dirty(bh); |
| 269 | |
| 270 | insert_inode_hash(result); |
| 271 | |
| 272 | hpfs_write_inode_nolock(result); |
| 273 | d_instantiate(dentry, result); |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 274 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | brelse(bh); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 276 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | return 0; |
| 278 | bail2: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 279 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | iput(result); |
| 281 | bail1: |
| 282 | brelse(bh); |
| 283 | hpfs_free_sectors(dir->i_sb, fno, 1); |
| 284 | bail: |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 285 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | return err; |
| 287 | } |
| 288 | |
| 289 | static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink) |
| 290 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 291 | const unsigned char *name = dentry->d_name.name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | unsigned len = dentry->d_name.len; |
| 293 | struct buffer_head *bh; |
| 294 | struct fnode *fnode; |
| 295 | fnode_secno fno; |
| 296 | int r; |
| 297 | struct hpfs_dirent dee; |
| 298 | struct inode *result; |
| 299 | int err; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 300 | if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 301 | hpfs_lock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | if (hpfs_sb(dir->i_sb)->sb_eas < 2) { |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 303 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | return -EPERM; |
| 305 | } |
| 306 | err = -ENOSPC; |
| 307 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
| 308 | if (!fnode) |
| 309 | goto bail; |
| 310 | memset(&dee, 0, sizeof dee); |
| 311 | dee.archive = 1; |
| 312 | dee.hidden = name[0] == '.'; |
| 313 | dee.fnode = fno; |
| 314 | dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); |
| 315 | |
| 316 | result = new_inode(dir->i_sb); |
| 317 | if (!result) |
| 318 | goto bail1; |
| 319 | result->i_ino = fno; |
| 320 | hpfs_init_inode(result); |
| 321 | hpfs_i(result)->i_parent_dir = dir->i_ino; |
| 322 | result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); |
| 323 | result->i_ctime.tv_nsec = 0; |
| 324 | result->i_mtime.tv_nsec = 0; |
| 325 | result->i_atime.tv_nsec = 0; |
| 326 | hpfs_i(result)->i_ea_size = 0; |
| 327 | result->i_mode = S_IFLNK | 0777; |
David Howells | de395b8 | 2008-11-14 10:38:55 +1100 | [diff] [blame] | 328 | result->i_uid = current_fsuid(); |
| 329 | result->i_gid = current_fsgid(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | result->i_blocks = 1; |
| 331 | result->i_nlink = 1; |
| 332 | result->i_size = strlen(symlink); |
| 333 | result->i_op = &page_symlink_inode_operations; |
| 334 | result->i_data.a_ops = &hpfs_symlink_aops; |
| 335 | |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 336 | mutex_lock(&hpfs_i(dir)->i_mutex); |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 337 | r = hpfs_add_dirent(dir, name, len, &dee, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | if (r == 1) |
| 339 | goto bail2; |
| 340 | if (r == -1) { |
| 341 | err = -EEXIST; |
| 342 | goto bail2; |
| 343 | } |
| 344 | fnode->len = len; |
| 345 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
| 346 | fnode->up = dir->i_ino; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 347 | hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | mark_buffer_dirty(bh); |
| 349 | brelse(bh); |
| 350 | |
| 351 | insert_inode_hash(result); |
| 352 | |
| 353 | hpfs_write_inode_nolock(result); |
| 354 | d_instantiate(dentry, result); |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 355 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 356 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | return 0; |
| 358 | bail2: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 359 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | iput(result); |
| 361 | bail1: |
| 362 | brelse(bh); |
| 363 | hpfs_free_sectors(dir->i_sb, fno, 1); |
| 364 | bail: |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 365 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | return err; |
| 367 | } |
| 368 | |
| 369 | static int hpfs_unlink(struct inode *dir, struct dentry *dentry) |
| 370 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 371 | const unsigned char *name = dentry->d_name.name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | unsigned len = dentry->d_name.len; |
| 373 | struct quad_buffer_head qbh; |
| 374 | struct hpfs_dirent *de; |
| 375 | struct inode *inode = dentry->d_inode; |
| 376 | dnode_secno dno; |
| 377 | fnode_secno fno; |
| 378 | int r; |
| 379 | int rep = 0; |
| 380 | int err; |
| 381 | |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 382 | hpfs_lock(dir->i_sb); |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 383 | hpfs_adjust_length(name, &len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | again: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 385 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); |
| 386 | mutex_lock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | err = -ENOENT; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 388 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | if (!de) |
| 390 | goto out; |
| 391 | |
| 392 | err = -EPERM; |
| 393 | if (de->first) |
| 394 | goto out1; |
| 395 | |
| 396 | err = -EISDIR; |
| 397 | if (de->directory) |
| 398 | goto out1; |
| 399 | |
| 400 | fno = de->fnode; |
| 401 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); |
| 402 | switch (r) { |
| 403 | case 1: |
| 404 | hpfs_error(dir->i_sb, "there was error when removing dirent"); |
| 405 | err = -EFSERROR; |
| 406 | break; |
| 407 | case 2: /* no space for deleting, try to truncate file */ |
| 408 | |
| 409 | err = -ENOSPC; |
| 410 | if (rep++) |
| 411 | break; |
| 412 | |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 413 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
| 414 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); |
Al Viro | e21e709 | 2010-02-01 11:05:16 -0500 | [diff] [blame] | 415 | dentry_unhash(dentry); |
| 416 | if (!d_unhashed(dentry)) { |
| 417 | dput(dentry); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 418 | hpfs_unlock(dir->i_sb); |
Al Viro | e21e709 | 2010-02-01 11:05:16 -0500 | [diff] [blame] | 419 | return -ENOSPC; |
| 420 | } |
Nick Piggin | b74c79e | 2011-01-07 17:49:58 +1100 | [diff] [blame] | 421 | if (generic_permission(inode, MAY_WRITE, 0, NULL) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | !S_ISREG(inode->i_mode) || |
| 423 | get_write_access(inode)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | d_rehash(dentry); |
Al Viro | e21e709 | 2010-02-01 11:05:16 -0500 | [diff] [blame] | 425 | dput(dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | } else { |
| 427 | struct iattr newattrs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | /*printk("HPFS: truncating file before delete.\n");*/ |
| 429 | newattrs.ia_size = 0; |
| 430 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; |
| 431 | err = notify_change(dentry, &newattrs); |
| 432 | put_write_access(inode); |
Al Viro | e21e709 | 2010-02-01 11:05:16 -0500 | [diff] [blame] | 433 | dput(dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | if (!err) |
| 435 | goto again; |
| 436 | } |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 437 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | return -ENOSPC; |
| 439 | default: |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 440 | drop_nlink(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | err = 0; |
| 442 | } |
| 443 | goto out; |
| 444 | |
| 445 | out1: |
| 446 | hpfs_brelse4(&qbh); |
| 447 | out: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 448 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
| 449 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 450 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | return err; |
| 452 | } |
| 453 | |
| 454 | static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) |
| 455 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 456 | const unsigned char *name = dentry->d_name.name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | unsigned len = dentry->d_name.len; |
| 458 | struct quad_buffer_head qbh; |
| 459 | struct hpfs_dirent *de; |
| 460 | struct inode *inode = dentry->d_inode; |
| 461 | dnode_secno dno; |
| 462 | fnode_secno fno; |
| 463 | int n_items = 0; |
| 464 | int err; |
| 465 | int r; |
| 466 | |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 467 | hpfs_adjust_length(name, &len); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 468 | hpfs_lock(dir->i_sb); |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 469 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); |
| 470 | mutex_lock(&hpfs_i(dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | err = -ENOENT; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 472 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | if (!de) |
| 474 | goto out; |
| 475 | |
| 476 | err = -EPERM; |
| 477 | if (de->first) |
| 478 | goto out1; |
| 479 | |
| 480 | err = -ENOTDIR; |
| 481 | if (!de->directory) |
| 482 | goto out1; |
| 483 | |
| 484 | hpfs_count_dnodes(dir->i_sb, hpfs_i(inode)->i_dno, NULL, NULL, &n_items); |
| 485 | err = -ENOTEMPTY; |
| 486 | if (n_items) |
| 487 | goto out1; |
| 488 | |
| 489 | fno = de->fnode; |
| 490 | r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); |
| 491 | switch (r) { |
| 492 | case 1: |
| 493 | hpfs_error(dir->i_sb, "there was error when removing dirent"); |
| 494 | err = -EFSERROR; |
| 495 | break; |
| 496 | case 2: |
| 497 | err = -ENOSPC; |
| 498 | break; |
| 499 | default: |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 500 | drop_nlink(dir); |
Dave Hansen | ce71ec3 | 2006-09-30 23:29:06 -0700 | [diff] [blame] | 501 | clear_nlink(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | err = 0; |
| 503 | } |
| 504 | goto out; |
| 505 | out1: |
| 506 | hpfs_brelse4(&qbh); |
| 507 | out: |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 508 | mutex_unlock(&hpfs_i(dir)->i_mutex); |
| 509 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 510 | hpfs_unlock(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | return err; |
| 512 | } |
| 513 | |
| 514 | static int hpfs_symlink_readpage(struct file *file, struct page *page) |
| 515 | { |
| 516 | char *link = kmap(page); |
| 517 | struct inode *i = page->mapping->host; |
| 518 | struct fnode *fnode; |
| 519 | struct buffer_head *bh; |
| 520 | int err; |
| 521 | |
| 522 | err = -EIO; |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 523 | hpfs_lock(i->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) |
| 525 | goto fail; |
| 526 | err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE); |
| 527 | brelse(bh); |
| 528 | if (err) |
| 529 | goto fail; |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 530 | hpfs_unlock(i->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | SetPageUptodate(page); |
| 532 | kunmap(page); |
| 533 | unlock_page(page); |
| 534 | return 0; |
| 535 | |
| 536 | fail: |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 537 | hpfs_unlock(i->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | SetPageError(page); |
| 539 | kunmap(page); |
| 540 | unlock_page(page); |
| 541 | return err; |
| 542 | } |
| 543 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 544 | const struct address_space_operations hpfs_symlink_aops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | .readpage = hpfs_symlink_readpage |
| 546 | }; |
| 547 | |
| 548 | static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 549 | struct inode *new_dir, struct dentry *new_dentry) |
| 550 | { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 551 | const unsigned char *old_name = old_dentry->d_name.name; |
| 552 | unsigned old_len = old_dentry->d_name.len; |
| 553 | const unsigned char *new_name = new_dentry->d_name.name; |
| 554 | unsigned new_len = new_dentry->d_name.len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | struct inode *i = old_dentry->d_inode; |
| 556 | struct inode *new_inode = new_dentry->d_inode; |
| 557 | struct quad_buffer_head qbh, qbh1; |
| 558 | struct hpfs_dirent *dep, *nde; |
| 559 | struct hpfs_dirent de; |
| 560 | dnode_secno dno; |
| 561 | int r; |
| 562 | struct buffer_head *bh; |
| 563 | struct fnode *fnode; |
| 564 | int err; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 565 | if ((err = hpfs_chk_name(new_name, &new_len))) return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | err = 0; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 567 | hpfs_adjust_length(old_name, &old_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 569 | hpfs_lock(i->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | /* order doesn't matter, due to VFS exclusion */ |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 571 | mutex_lock(&hpfs_i(i)->i_parent_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | if (new_inode) |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 573 | mutex_lock(&hpfs_i(new_inode)->i_parent_mutex); |
| 574 | mutex_lock(&hpfs_i(old_dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | if (new_dir != old_dir) |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 576 | mutex_lock(&hpfs_i(new_dir)->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
| 578 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ |
| 579 | if (new_inode && S_ISDIR(new_inode->i_mode)) { |
| 580 | err = -EINVAL; |
| 581 | goto end1; |
| 582 | } |
| 583 | |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 584 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed"); |
| 586 | err = -ENOENT; |
| 587 | goto end1; |
| 588 | } |
| 589 | copy_de(&de, dep); |
| 590 | de.hidden = new_name[0] == '.'; |
| 591 | |
| 592 | if (new_inode) { |
| 593 | int r; |
| 594 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) { |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 595 | if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, new_name, new_len, NULL, &qbh1))) { |
Dave Hansen | ce71ec3 | 2006-09-30 23:29:06 -0700 | [diff] [blame] | 596 | clear_nlink(new_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | copy_de(nde, &de); |
| 598 | memcpy(nde->name, new_name, new_len); |
| 599 | hpfs_mark_4buffers_dirty(&qbh1); |
| 600 | hpfs_brelse4(&qbh1); |
| 601 | goto end; |
| 602 | } |
| 603 | hpfs_error(new_dir->i_sb, "hpfs_rename: could not find dirent"); |
| 604 | err = -EFSERROR; |
| 605 | goto end1; |
| 606 | } |
| 607 | err = r == 2 ? -ENOSPC : r == 1 ? -EFSERROR : 0; |
| 608 | goto end1; |
| 609 | } |
| 610 | |
| 611 | if (new_dir == old_dir) hpfs_brelse4(&qbh); |
| 612 | |
| 613 | hpfs_lock_creation(i->i_sb); |
| 614 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de, 1))) { |
| 615 | hpfs_unlock_creation(i->i_sb); |
| 616 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); |
| 617 | err = r == 1 ? -ENOSPC : -EFSERROR; |
| 618 | if (new_dir != old_dir) hpfs_brelse4(&qbh); |
| 619 | goto end1; |
| 620 | } |
| 621 | |
| 622 | if (new_dir == old_dir) |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 623 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | hpfs_unlock_creation(i->i_sb); |
| 625 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); |
| 626 | err = -ENOENT; |
| 627 | goto end1; |
| 628 | } |
| 629 | |
| 630 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { |
| 631 | hpfs_unlock_creation(i->i_sb); |
| 632 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); |
| 633 | err = r == 2 ? -ENOSPC : -EFSERROR; |
| 634 | goto end1; |
| 635 | } |
| 636 | hpfs_unlock_creation(i->i_sb); |
| 637 | |
| 638 | end: |
| 639 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; |
| 640 | if (S_ISDIR(i->i_mode)) { |
Dave Hansen | d8c76e6 | 2006-09-30 23:29:04 -0700 | [diff] [blame] | 641 | inc_nlink(new_dir); |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 642 | drop_nlink(old_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | } |
| 644 | if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { |
| 645 | fnode->up = new_dir->i_ino; |
| 646 | fnode->len = new_len; |
| 647 | memcpy(fnode->name, new_name, new_len>15?15:new_len); |
| 648 | if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); |
| 649 | mark_buffer_dirty(bh); |
| 650 | brelse(bh); |
| 651 | } |
| 652 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; |
Al Viro | 7e7742e | 2010-01-31 17:09:29 -0500 | [diff] [blame] | 653 | hpfs_decide_conv(i, new_name, new_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | end1: |
| 655 | if (old_dir != new_dir) |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 656 | mutex_unlock(&hpfs_i(new_dir)->i_mutex); |
| 657 | mutex_unlock(&hpfs_i(old_dir)->i_mutex); |
| 658 | mutex_unlock(&hpfs_i(i)->i_parent_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | if (new_inode) |
Ingo Molnar | 7bf6d78 | 2006-03-23 03:00:42 -0800 | [diff] [blame] | 660 | mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); |
Arnd Bergmann | 9a311b9 | 2011-01-22 20:26:12 +0100 | [diff] [blame] | 661 | hpfs_unlock(i->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | return err; |
| 663 | } |
| 664 | |
Arjan van de Ven | 92e1d5b | 2007-02-12 00:55:39 -0800 | [diff] [blame] | 665 | const struct inode_operations hpfs_dir_iops = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | { |
| 667 | .create = hpfs_create, |
| 668 | .lookup = hpfs_lookup, |
| 669 | .unlink = hpfs_unlink, |
| 670 | .symlink = hpfs_symlink, |
| 671 | .mkdir = hpfs_mkdir, |
| 672 | .rmdir = hpfs_rmdir, |
| 673 | .mknod = hpfs_mknod, |
| 674 | .rename = hpfs_rename, |
Christoph Hellwig | ca30bc9 | 2008-08-11 00:27:59 +0200 | [diff] [blame] | 675 | .setattr = hpfs_setattr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | }; |