This source file includes following definitions.
- bin_search_in_dir_item
- set_de_item_location
- set_de_name_and_namelen
- set_de_object_key
- store_de_entry_key
- search_by_entry_key
- get_third_component
- reiserfs_match
- linear_search_in_dir_item
- reiserfs_find_entry
- reiserfs_lookup
- reiserfs_get_parent
- reiserfs_add_entry
- drop_new_inode
- new_inode_init
- reiserfs_create
- reiserfs_mknod
- reiserfs_mkdir
- reiserfs_empty_dir
- reiserfs_rmdir
- reiserfs_unlink
- reiserfs_symlink
- reiserfs_link
- de_still_valid
- entry_points_to_object
- set_ino_in_dir_entry
- reiserfs_rename
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include <linux/time.h>
15 #include <linux/bitops.h>
16 #include <linux/slab.h>
17 #include "reiserfs.h"
18 #include "acl.h"
19 #include "xattr.h"
20 #include <linux/quotaops.h>
21
22 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
23 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
24
25
26
27
28
29 static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
30 {
31 struct item_head *ih = de->de_ih;
32 struct reiserfs_de_head *deh = de->de_deh;
33 int rbound, lbound, j;
34
35 lbound = 0;
36 rbound = ih_entry_count(ih) - 1;
37
38 for (j = (rbound + lbound) / 2; lbound <= rbound;
39 j = (rbound + lbound) / 2) {
40 if (off < deh_offset(deh + j)) {
41 rbound = j - 1;
42 continue;
43 }
44 if (off > deh_offset(deh + j)) {
45 lbound = j + 1;
46 continue;
47 }
48
49 de->de_entry_num = j;
50 return NAME_FOUND;
51 }
52
53 de->de_entry_num = lbound;
54 return NAME_NOT_FOUND;
55 }
56
57
58
59
60 static inline void set_de_item_location(struct reiserfs_dir_entry *de,
61 struct treepath *path)
62 {
63 de->de_bh = get_last_bh(path);
64 de->de_ih = tp_item_head(path);
65 de->de_deh = B_I_DEH(de->de_bh, de->de_ih);
66 de->de_item_num = PATH_LAST_POSITION(path);
67 }
68
69
70
71
72 inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
73 {
74 struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
75
76 BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
77
78 de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num);
79 de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0);
80 de->de_name = ih_item_body(de->de_bh, de->de_ih) + deh_location(deh);
81 if (de->de_name[de->de_namelen - 1] == 0)
82 de->de_namelen = strlen(de->de_name);
83 }
84
85
86 static inline void set_de_object_key(struct reiserfs_dir_entry *de)
87 {
88 BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
89 de->de_dir_id = deh_dir_id(&de->de_deh[de->de_entry_num]);
90 de->de_objectid = deh_objectid(&de->de_deh[de->de_entry_num]);
91 }
92
93 static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
94 {
95 struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
96
97 BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih));
98
99
100 de->de_entry_key.version = KEY_FORMAT_3_5;
101 de->de_entry_key.on_disk_key.k_dir_id =
102 le32_to_cpu(de->de_ih->ih_key.k_dir_id);
103 de->de_entry_key.on_disk_key.k_objectid =
104 le32_to_cpu(de->de_ih->ih_key.k_objectid);
105 set_cpu_key_k_offset(&de->de_entry_key, deh_offset(deh));
106 set_cpu_key_k_type(&de->de_entry_key, TYPE_DIRENTRY);
107 }
108
109
110
111
112
113
114
115
116
117
118
119
120 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
121 struct treepath *path, struct reiserfs_dir_entry *de)
122 {
123 int retval;
124
125 retval = search_item(sb, key, path);
126 switch (retval) {
127 case ITEM_NOT_FOUND:
128 if (!PATH_LAST_POSITION(path)) {
129 reiserfs_error(sb, "vs-7000", "search_by_key "
130 "returned item position == 0");
131 pathrelse(path);
132 return IO_ERROR;
133 }
134 PATH_LAST_POSITION(path)--;
135
136 case ITEM_FOUND:
137 break;
138
139 case IO_ERROR:
140 return retval;
141
142 default:
143 pathrelse(path);
144 reiserfs_error(sb, "vs-7002", "no path to here");
145 return IO_ERROR;
146 }
147
148 set_de_item_location(de, path);
149
150 #ifdef CONFIG_REISERFS_CHECK
151 if (!is_direntry_le_ih(de->de_ih) ||
152 COMP_SHORT_KEYS(&de->de_ih->ih_key, key)) {
153 print_block(de->de_bh, 0, -1, -1);
154 reiserfs_panic(sb, "vs-7005", "found item %h is not directory "
155 "item or does not belong to the same directory "
156 "as key %K", de->de_ih, key);
157 }
158 #endif
159
160
161
162
163
164 retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
165 path->pos_in_item = de->de_entry_num;
166 if (retval != NAME_NOT_FOUND) {
167
168
169
170
171 set_de_name_and_namelen(de);
172 set_de_object_key(de);
173 }
174 return retval;
175 }
176
177
178
179
180
181
182
183
184
185 static __u32 get_third_component(struct super_block *s,
186 const char *name, int len)
187 {
188 __u32 res;
189
190 if (!len || (len == 1 && name[0] == '.'))
191 return DOT_OFFSET;
192 if (len == 2 && name[0] == '.' && name[1] == '.')
193 return DOT_DOT_OFFSET;
194
195 res = REISERFS_SB(s)->s_hash_function(name, len);
196
197
198 res = GET_HASH_VALUE(res);
199 if (res == 0)
200
201
202
203
204 res = 128;
205 return res + MAX_GENERATION_NUMBER;
206 }
207
208 static int reiserfs_match(struct reiserfs_dir_entry *de,
209 const char *name, int namelen)
210 {
211 int retval = NAME_NOT_FOUND;
212
213 if ((namelen == de->de_namelen) &&
214 !memcmp(de->de_name, name, de->de_namelen))
215 retval =
216 (de_visible(de->de_deh + de->de_entry_num) ? NAME_FOUND :
217 NAME_FOUND_INVISIBLE);
218
219 return retval;
220 }
221
222
223
224
225
226 static int linear_search_in_dir_item(struct cpu_key *key,
227 struct reiserfs_dir_entry *de,
228 const char *name, int namelen)
229 {
230 struct reiserfs_de_head *deh = de->de_deh;
231 int retval;
232 int i;
233
234 i = de->de_entry_num;
235
236 if (i == ih_entry_count(de->de_ih) ||
237 GET_HASH_VALUE(deh_offset(deh + i)) !=
238 GET_HASH_VALUE(cpu_key_k_offset(key))) {
239 i--;
240 }
241
242 RFALSE(de->de_deh != B_I_DEH(de->de_bh, de->de_ih),
243 "vs-7010: array of entry headers not found");
244
245 deh += i;
246
247 for (; i >= 0; i--, deh--) {
248
249 if (GET_HASH_VALUE(deh_offset(deh)) !=
250 GET_HASH_VALUE(cpu_key_k_offset(key))) {
251 return NAME_NOT_FOUND;
252 }
253
254
255 if (de->de_gen_number_bit_string)
256 set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
257 de->de_gen_number_bit_string);
258
259
260 de->de_entry_num = i;
261 set_de_name_and_namelen(de);
262
263
264
265
266
267 if ((retval =
268 reiserfs_match(de, name, namelen)) != NAME_NOT_FOUND) {
269
270
271 set_de_object_key(de);
272
273 store_de_entry_key(de);
274
275
276 return retval;
277 }
278 }
279
280 if (GET_GENERATION_NUMBER(le_ih_k_offset(de->de_ih)) == 0)
281
282
283
284
285
286
287
288
289
290
291
292 return NAME_NOT_FOUND;
293
294 RFALSE(de->de_item_num,
295 "vs-7015: two diritems of the same directory in one node?");
296
297 return GOTO_PREVIOUS_ITEM;
298 }
299
300
301
302
303
304 static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
305 struct treepath *path_to_entry,
306 struct reiserfs_dir_entry *de)
307 {
308 struct cpu_key key_to_search;
309 int retval;
310
311 if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
312 return NAME_NOT_FOUND;
313
314
315 make_cpu_key(&key_to_search, dir,
316 get_third_component(dir->i_sb, name, namelen),
317 TYPE_DIRENTRY, 3);
318
319 while (1) {
320 retval =
321 search_by_entry_key(dir->i_sb, &key_to_search,
322 path_to_entry, de);
323 if (retval == IO_ERROR) {
324 reiserfs_error(dir->i_sb, "zam-7001", "io error");
325 return IO_ERROR;
326 }
327
328
329 retval =
330 linear_search_in_dir_item(&key_to_search, de, name,
331 namelen);
332
333
334
335
336 if (retval != GOTO_PREVIOUS_ITEM) {
337 path_to_entry->pos_in_item = de->de_entry_num;
338 return retval;
339 }
340
341
342
343
344
345 set_cpu_key_k_offset(&key_to_search,
346 le_ih_k_offset(de->de_ih) - 1);
347 pathrelse(path_to_entry);
348
349 }
350 }
351
352 static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
353 unsigned int flags)
354 {
355 int retval;
356 struct inode *inode = NULL;
357 struct reiserfs_dir_entry de;
358 INITIALIZE_PATH(path_to_entry);
359
360 if (REISERFS_MAX_NAME(dir->i_sb->s_blocksize) < dentry->d_name.len)
361 return ERR_PTR(-ENAMETOOLONG);
362
363 reiserfs_write_lock(dir->i_sb);
364
365 de.de_gen_number_bit_string = NULL;
366 retval =
367 reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
368 &path_to_entry, &de);
369 pathrelse(&path_to_entry);
370 if (retval == NAME_FOUND) {
371 inode = reiserfs_iget(dir->i_sb,
372 (struct cpu_key *)&de.de_dir_id);
373 if (!inode || IS_ERR(inode)) {
374 reiserfs_write_unlock(dir->i_sb);
375 return ERR_PTR(-EACCES);
376 }
377
378
379
380
381
382
383 if (IS_PRIVATE(dir)) {
384 inode->i_flags |= S_PRIVATE;
385 inode->i_opflags &= ~IOP_XATTR;
386 }
387 }
388 reiserfs_write_unlock(dir->i_sb);
389 if (retval == IO_ERROR) {
390 return ERR_PTR(-EIO);
391 }
392
393 return d_splice_alias(inode, dentry);
394 }
395
396
397
398
399
400 struct dentry *reiserfs_get_parent(struct dentry *child)
401 {
402 int retval;
403 struct inode *inode = NULL;
404 struct reiserfs_dir_entry de;
405 INITIALIZE_PATH(path_to_entry);
406 struct inode *dir = d_inode(child);
407
408 if (dir->i_nlink == 0) {
409 return ERR_PTR(-ENOENT);
410 }
411 de.de_gen_number_bit_string = NULL;
412
413 reiserfs_write_lock(dir->i_sb);
414 retval = reiserfs_find_entry(dir, "..", 2, &path_to_entry, &de);
415 pathrelse(&path_to_entry);
416 if (retval != NAME_FOUND) {
417 reiserfs_write_unlock(dir->i_sb);
418 return ERR_PTR(-ENOENT);
419 }
420 inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&de.de_dir_id);
421 reiserfs_write_unlock(dir->i_sb);
422
423 return d_obtain_alias(inode);
424 }
425
426
427
428
429
430
431
432 static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
433 struct inode *dir, const char *name, int namelen,
434 struct inode *inode, int visible)
435 {
436 struct cpu_key entry_key;
437 struct reiserfs_de_head *deh;
438 INITIALIZE_PATH(path);
439 struct reiserfs_dir_entry de;
440 DECLARE_BITMAP(bit_string, MAX_GENERATION_NUMBER + 1);
441 int gen_number;
442
443
444
445
446
447 char small_buf[32 + DEH_SIZE];
448
449 char *buffer;
450 int buflen, paste_size;
451 int retval;
452
453 BUG_ON(!th->t_trans_id);
454
455
456 if (!namelen)
457 return -EINVAL;
458
459 if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
460 return -ENAMETOOLONG;
461
462
463 make_cpu_key(&entry_key, dir,
464 get_third_component(dir->i_sb, name, namelen),
465 TYPE_DIRENTRY, 3);
466
467
468 buflen = DEH_SIZE + ROUND_UP(namelen);
469 if (buflen > sizeof(small_buf)) {
470 buffer = kmalloc(buflen, GFP_NOFS);
471 if (!buffer)
472 return -ENOMEM;
473 } else
474 buffer = small_buf;
475
476 paste_size =
477 (get_inode_sd_version(dir) ==
478 STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
479
480
481
482
483
484 deh = (struct reiserfs_de_head *)buffer;
485 deh->deh_location = 0;
486 put_deh_offset(deh, cpu_key_k_offset(&entry_key));
487 deh->deh_state = 0;
488
489
490
491 deh->deh_dir_id = INODE_PKEY(inode)->k_dir_id;
492
493 deh->deh_objectid = INODE_PKEY(inode)->k_objectid;
494
495
496 memcpy((char *)(deh + 1), name, namelen);
497
498 padd_item((char *)(deh + 1), ROUND_UP(namelen), namelen);
499
500
501
502
503
504 mark_de_without_sd(deh);
505 visible ? mark_de_visible(deh) : mark_de_hidden(deh);
506
507
508 memset(bit_string, 0, sizeof(bit_string));
509 de.de_gen_number_bit_string = bit_string;
510 retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
511 if (retval != NAME_NOT_FOUND) {
512 if (buffer != small_buf)
513 kfree(buffer);
514 pathrelse(&path);
515
516 if (retval == IO_ERROR) {
517 return -EIO;
518 }
519
520 if (retval != NAME_FOUND) {
521 reiserfs_error(dir->i_sb, "zam-7002",
522 "reiserfs_find_entry() returned "
523 "unexpected value (%d)", retval);
524 }
525
526 return -EEXIST;
527 }
528
529 gen_number =
530 find_first_zero_bit(bit_string,
531 MAX_GENERATION_NUMBER + 1);
532 if (gen_number > MAX_GENERATION_NUMBER) {
533
534 reiserfs_warning(dir->i_sb, "reiserfs-7010",
535 "Congratulations! we have got hash function "
536 "screwed up");
537 if (buffer != small_buf)
538 kfree(buffer);
539 pathrelse(&path);
540 return -EBUSY;
541 }
542
543 put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
544 set_cpu_key_k_offset(&entry_key, deh_offset(deh));
545
546
547 PROC_INFO_MAX(th->t_super, max_hash_collisions, gen_number);
548
549
550 if (gen_number != 0) {
551 if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
552 NAME_NOT_FOUND) {
553 reiserfs_warning(dir->i_sb, "vs-7032",
554 "entry with this key (%K) already "
555 "exists", &entry_key);
556
557 if (buffer != small_buf)
558 kfree(buffer);
559 pathrelse(&path);
560 return -EBUSY;
561 }
562 }
563
564
565 retval =
566 reiserfs_paste_into_item(th, &path, &entry_key, dir, buffer,
567 paste_size);
568 if (buffer != small_buf)
569 kfree(buffer);
570 if (retval) {
571 reiserfs_check_path(&path);
572 return retval;
573 }
574
575 dir->i_size += paste_size;
576 dir->i_mtime = dir->i_ctime = current_time(dir);
577 if (!S_ISDIR(inode->i_mode) && visible)
578
579 reiserfs_update_sd(th, dir);
580
581 reiserfs_check_path(&path);
582 return 0;
583 }
584
585
586
587
588
589
590
591 static int drop_new_inode(struct inode *inode)
592 {
593 dquot_drop(inode);
594 make_bad_inode(inode);
595 inode->i_flags |= S_NOQUOTA;
596 iput(inode);
597 return 0;
598 }
599
600
601
602
603
604
605
606 static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
607 {
608
609
610
611
612 INODE_PKEY(inode)->k_objectid = 0;
613
614
615
616
617
618 inode_init_owner(inode, dir, mode);
619 return dquot_initialize(inode);
620 }
621
622 static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
623 bool excl)
624 {
625 int retval;
626 struct inode *inode;
627
628
629
630
631 int jbegin_count =
632 JOURNAL_PER_BALANCE_CNT * 2 +
633 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
634 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
635 struct reiserfs_transaction_handle th;
636 struct reiserfs_security_handle security;
637
638 retval = dquot_initialize(dir);
639 if (retval)
640 return retval;
641
642 if (!(inode = new_inode(dir->i_sb))) {
643 return -ENOMEM;
644 }
645 retval = new_inode_init(inode, dir, mode);
646 if (retval) {
647 drop_new_inode(inode);
648 return retval;
649 }
650
651 jbegin_count += reiserfs_cache_default_acl(dir);
652 retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security);
653 if (retval < 0) {
654 drop_new_inode(inode);
655 return retval;
656 }
657 jbegin_count += retval;
658 reiserfs_write_lock(dir->i_sb);
659
660 retval = journal_begin(&th, dir->i_sb, jbegin_count);
661 if (retval) {
662 drop_new_inode(inode);
663 goto out_failed;
664 }
665
666 retval =
667 reiserfs_new_inode(&th, dir, mode, NULL, 0 , dentry,
668 inode, &security);
669 if (retval)
670 goto out_failed;
671
672 inode->i_op = &reiserfs_file_inode_operations;
673 inode->i_fop = &reiserfs_file_operations;
674 inode->i_mapping->a_ops = &reiserfs_address_space_operations;
675
676 retval =
677 reiserfs_add_entry(&th, dir, dentry->d_name.name,
678 dentry->d_name.len, inode, 1 );
679 if (retval) {
680 int err;
681 drop_nlink(inode);
682 reiserfs_update_sd(&th, inode);
683 err = journal_end(&th);
684 if (err)
685 retval = err;
686 unlock_new_inode(inode);
687 iput(inode);
688 goto out_failed;
689 }
690 reiserfs_update_inode_transaction(inode);
691 reiserfs_update_inode_transaction(dir);
692
693 d_instantiate_new(dentry, inode);
694 retval = journal_end(&th);
695
696 out_failed:
697 reiserfs_write_unlock(dir->i_sb);
698 return retval;
699 }
700
701 static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
702 dev_t rdev)
703 {
704 int retval;
705 struct inode *inode;
706 struct reiserfs_transaction_handle th;
707 struct reiserfs_security_handle security;
708
709
710
711
712 int jbegin_count =
713 JOURNAL_PER_BALANCE_CNT * 3 +
714 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
715 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
716
717 retval = dquot_initialize(dir);
718 if (retval)
719 return retval;
720
721 if (!(inode = new_inode(dir->i_sb))) {
722 return -ENOMEM;
723 }
724 retval = new_inode_init(inode, dir, mode);
725 if (retval) {
726 drop_new_inode(inode);
727 return retval;
728 }
729
730 jbegin_count += reiserfs_cache_default_acl(dir);
731 retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security);
732 if (retval < 0) {
733 drop_new_inode(inode);
734 return retval;
735 }
736 jbegin_count += retval;
737 reiserfs_write_lock(dir->i_sb);
738
739 retval = journal_begin(&th, dir->i_sb, jbegin_count);
740 if (retval) {
741 drop_new_inode(inode);
742 goto out_failed;
743 }
744
745 retval =
746 reiserfs_new_inode(&th, dir, mode, NULL, 0 , dentry,
747 inode, &security);
748 if (retval) {
749 goto out_failed;
750 }
751
752 inode->i_op = &reiserfs_special_inode_operations;
753 init_special_inode(inode, inode->i_mode, rdev);
754
755
756 reiserfs_update_sd(&th, inode);
757
758 reiserfs_update_inode_transaction(inode);
759 reiserfs_update_inode_transaction(dir);
760
761 retval =
762 reiserfs_add_entry(&th, dir, dentry->d_name.name,
763 dentry->d_name.len, inode, 1 );
764 if (retval) {
765 int err;
766 drop_nlink(inode);
767 reiserfs_update_sd(&th, inode);
768 err = journal_end(&th);
769 if (err)
770 retval = err;
771 unlock_new_inode(inode);
772 iput(inode);
773 goto out_failed;
774 }
775
776 d_instantiate_new(dentry, inode);
777 retval = journal_end(&th);
778
779 out_failed:
780 reiserfs_write_unlock(dir->i_sb);
781 return retval;
782 }
783
784 static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
785 {
786 int retval;
787 struct inode *inode;
788 struct reiserfs_transaction_handle th;
789 struct reiserfs_security_handle security;
790
791
792
793
794 int jbegin_count =
795 JOURNAL_PER_BALANCE_CNT * 3 +
796 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
797 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
798
799 retval = dquot_initialize(dir);
800 if (retval)
801 return retval;
802
803 #ifdef DISPLACE_NEW_PACKING_LOCALITIES
804
805
806
807
808 REISERFS_I(dir)->new_packing_locality = 1;
809 #endif
810 mode = S_IFDIR | mode;
811 if (!(inode = new_inode(dir->i_sb))) {
812 return -ENOMEM;
813 }
814 retval = new_inode_init(inode, dir, mode);
815 if (retval) {
816 drop_new_inode(inode);
817 return retval;
818 }
819
820 jbegin_count += reiserfs_cache_default_acl(dir);
821 retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security);
822 if (retval < 0) {
823 drop_new_inode(inode);
824 return retval;
825 }
826 jbegin_count += retval;
827 reiserfs_write_lock(dir->i_sb);
828
829 retval = journal_begin(&th, dir->i_sb, jbegin_count);
830 if (retval) {
831 drop_new_inode(inode);
832 goto out_failed;
833 }
834
835
836
837
838
839 INC_DIR_INODE_NLINK(dir)
840
841 retval = reiserfs_new_inode(&th, dir, mode, NULL ,
842 old_format_only(dir->i_sb) ?
843 EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
844 dentry, inode, &security);
845 if (retval) {
846 DEC_DIR_INODE_NLINK(dir)
847 goto out_failed;
848 }
849
850 reiserfs_update_inode_transaction(inode);
851 reiserfs_update_inode_transaction(dir);
852
853 inode->i_op = &reiserfs_dir_inode_operations;
854 inode->i_fop = &reiserfs_dir_operations;
855
856
857 retval =
858 reiserfs_add_entry(&th, dir, dentry->d_name.name,
859 dentry->d_name.len, inode, 1 );
860 if (retval) {
861 int err;
862 clear_nlink(inode);
863 DEC_DIR_INODE_NLINK(dir);
864 reiserfs_update_sd(&th, inode);
865 err = journal_end(&th);
866 if (err)
867 retval = err;
868 unlock_new_inode(inode);
869 iput(inode);
870 goto out_failed;
871 }
872
873 reiserfs_update_sd(&th, dir);
874
875 d_instantiate_new(dentry, inode);
876 retval = journal_end(&th);
877 out_failed:
878 reiserfs_write_unlock(dir->i_sb);
879 return retval;
880 }
881
882 static inline int reiserfs_empty_dir(struct inode *inode)
883 {
884
885
886
887
888
889
890 if (inode->i_size != EMPTY_DIR_SIZE &&
891 inode->i_size != EMPTY_DIR_SIZE_V1) {
892 return 0;
893 }
894 return 1;
895 }
896
897 static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
898 {
899 int retval, err;
900 struct inode *inode;
901 struct reiserfs_transaction_handle th;
902 int jbegin_count;
903 INITIALIZE_PATH(path);
904 struct reiserfs_dir_entry de;
905
906
907
908
909
910
911
912 jbegin_count =
913 JOURNAL_PER_BALANCE_CNT * 2 + 2 +
914 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
915
916 retval = dquot_initialize(dir);
917 if (retval)
918 return retval;
919
920 reiserfs_write_lock(dir->i_sb);
921 retval = journal_begin(&th, dir->i_sb, jbegin_count);
922 if (retval)
923 goto out_rmdir;
924
925 de.de_gen_number_bit_string = NULL;
926 if ((retval =
927 reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
928 &path, &de)) == NAME_NOT_FOUND) {
929 retval = -ENOENT;
930 goto end_rmdir;
931 } else if (retval == IO_ERROR) {
932 retval = -EIO;
933 goto end_rmdir;
934 }
935
936 inode = d_inode(dentry);
937
938 reiserfs_update_inode_transaction(inode);
939 reiserfs_update_inode_transaction(dir);
940
941 if (de.de_objectid != inode->i_ino) {
942
943
944
945 retval = -EIO;
946 goto end_rmdir;
947 }
948 if (!reiserfs_empty_dir(inode)) {
949 retval = -ENOTEMPTY;
950 goto end_rmdir;
951 }
952
953
954 retval = reiserfs_cut_from_item(&th, &path, &de.de_entry_key,
955 dir, NULL,
956 0 );
957 if (retval < 0)
958 goto end_rmdir;
959
960 if (inode->i_nlink != 2 && inode->i_nlink != 1)
961 reiserfs_error(inode->i_sb, "reiserfs-7040",
962 "empty directory has nlink != 2 (%d)",
963 inode->i_nlink);
964
965 clear_nlink(inode);
966 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(dir);
967 reiserfs_update_sd(&th, inode);
968
969 DEC_DIR_INODE_NLINK(dir)
970 dir->i_size -= (DEH_SIZE + de.de_entrylen);
971 reiserfs_update_sd(&th, dir);
972
973
974 add_save_link(&th, inode, 0 );
975
976 retval = journal_end(&th);
977 reiserfs_check_path(&path);
978 out_rmdir:
979 reiserfs_write_unlock(dir->i_sb);
980 return retval;
981
982 end_rmdir:
983
984
985
986
987
988 pathrelse(&path);
989 err = journal_end(&th);
990 reiserfs_write_unlock(dir->i_sb);
991 return err ? err : retval;
992 }
993
994 static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
995 {
996 int retval, err;
997 struct inode *inode;
998 struct reiserfs_dir_entry de;
999 INITIALIZE_PATH(path);
1000 struct reiserfs_transaction_handle th;
1001 int jbegin_count;
1002 unsigned long savelink;
1003
1004 retval = dquot_initialize(dir);
1005 if (retval)
1006 return retval;
1007
1008 inode = d_inode(dentry);
1009
1010
1011
1012
1013
1014
1015
1016
1017 jbegin_count =
1018 JOURNAL_PER_BALANCE_CNT * 2 + 2 +
1019 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
1020
1021 reiserfs_write_lock(dir->i_sb);
1022 retval = journal_begin(&th, dir->i_sb, jbegin_count);
1023 if (retval)
1024 goto out_unlink;
1025
1026 de.de_gen_number_bit_string = NULL;
1027 if ((retval =
1028 reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
1029 &path, &de)) == NAME_NOT_FOUND) {
1030 retval = -ENOENT;
1031 goto end_unlink;
1032 } else if (retval == IO_ERROR) {
1033 retval = -EIO;
1034 goto end_unlink;
1035 }
1036
1037 reiserfs_update_inode_transaction(inode);
1038 reiserfs_update_inode_transaction(dir);
1039
1040 if (de.de_objectid != inode->i_ino) {
1041
1042
1043
1044 retval = -EIO;
1045 goto end_unlink;
1046 }
1047
1048 if (!inode->i_nlink) {
1049 reiserfs_warning(inode->i_sb, "reiserfs-7042",
1050 "deleting nonexistent file (%lu), %d",
1051 inode->i_ino, inode->i_nlink);
1052 set_nlink(inode, 1);
1053 }
1054
1055 drop_nlink(inode);
1056
1057
1058
1059
1060
1061 savelink = inode->i_nlink;
1062
1063 retval =
1064 reiserfs_cut_from_item(&th, &path, &de.de_entry_key, dir, NULL,
1065 0);
1066 if (retval < 0) {
1067 inc_nlink(inode);
1068 goto end_unlink;
1069 }
1070 inode->i_ctime = current_time(inode);
1071 reiserfs_update_sd(&th, inode);
1072
1073 dir->i_size -= (de.de_entrylen + DEH_SIZE);
1074 dir->i_ctime = dir->i_mtime = current_time(dir);
1075 reiserfs_update_sd(&th, dir);
1076
1077 if (!savelink)
1078
1079 add_save_link(&th, inode, 0 );
1080
1081 retval = journal_end(&th);
1082 reiserfs_check_path(&path);
1083 reiserfs_write_unlock(dir->i_sb);
1084 return retval;
1085
1086 end_unlink:
1087 pathrelse(&path);
1088 err = journal_end(&th);
1089 reiserfs_check_path(&path);
1090 if (err)
1091 retval = err;
1092 out_unlink:
1093 reiserfs_write_unlock(dir->i_sb);
1094 return retval;
1095 }
1096
1097 static int reiserfs_symlink(struct inode *parent_dir,
1098 struct dentry *dentry, const char *symname)
1099 {
1100 int retval;
1101 struct inode *inode;
1102 char *name;
1103 int item_len;
1104 struct reiserfs_transaction_handle th;
1105 struct reiserfs_security_handle security;
1106 int mode = S_IFLNK | S_IRWXUGO;
1107
1108
1109
1110
1111 int jbegin_count =
1112 JOURNAL_PER_BALANCE_CNT * 3 +
1113 2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
1114 REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
1115
1116 retval = dquot_initialize(parent_dir);
1117 if (retval)
1118 return retval;
1119
1120 if (!(inode = new_inode(parent_dir->i_sb))) {
1121 return -ENOMEM;
1122 }
1123 retval = new_inode_init(inode, parent_dir, mode);
1124 if (retval) {
1125 drop_new_inode(inode);
1126 return retval;
1127 }
1128
1129 retval = reiserfs_security_init(parent_dir, inode, &dentry->d_name,
1130 &security);
1131 if (retval < 0) {
1132 drop_new_inode(inode);
1133 return retval;
1134 }
1135 jbegin_count += retval;
1136
1137 reiserfs_write_lock(parent_dir->i_sb);
1138 item_len = ROUND_UP(strlen(symname));
1139 if (item_len > MAX_DIRECT_ITEM_LEN(parent_dir->i_sb->s_blocksize)) {
1140 retval = -ENAMETOOLONG;
1141 drop_new_inode(inode);
1142 goto out_failed;
1143 }
1144
1145 name = kmalloc(item_len, GFP_NOFS);
1146 if (!name) {
1147 drop_new_inode(inode);
1148 retval = -ENOMEM;
1149 goto out_failed;
1150 }
1151 memcpy(name, symname, strlen(symname));
1152 padd_item(name, item_len, strlen(symname));
1153
1154 retval = journal_begin(&th, parent_dir->i_sb, jbegin_count);
1155 if (retval) {
1156 drop_new_inode(inode);
1157 kfree(name);
1158 goto out_failed;
1159 }
1160
1161 retval =
1162 reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
1163 dentry, inode, &security);
1164 kfree(name);
1165 if (retval) {
1166 goto out_failed;
1167 }
1168
1169 reiserfs_update_inode_transaction(inode);
1170 reiserfs_update_inode_transaction(parent_dir);
1171
1172 inode->i_op = &reiserfs_symlink_inode_operations;
1173 inode_nohighmem(inode);
1174 inode->i_mapping->a_ops = &reiserfs_address_space_operations;
1175
1176 retval = reiserfs_add_entry(&th, parent_dir, dentry->d_name.name,
1177 dentry->d_name.len, inode, 1 );
1178 if (retval) {
1179 int err;
1180 drop_nlink(inode);
1181 reiserfs_update_sd(&th, inode);
1182 err = journal_end(&th);
1183 if (err)
1184 retval = err;
1185 unlock_new_inode(inode);
1186 iput(inode);
1187 goto out_failed;
1188 }
1189
1190 d_instantiate_new(dentry, inode);
1191 retval = journal_end(&th);
1192 out_failed:
1193 reiserfs_write_unlock(parent_dir->i_sb);
1194 return retval;
1195 }
1196
1197 static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
1198 struct dentry *dentry)
1199 {
1200 int retval;
1201 struct inode *inode = d_inode(old_dentry);
1202 struct reiserfs_transaction_handle th;
1203
1204
1205
1206
1207 int jbegin_count =
1208 JOURNAL_PER_BALANCE_CNT * 3 +
1209 2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
1210
1211 retval = dquot_initialize(dir);
1212 if (retval)
1213 return retval;
1214
1215 reiserfs_write_lock(dir->i_sb);
1216 if (inode->i_nlink >= REISERFS_LINK_MAX) {
1217
1218 reiserfs_write_unlock(dir->i_sb);
1219 return -EMLINK;
1220 }
1221
1222
1223 inc_nlink(inode);
1224
1225 retval = journal_begin(&th, dir->i_sb, jbegin_count);
1226 if (retval) {
1227 drop_nlink(inode);
1228 reiserfs_write_unlock(dir->i_sb);
1229 return retval;
1230 }
1231
1232
1233 retval =
1234 reiserfs_add_entry(&th, dir, dentry->d_name.name,
1235 dentry->d_name.len, inode, 1 );
1236
1237 reiserfs_update_inode_transaction(inode);
1238 reiserfs_update_inode_transaction(dir);
1239
1240 if (retval) {
1241 int err;
1242 drop_nlink(inode);
1243 err = journal_end(&th);
1244 reiserfs_write_unlock(dir->i_sb);
1245 return err ? err : retval;
1246 }
1247
1248 inode->i_ctime = current_time(inode);
1249 reiserfs_update_sd(&th, inode);
1250
1251 ihold(inode);
1252 d_instantiate(dentry, inode);
1253 retval = journal_end(&th);
1254 reiserfs_write_unlock(dir->i_sb);
1255 return retval;
1256 }
1257
1258
1259 static int de_still_valid(const char *name, int len,
1260 struct reiserfs_dir_entry *de)
1261 {
1262 struct reiserfs_dir_entry tmp = *de;
1263
1264
1265 set_de_name_and_namelen(&tmp);
1266
1267 if (tmp.de_namelen != len || memcmp(name, de->de_name, len))
1268 return 0;
1269 return 1;
1270 }
1271
1272 static int entry_points_to_object(const char *name, int len,
1273 struct reiserfs_dir_entry *de,
1274 struct inode *inode)
1275 {
1276 if (!de_still_valid(name, len, de))
1277 return 0;
1278
1279 if (inode) {
1280 if (!de_visible(de->de_deh + de->de_entry_num))
1281 reiserfs_panic(inode->i_sb, "vs-7042",
1282 "entry must be visible");
1283 return (de->de_objectid == inode->i_ino) ? 1 : 0;
1284 }
1285
1286
1287 if (de_visible(de->de_deh + de->de_entry_num))
1288 reiserfs_panic(NULL, "vs-7043", "entry must be visible");
1289
1290 return 1;
1291 }
1292
1293
1294 static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
1295 struct reiserfs_key *key)
1296 {
1297
1298 de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
1299 de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
1300 }
1301
1302
1303
1304
1305
1306
1307 static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1308 struct inode *new_dir, struct dentry *new_dentry,
1309 unsigned int flags)
1310 {
1311 int retval;
1312 INITIALIZE_PATH(old_entry_path);
1313 INITIALIZE_PATH(new_entry_path);
1314 INITIALIZE_PATH(dot_dot_entry_path);
1315 struct item_head new_entry_ih, old_entry_ih, dot_dot_ih;
1316 struct reiserfs_dir_entry old_de, new_de, dot_dot_de;
1317 struct inode *old_inode, *new_dentry_inode;
1318 struct reiserfs_transaction_handle th;
1319 int jbegin_count;
1320 umode_t old_inode_mode;
1321 unsigned long savelink = 1;
1322 struct timespec64 ctime;
1323
1324 if (flags & ~RENAME_NOREPLACE)
1325 return -EINVAL;
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337 jbegin_count =
1338 JOURNAL_PER_BALANCE_CNT * 3 + 5 +
1339 4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
1340
1341 retval = dquot_initialize(old_dir);
1342 if (retval)
1343 return retval;
1344 retval = dquot_initialize(new_dir);
1345 if (retval)
1346 return retval;
1347
1348 old_inode = d_inode(old_dentry);
1349 new_dentry_inode = d_inode(new_dentry);
1350
1351
1352
1353
1354
1355 old_de.de_gen_number_bit_string = NULL;
1356 reiserfs_write_lock(old_dir->i_sb);
1357 retval =
1358 reiserfs_find_entry(old_dir, old_dentry->d_name.name,
1359 old_dentry->d_name.len, &old_entry_path,
1360 &old_de);
1361 pathrelse(&old_entry_path);
1362 if (retval == IO_ERROR) {
1363 reiserfs_write_unlock(old_dir->i_sb);
1364 return -EIO;
1365 }
1366
1367 if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
1368 reiserfs_write_unlock(old_dir->i_sb);
1369 return -ENOENT;
1370 }
1371
1372 old_inode_mode = old_inode->i_mode;
1373 if (S_ISDIR(old_inode_mode)) {
1374
1375
1376
1377
1378
1379 if (new_dentry_inode) {
1380 if (!reiserfs_empty_dir(new_dentry_inode)) {
1381 reiserfs_write_unlock(old_dir->i_sb);
1382 return -ENOTEMPTY;
1383 }
1384 }
1385
1386
1387
1388
1389
1390 dot_dot_de.de_gen_number_bit_string = NULL;
1391 retval =
1392 reiserfs_find_entry(old_inode, "..", 2, &dot_dot_entry_path,
1393 &dot_dot_de);
1394 pathrelse(&dot_dot_entry_path);
1395 if (retval != NAME_FOUND) {
1396 reiserfs_write_unlock(old_dir->i_sb);
1397 return -EIO;
1398 }
1399
1400
1401 if (dot_dot_de.de_objectid != old_dir->i_ino) {
1402 reiserfs_write_unlock(old_dir->i_sb);
1403 return -EIO;
1404 }
1405 }
1406
1407 retval = journal_begin(&th, old_dir->i_sb, jbegin_count);
1408 if (retval) {
1409 reiserfs_write_unlock(old_dir->i_sb);
1410 return retval;
1411 }
1412
1413
1414 retval =
1415 reiserfs_add_entry(&th, new_dir, new_dentry->d_name.name,
1416 new_dentry->d_name.len, old_inode, 0);
1417 if (retval == -EEXIST) {
1418 if (!new_dentry_inode) {
1419 reiserfs_panic(old_dir->i_sb, "vs-7050",
1420 "new entry is found, new inode == 0");
1421 }
1422 } else if (retval) {
1423 int err = journal_end(&th);
1424 reiserfs_write_unlock(old_dir->i_sb);
1425 return err ? err : retval;
1426 }
1427
1428 reiserfs_update_inode_transaction(old_dir);
1429 reiserfs_update_inode_transaction(new_dir);
1430
1431
1432
1433
1434
1435 reiserfs_update_inode_transaction(old_inode);
1436
1437 if (new_dentry_inode)
1438 reiserfs_update_inode_transaction(new_dentry_inode);
1439
1440 while (1) {
1441
1442
1443
1444
1445 if ((retval =
1446 search_by_entry_key(new_dir->i_sb, &old_de.de_entry_key,
1447 &old_entry_path,
1448 &old_de)) != NAME_FOUND) {
1449 pathrelse(&old_entry_path);
1450 journal_end(&th);
1451 reiserfs_write_unlock(old_dir->i_sb);
1452 return -EIO;
1453 }
1454
1455 copy_item_head(&old_entry_ih, tp_item_head(&old_entry_path));
1456
1457 reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1);
1458
1459
1460 new_de.de_gen_number_bit_string = NULL;
1461 retval =
1462 reiserfs_find_entry(new_dir, new_dentry->d_name.name,
1463 new_dentry->d_name.len, &new_entry_path,
1464 &new_de);
1465
1466
1467
1468
1469
1470
1471 if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
1472 pathrelse(&new_entry_path);
1473 pathrelse(&old_entry_path);
1474 journal_end(&th);
1475 reiserfs_write_unlock(old_dir->i_sb);
1476 return -EIO;
1477 }
1478
1479 copy_item_head(&new_entry_ih, tp_item_head(&new_entry_path));
1480
1481 reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1);
1482
1483 if (S_ISDIR(old_inode->i_mode)) {
1484 if ((retval =
1485 search_by_entry_key(new_dir->i_sb,
1486 &dot_dot_de.de_entry_key,
1487 &dot_dot_entry_path,
1488 &dot_dot_de)) != NAME_FOUND) {
1489 pathrelse(&dot_dot_entry_path);
1490 pathrelse(&new_entry_path);
1491 pathrelse(&old_entry_path);
1492 journal_end(&th);
1493 reiserfs_write_unlock(old_dir->i_sb);
1494 return -EIO;
1495 }
1496 copy_item_head(&dot_dot_ih,
1497 tp_item_head(&dot_dot_entry_path));
1498
1499 reiserfs_prepare_for_journal(old_inode->i_sb,
1500 dot_dot_de.de_bh, 1);
1501 }
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519 if (item_moved(&new_entry_ih, &new_entry_path) ||
1520 !entry_points_to_object(new_dentry->d_name.name,
1521 new_dentry->d_name.len,
1522 &new_de, new_dentry_inode) ||
1523 item_moved(&old_entry_ih, &old_entry_path) ||
1524 !entry_points_to_object(old_dentry->d_name.name,
1525 old_dentry->d_name.len,
1526 &old_de, old_inode)) {
1527 reiserfs_restore_prepared_buffer(old_inode->i_sb,
1528 new_de.de_bh);
1529 reiserfs_restore_prepared_buffer(old_inode->i_sb,
1530 old_de.de_bh);
1531 if (S_ISDIR(old_inode_mode))
1532 reiserfs_restore_prepared_buffer(old_inode->
1533 i_sb,
1534 dot_dot_de.
1535 de_bh);
1536 continue;
1537 }
1538 if (S_ISDIR(old_inode_mode)) {
1539 if (item_moved(&dot_dot_ih, &dot_dot_entry_path) ||
1540 !entry_points_to_object("..", 2, &dot_dot_de,
1541 old_dir)) {
1542 reiserfs_restore_prepared_buffer(old_inode->
1543 i_sb,
1544 old_de.de_bh);
1545 reiserfs_restore_prepared_buffer(old_inode->
1546 i_sb,
1547 new_de.de_bh);
1548 reiserfs_restore_prepared_buffer(old_inode->
1549 i_sb,
1550 dot_dot_de.
1551 de_bh);
1552 continue;
1553 }
1554 }
1555
1556 RFALSE(S_ISDIR(old_inode_mode) &&
1557 !buffer_journal_prepared(dot_dot_de.de_bh), "");
1558
1559 break;
1560 }
1561
1562
1563
1564
1565
1566
1567 mark_de_visible(new_de.de_deh + new_de.de_entry_num);
1568 set_ino_in_dir_entry(&new_de, INODE_PKEY(old_inode));
1569 journal_mark_dirty(&th, new_de.de_bh);
1570
1571 mark_de_hidden(old_de.de_deh + old_de.de_entry_num);
1572 journal_mark_dirty(&th, old_de.de_bh);
1573 ctime = current_time(old_dir);
1574 old_dir->i_ctime = old_dir->i_mtime = ctime;
1575 new_dir->i_ctime = new_dir->i_mtime = ctime;
1576
1577
1578
1579
1580 old_inode->i_ctime = ctime;
1581
1582 if (new_dentry_inode) {
1583
1584 if (S_ISDIR(new_dentry_inode->i_mode)) {
1585 clear_nlink(new_dentry_inode);
1586 } else {
1587 drop_nlink(new_dentry_inode);
1588 }
1589 new_dentry_inode->i_ctime = ctime;
1590 savelink = new_dentry_inode->i_nlink;
1591 }
1592
1593 if (S_ISDIR(old_inode_mode)) {
1594
1595 set_ino_in_dir_entry(&dot_dot_de, INODE_PKEY(new_dir));
1596 journal_mark_dirty(&th, dot_dot_de.de_bh);
1597
1598
1599
1600
1601
1602 if (!new_dentry_inode)
1603 INC_DIR_INODE_NLINK(new_dir);
1604
1605
1606 DEC_DIR_INODE_NLINK(old_dir);
1607 }
1608
1609
1610
1611
1612 pathrelse(&new_entry_path);
1613 pathrelse(&dot_dot_entry_path);
1614
1615
1616
1617
1618
1619
1620 if (reiserfs_cut_from_item
1621 (&th, &old_entry_path, &old_de.de_entry_key, old_dir, NULL,
1622 0) < 0)
1623 reiserfs_error(old_dir->i_sb, "vs-7060",
1624 "couldn't not cut old name. Fsck later?");
1625
1626 old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
1627
1628 reiserfs_update_sd(&th, old_dir);
1629 reiserfs_update_sd(&th, new_dir);
1630 reiserfs_update_sd(&th, old_inode);
1631
1632 if (new_dentry_inode) {
1633 if (savelink == 0)
1634 add_save_link(&th, new_dentry_inode,
1635 0 );
1636 reiserfs_update_sd(&th, new_dentry_inode);
1637 }
1638
1639 retval = journal_end(&th);
1640 reiserfs_write_unlock(old_dir->i_sb);
1641 return retval;
1642 }
1643
1644
1645 const struct inode_operations reiserfs_dir_inode_operations = {
1646 .create = reiserfs_create,
1647 .lookup = reiserfs_lookup,
1648 .link = reiserfs_link,
1649 .unlink = reiserfs_unlink,
1650 .symlink = reiserfs_symlink,
1651 .mkdir = reiserfs_mkdir,
1652 .rmdir = reiserfs_rmdir,
1653 .mknod = reiserfs_mknod,
1654 .rename = reiserfs_rename,
1655 .setattr = reiserfs_setattr,
1656 .listxattr = reiserfs_listxattr,
1657 .permission = reiserfs_permission,
1658 .get_acl = reiserfs_get_acl,
1659 .set_acl = reiserfs_set_acl,
1660 };
1661
1662
1663
1664
1665
1666 const struct inode_operations reiserfs_symlink_inode_operations = {
1667 .get_link = page_get_link,
1668 .setattr = reiserfs_setattr,
1669 .listxattr = reiserfs_listxattr,
1670 .permission = reiserfs_permission,
1671 };
1672
1673
1674
1675
1676 const struct inode_operations reiserfs_special_inode_operations = {
1677 .setattr = reiserfs_setattr,
1678 .listxattr = reiserfs_listxattr,
1679 .permission = reiserfs_permission,
1680 .get_acl = reiserfs_get_acl,
1681 .set_acl = reiserfs_set_acl,
1682 };