The Samba-Bugzilla – Attachment 5063 Details for
Bug 6925
Kernel does not refresh mtime after write
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
A short test program
test-utimes.c (text/plain), 2.55 KB, created by
Jörg Sommer (mail address dead)
on 2009-12-07 14:47:37 UTC
(
hide
)
Description:
A short test program
Filename:
MIME Type:
Creator:
Jörg Sommer (mail address dead)
Created:
2009-12-07 14:47:37 UTC
Size:
2.55 KB
patch
obsolete
>#include <errno.h> >#include <libsmbclient.h> >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <sys/types.h> >#include <sys/time.h> >#include <time.h> >#include <unistd.h> > >static void >get_auth_data_fn(const char * pServer, > const char * pShare, > char * pWorkgroup, > int maxLenWorkgroup, > char * pUsername, > int maxLenUsername, > char * pPassword, > int maxLenPassword) >{ > (void)pServer; > (void)pShare; > strncpy(pWorkgroup, "", (size_t)maxLenWorkgroup - 1); > strncpy(pUsername, "", (size_t)maxLenUsername - 1); > strncpy(pPassword, "", (size_t)maxLenPassword - 1); > return; >} > >void print_stat_real(const char *prefix, const struct stat *st) >{ > char mtime[32], Ctime[32], atime[32]; > strncpy(mtime, ctime(&st->st_mtime), sizeof(mtime)); > strncpy(Ctime, ctime(&st->st_ctime), sizeof(Ctime)); > strncpy(atime, ctime(&st->st_atime), sizeof(atime)); > mtime[strlen(mtime)-1] = '\0'; > Ctime[strlen(Ctime)-1] = '\0'; > atime[strlen(atime)-1] = '\0'; > > printf("%-10s: mtime=%s ctime=%s atime=%s\n", prefix, mtime, Ctime, atime); >} > >void print_stat(const char* path, int fd) >{ > struct stat st; > > if (smbc_stat(path, &st) == 0) > print_stat_real("stat", &st); > else > printf("stat(%s): %s\n", path, strerror(errno)); > > if (fd != -1) > { > if (smbc_fstat(fd, &st) == 0) > print_stat_real("fstat", &st); > else > printf("fstat(%d): %s\n", fd, strerror(errno)); > } >} > >int main(void) >{ > const int debug = 0; > const char path[2048] = "smb://10.10.10.6/all-homes/joerg/test"; > > smbc_init(get_auth_data_fn, debug); > > const time_t now = time(NULL); > printf("Current time: %s", ctime(&now)); > > int fd = smbc_open(path, O_WRONLY | O_TRUNC | O_CREAT, 0666); > if (fd < 0) > { > perror("smbc_open new"); > return 1; > } > puts("open succeed"); > > print_stat(path, fd); > > struct timeval tv[2]; > tv[0].tv_sec = now; > tv[0].tv_usec = 0; > tv[1].tv_sec = now - 16; > tv[1].tv_usec = 0; > if (smbc_utimes(path, tv) != 0) > { > perror("utimes"); > goto end; > } > puts("utimes succeed"); > > print_stat(path, fd); > > char buffer[2048]; > strncpy(buffer, "Hello world\n", sizeof(buffer)); > if (smbc_write(fd, buffer, strlen(buffer)) < 0) > { > perror("write"); > goto end; > } > puts("write succeed"); > > print_stat(path, fd); > >end: > smbc_close(fd); > puts("close succeed"); > > print_stat(path, -1); > > return 0; >}
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 6925
:
4994
|
4995
|
4996
| 5063 |
5265
|
5266