2 Unix SMB/CIFS implementation.
5 Copyright (C) Simo Sorce 2002
6 Copyright (C) Eric Lorimer 2002
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 static char *null_string = "";
28 static NTSTATUS cmd_load_module(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
30 struct smb_vfs_handle_struct *handle;
33 printf("Usage: load <module path>\n");
36 vfs->conn->vfs_private = NULL;
37 handle = (struct smb_vfs_handle_struct *) smb_xmalloc(sizeof(smb_vfs_handle_struct));
38 handle->handle = NULL;
39 DLIST_ADD(vfs->conn->vfs_private, handle)
40 if (!vfs_init_custom(vfs->conn, argv[1])) {
41 DEBUG(0, ("load: error=-1 (vfs_init_custom failed for %s)\n", argv[1]));
42 return NT_STATUS_UNSUCCESSFUL;
48 static NTSTATUS cmd_populate(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
53 printf("Usage: populate <char> <size>\n");
58 vfs->data = (char *)talloc(mem_ctx, size);
59 if (vfs->data == NULL) {
60 printf("populate: error=-1 (not enough memory)");
61 return NT_STATUS_UNSUCCESSFUL;
63 memset(vfs->data, c, size);
64 vfs->data_size = size;
68 static NTSTATUS cmd_show_data(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
72 if (argc != 1 && argc != 3) {
73 printf("Usage: showdata [<offset> <len>]\n");
76 if (vfs->data == NULL || vfs->data_size == 0) {
77 printf("show_data: error=-1 (buffer empty)\n");
78 return NT_STATUS_UNSUCCESSFUL;
82 offset = atoi(argv[1]);
88 if ((offset + len) > vfs->data_size) {
89 printf("show_data: error=-1 (not enough data in buffer)\n");
90 return NT_STATUS_UNSUCCESSFUL;
92 dump_data(0, (char *)(vfs->data) + offset, len);
96 static NTSTATUS cmd_connect(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
98 vfs->conn->vfs_ops.connect(vfs->conn, lp_servicename(vfs->conn->service), "vfstest");
102 static NTSTATUS cmd_disconnect(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
104 vfs->conn->vfs_ops.disconnect(vfs->conn);
108 static NTSTATUS cmd_disk_free(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
110 SMB_BIG_UINT diskfree, bsize, dfree, dsize;
112 printf("Usage: disk_free <path>\n");
116 diskfree = vfs->conn->vfs_ops.disk_free(vfs->conn, argv[1], False, &bsize, &dfree, &dsize);
117 printf("disk_free: %ld, bsize = %ld, dfree = %ld, dsize = %ld\n", diskfree, bsize, dfree, dsize);
122 static NTSTATUS cmd_opendir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
125 printf("Usage: opendir <fname>\n");
129 vfs->currentdir = vfs->conn->vfs_ops.opendir(vfs->conn, argv[1]);
130 if (vfs->currentdir == NULL) {
131 printf("opendir error=%d (%s)\n", errno, strerror(errno));
132 return NT_STATUS_UNSUCCESSFUL;
135 printf("opendir: ok\n");
140 static NTSTATUS cmd_readdir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
144 if (vfs->currentdir == NULL) {
145 printf("readdir: error=-1 (no open directory)\n");
146 return NT_STATUS_UNSUCCESSFUL;
149 dent = vfs->conn->vfs_ops.readdir(vfs->conn, vfs->currentdir);
151 printf("readdir: NULL\n");
155 printf("readdir: %s\n", dent->d_name);
160 static NTSTATUS cmd_mkdir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
163 printf("Usage: mkdir <path>\n");
167 if (vfs->conn->vfs_ops.mkdir(vfs->conn, argv[1], 00755) == -1) {
168 printf("mkdir error=%d (%s)\n", errno, strerror(errno));
169 return NT_STATUS_UNSUCCESSFUL;
172 printf("mkdir: ok\n");
177 static NTSTATUS cmd_closedir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
181 if (vfs->currentdir == NULL) {
182 printf("closedir: failure (no directory open)\n");
183 return NT_STATUS_UNSUCCESSFUL;
186 ret = vfs->conn->vfs_ops.closedir(vfs->conn, vfs->currentdir);
188 printf("closedir failure: %s\n", strerror(errno));
189 return NT_STATUS_UNSUCCESSFUL;
192 printf("closedir: ok\n");
193 vfs->currentdir = NULL;
198 static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
205 if (argc < 3 || argc > 5) {
206 printf("Usage: open <filename> <flags> <mode>\n");
207 printf(" flags: O = O_RDONLY\n");
208 printf(" R = O_RDWR\n");
209 printf(" W = O_WRONLY\n");
210 printf(" C = O_CREAT\n");
211 printf(" E = O_EXCL\n");
212 printf(" T = O_TRUNC\n");
213 printf(" A = O_APPEND\n");
214 printf(" N = O_NONBLOCK/O_NDELAY\n");
215 printf(" S = O_SYNC\n");
217 printf(" F = O_NOFOLLOW\n");
219 printf(" mode: see open.2\n");
220 printf(" mode is ignored if C flag not present\n");
221 printf(" mode defaults to 00400\n");
261 printf("open: error=-1 (invalid flag!)\n");
262 return NT_STATUS_UNSUCCESSFUL;
266 if ((flags & O_CREAT) && argc == 4) {
267 if (sscanf(argv[3], "%o", &mode) == 0) {
268 printf("open: error=-1 (invalid mode!)\n");
269 return NT_STATUS_UNSUCCESSFUL;
273 fd = vfs->conn->vfs_ops.open(vfs->conn, argv[1], flags, mode);
275 printf("open: error=%d (%s)\n", errno, strerror(errno));
276 return NT_STATUS_UNSUCCESSFUL;
279 vfs->files[fd] = (struct files_struct *)malloc(sizeof(struct files_struct));
280 vfs->files[fd]->fsp_name = strdup(argv[1]);
281 vfs->files[fd]->fd = fd;
282 vfs->files[fd]->conn = vfs->conn;
283 printf("open: fd=%d\n", fd);
288 static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
291 struct func_entry *fptr;
292 struct func_entry func_table[] = {
293 { "rmdir", vfs->conn->vfs_ops.rmdir },
294 { "unlink", vfs->conn->vfs_ops.unlink },
295 { "chdir", vfs->conn->vfs_ops.chdir },
300 printf("Usage: %s <path>\n", argv[0]);
304 for (fptr=func_table; *fptr->name; fptr++)
305 if (strcmp(fptr->name, argv[0]) == 0 )
306 ret = fptr->fn(vfs->conn, argv[1]);
309 printf("%s: error=%d (%s)\n", argv[0], errno, strerror(errno));
310 return NT_STATUS_UNSUCCESSFUL;
313 printf("%s: ok\n", argv[0]);
318 static NTSTATUS cmd_close(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
323 printf("Usage: close <fd>\n");
328 if (vfs->files[fd] == NULL) {
329 printf("close: error=-1 (invalid file descriptor)\n");
333 ret = vfs->conn->vfs_ops.close(vfs->files[fd], fd);
335 printf("close: error=%d (%s)\n", errno, strerror(errno));
337 printf("close: ok\n");
339 SAFE_FREE(vfs->files[fd]->fsp_name);
340 SAFE_FREE(vfs->files[fd]);
341 vfs->files[fd] = NULL;
346 static NTSTATUS cmd_read(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
352 printf("Usage: read <fd> <size>\n");
356 /* do some error checking on these */
358 size = atoi(argv[2]);
359 vfs->data = (char *)talloc(mem_ctx, size);
360 if (vfs->data == NULL) {
361 printf("read: error=-1 (not enough memory)");
362 return NT_STATUS_UNSUCCESSFUL;
364 vfs->data_size = size;
366 rsize = vfs->conn->vfs_ops.read(vfs->files[fd], fd, vfs->data, size);
368 printf("read: error=%d (%s)\n", errno, strerror(errno));
369 return NT_STATUS_UNSUCCESSFUL;
372 printf("read: ok\n");
377 static NTSTATUS cmd_write(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
382 printf("Usage: write <fd> <size>\n");
386 /* some error checking should go here */
388 size = atoi(argv[2]);
389 if (vfs->data == NULL) {
390 printf("write: error=-1 (buffer empty, please populate it before writing)");
391 return NT_STATUS_UNSUCCESSFUL;
394 if (vfs->data_size < size) {
395 printf("write: error=-1 (buffer too small, please put some more data in)");
396 return NT_STATUS_UNSUCCESSFUL;
399 wsize = vfs->conn->vfs_ops.write(vfs->files[fd], fd, vfs->data, size);
402 printf("write: error=%d (%s)\n", errno, strerror(errno));
403 return NT_STATUS_UNSUCCESSFUL;
406 printf("write: ok\n");
411 static NTSTATUS cmd_lseek(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
413 int fd, offset, whence;
417 printf("Usage: lseek <fd> <offset> <whence>\n...where whence is 1 => SEEK_SET, 2 => SEEK_CUR, 3 => SEEK_END\n");
422 offset = atoi(argv[2]);
423 whence = atoi(argv[3]);
425 case 1: whence = SEEK_SET; break;
426 case 2: whence = SEEK_CUR; break;
427 default: whence = SEEK_END;
430 pos = vfs->conn->vfs_ops.lseek(vfs->files[fd], fd, offset, whence);
431 if (pos == (SMB_OFF_T)-1) {
432 printf("lseek: error=%d (%s)\n", errno, strerror(errno));
433 return NT_STATUS_UNSUCCESSFUL;
436 printf("lseek: ok\n");
441 static NTSTATUS cmd_rename(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
445 printf("Usage: rename <old> <new>\n");
449 ret = vfs->conn->vfs_ops.rename(vfs->conn, argv[1], argv[2]);
451 printf("rename: error=%d (%s)\n", errno, strerror(errno));
452 return NT_STATUS_UNSUCCESSFUL;
455 printf("rename: ok\n");
460 static NTSTATUS cmd_fsync(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
464 printf("Usage: fsync <fd>\n");
469 ret = vfs->conn->vfs_ops.fsync(vfs->files[fd], fd);
471 printf("fsync: error=%d (%s)\n", errno, strerror(errno));
472 return NT_STATUS_UNSUCCESSFUL;
475 printf("fsync: ok\n");
480 static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
490 printf("Usage: stat <fname>\n");
494 ret = vfs->conn->vfs_ops.stat(vfs->conn, argv[1], &st);
496 printf("stat: error=%d (%s)\n", errno, strerror(errno));
497 return NT_STATUS_UNSUCCESSFUL;
500 pwd = sys_getpwuid(st.st_uid);
501 if (pwd != NULL) user = strdup(pwd->pw_name);
502 else user = null_string;
503 grp = sys_getgrgid(st.st_gid);
504 if (grp != NULL) group = strdup(grp->gr_name);
505 else group = null_string;
507 printf("stat: ok\n");
508 printf(" File: %s", argv[1]);
509 if (S_ISREG(st.st_mode)) printf(" Regular File\n");
510 else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
511 else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
512 else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
513 else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
514 else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
515 else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
516 printf(" Size: %10d", st.st_size);
517 printf(" Blocks: %9d", st.st_blocks);
518 printf(" IO Block: %d\n", st.st_blksize);
519 printf(" Device: 0x%.10x", st.st_dev);
520 printf(" Inode: %10d", st.st_ino);
521 printf(" Links: %10d\n", st.st_nlink);
522 printf(" Access: %05o", (st.st_mode) & 007777);
523 printf(" Uid: %5d/%.16s Gid: %5d/%.16s\n", st.st_uid, user, st.st_gid, group);
524 printf(" Access: %s", ctime(&(st.st_atime)));
525 printf(" Modify: %s", ctime(&(st.st_mtime)));
526 printf(" Change: %s", ctime(&(st.st_ctime)));
527 if (user != null_string) SAFE_FREE(user);
528 if (group!= null_string) SAFE_FREE(group);
533 static NTSTATUS cmd_fstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
543 printf("Usage: fstat <fd>\n");
548 if (fd < 0 || fd > 1024) {
549 printf("fstat: error=%d (file descriptor out of range)\n", EBADF);
553 if (vfs->files[fd] == NULL) {
554 printf("fstat: error=%d (invalid file descriptor)\n", EBADF);
558 if (vfs->conn->vfs_ops.fstat(vfs->files[fd], fd, &st) == -1) {
559 printf("fstat: error=%d (%s)\n", errno, strerror(errno));
560 return NT_STATUS_UNSUCCESSFUL;
563 pwd = sys_getpwuid(st.st_uid);
564 if (pwd != NULL) user = strdup(pwd->pw_name);
565 else user = null_string;
566 grp = sys_getgrgid(st.st_gid);
567 if (grp != NULL) group = strdup(grp->gr_name);
568 else group = null_string;
570 printf("fstat: ok\n");
571 if (S_ISREG(st.st_mode)) printf(" Regular File\n");
572 else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
573 else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
574 else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
575 else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
576 else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
577 else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
578 printf(" Size: %10d", st.st_size);
579 printf(" Blocks: %9d", st.st_blocks);
580 printf(" IO Block: %d\n", st.st_blksize);
581 printf(" Device: 0x%10x", st.st_dev);
582 printf(" Inode: %10d", st.st_ino);
583 printf(" Links: %10d\n", st.st_nlink);
584 printf(" Access: %05o", (st.st_mode) & 007777);
585 printf(" Uid: %5d/%.16s Gid: %5d/%.16s\n", st.st_uid, user, st.st_gid, group);
586 printf(" Access: %s", ctime(&(st.st_atime)));
587 printf(" Modify: %s", ctime(&(st.st_mtime)));
588 printf(" Change: %s", ctime(&(st.st_ctime)));
589 if (user != null_string) SAFE_FREE(user);
590 if (group!= null_string) SAFE_FREE(group);
595 static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
604 printf("Usage: lstat <path>\n");
608 if (vfs->conn->vfs_ops.lstat(vfs->conn, argv[1], &st) == -1) {
609 printf("lstat: error=%d (%s)\n", errno, strerror(errno));
610 return NT_STATUS_UNSUCCESSFUL;
613 pwd = sys_getpwuid(st.st_uid);
614 if (pwd != NULL) user = strdup(pwd->pw_name);
615 else user = null_string;
616 grp = sys_getgrgid(st.st_gid);
617 if (grp != NULL) group = strdup(grp->gr_name);
618 else group = null_string;
620 printf("lstat: ok\n");
621 if (S_ISREG(st.st_mode)) printf(" Regular File\n");
622 else if (S_ISDIR(st.st_mode)) printf(" Directory\n");
623 else if (S_ISCHR(st.st_mode)) printf(" Character Device\n");
624 else if (S_ISBLK(st.st_mode)) printf(" Block Device\n");
625 else if (S_ISFIFO(st.st_mode)) printf(" Fifo\n");
626 else if (S_ISLNK(st.st_mode)) printf(" Symbolic Link\n");
627 else if (S_ISSOCK(st.st_mode)) printf(" Socket\n");
628 printf(" Size: %10d", st.st_size);
629 printf(" Blocks: %9d", st.st_blocks);
630 printf(" IO Block: %d\n", st.st_blksize);
631 printf(" Device: 0x%10x", st.st_dev);
632 printf(" Inode: %10d", st.st_ino);
633 printf(" Links: %10d\n", st.st_nlink);
634 printf(" Access: %05o", (st.st_mode) & 007777);
635 printf(" Uid: %5d/%.16s Gid: %5d/%.16s\n", st.st_uid, user, st.st_gid, group);
636 printf(" Access: %s", ctime(&(st.st_atime)));
637 printf(" Modify: %s", ctime(&(st.st_mtime)));
638 printf(" Change: %s", ctime(&(st.st_ctime)));
639 if (user != null_string) SAFE_FREE(user);
640 if (group!= null_string) SAFE_FREE(group);
645 static NTSTATUS cmd_chmod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
649 printf("Usage: chmod <path> <mode>\n");
653 mode = atoi(argv[2]);
654 if (vfs->conn->vfs_ops.chmod(vfs->conn, argv[1], mode) == -1) {
655 printf("chmod: error=%d (%s)\n", errno, strerror(errno));
656 return NT_STATUS_UNSUCCESSFUL;
659 printf("chmod: ok\n");
664 static NTSTATUS cmd_fchmod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
669 printf("Usage: fchmod <fd> <mode>\n");
674 mode = atoi(argv[2]);
675 if (fd < 0 || fd > 1024) {
676 printf("fchmod: error=%d (file descriptor out of range)\n", EBADF);
679 if (vfs->files[fd] == NULL) {
680 printf("fchmod: error=%d (invalid file descriptor)\n", EBADF);
684 if (vfs->conn->vfs_ops.fchmod(vfs->files[fd], fd, mode) == -1) {
685 printf("fchmod: error=%d (%s)\n", errno, strerror(errno));
686 return NT_STATUS_UNSUCCESSFUL;
689 printf("fchmod: ok\n");
694 static NTSTATUS cmd_chown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
699 printf("Usage: chown <path> <uid> <gid>\n");
705 if (vfs->conn->vfs_ops.chown(vfs->conn, argv[1], uid, gid) == -1) {
706 printf("chown: error=%d (%s)\n", errno, strerror(errno));
707 return NT_STATUS_UNSUCCESSFUL;
710 printf("chown: ok\n");
715 static NTSTATUS cmd_fchown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
721 printf("Usage: fchown <fd> <uid> <gid>\n");
728 if (fd < 0 || fd > 1024) {
729 printf("fchown: faliure=%d (file descriptor out of range)\n", EBADF);
732 if (vfs->files[fd] == NULL) {
733 printf("fchown: error=%d (invalid file descriptor)\n", EBADF);
736 if (vfs->conn->vfs_ops.fchown(vfs->files[fd], fd, uid, gid) == -1) {
737 printf("fchown error=%d (%s)\n", errno, strerror(errno));
738 return NT_STATUS_UNSUCCESSFUL;
741 printf("fchown: ok\n");
746 static NTSTATUS cmd_getwd(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
749 if (vfs->conn->vfs_ops.getwd(vfs->conn, buf) == NULL) {
750 printf("getwd: error=%d (%s)\n", errno, strerror(errno));
751 return NT_STATUS_UNSUCCESSFUL;
754 printf("getwd: %s\n", buf);
758 static NTSTATUS cmd_utime(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
760 struct utimbuf times;
762 printf("Usage: utime <path> <access> <modify>\n");
765 times.actime = atoi(argv[2]);
766 times.modtime = atoi(argv[3]);
767 if (vfs->conn->vfs_ops.utime(vfs->conn, argv[1], ×) != 0) {
768 printf("utime: error=%d (%s)\n", errno, strerror(errno));
769 return NT_STATUS_UNSUCCESSFUL;
772 printf("utime: ok\n");
776 static NTSTATUS cmd_ftruncate(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
781 printf("Usage: ftruncate <fd> <length>\n");
787 if (fd < 0 || fd > 1024) {
788 printf("ftruncate: error=%d (file descriptor out of range)\n", EBADF);
791 if (vfs->files[fd] == NULL) {
792 printf("ftruncate: error=%d (invalid file descriptor)\n", EBADF);
796 if (vfs->conn->vfs_ops.ftruncate(vfs->files[fd], fd, off) == -1) {
797 printf("ftruncate: error=%d (%s)\n", errno, strerror(errno));
798 return NT_STATUS_UNSUCCESSFUL;
801 printf("ftruncate: ok\n");
805 static NTSTATUS cmd_lock(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
807 printf("lock: Not yet implemented!\n");
811 static NTSTATUS cmd_symlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
814 printf("Usage: symlink <path> <link>\n");
818 if (vfs->conn->vfs_ops.symlink(vfs->conn, argv[1], argv[2]) == -1) {
819 printf("symlink: error=%d (%s)\n", errno, strerror(errno));
820 return NT_STATUS_UNSUCCESSFUL;
823 printf("symlink: ok\n");
828 static NTSTATUS cmd_readlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
830 char buffer[PATH_MAX];
834 printf("Usage: readlink <path>\n");
838 if ((size = vfs->conn->vfs_ops.readlink(vfs->conn, argv[1], buffer, PATH_MAX)) == -1) {
839 printf("readlink: error=%d (%s)\n", errno, strerror(errno));
840 return NT_STATUS_UNSUCCESSFUL;
844 printf("readlink: %s\n", buffer);
849 static NTSTATUS cmd_link(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
852 printf("Usage: link <path> <link>\n");
856 if (vfs->conn->vfs_ops.link(vfs->conn, argv[1], argv[2]) == -1) {
857 printf("link: error=%d (%s)\n", errno, strerror(errno));
858 return NT_STATUS_UNSUCCESSFUL;
861 printf("link: ok\n");
865 static NTSTATUS cmd_mknod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
867 printf("lock: Not yet implemented!\n");
871 static NTSTATUS cmd_realpath(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, char **argv)
873 char respath[PATH_MAX];
876 printf("Usage: realpath <path>\n");
880 if (vfs->conn->vfs_ops.realpath(vfs->conn, argv[1], respath) == NULL) {
881 printf("realpath: error=%d (%s)\n", errno, strerror(errno));
882 return NT_STATUS_UNSUCCESSFUL;
885 printf("realpath: ok\n");
889 struct cmd_set vfs_commands[] = {
893 { "load", cmd_load_module, "Load a module", "load <module.so>" },
894 { "populate", cmd_populate, "Populate a data buffer", "populate <char> <size>" },
895 { "showdata", cmd_show_data, "Show data currently in data buffer", "show_data [<offset> <len>]"},
896 { "connect", cmd_connect, "VFS connect()", "connect" },
897 { "disconnect", cmd_disconnect, "VFS disconnect()", "disconnect" },
898 { "disk_free", cmd_disk_free, "VFS disk_free()", "disk_free <path>" },
899 { "opendir", cmd_opendir, "VFS opendir()", "opendir <fname>" },
900 { "readdir", cmd_readdir, "VFS readdir()", "readdir" },
901 { "mkdir", cmd_mkdir, "VFS mkdir()", "mkdir <path>" },
902 { "rmdir", cmd_pathfunc, "VFS rmdir()", "rmdir <path>" },
903 { "closedir", cmd_closedir, "VFS closedir()", "closedir" },
904 { "open", cmd_open, "VFS open()", "open <fname>" },
905 { "close", cmd_close, "VFS close()", "close <fd>" },
906 { "read", cmd_read, "VFS read()", "read <fd> <size>" },
907 { "write", cmd_write, "VFS write()", "write <fd> <size>" },
908 { "lseek", cmd_lseek, "VFS lseek()", "lseek <fd> <offset> <whence>" },
909 { "rename", cmd_rename, "VFS rename()", "rename <old> <new>" },
910 { "fsync", cmd_fsync, "VFS fsync()", "fsync <fd>" },
911 { "stat", cmd_stat, "VFS stat()", "stat <fname>" },
912 { "fstat", cmd_fstat, "VFS fstat()", "fstat <fd>" },
913 { "lstat", cmd_lstat, "VFS lstat()", "lstat <fname>" },
914 { "unlink", cmd_pathfunc, "VFS unlink()", "unlink <fname>" },
915 { "chmod", cmd_chmod, "VFS chmod()", "chmod <path> <mode>" },
916 { "fchmod", cmd_fchmod, "VFS fchmod()", "fchmod <fd> <mode>" },
917 { "chown", cmd_chown, "VFS chown()", "chown <path> <uid> <gid>" },
918 { "fchown", cmd_fchown, "VFS fchown()", "fchown <fd> <uid> <gid>" },
919 { "chdir", cmd_pathfunc, "VFS chdir()", "chdir <path>" },
920 { "getwd", cmd_getwd, "VFS getwd()", "getwd" },
921 { "utime", cmd_utime, "VFS utime()", "utime <path> <access> <modify>" },
922 { "ftruncate", cmd_ftruncate, "VFS ftruncate()", "ftruncate <fd> <length>" },
923 { "lock", cmd_lock, "VFS lock()", "lock: Not yet implemented!" },
924 { "symlink", cmd_symlink, "VFS symlink()", "symlink <old> <new>" },
925 { "readlink", cmd_readlink, "VFS readlink()", "readlink <path>" },
926 { "link", cmd_link, "VFS link()", "link <oldpath> <newpath>" },
927 { "mknod", cmd_mknod, "VFS mknod()", "mknod: Not yet implemented!" },
928 { "realpath", cmd_realpath, "VFS realpath()", "realpath <path>" },