source: trunk/minix/commands/i386/mtools-3.9.7/mshowfat.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.4 KB
Line 
1/*
2 * mcopy.c
3 * Copy an MSDOS files to and from Unix
4 *
5 */
6
7
8#define LOWERCASE
9
10#include "sysincludes.h"
11#include "msdos.h"
12#include "mtools.h"
13#include "vfat.h"
14#include "mainloop.h"
15#include "plain_io.h"
16#include "nameclash.h"
17#include "file.h"
18#include "fs.h"
19
20
21
22typedef struct Arg_t {
23 char *target;
24 MainParam_t mp;
25 ClashHandling_t ch;
26 Stream_t *sourcefile;
27} Arg_t;
28
29static int dos_showfat(direntry_t *entry, MainParam_t *mp)
30{
31 Stream_t *File=mp->File;
32
33 fprintPwd(stdout, entry,0);
34 putchar(' ');
35 printFat(File);
36 printf("\n");
37 return GOT_ONE;
38}
39
40static int unix_showfat(MainParam_t *mp)
41{
42 fprintf(stderr,"File does not reside on a Dos fs\n");
43 return ERROR_ONE;
44}
45
46
47static void usage(void)
48{
49 fprintf(stderr,
50 "Mtools version %s, dated %s\n", mversion, mdate);
51 fprintf(stderr,
52 "Usage: %s file ...\n", progname);
53 exit(1);
54}
55
56void mshowfat(int argc, char **argv, int mtype)
57{
58 Arg_t arg;
59 int c, ret;
60
61 /* get command line options */
62
63 init_clash_handling(& arg.ch);
64
65 /* get command line options */
66 while ((c = getopt(argc, argv, "")) != EOF) {
67 switch (c) {
68 case '?':
69 usage();
70 break;
71 }
72 }
73
74 if (argc - optind < 1)
75 usage();
76
77 /* only 1 file to copy... */
78 init_mp(&arg.mp);
79 arg.mp.arg = (void *) &arg;
80
81 arg.mp.callback = dos_showfat;
82 arg.mp.unixcallback = unix_showfat;
83
84 arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN;
85 ret=main_loop(&arg.mp, argv + optind, argc - optind);
86 exit(ret);
87}
Note: See TracBrowser for help on using the repository browser.