[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-test-1457-g15ef5e4
Derrell Lipman
derrell.lipman at unwireduniverse.com
Thu Jan 17 14:30:21 GMT 2008
The branch, v3-2-test has been updated
via 15ef5e4884505bca7990e44200d0235764e9057f (commit)
via b4282fbd6d27d868b2d5c04bb72d2d7421822da1 (commit)
via 5a4a7aec761c3388b741b9b47fa6358fc71a66ce (commit)
from e342ca0d931f9a5c8ec9e472dc9c63f1fe012b3a (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 15ef5e4884505bca7990e44200d0235764e9057f
Merge: b4282fbd6d27d868b2d5c04bb72d2d7421822da1 e342ca0d931f9a5c8ec9e472dc9c63f1fe012b3a
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date: Thu Jan 17 09:29:52 2008 -0500
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
commit b4282fbd6d27d868b2d5c04bb72d2d7421822da1
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date: Thu Jan 17 09:29:13 2008 -0500
Fix stat results to be consistent between smbc_stat and smbc_fstat.
We create a kludged inode based on the checksum of the path. We therefore
need to use the same (full) path when calculating it in both smbc_stat() and
smbc_fstat().
If struct stat has an rdev field, set it to zero.
Derrell
commit 5a4a7aec761c3388b741b9b47fa6358fc71a66ce
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date: Thu Jan 17 09:26:36 2008 -0500
Add some additional libsmbclient test programs.
testwrite: create or truncate a file and write to it.
teststat3: compare the results from smbc_stat() and smbc_fstat()
Derrell
-----------------------------------------------------------------------
Summary of changes:
examples/libsmbclient/Makefile | 12 +++-
examples/libsmbclient/teststat3.c | 78 +++++++++++++++++++++
examples/libsmbclient/{testread.c => testwrite.c} | 20 +++---
source/libsmb/libsmbclient.c | 5 +-
4 files changed, 104 insertions(+), 11 deletions(-)
create mode 100644 examples/libsmbclient/teststat3.c
copy examples/libsmbclient/{testread.c => testwrite.c} (71%)
Changeset truncated at 500 lines:
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index 26b8057..9657957 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -22,9 +22,11 @@ TESTS= testsmbc \
testbrowse2 \
teststat \
teststat2 \
+ teststat3 \
testchmod \
testutime \
- testread
+ testread \
+ testwrite
# tree \
@@ -62,6 +64,10 @@ teststat2: teststat2.o
@echo Linking teststat2
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+teststat3: teststat3.o
+ @echo Linking teststat3
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
testchmod: testchmod.o
@echo Linking testchmod
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
@@ -74,6 +80,10 @@ testread: testread.o
@echo Linking testread
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+testwrite: testwrite.o
+ @echo Linking testwrite
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
smbsh:
make -C smbwrapper
diff --git a/examples/libsmbclient/teststat3.c b/examples/libsmbclient/teststat3.c
new file mode 100644
index 0000000..26348b3
--- /dev/null
+++ b/examples/libsmbclient/teststat3.c
@@ -0,0 +1,78 @@
+#include <libsmbclient.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+#include "get_auth_data_fn.h"
+
+/*
+ * This test is intended to ensure that the timestamps returned by
+ * libsmbclient using smbc_stat() are the same as those returned by
+ * smbc_fstat().
+ */
+
+
+int main(int argc, char* argv[])
+{
+ int fd;
+ struct stat st1;
+ struct stat st2;
+ char mtime[32];
+ char ctime[32];
+ char atime[32];
+ char * pUrl = argv[1];
+
+ if(argc != 2)
+ {
+ printf("usage: %s <file_url>\n", argv[0]);
+ return 1;
+ }
+
+
+ smbc_init(get_auth_data_fn, 0);
+
+ if (smbc_stat(pUrl, &st1) < 0)
+ {
+ perror("smbc_stat");
+ return 1;
+ }
+
+ if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
+ {
+ perror("smbc_open");
+ return 1;
+ }
+
+ if (smbc_fstat(fd, &st2) < 0)
+ {
+ perror("smbc_fstat");
+ return 1;
+ }
+
+ smbc_close(fd);
+
+#define COMPARE(name, field) \
+ if (st1.field != st2.field) \
+ { \
+ printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \
+ (unsigned long) st1.field, \
+ (unsigned long) st2.field); \
+ }
+
+ COMPARE("st_dev", st_dev);
+ COMPARE("st_ino", st_ino);
+ COMPARE("st_mode", st_mode);
+ COMPARE("st_nlink", st_nlink);
+ COMPARE("st_uid", st_uid);
+ COMPARE("st_gid", st_gid);
+ COMPARE("st_rdev", st_rdev);
+ COMPARE("st_size", st_size);
+ COMPARE("st_blksize", st_blksize);
+ COMPARE("st_blocks", st_blocks);
+ COMPARE("st_atime", st_atime);
+ COMPARE("st_mtime", st_mtime);
+ COMPARE("st_ctime", st_ctime);
+
+ return 0;
+}
+
diff --git a/examples/libsmbclient/testread.c b/examples/libsmbclient/testwrite.c
similarity index 71%
copy from examples/libsmbclient/testread.c
copy to examples/libsmbclient/testwrite.c
index 3f94884..780f0e9 100644
--- a/examples/libsmbclient/testread.c
+++ b/examples/libsmbclient/testwrite.c
@@ -25,9 +25,14 @@ int main(int argc, char * argv[])
smbc_init(get_auth_data_fn, debug);
+ printf("CAUTION: This program will overwrite a file. "
+ "Press ENTER to continue.");
+ fgets(buffer, sizeof(buffer), stdin);
+
+
for (;;)
{
- fprintf(stdout, "Path: ");
+ fprintf(stdout, "\nPath: ");
*path = '\0';
fgets(path, sizeof(path) - 1, stdin);
if (strlen(path) == 0)
@@ -41,25 +46,22 @@ int main(int argc, char * argv[])
*p = '\0';
}
- if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
+ if ((fd = smbc_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
{
perror("smbc_open");
continue;
}
- do
- {
- ret = smbc_read(fd, buffer, sizeof(buffer));
- savedErrno = errno;
- if (ret > 0) fwrite(buffer, 1, ret, stdout);
- } while (ret > 0);
+ strcpy(buffer, "Hello world\n");
+ ret = smbc_write(fd, buffer, strlen(buffer));
+ savedErrno = errno;
smbc_close(fd);
if (ret < 0)
{
errno = savedErrno;
- perror("read");
+ perror("write");
}
}
diff --git a/source/libsmb/libsmbclient.c b/source/libsmb/libsmbclient.c
index fb04d14..0779706 100644
--- a/source/libsmb/libsmbclient.c
+++ b/source/libsmb/libsmbclient.c
@@ -2264,6 +2264,9 @@ smbc_setup_stat(SMBCCTX *context,
#ifdef HAVE_STAT_ST_BLOCKS
st->st_blocks = (size+511)/512;
#endif
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ st->st_rdev = 0;
+#endif
st->st_uid = getuid();
st->st_gid = getgid();
@@ -2367,7 +2370,7 @@ smbc_stat_ctx(SMBCCTX *context,
st->st_ino = ino;
- smbc_setup_stat(context, st, path, size, mode);
+ smbc_setup_stat(context, st, (char *) fname, size, mode);
set_atimespec(st, access_time_ts);
set_ctimespec(st, change_time_ts);
--
Samba Shared Repository
More information about the samba-cvs
mailing list