Ignore:
File:
1 edited

Legend:

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

    rdf3caec5 r9d58539  
    384384        if (flags & L_DIRECTORY) {
    385385                ino_i->i_mode = S_IFDIR;
    386                 ino_i->i_nlinks = 2; /* This accounts for the '.' dentry */
    387         } else {
     386                ino_i->i_nlinks = 1; /* This accounts for the '.' dentry */
     387        } else
    388388                ino_i->i_mode = S_IFREG;
    389                 ino_i->i_nlinks = 1;
    390         }
    391389
    392390        ino_i->i_uid = 0;
     
    666664        struct mfs_node *child = cfn->data;
    667665        struct mfs_sb_info *sbi = parent->instance->sbi;
     666        bool destroy_dentry = false;
    668667
    669668        mfsdebug("%s()\n", __FUNCTION__);
     
    674673        int r = mfs_insert_dentry(parent, name, child->ino_i->index);
    675674        if (r != EOK)
    676                 goto exit_error;
     675                return r;
    677676
    678677        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                }
    679684                r = mfs_insert_dentry(child, ".", child->ino_i->index);
    680                 if (r != EOK)
    681                         goto exit_error;
     685                if (r != EOK) {
     686                        destroy_dentry = true;
     687                        goto exit;
     688                }
    682689
    683690                r = mfs_insert_dentry(child, "..", parent->ino_i->index);
    684                 if (r != EOK)
    685                         goto exit_error;
     691                if (r != EOK) {
     692                        destroy_dentry = true;
     693                        goto exit;
     694                }
    686695
    687696                parent->ino_i->i_nlinks++;
     
    689698        }
    690699
    691 exit_error:
     700exit:
     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        }
    692709        return r;
    693710}
     
    820837found:
    821838                async_data_read_finalize(callid, d_info.d_name,
    822                                         str_size(d_info.d_name) + 1);
     839                    str_size(d_info.d_name) + 1);
    823840                bytes = ((pos - spos) + 1);
    824841        } else {
Note: See TracChangeset for help on using the changeset viewer.