commit
[crak.git] / tests / res.c
blob8ac58c930b4c1385b1e1c3d4c905b7a104b580c0
1 /*!
2 * \file res.c
3 * - Author: Alejandro Cabrera
4 * - Date: August 2008
5 * - Brief: Library interface to CRAK module. Wraps IOCTL
6 * functionality in convenient uspace functions.
7 * - Modifications:
8 * - Added doxygen-style documentation.
9 */
10 #include <stdio.h>
11 #include <sys/ioctl.h>
12 #include <fcntl.h>
13 #include "../src/ckpt.h"
15 #define CKPT_TEST "testfile"
17 /*!
18 * \brief IOCTL wrapper to run kernel-level restart.
19 * @param[in] fd
20 * @param[in] pid
21 * @param[in] flags
22 * @return < 0 - error, 0 - success
24 int restart(int fd, const char * filename, int pid, int flags)
26 struct ckpt_param param;
27 int ret, dev_fd;
29 dev_fd = open(CKPT_DEV_FILE, O_RDONLY);
30 if (dev_fd<0)
31 return dev_fd;
33 param.fd = fd;
34 param.filename = filename;
35 param.pid = pid;
36 param.flags = flags;
38 ret = ioctl(dev_fd, CKPT_IOCTL_RESTART, (int)&param);
39 close(dev_fd);
41 return ret;
44 int main()
46 int fd, pid;
48 fd = open(CKPT_TEST, O_RDWR);
49 if(!fd){
50 perror(CKPT_TEST);
51 return -1;
54 printf("Restarting...\n");
56 restart(fd, CKPT_TEST, getpid(), 0);//RESTART_NOTIFY);
58 close(fd);
60 return 0;