propagator/common.c

33 lines
565 B
C
Raw Normal View History

#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include "common.h"
int mkdir_dev(const char * name)
{
char pathname[PATH_MAX + 1] = "/dev/";
strcpy(pathname + 5, name);
return (mkdir(pathname, 0755) == 0 || errno == EEXIST) ? 0 : -1;
}
int mkdirs_dev(const char * name, ...)
{
va_list args;
int ret = 0;
va_start(args, name);
for (; name; name = va_arg(args, const char *))
if (mkdir_dev(name) && errno != EEXIST) {
ret = -1;
break;
}
va_end(args);
return ret;
}