









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










An introduction to some privileged Linux system-calls (needed for an upcoming programming exercise)
#include <asm/uaccess.h> // for get_fs(), set_ds() char pathname[] = “/dev/cmos”; // pathname for file to be ‘unlinked’ int retval; // for the system-call’s return-value
{ set_fs( get_ds() ); // allow kernel to address our data asm(“ pushal “); // preserve registers asm(“ mov $15, %eax “); // ID for ‘sys_chmod()’ asm(“ mov $pathname, %ebx “); // address of pathname asm(“ mov $000666, %ecx “); // read-and-write by all asm(“ int $0x80 “); // invoke kernel service asm(“ mov %eax, retval “); // save the return-value asm(“ popal “); // recover registers }