Skip to contentSkip to conversation

reiser4: Request for minor change in max_name_len_cde()

DISCUSSION Peter Klotz 2 participants 2 messages Feb 16, 2006 – Feb 17, 2006

lore
Share & tools
lore
#0 lore raw

The function max_name_len_cde() in reiser4/plugin/item/cde40.c in my opinion limits the file name length too strict.

One finds:

  return
      tree_by_inode(dir)->nplug->max_item_size() -
      sizeof(directory_entry_format) - sizeof(cde_item_format) -
      sizeof(cde_unit_header) - 2;

I think the -2 can be safely changed to -1 since the only extra byte that has to be taken into account is the terminating zero of the file name in case a longname key is encountered.

The maximum file name length in the original case is 3976 bytes if the filesystem uses 4096 byte blocks. In this case the node header of the node containing the cde40 item reports 1 byte of free space.

4096 block size

-28   sizeof(node40_header)
-38   sizeof(item_header40)
 -2   sizeof(cde_item_format)
-26   sizeof(cde_unit_header)
-24   sizeof(directory_entry_format)
 -1   terminating zero of file name
 -1   ?

-----
3976

I changed the -2 to -1 and recompiled the kernel. Then I was able to create a file with a 3977 byte name. In this case the node header reports 0 bytes of free space.

Best regards, Peter.

#1 lore raw

Hello

Quoted 26 lines · Peter Klotz

The function max_name_len_cde() in reiser4/plugin/item/cde40.c in my opinion limits the file name length too strict.

One finds:

   return
       tree_by_inode(dir)->nplug->max_item_size() -
       sizeof(directory_entry_format) - sizeof(cde_item_format) -
       sizeof(cde_unit_header) - 2;

I think the -2 can be safely changed to -1 since the only extra byte that has to be taken into account is the terminating zero of the file name in case a longname key is encountered.

The maximum file name length in the original case is 3976 bytes if the filesystem uses 4096 byte blocks. In this case the node header of the node containing the cde40 item reports 1 byte of free space.

4096   block size
 -28   sizeof(node40_header)
 -38   sizeof(item_header40)
  -2   sizeof(cde_item_format)
 -26   sizeof(cde_unit_header)
 -24   sizeof(directory_entry_format)
  -1   terminating zero of file name
  -1   ?
Quoted 7 lines

-----
3976

I changed the -2 to -1 and recompiled the kernel. Then I was able to create a file with a 3977 byte name. In this case the node header reports 0 bytes of free space.

Thanks, we will fix it

Quoted 2 lines

Best regards, Peter.