svn commit: samba r9306 - in branches/SOC/SAMBA_3_0/source/client: .
kalim at samba.org
kalim at samba.org
Mon Aug 15 03:01:17 GMT 2005
Author: kalim
Date: 2005-08-15 03:01:16 +0000 (Mon, 15 Aug 2005)
New Revision: 9306
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9306
Log:
Fixed minor errors with mkdir.
Added rudimentary dir command to make testing easier while writing do_list related stuff.
-Kalim
Modified:
branches/SOC/SAMBA_3_0/source/client/client.c
Changeset:
Modified: branches/SOC/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-15 01:38:21 UTC (rev 9305)
+++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-15 03:01:16 UTC (rev 9306)
@@ -678,13 +678,40 @@
reset_do_list_queue();
}
+/*******************************************************************
+ Return a string representing an attribute for a file.
+********************************************************************/
+
+fstring *mode_t_string(mode_t mode)
+{
+ static fstring attrstr;
+
+ attrstr[0] = 0;
+
+ S_ISDIR(mode) ? fstrcat(attrstr, "d") : fstrcat(attrstr, "-");
+ (mode & S_IRUSR) ? fstrcat(attrstr, "r") : fstrcat(attrstr, "-");
+ (mode & S_IWUSR) ? fstrcat(attrstr, "w") : fstrcat(attrstr, "-");
+ (mode & S_IXUSR) ? fstrcat(attrstr, "x") : fstrcat(attrstr, "-");
+
+ (mode & S_IRGRP) ? fstrcat(attrstr, "r") : fstrcat(attrstr, "-");
+ (mode & S_IWGRP) ? fstrcat(attrstr, "w") : fstrcat(attrstr, "-");
+ (mode & S_IXGRP) ? fstrcat(attrstr, "x") : fstrcat(attrstr, "-");
+
+ (mode & S_IROTH) ? fstrcat(attrstr, "r") : fstrcat(attrstr, "-");
+ (mode & S_IWOTH) ? fstrcat(attrstr, "w") : fstrcat(attrstr, "-");
+ (mode & S_IXOTH) ? fstrcat(attrstr, "x") : fstrcat(attrstr, "-");
+
+
+ return(&attrstr);
+}
+
/****************************************************************************
Get a directory listing.
****************************************************************************/
static int cmd_dir(void)
{
- uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
+ /*uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
pstring mask;
pstring buf;
char *p=buf;
@@ -715,7 +742,66 @@
DEBUG(3, ("Total bytes listed: %.0f\n", dir_total));
- return rc;
+ return rc;*/
+
+ int dh;
+ pstring res;
+ pstring dpath;
+ pstring dentname;
+ struct stat stat;
+ struct smbc_dirent* dent;
+
+ pstrcpy(dpath, service);
+ pstrcat(dpath, cur_dir);
+ pstrcpy(res, "smb:");
+ pstrcat(res, dpath);
+
+ if ((dh = smbc_opendir(res)) < 1)
+ {
+ d_printf("Error: %s opening %s\n", strerror(errno), res);
+ return 1;
+ }
+
+ while (dent = smbc_readdir(dh))
+ {
+ d_printf("> %-30s", dent->name);
+
+ switch(dent->smbc_type)
+ {
+ case SMBC_WORKGROUP:
+ case SMBC_SERVER:
+ case SMBC_FILE_SHARE:
+ case SMBC_PRINTER_SHARE:
+ case SMBC_COMMS_SHARE:
+ case SMBC_IPC_SHARE:
+ break;
+ case SMBC_DIR:
+ case SMBC_FILE:
+ pstrcpy(dentname, res);
+ pstrcat(dentname, "/");
+ pstrcat(dentname, dent->name);
+ if (smbc_stat(dentname, &stat) < 0)
+ {
+ d_printf(" error: %s", strerror(errno));
+ }
+ else
+ {
+ time_t t = stat.st_mtime;
+ pstring time_str;
+ pstrcpy(time_str, asctime(LocalTime(&t)));
+ time_str[strlen(time_str)-1] = 0;
+ d_printf("%10.10s %8.0f %s", *mode_t_string(stat.st_mode), (double)stat.st_size, time_str);
+ }
+ break;
+
+ case SMBC_LINK:
+ break;
+ }
+
+ printf("\n");
+ }
+ smbc_closedir(dh);
+ return 0;
}
/****************************************************************************
@@ -1083,7 +1169,7 @@
{
if (smbc_mkdir(name, 755) < 0)
{
- DEBUG(2, ("Error: %s making remote directory %s\n", strerror(errno), name));
+ d_printf("Error: %s making remote directory %s\n", strerror(errno), name);
return False;
}
@@ -1157,10 +1243,8 @@
pstrcat(targetname, ddir2);
DEBUG(3, ("Recursively making directory %s\n", targetname));
if ((dh = smbc_opendir(targetname)) < 0) {
- if (!do_mkdir(targetname)) {
- d_printf("Error: %s making remote directory %s\n", strerror(errno), targetname);
- break;
- }
+ if (!do_mkdir(targetname))
+ return 1;
}
else
smbc_closedir(dh);
@@ -1175,7 +1259,7 @@
pstrcat(targetname, mask);
if (!do_mkdir(targetname))
- d_printf("Error: %s making remote directory %s\n", strerror(errno), targetname);
+ return 1;
}
return 0;
@@ -2771,7 +2855,7 @@
/* {"chmod",cmd_chmod,"<src> <mode> chmod a file using UNIX permission",{COMPL_REMOTE,COMPL_REMOTE}}, */
/* {"chown",cmd_chown,"<src> <uid> <gid> chown a file using UNIX uids and gids",{COMPL_REMOTE,COMPL_REMOTE}}, */
/* {"del",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}}, */
-/* {"dir",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},*/
+ {"dir",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
/* {"du",cmd_du,"<mask> computes the total size of the current directory",{COMPL_REMOTE,COMPL_NONE}}, */
{"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
/* {"get",cmd_get,"<remote name> [local name] get a file",{COMPL_REMOTE,COMPL_LOCAL}}, */
@@ -2784,7 +2868,7 @@
/* {"listconnect",cmd_list_connect,"list open connections",{COMPL_NONE,COMPL_NONE}}, */
/* {"logon",cmd_logon,"establish new logon",{COMPL_NONE,COMPL_NONE}}, */
{"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},
-/* {"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},*/
+ {"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
/* {"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}}, */
{"md",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
/* {"mget",cmd_mget,"<mask> get all the matching files",{COMPL_REMOTE,COMPL_NONE}}, */
More information about the samba-cvs
mailing list