Ejemplo n.º 1
0
        /// <summary>
        /// Read
        /// </summary>
        /// <param name="node">The node</param>
        /// <param name="offset">The offset</param>
        /// <param name="size">The size</param>
        /// <param name="buffer">The buffer</param>
        /// <returns>The amount of bytes written</returns>
        private static unsafe uint infoReadImpl(Node node, uint offset, uint size, byte[] buffer)
        {
            // Check if the task still exists
            IDCookie cookie = (IDCookie)node.Cookie;
            Task     task   = Tasking.GetTaskByPID(cookie.ID);

            if (task == null)
            {
                return(0);
            }

            ProcFSInfo info = new ProcFSInfo();

            info.Uptime      = task.Uptime;
            info.Priority    = (int)task.Priority;
            info.ThreadCount = task.ThreadCount;
            info.Pid         = task.PID;

            // Copy name and cmdline
            String.CopyTo(info.Name, task.Name, 64);
            String.CopyTo(info.CMDLine, task.CMDLine, 256);

            if (size > sizeof(ProcFSInfo))
            {
                size = (uint)sizeof(ProcFSInfo);
            }

            Memory.Memcpy(Util.ObjectToVoidPtr(buffer), &info, (int)size);

            return(size);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Prints information about a process
        /// </summary>
        /// <param name="name">The directory name</param>
        private static void printProcess(string name)
        {
            string tmp1 = String.Merge("proc://", name);
            string tmp2 = String.Merge(tmp1, "/info");

            File file = new File(tmp2, File.FileMode.ReadOnly);

            if (file.IsOpen)
            {
                ProcFSInfo info = new ProcFSInfo();
                file.Read(&info, sizeof(ProcFSInfo));

                Console.Write("Process ");
                Console.Write(info.Pid);
                Console.Write("\t\t");
                Console.WriteLine(Util.CharPtrToString(info.Name));
                Console.Write("\tCMDLine\t\t");
                Console.WriteLine(Util.CharPtrToString(info.CMDLine));
                Console.Write("\tPriority\t");
                Console.WriteLine(getPriority(info.Priority));
                Console.Write("\tThreads\t\t");
                Console.WriteLine(info.ThreadCount);
                Console.Write("\tUptime\t\t");
                Console.WriteLine((int)info.Uptime);
            }

            file.Close();
            Heap.Free(file);

            Heap.Free(tmp1);
            Heap.Free(tmp2);
        }