public virtual void TestOperationsWhileInSafeMode() { Path file1 = new Path("/file1"); NUnit.Framework.Assert.IsFalse(dfs.SetSafeMode(HdfsConstants.SafeModeAction.SafemodeGet )); DFSTestUtil.CreateFile(fs, file1, 1024, (short)1, 0); NUnit.Framework.Assert.IsTrue("Could not enter SM", dfs.SetSafeMode(HdfsConstants.SafeModeAction .SafemodeEnter)); RunFsFun("Set quota while in SM", new _FSRun_319(file1)); RunFsFun("Set perm while in SM", new _FSRun_325(file1)); RunFsFun("Set owner while in SM", new _FSRun_331(file1)); RunFsFun("Set repl while in SM", new _FSRun_337(file1)); RunFsFun("Append file while in SM", new _FSRun_343(file1)); RunFsFun("Truncate file while in SM", new _FSRun_349(file1)); RunFsFun("Delete file while in SM", new _FSRun_355(file1)); RunFsFun("Rename file while in SM", new _FSRun_361(file1)); RunFsFun("Set time while in SM", new _FSRun_367(file1)); RunFsFun("modifyAclEntries while in SM", new _FSRun_373(file1)); RunFsFun("removeAclEntries while in SM", new _FSRun_379(file1)); RunFsFun("removeDefaultAcl while in SM", new _FSRun_385(file1)); RunFsFun("removeAcl while in SM", new _FSRun_391(file1)); RunFsFun("setAcl while in SM", new _FSRun_397(file1)); RunFsFun("setXAttr while in SM", new _FSRun_403(file1)); RunFsFun("removeXAttr while in SM", new _FSRun_409(file1)); try { DFSTestUtil.ReadFile(fs, file1); } catch (IOException) { NUnit.Framework.Assert.Fail("Set times failed while in SM"); } try { fs.GetAclStatus(file1); } catch (IOException) { NUnit.Framework.Assert.Fail("getAclStatus failed while in SM"); } // Test access UserGroupInformation ugiX = UserGroupInformation.CreateRemoteUser("userX"); FileSystem myfs = ugiX.DoAs(new _PrivilegedExceptionAction_429(this)); myfs.Access(file1, FsAction.Read); try { myfs.Access(file1, FsAction.Write); NUnit.Framework.Assert.Fail("The access call should have failed."); } catch (AccessControlException) { } // expected NUnit.Framework.Assert.IsFalse("Could not leave SM", dfs.SetSafeMode(HdfsConstants.SafeModeAction .SafemodeLeave)); }
/// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/> /// <exception cref="System.IO.FileNotFoundException"/> /// <exception cref="System.IO.IOException"/> public override void Access(Path path, FsAction mode) { fs.Access(path, mode); }
internal static int Dispatch(Thread current, ref ExceptionRegisters regs) { int scno, arg0, arg1, arg2, arg3, arg4, arg5; ArchAPI.GetSyscallParameters(regs, out scno, out arg0, out arg1, out arg2, out arg3, out arg4, out arg5); current.AsyncReturn = false; int retval = 0; switch (scno) { case __NR_exit: Console.Write("Thread "); Console.Write(current.Tid); Console.WriteLine(" Exited"); current.Exit(); current.AsyncReturn = true; break; case __NR_read: retval = FileSystem.Read(current, ref regs, arg0, new UserPtr(arg1), arg2); break; case __NR_write: retval = FileSystem.Write(current, ref regs, arg0, new UserPtr(arg1), arg2); break; case __NR_open: retval = FileSystem.Open(current, ref regs, new UserPtr(arg0), arg1, arg2); break; case __NR_close: retval = FileSystem.Close(current, arg0); break; case __NR_unlink: retval = FileSystem.Unlink(current, new UserPtr(arg0)); break; case __NR_lseek: retval = FileSystem.Lseek(current, arg0, arg1, arg2); break; case __NR_getpid: retval = ExpressOS.Kernel.Misc.Getpid(current); break; case __NR_access: retval = FileSystem.Access(current, ref regs, new UserPtr(arg0), arg1); break; case __NR_mkdir: retval = FileSystem.Mkdir(current, new UserPtr(arg0), arg1); break; case __NR_clone: retval = ExpressOS.Kernel.Exec.Clone(current, (uint)arg0, new UserPtr(arg1), new UserPtr(arg2), new UserPtr(arg3), ref regs); break; case __NR_mprotect: retval = ExpressOS.Kernel.Memory.mprotect(current, new UserPtr(arg0), arg1, arg2); break; case __NR__newselect: retval = ExpressOS.Kernel.Net.Select(current, ref regs, arg0, new UserPtr(arg1), new UserPtr(arg2), new UserPtr(arg3), new UserPtr(arg4)); break; case __NR_writev: retval = FileSystem.Writev(current, ref regs, arg0, new UserPtr(arg1), arg2); break; case __NR_uname: retval = ExpressOS.Kernel.Misc.UName(current, new UserPtr(arg0)); break; case __NR_fcntl64: retval = FileSystem.Fcntl64(current, arg0, arg1, arg2); break; case __NR_gettid: retval = ExpressOS.Kernel.Misc.Gettid(current); break; case __NR_dup: retval = FileSystem.Dup(current, arg0); break; case __NR_pipe: retval = FileSystem.Pipe(current, new UserPtr(arg0)); break; case __NR_brk: retval = (int)ExpressOS.Kernel.Memory.Brk(current, (uint)arg0); break; case __NR_ioctl: retval = FileSystem.Ioctl(current, ref regs, arg0, arg1, arg2); break; case __NR_setgid32: case __NR_setuid32: case __NR_flock: case __NR_sigaction: case __NR_sigprocmask: case __NR_sched_setscheduler: case __NR_setpriority: case __NR_fsync: //Console.Write("Mock syscall "); //Console.Write(scno); //Console.WriteLine(); retval = 0; break; case __NR_futex: retval = ExpressOS.Kernel.Futex.DoFutex(current, ref regs, new UserPtr(arg0), arg1, arg2, new UserPtr(arg3), new UserPtr(arg4), (uint)arg5); break; case __NR_dup2: retval = FileSystem.Dup2(current, arg0, arg1); break; case __NR_gettimeofday: retval = ExpressOS.Kernel.Misc.Gettimeofday(current, new UserPtr(arg0)); break; case __NR_munmap: retval = ExpressOS.Kernel.Memory.munmap(current, new UserPtr(arg0), arg1); break; case __NR_ftruncate: retval = FileSystem.ftruncate(current, arg0, arg1); break; case __NR_socketcall: retval = ExpressOS.Kernel.Net.socketcall(current, ref regs, arg0, new UserPtr(arg1)); break; case __NR_getpriority: retval = ExpressOS.Kernel.Misc.Getpriority(current, arg0, arg1); break; case __NR_pread64: retval = FileSystem.Pread64(current, ref regs, arg0, new UserPtr(arg1), arg2, (uint)arg3); break; case __NR_getcwd: retval = FileSystem.Getcwd(current, new UserPtr(arg0), arg1); break; case __NR_mmap2: retval = ExpressOS.Kernel.Memory.mmap2(current, new UserPtr(arg0), arg1, arg2, arg3, arg4, arg5); break; case __NR_stat64: retval = FileSystem.Stat64(current, new UserPtr(arg0), new UserPtr(arg1)); break; case __NR_fstat64: retval = FileSystem.FStat64(current, arg0, new UserPtr(arg1)); break; case __NR_lstat64: retval = FileSystem.LStat64(current, new UserPtr(arg0), new UserPtr(arg1)); break; case __NR_getuid32: case __NR_geteuid32: retval = ExpressOS.Kernel.Misc.Getuid32(current); break; case __NR_madvise: retval = ExpressOS.Kernel.Memory.madvise(current, (uint)arg0, arg1, arg2); break; case __NR_nanosleep: retval = ExpressOS.Kernel.Misc.Nanosleep(current, ref regs, new UserPtr(arg0), new UserPtr(arg1)); break; case __NR_sched_yield: retval = ExpressOS.Kernel.Misc.Yield(current, ref regs); break; case __NR_poll: retval = ExpressOS.Kernel.Net.Poll(current, ref regs, new UserPtr(arg0), arg1, arg2); break; case __NR_set_thread_area: retval = ExpressOS.Kernel.TLS.SetThreadArea(current, new UserPtr(arg0)); break; case __NR_clock_gettime: retval = ExpressOS.Kernel.Misc.ClockGetTime(current, arg0, new UserPtr(arg1)); break; case __NR_exit_group: Console.WriteLine("Process exited"); Console.Flush(); //Misc.DumpStackTrace(current, new UserPtr(pt_regs->ebp)); //current.Parent.Space.Regions.DumpAll(); current.AsyncReturn = true; break; case __NR_vbinder: retval = ExpressOS.Kernel.VBinder.Dispatch(current, ref regs, arg0, arg1, arg2, arg3); break; default: Console.Write("Unknown syscall "); Console.Write(scno); Console.Write('@'); Console.Write(regs.ip); Console.Write(" tid="); Console.Write(current.Tid); Console.WriteLine(); retval = -ErrorCode.ENOSYS; break; } return(retval); }