Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/mfs/mfs_ops.c

    r9d58539 rdf3caec5  
    384384        if (flags & L_DIRECTORY) {
    385385                ino_i->i_mode = S_IFDIR;
    386                 ino_i->i_nlinks = 1; /* This accounts for the '.' dentry */
    387         } else
     386                ino_i->i_nlinks = 2; /* This accounts for the '.' dentry */
     387        } else {
    388388                ino_i->i_mode = S_IFREG;
     389                ino_i->i_nlinks = 1;
     390        }
    389391
    390392        ino_i->i_uid = 0;
     
    664666        struct mfs_node *child = cfn->data;
    665667        struct mfs_sb_info *sbi = parent->instance->sbi;
    666         bool destroy_dentry = false;
    667668
    668669        mfsdebug("%s()\n", __FUNCTION__);
     
    673674        int r = mfs_insert_dentry(parent, name, child->ino_i->index);
    674675        if (r != EOK)
    675                 return r;
     676                goto exit_error;
    676677
    677678        if (S_ISDIR(child->ino_i->i_mode)) {
    678                 if (child->ino_i->i_nlinks != 1) {
    679                         /* It's not possible to hardlink directories in MFS */
    680                         destroy_dentry = true;
    681                         r = EMLINK;
    682                         goto exit;
    683                 }
    684679                r = mfs_insert_dentry(child, ".", child->ino_i->index);
    685                 if (r != EOK) {
    686                         destroy_dentry = true;
    687                         goto exit;
    688                 }
     680                if (r != EOK)
     681                        goto exit_error;
    689682
    690683                r = mfs_insert_dentry(child, "..", parent->ino_i->index);
    691                 if (r != EOK) {
    692                         destroy_dentry = true;
    693                         goto exit;
    694                 }
     684                if (r != EOK)
     685                        goto exit_error;
    695686
    696687                parent->ino_i->i_nlinks++;
     
    698689        }
    699690
    700 exit:
    701         if (destroy_dentry) {
    702                 int r2 = mfs_remove_dentry(parent, name);
    703                 if (r2 != EOK)
    704                         r = r2;
    705         } else {
    706                 child->ino_i->i_nlinks++;
    707                 child->ino_i->dirty = true;
    708         }
     691exit_error:
    709692        return r;
    710693}
     
    837820found:
    838821                async_data_read_finalize(callid, d_info.d_name,
    839                     str_size(d_info.d_name) + 1);
     822                                        str_size(d_info.d_name) + 1);
    840823                bytes = ((pos - spos) + 1);
    841824        } else {
Note: See TracChangeset for help on using the changeset viewer.