#include <stdio.h>#include <unistd.h>#include <string.h>#include <time.h>#include <libsmbclient.h>#include "get_auth_data_fn.h"Go to the source code of this file.
Functions | |
| int | main (int argc, char *argv[]) |
|
||||||||||||
|
Definition at line 9 of file testchmod.c. References get_auth_data_fn, mode, printf(), smbc_chmod(), smbc_init(), smbc_stat(), and stat(). 00010 { 00011 int ret; 00012 int debug = 0; 00013 int mode = 0666; 00014 char buffer[16384]; 00015 char * pSmbPath = NULL; 00016 struct stat st; 00017 00018 if (argc == 1) 00019 { 00020 pSmbPath = "smb://RANDOM/Public/small"; 00021 } 00022 else if (argc == 2) 00023 { 00024 pSmbPath = argv[1]; 00025 } 00026 else if (argc == 3) 00027 { 00028 pSmbPath = argv[1]; 00029 mode = (int) strtol(argv[2], NULL, 8); 00030 } 00031 else 00032 { 00033 printf("usage: " 00034 "%s [ smb://path/to/file [ octal_mode ] ]\n", 00035 argv[0]); 00036 return 1; 00037 } 00038 00039 smbc_init(get_auth_data_fn, debug); 00040 00041 if (smbc_stat(pSmbPath, &st) < 0) 00042 { 00043 perror("smbc_stat"); 00044 return 1; 00045 } 00046 00047 printf("\nBefore chmod: mode = %04o\n", st.st_mode); 00048 00049 if (smbc_chmod(pSmbPath, mode) < 0) 00050 { 00051 perror("smbc_chmod"); 00052 return 1; 00053 } 00054 00055 if (smbc_stat(pSmbPath, &st) < 0) 00056 { 00057 perror("smbc_stat"); 00058 return 1; 00059 } 00060 00061 printf("After chmod: mode = %04o\n", st.st_mode); 00062 00063 return 0; 00064 }
|