The Samba-Bugzilla – Attachment 1881 Details for
Bug 3564
smbget have reversed exit status codes.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
With this patch smbget would return 0 on every INCOMPLETE download and would return 1 on a SUCCESSFUL download
patch-smbget (text/plain), 3.51 KB, created by
Amit Regmi
on 2006-04-27 07:55:48 UTC
(
hide
)
Description:
With this patch smbget would return 0 on every INCOMPLETE download and would return 1 on a SUCCESSFUL download
Filename:
MIME Type:
Creator:
Amit Regmi
Created:
2006-04-27 07:55:48 UTC
Size:
3.51 KB
patch
obsolete
>diff -Naur samba-3.0.21c/source/utils/smbget.c samba-3.0.21c.new/source/utils/smbget.c >--- samba-3.0.21c/source/utils/smbget.c 2006-01-24 23:46:40.000000000 +0000 >+++ samba-3.0.21c.new/source/utils/smbget.c 2006-04-26 19:03:33.295307224 +0000 >@@ -121,12 +121,19 @@ > const char *relname = name; > char *tmpname; > struct stat remotestat; >+ int flag1 =1, flag2 ; /* will remain 1 for COMPLETE DOWNLOAD .. else 0 */ > snprintf(path, SMB_MAXPATHLEN-1, "%s%s%s", base, (base[0] && name[0] && name[0] != '/' && base[strlen(base)-1] != '/')?"/":"", name); > > /* List files in directory and call smb_download_file on them */ > dirhandle = smbc_opendir(path); > if(dirhandle < 1) { >- if(errno == ENOTDIR) return smb_download_file(base, name, 1, resume, NULL); >+ if(errno == ENOTDIR) { >+ flag2 = smb_download_file(base, name, 1, resume, NULL); >+ printf("\n flag2 =%d \n", flag2); >+ if(flag2 == 0) >+ flag1 = 0; >+ return(flag2); >+ } > fprintf(stderr, "Can't open directory %s: %s\n", path, strerror(errno)); > return 0; > } >@@ -154,7 +161,10 @@ > break; > > case SMBC_FILE: >- smb_download_file(base, newname, 1, resume, NULL); >+ flag2 = smb_download_file(base, newname, 1, resume, NULL); >+ printf("\n flag2 =%d \n", flag2); >+ if(flag2 == 0) >+ flag1 = 0; > break; > > case SMBC_FILE_SHARE: >@@ -194,9 +204,11 @@ > return 0; > } > } >- > smbc_closedir(dirhandle); >- return 1; >+ if(flag1 == 0) >+ return 0; /* INCOMPLETE DOWNLOAD */ >+ else >+ return 1; /* COMPLETE DOWNLOAD */ > } > > char *print_time(long t) >@@ -266,7 +278,7 @@ > return 0; > } > smb_download_dir(base, name, resume); >- return 0; >+ return 1; > > case ENOENT: > fprintf(stderr, "%s can't be found on the remote server\n", path); >@@ -447,17 +459,20 @@ > return 1; > } > >-void clean_exit(void) >+void clean_exit(int n) > { > char bs[100]; > human_readable(total_bytes, bs, sizeof(bs)); > if(!quiet)fprintf(stderr, "Downloaded %s in %lu seconds\n", bs, time(NULL) - total_start_time); >- exit(0); >+ if(n==-1) >+ exit(1); /*comes from the end of main */ >+ else >+ exit(0); /*comes from signal interrupts SIGINT and SIGTERM*/ > } > > void signal_quit(int v) > { >- clean_exit(); >+ clean_exit(v); > } > > int readrcfile(const char *name, const struct poptOption long_options[]) >@@ -469,7 +484,7 @@ > int *intdata; char **stringdata; > if(!fd) { > fprintf(stderr, "Can't open RC file %s\n", name); >- return 1; >+ return 0; /*read failure*/ > } > > while(!feof(fd)) { >@@ -505,7 +520,7 @@ > fprintf(stderr, "Invalid variable %s at line %d in %s\n", var, lineno, name); > break; > } >- >+ > found = 1; > } > if(!found) { >@@ -514,7 +529,7 @@ > } > > fclose(fd); >- return 0; >+ return 1; /*successful read*/ > } > > int main(int argc, const char **argv) >@@ -573,17 +588,17 @@ > > if((send_stdout || outputfile) && _recursive) { > fprintf(stderr, "The -o or -O and -R options can not be used together.\n"); >- return 1; >+ return 0; > } > > if(outputfile && send_stdout) { > fprintf(stderr, "The -o and -O options cannot be used together.\n"); >- return 1; >+ return 0; > } > > if(smbc_init(get_auth_data, debuglevel) < 0) { > fprintf(stderr, "Unable to initialize libsmbclient\n"); >- return 1; >+ return 0; > } > > columns = get_num_cols(); >@@ -593,11 +608,9 @@ > while ( (file = poptGetArg(pc)) ) { > if (!_recursive) > return smb_download_file(file, "", _recursive, _resume, outputfile); >- else >+ else > return smb_download_dir(file, "", _resume); > } >- >- clean_exit(); >- >- return 0; >+ clean_exit(-1); /* a download success call */ >+ return 1; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 3564
:
1880
| 1881