Changeset 07dcec5 in mainline
- Timestamp:
- 2011-04-07T19:48:48Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a57269f
- Parents:
- 04be5a0
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
r04be5a0 r07dcec5 90 90 mfs_version_t fs_version; 91 91 int ino_per_block; 92 int dirsize;92 size_t dirsize; 93 93 int itable_off; 94 94 unsigned max_name_len; … … 122 122 struct mfs_dentry_info { 123 123 uint32_t d_inum; 124 char d_name[MFS3_MAX_NAME_LEN ];124 char d_name[MFS3_MAX_NAME_LEN + 1]; 125 125 126 126 /*The following fields do not exist on disk but only in memory*/ … … 182 182 write_dentry(struct mfs_dentry_info *d_info); 183 183 184 int 185 insert_dentry(struct mfs_node *mnode, char *d_name, fs_index_t d_inum); 186 184 187 /*mfs_balloc.c*/ 185 188 extern int -
uspace/srv/fs/minixfs/mfs_dentry.c
r04be5a0 r07dcec5 107 107 goto out; 108 108 109 const size_t name_len = s tr_size(d_info->d_name);109 const size_t name_len = sbi->max_name_len; 110 110 uint8_t *ptr = b->data; 111 111 ptr += (d_info->index % dirs_per_block) * sbi->dirsize; … … 132 132 } 133 133 134 int 135 insert_dentry(struct mfs_node *mnode, char *d_name, fs_index_t d_inum) 136 { 137 int i, r; 138 struct mfs_sb_info *sbi = mnode->instance->sbi; 139 struct mfs_dentry_info *d_info; 140 bool empty_dentry_found = false; 141 142 const size_t name_len = str_size(d_name); 143 144 assert(name_len <= sbi->max_name_len); 145 146 /*Search for an empty dentry*/ 147 148 for (i = 2; ; ++i) { 149 d_info = read_directory_entry(mnode, i); 150 151 if (!d_info) { 152 /*Reached the end of the dentries list*/ 153 break; 154 } 155 156 if (d_info->d_inum == 0) { 157 /*This entry is not used*/ 158 empty_dentry_found = true; 159 break; 160 } 161 free(d_info); 162 } 163 164 if (!empty_dentry_found) { 165 r = inode_grow(mnode, sbi->dirsize); 166 if (r != EOK) 167 return r; 168 169 d_info = read_directory_entry(mnode, i); 170 if (!d_info) 171 return EIO; 172 } 173 174 d_info->d_inum = d_inum; 175 memcpy(d_info->d_name, d_name, name_len); 176 d_info->d_name[name_len] = 0; 177 178 return write_dentry(d_info); 179 } 180 181 134 182 /** 135 183 * @}
Note:
See TracChangeset
for help on using the changeset viewer.