#include <stdio.h>
#include <stdlib.h>
-#include <stdbool.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <time.h>
#include <assert.h>
-#include <sys/time.h>
#include <fcntl.h>
-#include <signal.h>
#include <dirent.h>
-#include <ctype.h>
#include <string.h>
-#include <stdarg.h>
#include <errno.h>
-#include <poll.h>
#include "log.h"
#include "common.h"
-#define BUFF_MAX 255
-
int get_systemd_reboot_param(char *buf, unsigned bufsize)
{
int r = sys_read_buf("/run/systemd/reboot-param", buf, bufsize);
return 0;
}
-int get_command(pid_t pid, char *comm, size_t len)
-{
- FILE *fp;
- char path[PATH_MAX];
- char name[NAME_MAX];
- char *tmp;
- int ret;
-
- snprintf(path, sizeof(path), "/proc/%d/comm", pid);
-
- fp = fopen(path, "r");
- if (!fp) {
- _E("Failed to open file %s, errno:%d", path, errno);
- return -errno;
- }
-
- ret = fread(name, 1, sizeof(name) - 1, fp);
- name[ret] = '\0';
- fclose(fp);
-
- tmp = name;
- while (*tmp != '\0') {
- if (*tmp == '\n' ||
- *tmp == '\r') {
- *tmp = '\0';
- break;
- }
- tmp++;
- }
-
- snprintf(comm, len, "%s", name);
-
- return 0;
-}
-