- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 - 69
 - 70
 - 71
 - 72
 - 73
 - 74
 - 75
 - 76
 
                        #include "uni.h"
int getopt_long(int argc, char *const argv[],const char *optstring,const struct option *longopts, int *longindex);
int getopt__long_only(int argc, char *const argv[],const char *optstring,const struct option *longopts, int *longindex);
int chown(const char *path, uid_t owner, gid_t group);
uid_t getuid(void);
int mkdir(const char *pathname, mode_t mode);
gid_t getgid(void);
char *dirname;
mode_t perm;
uid_t owner;
gid_t group;
int main(int argc,char **argv){
  owner=getuid();
  group=getgid();
  perm=0600;
char *pEnd;
char *dirname=(char*)malloc(16);
  if(dirname==NULL){fprintf(stderr, "out of memory!\n");return -1;}
   memset( dirname,'\0',16); 
   strcat(dirname,argv[argc-1]);
struct option longopts[] = {
  { "mode", required_argument, NULL, 'm' },
  { "parents", NULL, NULL, 'p'},
  { "verbose", required_argument, NULL, 'v'},
  { "context", required_argument, NULL, 'c'},
  { "help", NULL, NULL, 'h'},
  { "version", NULL, NULL, 'r'},
{ 0, 0, 0, 0 } 
};
char c;
while((c=getopt_long(argc,argv,"m:p:v:c:r:h",longopts,NULL)) != -1) {
  switch (c) {
    case 'm':
      perm=strtol(optarg,&pEnd,8);
      printf("%s\n",pEnd);
      break;
    case 'p':
      if(rmdir(dirname)<0){
        fprintf(stderr, "don't manage to delete folder!\n");return -1;
      }
      break;
    case 'v':
      if(mkdir(dirname,perm)<0){
        fprintf(stderr, "mkdir: cannot create directory `%s`: file exists\n",dirname);return -1;
      } else {
        printf("mkdir: created directory `%s`\n",dirname);
        return 0;
      }
      break;
    case 'c':
      break;
    case 'h':
      printf("Usage: mkdir [OPTION]... DIRECTORY...\n");
      printf("Create the DIRECTORY(ies), if they do not already exist.\n");
      printf("\n");
      printf("Mandatory arguments to long options are mandatory for short options too.\n");
      printf("  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask\n");
      printf("  -p, --parents     no error if existing, make parent directories as needed\n");
      printf("  -v, --verbose     print a message for each created directory\n");
      printf("  -Z, --context=CTX  set the SELinux security context of each created\n");
      printf("                      directory to CTX\n");
      printf("      --help     display this help and exit\n");
      printf("      --version  output version information and exit\n");
      printf("\tAuthor AliceGoth\n");
      return 0;
      break;
    case 'r':
      printf("\tMy own mkdir\n");
      printf("\tVersion 1.0\n");
      printf("\tAuthor AliceGoth\n");
      printf("\tEmail [email protected]\n");
      break;
    case 1: