Use <dirent.h> instead of <sys/dir.h>

Using <dirent.h> and struct dirent instead of <sys/dir.h> and struct direct
is preferred and works on Android which lacks sys/dir.h.

See:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
This commit is contained in:
Fredrik Fornwall 2014-07-06 16:21:01 +02:00 committed by Jaromir Capik
parent 5d818a7a6d
commit 00279d692a
4 changed files with 5 additions and 6 deletions

View File

@ -34,7 +34,7 @@
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/dir.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef WITH_SYSTEMD
@ -1099,7 +1099,7 @@ next_task:
// This finds processes in /proc in the traditional way.
// Return non-zero on success.
static int simple_nextpid(PROCTAB *restrict const PT, proc_t *restrict const p) {
static struct direct *ent; /* dirent handle */
static struct dirent *ent; /* dirent handle */
char *restrict const path = PT->path;
for (;;) {
ent = readdir(PT->procfs);
@ -1117,7 +1117,7 @@ static int simple_nextpid(PROCTAB *restrict const PT, proc_t *restrict const p)
// This finds tasks in /proc/*/task/ in the traditional way.
// Return non-zero on success.
static int simple_nexttid(PROCTAB *restrict const PT, const proc_t *restrict const p, proc_t *restrict const t, char *restrict const path) {
static struct direct *ent; /* dirent handle */
static struct dirent *ent; /* dirent handle */
if(PT->taskdir_user != p->tgid){
if(PT->taskdir){
closedir(PT->taskdir);

View File

@ -399,7 +399,7 @@ static void crash(const char *filename) {
/***********************************************************************/
static void getrunners(unsigned int *restrict running, unsigned int *restrict blocked) {
struct direct *ent;
struct dirent *ent;
DIR *proc;
*running=0;

View File

@ -1,7 +1,7 @@
#ifndef PROC_SYSINFO_H
#define PROC_SYSINFO_H
#include <sys/types.h>
#include <sys/dir.h>
#include <dirent.h>
#include "procps.h"
EXTERN_C_BEGIN

View File

@ -38,7 +38,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dir.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <termios.h>