system-calls

How to obtain detailed device / partition info from file path on Linux (like UUID, hard drive serial etc.)

孤人 提交于 2019-12-03 11:46:16
Starting with an absolute file path, I want to obtain the following information: The mount point of the filesystem on which the file is stored (in order to compute the path relative to the mount point) The UUID and label of the file system The type (or vendor name) and the serial number of the hard drive that contains the partition I am aware that 2 and 3 may be undefined in many cases (e.g. for loopback, ramfs, encyrpted devices), which is totally fine. I also know how to obtain that information using a shell and system tools like df and the /sys or /proc filesystem. See this question for

New syscall not found (linux kernel 3.0.0) where should I start looking?

北城以北 提交于 2019-12-03 09:49:32
I created two new syscalls, but when I try to test them I get the following error: matt@ubuntu:~/test$ gcc test.c test.c: In function ‘newcall’: test.c:6:17: error: ‘sys_get_slob_amnt_free’ undeclared (first use in this function) test.c:6:17: note: each undeclared identifier is reported only once for each function it appears in matt@ubuntu:~/test$ I also tried this with syscall(sys_get_slob_amnt_free) with the same result. Here is the test code: #include <unistd.h> #include <stdio.h> unsigned long newcall() { return syscall(__NR_get_slob_amnt_free); } int main() { printf("%d\n", newcall());

Trap all accesses to an address range (Linux)

蓝咒 提交于 2019-12-03 09:38:39
问题 Background I'm writing a framework to enable co-simulation of RTL running in a simulator and un-modified host software. The host software is written to control actual hardware and typically works in one of two ways: Read/Write calls through a driver Memory mapped access using mmap The former case is pretty straightforward - write a library that implements the same read / write calls as the driver and link against that when running a simulation. This all works wonderfully and I can run un

GCC how to block system calls within a program?

末鹿安然 提交于 2019-12-03 09:04:30
Does anyone tell me how to block some specific system calls within a program, please? I am building a system which takes a piece of C source code, compiles it with gcc and runs it. For security reasons, I need to prevent the compiled program from calling some system calls. Is there any way to do it, from the source code level (e.g. stripping the header files of gcc, detecting malicious external calls, ...) to the executable level? Edited #1: Add details about malicious calls. Edited #2: My system is a GNU/Linux one. Edited #3: I have tried some methods within a few days and here are the

What is meant by “blocking system call”?

◇◆丶佛笑我妖孽 提交于 2019-12-03 08:26:05
问题 What is the meaning of "blocking system call"? In my operating systems course, we are studying multithreaded programming. I'm unsure what is meant when I read in my textbook "it can allow another thread to run when a thread make a blocking system call" 回答1: A blocking system call is one that must wait until the action can be completed. read() would be a good example - if no input is ready, it'll sit there and wait until some is (provided you haven't set it to non-blocking, of course, in which

Assembly, hello world question

北城余情 提交于 2019-12-03 07:59:50
I'm learning asm on Linux (noobuntu 10.04) I got the following code off of: http://asm.sourceforge.net/intro/hello.html section .text global _start ;must be declared for linker (ld) _start: ;tell linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello, world!',0xa ;our dear string len equ $ - msg ;length of our dear string It's a simple hello world. Runs on Linux + calls the kernel

C++ gettid() was not declared in this scope

故事扮演 提交于 2019-12-03 07:26:37
问题 A simple program is: I would like to get the thread ID of both of the threads using this gettid function. I do not want to do the sysCall directly. I want to use this function. #include <iostream> #include <boost/thread/thread.hpp> #include <boost/date_time/date.hpp> #include <unistd.h> #include <sys/types.h> using namespace boost; using namespace std; boost::thread thread_obj; boost::thread thread_obj1; void func(void) { char x; cout << "enter y to interrupt" << endl; cin >> x; pid_t tid =

Get Sleep/Hibernate and Resume/Wakeup events in Visual Basic.NET

ε祈祈猫儿з 提交于 2019-12-03 07:24:40
I have VB.NET app that communicates with some external server (maintains login sessions via Intranet), and I want to listen for Sleep/Hibernate events such that when it happens, I want to logout an existing session system before computer goes to sleep, while my app will remain running in the background but won't do anything. And vice versa, when computer is resumed from Hibernate or Woke up from sleep, I want to immediately login to the server. How can I grab those events and execute my code? I believe this relates to Win32 API which I'm supposed to use in VB. Thanks. If your application is

How can I make the system call write() print to the screen?

跟風遠走 提交于 2019-12-03 07:22:22
问题 For my OS class I'm supposed to implement Linux's cat using only system calls (no printf) Reading this reference I found it being used to print to a file. I guess I should manipulate ofstream. In the example appears: ofstream outfile ("new.txt",ofstream::binary); How can I make it write to the screen? EDIT: I realized this write() is part of iostream library, is this the same as the int write (int fd, char *buf , int size) system call? 回答1: Write to the file descriptor for standard output or

How can I get a list of Linux system calls and number of args they take automatically?

限于喜欢 提交于 2019-12-03 07:01:39
问题 I writing a Linux system call map for the radare2 debugger. This means providing a huge static array mapping system call number to a syscall name name and the number of arguments it takes. This was easy for OpenBSD as the syscall numbers are defined in sys/syscall.h and in a comment above each is the number of args. It was just a matter of writing a script to parse this and throw out the C code for the array. On linux however, we do not have this luxury. It is easy to get the syscall number