```
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/efiio.h>
int main(int argc __unused, char **argv __unused)
{
int efi_fd = open("/dev/efi", O_RDWR);
if (efi_fd < 0)
{
printf("Error: cannot open /dev/efi\n");
return 1;
}
struct efi_tm now;
int rv = ioctl(efi_fd, EFIIOC_GET_TIME, &now);
printf("rv = %i, errno = %i = %s\n", rv, errno, strerror(errno));
printf("EFI says now is: %i.%i.%i %i:%i:%i (%i)\n\n",
now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, now.tm_tz);
struct efi_waketime_ioc wt;
rv = ioctl(efi_fd, EFIIOC_GET_WAKETIME, &wt);
printf("rv = %i, errno = %i = %s\n", rv, errno, strerror(errno));
printf("EFI wake time is: %i.%i.%i %i:%i:%i (%i); enabled=%i, pending=%i\n\n",
wt.waketime.tm_year, wt.waketime.tm_mon, wt.waketime.tm_mday, wt.waketime.tm_hour,
wt.waketime.tm_min, wt.waketime.tm_sec, wt.waketime.tm_tz, wt.enabled, wt.pending);
wt.enabled = 1;
wt.waketime = now;
wt.waketime.tm_min = (wt.waketime.tm_min + 5) % 60;
rv = ioctl(efi_fd, EFIIOC_SET_WAKETIME, &wt);
printf("rv = %i, errno = %i = %s\n\n", rv, errno, strerror(errno));
return 0;
}
```
Tested on laptop: reports unsupported.
Tested on NAS: reports everything is fine, including enabled, pending etc. BUT: does not actually wake from S3.
So no idea if this actually works...