Fix a bunch of compiler warnings about wrong format types.
[ira/wip.git] / source3 / torture / cmd_vfs.c
index d984dd661c50a71c54a796e04d1f3acaba0086e2..80ee3ec0e8fb7f3ce700de958b853f638bf04aee 100644 (file)
@@ -141,20 +141,49 @@ static NTSTATUS cmd_opendir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc
 
 static NTSTATUS cmd_readdir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
-       SMB_STRUCT_DIRENT *dent;
+       SMB_STRUCT_STAT st;
+       SMB_STRUCT_DIRENT *dent = NULL;
 
        if (vfs->currentdir == NULL) {
                printf("readdir: error=-1 (no open directory)\n");
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       dent = SMB_VFS_READDIR(vfs->conn, vfs->currentdir);
+       dent = SMB_VFS_READDIR(vfs->conn, vfs->currentdir, &st);
        if (dent == NULL) {
                printf("readdir: NULL\n");
                return NT_STATUS_OK;
        }
 
        printf("readdir: %s\n", dent->d_name);
+       if (VALID_STAT(st)) {
+               printf("  stat available");
+               if (S_ISREG(st.st_mode)) printf("  Regular File\n");
+               else if (S_ISDIR(st.st_mode)) printf("  Directory\n");
+               else if (S_ISCHR(st.st_mode)) printf("  Character Device\n");
+               else if (S_ISBLK(st.st_mode)) printf("  Block Device\n");
+               else if (S_ISFIFO(st.st_mode)) printf("  Fifo\n");
+               else if (S_ISLNK(st.st_mode)) printf("  Symbolic Link\n");
+               else if (S_ISSOCK(st.st_mode)) printf("  Socket\n");
+               printf("  Size: %10u", (unsigned int)st.st_size);
+#ifdef HAVE_STAT_ST_BLOCKS
+               printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+#endif
+#ifdef HAVE_STAT_ST_BLKSIZE
+               printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+#endif
+               printf("  Device: 0x%10x", (unsigned int)st.st_dev);
+               printf(" Inode: %10u", (unsigned int)st.st_ino);
+               printf(" Links: %10u\n", (unsigned int)st.st_nlink);
+               printf("  Access: %05o", (int)((st.st_mode) & 007777));
+               printf(" Uid: %5lu Gid: %5lu\n",
+                      (unsigned long)st.st_uid,
+                      (unsigned long)st.st_gid);
+               printf("  Access: %s", ctime(&(st.st_atime)));
+               printf("  Modify: %s", ctime(&(st.st_mtime)));
+               printf("  Change: %s", ctime(&(st.st_ctime)));
+       }
+
        return NT_STATUS_OK;
 }
 
@@ -549,7 +578,7 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        printf("  Device: 0x%10x", (unsigned int)st.st_dev);
        printf(" Inode: %10u", (unsigned int)st.st_ino);
        printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-       printf("  Access: %05o", (st.st_mode) & 007777);
+       printf("  Access: %05o", (int)((st.st_mode) & 007777));
        printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user, 
               (unsigned long)st.st_gid, group);
        printf("  Access: %s", ctime(&(st.st_atime)));
@@ -615,7 +644,7 @@ static NTSTATUS cmd_fstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
        printf("  Device: 0x%10x", (unsigned int)st.st_dev);
        printf(" Inode: %10u", (unsigned int)st.st_ino);
        printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-       printf("  Access: %05o", (st.st_mode) & 007777);
+       printf("  Access: %05o", (int)((st.st_mode) & 007777));
        printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user, 
               (unsigned long)st.st_gid, group);
        printf("  Access: %s", ctime(&(st.st_atime)));
@@ -669,7 +698,7 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
        printf("  Device: 0x%10x", (unsigned int)st.st_dev);
        printf(" Inode: %10u", (unsigned int)st.st_ino);
        printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-       printf("  Access: %05o", (st.st_mode) & 007777);
+       printf("  Access: %05o", (int)((st.st_mode) & 007777));
        printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user, 
               (unsigned long)st.st_gid, group);
        printf("  Access: %s", ctime(&(st.st_atime)));
@@ -795,14 +824,17 @@ static NTSTATUS cmd_getwd(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
 
 static NTSTATUS cmd_utime(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
-       struct timespec ts[2];
+       struct smb_file_time ft;
        if (argc != 4) {
                printf("Usage: utime <path> <access> <modify>\n");
                return NT_STATUS_OK;
        }
-       ts[0] = convert_time_t_to_timespec(atoi(argv[2]));
-       ts[1] = convert_time_t_to_timespec(atoi(argv[3]));
-       if (SMB_VFS_NTIMES(vfs->conn, argv[1], ts) != 0) {
+
+       ZERO_STRUCT(ft);
+
+       ft.atime = convert_time_t_to_timespec(atoi(argv[2]));
+       ft.mtime = convert_time_t_to_timespec(atoi(argv[3]));
+       if (SMB_VFS_NTIMES(vfs->conn, argv[1], &ft) != 0) {
                printf("utime: error=%d (%s)\n", errno, strerror(errno));
                return NT_STATUS_UNSUCCESSFUL;
        }