Ticket #5698: reiserfs-label.patch

File reiserfs-label.patch, 2.9 KB (added by wtachi, 10 years ago)

Whoops, I missed that last strlen(). Patch updated to not use strlcpy().

  • src/add-ons/kernel/file_systems/reiserfs/Volume.cpp

     
    262262void
    263263Volume::UpdateName(partition_id partitionID)
    264264{
     265    if (fSuperBlock->GetLabel(fVolumeName, sizeof(fVolumeName)) == B_OK)
     266        return;
    265267    if (get_default_partition_content_name(partitionID, "ReiserFS",
    266             fVolumeName, sizeof(fVolumeName)) != B_OK) {
    267         strlcpy(fVolumeName, "ReiserFS Volume", sizeof(fVolumeName));
    268     }
     268            fVolumeName, sizeof(fVolumeName)) == B_OK)
     269        return;
     270    strlcpy(fVolumeName, "ReiserFS Volume", sizeof(fVolumeName));
    269271}
    270272
    271273
  • src/add-ons/kernel/file_systems/reiserfs/SuperBlock.h

     
    8585            : le2h(fOldData->s_tree_height));
    8686    }
    8787
     88    status_t GetLabel(char* buffer, size_t bufferSize) const;
     89
    8890private:
    8991    uint32  fFormatVersion;
    9092    union {
  • src/add-ons/kernel/file_systems/reiserfs/SuperBlock.cpp

     
    109109        fFormatVersion = REISERFS_3_5;
    110110    // try new version and new layout
    111111    } else if (read_super_block(device, REISERFS_DISK_OFFSET_IN_BYTES + offset,
    112             REISER2FS_SUPER_MAGIC_STRING, &fOldData) == B_OK) {
     112            REISER2FS_SUPER_MAGIC_STRING, &fCurrentData) == B_OK) {
    113113PRINT(("SuperBlock: ReiserFS 3.6\n"));
    114114        fFormatVersion = REISERFS_3_6;
    115115    // failure
     
    119119    return error;
    120120}
    121121
     122
     123// GetLabel
     124status_t
     125SuperBlock::GetLabel(char* buffer, size_t bufferSize) const
     126{
     127    if (GetFormatVersion() == REISERFS_3_6 && fCurrentData->s_label[0]) {
     128        size_t len = MIN(sizeof(fCurrentData->s_label), bufferSize - 1);
     129        memcpy(buffer, fCurrentData->s_label, len);
     130        buffer[len] = '\0';
     131        return B_OK;
     132    }
     133    return B_ENTRY_NOT_FOUND;
     134}
  • src/add-ons/kernel/file_systems/reiserfs/reiserfs.h

     
    272272                                   superblock. -Hans */
    273273  uint16 s_reserved;
    274274  uint32 s_inode_generation;
    275   char s_unused[124] ;          /* zero filled by mkreiserfs */
     275  uint32 s_flags;
     276  char s_uuid[16];
     277  char s_label[16];
     278  uint16 s_mnt_count;
     279  uint16 s_max_mnt_count;
     280  uint32 s_lastcheck;
     281  uint32 s_check_interval;
     282  char s_unused[76] ;           /* zero filled by mkreiserfs */
    276283} _PACKED;
    277284
    278285#define SB_SIZE (sizeof(struct reiserfs_super_block))