1 // Copyright 2016 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <zircon/device/device.h>
6 #include <fcntl.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 
main(int argc,char ** argv)11 int main(int argc, char **argv) {
12     if (argc != 2) {
13         fprintf(stderr, "Usage: %s <device path>\n", argv[0]);
14         return -1;
15     }
16 
17     const char* path = argv[1];
18 
19     int fd = open(path, O_RDWR);
20     if (fd < 0) {
21         fprintf(stderr, "could not open %s\n", path);
22         return -1;
23     }
24 
25     printf("suspending %s\n", path);
26     int ret = ioctl_device_debug_suspend(fd);
27     if (ret != ZX_OK) {
28         fprintf(stderr, "suspend failed: %d\n", ret);
29         goto out;
30     }
31 
32     sleep(5);
33 
34     printf("resuming %s\n", path);
35     ret = ioctl_device_debug_resume(fd);
36     if (ret != ZX_OK) {
37         fprintf(stderr, "resume failed: %d\n", ret);
38     }
39 
40 out:
41     close(fd);
42     return ret;
43 }
44