Last change
on this file was 206, checked in by Herwig Bauernfeind, 16 years ago |
Import Samba 3.3 branch at 3.0.0 level (psmedley's port)
|
File size:
1.2 KB
|
Rev | Line | |
---|
[206] | 1 | #include <stdio.h>
|
---|
| 2 | #include <unistd.h>
|
---|
| 3 | #include <string.h>
|
---|
| 4 | #include <time.h>
|
---|
| 5 | #include <libsmbclient.h>
|
---|
| 6 | #include "get_auth_data_fn.h"
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | int main(int argc, char * argv[])
|
---|
| 10 | {
|
---|
| 11 | int ret;
|
---|
| 12 | int debug = 0;
|
---|
| 13 | int mode = 0666;
|
---|
| 14 | char buffer[16384];
|
---|
| 15 | char * pSmbPath = NULL;
|
---|
| 16 | struct stat st;
|
---|
| 17 |
|
---|
| 18 | if (argc == 1)
|
---|
| 19 | {
|
---|
| 20 | pSmbPath = "smb://RANDOM/Public/small";
|
---|
| 21 | }
|
---|
| 22 | else if (argc == 2)
|
---|
| 23 | {
|
---|
| 24 | pSmbPath = argv[1];
|
---|
| 25 | }
|
---|
| 26 | else if (argc == 3)
|
---|
| 27 | {
|
---|
| 28 | pSmbPath = argv[1];
|
---|
| 29 | mode = (int) strtol(argv[2], NULL, 8);
|
---|
| 30 | }
|
---|
| 31 | else
|
---|
| 32 | {
|
---|
| 33 | printf("usage: "
|
---|
| 34 | "%s [ smb://path/to/file [ octal_mode ] ]\n",
|
---|
| 35 | argv[0]);
|
---|
| 36 | return 1;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | smbc_init(get_auth_data_fn, debug);
|
---|
| 40 |
|
---|
| 41 | if (smbc_stat(pSmbPath, &st) < 0)
|
---|
| 42 | {
|
---|
| 43 | perror("smbc_stat");
|
---|
| 44 | return 1;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | printf("\nBefore chmod: mode = %04o\n", st.st_mode);
|
---|
| 48 |
|
---|
| 49 | if (smbc_chmod(pSmbPath, mode) < 0)
|
---|
| 50 | {
|
---|
| 51 | perror("smbc_chmod");
|
---|
| 52 | return 1;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | if (smbc_stat(pSmbPath, &st) < 0)
|
---|
| 56 | {
|
---|
| 57 | perror("smbc_stat");
|
---|
| 58 | return 1;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | printf("After chmod: mode = %04o\n", st.st_mode);
|
---|
| 62 |
|
---|
| 63 | return 0;
|
---|
| 64 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.