Changeset bbd4c72 in mainline for uspace/srv/fs/minixfs/mfs_ops.c


Ignore:
Timestamp:
2011-09-05T18:16:45Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75e0f15
Parents:
3a5ee6c
Message:

The lnkcnt_get() function will ignore the ".." hardlinks when dealing with directories

File:
1 edited

Legend:

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

    r3a5ee6c rbbd4c72  
    161161
    162162        /* initialize libblock */
    163         rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
     163        rc = block_init(EXCHANGE_SERIALIZE, service_id, 4096);
    164164        if (rc != EOK)
    165165                return rc;
     
    175175        instance = malloc(sizeof(*instance));
    176176        if (!instance) {
     177                free(sbi);
    177178                block_fini(service_id);
    178179                return ENOMEM;
     
    307308        struct mfs_instance *inst;
    308309
     310        mfsdebug("%s()\n", __FUNCTION__);
     311
    309312        int r = mfs_instance_get(service_id, &inst);
    310313        if (r != EOK)
     
    372375        }
    373376
    374         if (flags & L_DIRECTORY)
     377        if (flags & L_DIRECTORY) {
    375378                ino_i->i_mode = S_IFDIR;
    376         else
     379                ino_i->i_nlinks = 2; /*This accounts for the '.' dentry*/
     380        } else {
    377381                ino_i->i_mode = S_IFREG;
    378 
    379         ino_i->i_nlinks = 1;
     382                ino_i->i_nlinks = 1;
     383        }
     384
    380385        ino_i->i_uid = 0;
    381386        ino_i->i_gid = 0;
     
    546551        mfsdebug("%s()\n", __FUNCTION__);
    547552
    548         assert(mnode);
    549         assert(mnode->ino_i);
     553        if (S_ISDIR(mnode->ino_i->i_mode)) {
     554                if (mnode->ino_i->i_nlinks > 1)
     555                        return 1;
     556                else
     557                        return 0;
     558        }
    550559
    551560        return mnode->ino_i->i_nlinks;
     
    662671                if (r != EOK)
    663672                        goto exit_error;
    664                 //child->ino_i->i_nlinks++;
    665                 //child->ino_i->dirty = true;
     673
    666674                r = mfs_insert_dentry(child, "..", parent->ino_i->index);
    667675                if (r != EOK)
    668676                        goto exit_error;
    669                 //parent->ino_i->i_nlinks++;
    670                 //parent->ino_i->dirty = true;
     677
     678                parent->ino_i->i_nlinks++;
     679                parent->ino_i->dirty = true;
    671680        }
    672681
     
    702711
    703712        assert(chino->i_nlinks >= 1);
    704         --chino->i_nlinks;
    705 /*
    706         if (chino->i_nlinks == 0 && S_ISDIR(chino->i_mode)) {
     713        chino->i_nlinks--;
     714        mfsdebug("Links: %d\n", chino->i_nlinks);
     715
     716        if (chino->i_nlinks <= 1 && S_ISDIR(chino->i_mode)) {
     717                /* The child directory will be destroyed, decrease the
     718                 * parent hard links counter.
     719                 */
    707720                parent->ino_i->i_nlinks--;
    708721                parent->ino_i->dirty = true;
    709722        }
    710 */
    711723
    712724        chino->dirty = true;
Note: See TracChangeset for help on using the changeset viewer.