コード例 #1
0
		public ProcFDTable Fork(int newpid)
		{
			ProcFDTable other = new ProcFDTable(newpid);

			foreach (var item in curFiles)
				other.curFiles[item.Key] = item.Value;

			return other;
		}
コード例 #2
0
ファイル: Program.cs プロジェクト: maheshdharhari/flash-sim
		static IOItem ProceedLineInTry(int pid, string line)
		{
			int eqPos = line.LastIndexOf(" = ");
			if (eqPos == -1)
				return null;

			string retstring = line.Substring(eqPos + 3).Split(' ')[0];
			long ret;

			if (retstring == "?")
				return null;
			ret = retstring.ParseHexLong();
			if (ret < 0)
				return null;


			int leftBracketPos = line.IndexOf('(');
			int rightBracketPos = line.LastIndexOf(')', eqPos);
			int beforeCmdSpace = line.LastIndexOf(' ', leftBracketPos);

			string cmd = line.Substring(beforeCmdSpace + 1, leftBracketPos - beforeCmdSpace - 1);
			string args = line.Substring(leftBracketPos + 1, rightBracketPos - leftBracketPos - 1);


			ProcFDTable table;
			if (!fdTables.TryGetValue(pid, out table))
			{
				table = new ProcFDTable(pid);
				fdTables[pid] = table;
			}

			switch (cmd)
			{
				case "fork":
				case "vfork":
				case "clone": fdTables[(int)ret] = table.Fork((int)ret); return null;

				case "dup":
				case "dup2": return table.OnDup(args, ret);

				case "open":
				case "creat": return table.OnOpen(args, ret);

				case "mmap": return table.OnMmap(1, args);
				case "mmap2": return table.OnMmap((int)Config.PageSize, args);
				case "mremap":
				case "msync":
				case "munmap": return null;

				case "read": return table.OnReadWrite(AccessRoutine.Read, args, ret);
				case "readv": return table.OnReadWrite(AccessRoutine.Readv, args, ret);
				case "pread": return table.OnReadWrite(AccessRoutine.Pread, args, ret);
				case "write": return table.OnReadWrite(AccessRoutine.Write, args, ret);
				case "writev": return table.OnReadWrite(AccessRoutine.Writev, args, ret);
				case "pwrite": return table.OnReadWrite(AccessRoutine.Pwrite, args, ret);

				case "accept": return table.OnAccept(args, ret);
				case "close": return table.OnClose(args);
				case "fcntl": return table.OnFcntl(args, ret);
				case "lseek": return table.OnLSeek(args, ret);
				case "_llseek": return table.OnLLSeek(args);
				case "pipe": return table.OnPipe(args);
				case "socket": return table.OnSocket(args, ret);

				default: return null;
			}
		}