Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, Guys can u please convert the psuedo code here to proper linux/C/kernel syntax. Ive finally managed to invoke the custom syscall in my codes but I require it to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    1

    Custom reboot system call


    Hi,

    Guys can u please convert the psuedo code here to proper linux/C/kernel syntax. Ive finally managed to invoke the custom syscall in my codes but I require it to do more than just print to screen


    Code:
    #include <linux/linkage.h>
    #include <linux/kernel.h>
    #include <unistd.h>
    #include <linux/reboot.h>
    #include <linux/timer.h>
    #include <sys/reboot.h> 
    
    asmlinkage long sys_customreboot ( int delay)
    {
    
    printk("<1>You have successfully called a custom syscall");
    
    // value= get current time  + delay (seconds);
    //
    // while ( current time != value)   /*after factor seconds*/
    // {};           /* wait here*/
    // reboot();
    
    return 1;
    }

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    So you just want to run a command (i.e., /sbin/reboot)? Tried the system func? Or do you mean something else?

  3. #3
    Just Joined!
    Join Date
    Oct 2006
    Posts
    3

    SystemCall *(reboot the system, only disk flush!!!)

    #include <stdio.h>
    #include <sys/reboot.h>


    int
    main (int argc, char **argv)
    {
    if (reboot (RB_AUTOBOOT) < 0) {
    fprintf (stderr, "%s: call to reboot() system call failed.\n",
    argv[0]);
    }

    return 0;
    }

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •