svn commit: samba r21641 - in branches: SAMBA_3_0/source/client SAMBA_3_0_25/source/client

jra at samba.org jra at samba.org
Thu Mar 1 21:56:55 GMT 2007


Author: jra
Date: 2007-03-01 21:56:54 +0000 (Thu, 01 Mar 2007)
New Revision: 21641

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21641

Log:
Add test code for POSIX pathname calls into smbclient.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/client/client.c
   branches/SAMBA_3_0_25/source/client/client.c


Changeset:
Modified: branches/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SAMBA_3_0/source/client/client.c	2007-03-01 21:36:05 UTC (rev 21640)
+++ branches/SAMBA_3_0/source/client/client.c	2007-03-01 21:56:54 UTC (rev 21641)
@@ -1747,6 +1747,146 @@
 	return 0;
 }
 
+/****************************************************************************
+****************************************************************************/
+
+static int cmd_posix_open(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+	mode_t mode;
+	int fnum;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_open <filename> 0<mode>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_open <filename> 0<mode>\n");
+		return 1;
+	}
+	mode = (mode_t)strtol(buf, (char **)NULL, 8);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname )) {
+		d_printf("posix_open %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	fnum = cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode);
+	if (fnum == -1) {
+		fnum = cli_posix_open(targetcli, targetname, O_CREAT|O_RDONLY, mode);
+		if (fnum != -1) {
+			d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+		} else {
+			d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
+		}
+	} else {
+		d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+	}
+
+	return 0;
+}
+
+static int cmd_posix_mkdir(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+	mode_t mode;
+	int fnum;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_mkdir <filename> 0<mode>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_mkdir <filename> 0<mode>\n");
+		return 1;
+	}
+	mode = (mode_t)strtol(buf, (char **)NULL, 8);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname )) {
+		d_printf("posix_mkdir %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	fnum = cli_posix_mkdir(targetcli, targetname, mode);
+	if (fnum == -1) {
+		d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
+	} else {
+		d_printf("posix_mkdir created directory %s\n", targetname);
+	}
+
+	return 0;
+}
+
+static int cmd_posix_unlink(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_unlink <filename>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname )) {
+		d_printf("posix_unlink %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	if (!cli_posix_unlink(targetcli, targetname)) {
+		d_printf("Failed to unlink file %s. %s\n", targetname, cli_errstr(cli));
+	} else {
+		d_printf("posix_unlink deleted file %s\n", targetname);
+	}
+
+	return 0;
+}
+
+static int cmd_posix_rmdir(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_rmdir <filename>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname)) {
+		d_printf("posix_rmdir %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	if (!cli_posix_rmdir(targetcli, targetname)) {
+		d_printf("Failed to unlink directory %s. %s\n", targetname, cli_errstr(cli));
+	} else {
+		d_printf("posix_rmdir deleted directory %s\n", targetname);
+	}
+
+	return 0;
+}
+
 static int cmd_close(void)
 {
 	fstring buf;
@@ -1797,6 +1937,9 @@
         if (caplow & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
 		pstrcat(caps, "pathnames ");
 	}
+        if (caplow & CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP) {
+		pstrcat(caps, "posix_path_operations ");
+	}
 
 	if (strlen(caps) > 0 && caps[strlen(caps)-1] == ' ') {
 		caps[strlen(caps)-1] = '\0';
@@ -3035,6 +3178,10 @@
   {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
   {"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
   {"posix", cmd_posix, "turn on all POSIX capabilities", {COMPL_REMOTE,COMPL_NONE}},
+  {"posix_open",cmd_posix_open,"<name> 0<mode> open_flags mode open a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
+  {"posix_mkdir",cmd_posix_mkdir,"<name> 0<mode> creates a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
+  {"posix_rmdir",cmd_posix_rmdir,"<name> removes a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
+  {"posix_unlink",cmd_posix_unlink,"<name> removes a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
   {"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}},
   {"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},  
   {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}},

Modified: branches/SAMBA_3_0_25/source/client/client.c
===================================================================
--- branches/SAMBA_3_0_25/source/client/client.c	2007-03-01 21:36:05 UTC (rev 21640)
+++ branches/SAMBA_3_0_25/source/client/client.c	2007-03-01 21:56:54 UTC (rev 21641)
@@ -1739,7 +1739,6 @@
 	return 0;
 }
 
-
 /****************************************************************************
 ****************************************************************************/
 
@@ -1779,6 +1778,146 @@
 	return 0;
 }
 
+/****************************************************************************
+****************************************************************************/
+
+static int cmd_posix_open(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+	mode_t mode;
+	int fnum;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_open <filename> 0<mode>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_open <filename> 0<mode>\n");
+		return 1;
+	}
+	mode = (mode_t)strtol(buf, (char **)NULL, 8);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname )) {
+		d_printf("posix_open %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	fnum = cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode);
+	if (fnum == -1) {
+		fnum = cli_posix_open(targetcli, targetname, O_CREAT|O_RDONLY, mode);
+		if (fnum != -1) {
+			d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+		} else {
+			d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
+		}
+	} else {
+		d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
+	}
+
+	return 0;
+}
+
+static int cmd_posix_mkdir(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+	mode_t mode;
+	int fnum;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_mkdir <filename> 0<mode>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_mkdir <filename> 0<mode>\n");
+		return 1;
+	}
+	mode = (mode_t)strtol(buf, (char **)NULL, 8);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname )) {
+		d_printf("posix_mkdir %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	fnum = cli_posix_mkdir(targetcli, targetname, mode);
+	if (fnum == -1) {
+		d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
+	} else {
+		d_printf("posix_mkdir created directory %s\n", targetname);
+	}
+
+	return 0;
+}
+
+static int cmd_posix_unlink(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_unlink <filename>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname )) {
+		d_printf("posix_unlink %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	if (!cli_posix_unlink(targetcli, targetname)) {
+		d_printf("Failed to unlink file %s. %s\n", targetname, cli_errstr(cli));
+	} else {
+		d_printf("posix_unlink deleted file %s\n", targetname);
+	}
+
+	return 0;
+}
+
+static int cmd_posix_rmdir(void)
+{
+	pstring mask;
+	pstring buf;
+	struct cli_state *targetcli;
+	pstring targetname;
+
+	pstrcpy(mask,cur_dir);
+	
+	if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+		d_printf("posix_rmdir <filename>\n");
+		return 1;
+	}
+	pstrcat(mask,buf);
+
+	if (!cli_resolve_path( "", cli, mask, &targetcli, targetname)) {
+		d_printf("posix_rmdir %s: %s\n", mask, cli_errstr(cli));
+		return 1;
+	}
+	
+	if (!cli_posix_rmdir(targetcli, targetname)) {
+		d_printf("Failed to unlink directory %s. %s\n", targetname, cli_errstr(cli));
+	} else {
+		d_printf("posix_rmdir deleted directory %s\n", targetname);
+	}
+
+	return 0;
+}
+
 static int cmd_close(void)
 {
 	fstring buf;
@@ -1829,6 +1968,9 @@
         if (caplow & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
 		pstrcat(caps, "pathnames ");
 	}
+        if (caplow & CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP) {
+		pstrcat(caps, "posix_path_operations ");
+	}
 
 	if (strlen(caps) > 0 && caps[strlen(caps)-1] == ' ') {
 		caps[strlen(caps)-1] = '\0';
@@ -3067,6 +3209,10 @@
   {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
   {"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
   {"posix", cmd_posix, "turn on all POSIX capabilities", {COMPL_REMOTE,COMPL_NONE}},
+  {"posix_open",cmd_posix_open,"<name> 0<mode> open_flags mode open a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
+  {"posix_mkdir",cmd_posix_mkdir,"<name> 0<mode> creates a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
+  {"posix_rmdir",cmd_posix_rmdir,"<name> removes a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
+  {"posix_unlink",cmd_posix_unlink,"<name> removes a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
   {"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}},
   {"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},  
   {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}},



More information about the samba-cvs mailing list