1
0
mirror of https://github.com/ioacademy-jikim/android_framwork synced 2025-06-07 07:56:34 +00:00
ioacademy-jikim 22beff8dbe 1
2018-06-14 09:32:50 +09:00

40 lines
637 B
C

#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
void foo( char *dname )
{
DIR *dp;
struct dirent *p;
struct stat buf;
chdir(dname);
dp = opendir(".");
while( p = readdir(dp))
{
int dfd = dirfd(dp);
int fd = openat(dfd, "uevent", O_WRONLY);
write(fd, "add\n", 4);
close(fd);
lstat(p->d_name, &buf);
if( S_ISDIR( buf.st_mode ) )
{
if( strcmp(p->d_name,".") && strcmp(p->d_name,"..") )
foo( p->d_name );
}
}
closedir(dp);
chdir("..");
}
int main()
{
foo(".");
return 0;
}