k9core

Coreutils for *nix operating systems [fork]
git clone git://bvnf.space/k9core.git
Log | Files | Refs | LICENSE

chmod.c (346B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>

int
main(int argc, char *argv[])
{
	mode_t mode = atoi(argv[1]);
	for(int i = 2; i < argc; i++) {
		int fd = chmod(argv[i], mode);
		if(fd == -1) {
			fprintf(stderr, "chmod: %s: %s", argv[i], strerror(errno));
			return 1;
		}
	}

	return 0;
}