public WIP_TYPE get_wiptype()
        {
            int      flag  = get_int(WIDOffsets.wip_flags);
            int      value = flag & 0x00000007;
            WIP_TYPE type  = WIP_TYPE.UNDEFINED;

            switch (value)
            {
            case 0:
                type = WIP_TYPE.PUBLIC_INODE_FILE;
                break;

            case 1:
                type = WIP_TYPE.PUBLIC_INODE_MAP;
                break;

            case 2:
                type = WIP_TYPE.DIRECTORY_FILE;
                break;

            case 3:
                type = WIP_TYPE.REGULAR_FILE;
                break;

            case 4:
                type = WIP_TYPE.UNDEFINED;
                break;
            }
            //DEFS.ASSERT(type != WIP_TYPE.UNDEFINED, "Entry for wip type in the flag is incorrect");
            return(type);
        }
        public void set_wiptype(WIP_TYPE type)
        {
            int flag  = get_int(WIDOffsets.wip_flags);
            int value = -1;

            switch (type)
            {
            case WIP_TYPE.PUBLIC_INODE_FILE:
                value = 0;
                break;

            case WIP_TYPE.PUBLIC_INODE_MAP:
                value = 1;
                break;

            case WIP_TYPE.DIRECTORY_FILE:
                value = 2;
                break;

            case WIP_TYPE.REGULAR_FILE:
                value = 3;
                break;

            case WIP_TYPE.UNDEFINED:
                value = 4;
                break;
            }
            //DEFS.ASSERT(value != -1 && value <= 3, "Entry for wip type in the flag is incorrect : type=" + type + " value = " + value);
            flag &= 0x0FFFFFF0;
            flag |= value;
            set_int(WIDOffsets.wip_flags, flag);
        }
 public RedFS_Inode(WIP_TYPE t, int ino, int pino)
 {
     m_ino = ino;
     for (int i = 0; i < 16; i++)
     {
         set_child_dbn(i, DBN.INVALID);
     }
     wiptype = t;
     set_wiptype(wiptype);
     set_int(WIDOffsets.wip_parent, pino);
     set_int(WIDOffsets.wip_inoloc, ino);
 }
Ejemplo n.º 4
0
        /*
         * The below functions will be used for dedupe/user command prompt etc.
         */
        private int LoadWip_FindPINO(int fsid, int ino, ref WIP_TYPE type)
        {
            lock (REDDY.FSIDList[fsid])
            {
                RedFS_Inode inowip = REDDY.FSIDList[fsid].get_inode_file_wip("Loadinode");
                lock (inowip)
                {
                    RedFS_Inode mywip = new RedFS_Inode(WIP_TYPE.UNDEFINED, ino, -1);

                    bool ret = OPS.Checkout_Wip2(inowip, mywip, ino);
                    REDDY.FSIDList[fsid].sync_internal();
                    type = mywip.get_wiptype();
                    //DEFS.DEBUG("LdIno", "Loaded ino= " + ino + "wip from disk, type = " + type);
                    //DEFS.DEBUG("LdIno", mywip.get_string_rep2());
                    return((ret) ? mywip.get_parent_ino() : -1);
                }
            }
        }
Ejemplo n.º 5
0
        /*
         * Returns the path of the inode, from here on always use the path
         * to access the inode.
         */
        public string Load_Inode(int fsid, int ino, ref FileAttributes fa)
        {
            int[] orderlist = new int[1024];
            int   length    = 0;

            lock (REDDY.FSIDList[fsid].rootdir)
            {
                //Prepare the path, one by one.
                int parent   = -1;
                int curr_ino = ino;
                do
                {
                    //till you find a incore directory or you reach the root node.
                    CInode cix = REDDY.FSIDList[fsid].rootdir.check_if_inode_incore(curr_ino, false);
                    if (cix != null || curr_ino == 0)
                    {
                        orderlist[length++] = curr_ino;
                        string computedpath = Load_Dirtree_Internal(fsid, orderlist, length, ref fa);
                        return((curr_ino == 0)? computedpath : cix.get_full_path() + computedpath);
                    }
                    else
                    {
                        WIP_TYPE type = WIP_TYPE.UNDEFINED;
                        parent = LoadWip_FindPINO(fsid, curr_ino, ref type);
                        //DEFS.DEBUGYELLOW("@", "(ino,pino,type) = (" + curr_ino + "," + parent + "," + type + ")");
                        DEFS.ASSERT(curr_ino == ino || type == WIP_TYPE.DIRECTORY_FILE, "Mismatch in load ino " + curr_ino + "," + ino);
                        if (parent == -1)
                        {
                            return(null);              //inode does not exist.
                        }
                        else
                        {
                            orderlist[length++] = curr_ino;
                        }

                        //move to parent now.
                        curr_ino = parent;
                    }
                } while (length < 1024);
            }
            return(null);
        }
Ejemplo n.º 6
0
        public static bool Checkout_Wip2(RedFS_Inode inowip, RedFS_Inode mywip, int m_ino)
        {
            WIP_TYPE oldtype = mywip.get_wiptype();

            for (int i = 0; i < 16; i++)
            {
                DEFS.ASSERT(mywip.get_child_dbn(i) == DBN.INVALID, "Wip cannot be valid during checkout, " +
                            i + " value = " + mywip.get_child_dbn(i));
            }
            long fileoffset = m_ino * 128;

            lock (inowip)
            {
                REDDY.ptrRedFS.redfs_read(inowip, fileoffset, mywip.data, 0, 128);
                if (oldtype != WIP_TYPE.UNDEFINED)
                {
                    mywip.set_wiptype(oldtype);
                }
            }
            DEFS.DEBUG("CO_WIP", mywip.get_string_rep2());
            return(mywip.verify_inode_number());
        }