mtools.h

Go to the documentation of this file.
00001 #ifndef MTOOLS_MTOOLS_H
00002 #define MTOOLS_MTOOLS_H
00003 
00004 #include "msdos.h"
00005 
00006 #if defined(OS_sco3)
00007 #define MAXPATHLEN 1024
00008 #include <signal.h>
00009 extern int lockf(int, int, off_t);  /* SCO has no proper include file for lockf */
00010 #endif 
00011 
00012 #define SCSI_FLAG 1
00013 #define PRIV_FLAG 2
00014 #define NOLOCK_FLAG 4
00015 #define USE_XDF_FLAG 8
00016 #define MFORMAT_ONLY_FLAG 16
00017 #define VOLD_FLAG 32
00018 #define FLOPPYD_FLAG 64
00019 #define FILTER_FLAG 128
00020 
00021 #define IS_SCSI(x)  ((x) && ((x)->misc_flags & SCSI_FLAG))
00022 #define IS_PRIVILEGED(x) ((x) && ((x)->misc_flags & PRIV_FLAG))
00023 #define IS_NOLOCK(x) ((x) && ((x)->misc_flags & NOLOCK_FLAG))
00024 #define IS_MFORMAT_ONLY(x) ((x) && ((x)->misc_flags & MFORMAT_ONLY_FLAG))
00025 #define SHOULD_USE_VOLD(x) ((x)&& ((x)->misc_flags & VOLD_FLAG))
00026 #define SHOULD_USE_XDF(x) ((x)&& ((x)->misc_flags & USE_XDF_FLAG))
00027 
00028 typedef struct device {
00029         const char *name;       /* full path to device */
00030 
00031         char *drive;                    /* the drive letter / device name */
00032         int fat_bits;                   /* FAT encoding scheme */
00033 
00034         unsigned int mode;              /* any special open() flags */
00035         unsigned int tracks;    /* tracks */
00036         unsigned int heads;             /* heads */
00037         unsigned int sectors;   /* sectors */
00038         unsigned int hidden;    /* number of hidden sectors. Used for
00039                                                          * mformatting partitioned devices */
00040 
00041         off_t offset;           /* skip this many bytes */
00042 
00043         unsigned int partition;
00044 
00045         unsigned int misc_flags;
00046 
00047         /* Linux only stuff */
00048         unsigned int ssize;
00049         unsigned int use_2m;
00050 
00051         char *precmd;           /* command to be executed before opening
00052                                                  * the drive */
00053 
00054         /* internal variables */
00055         int file_nr;            /* used during parsing */
00056         int blocksize;          /* size of disk block in bytes */
00057 
00058         const char *cfg_filename; /* used for debugging purposes */
00059 } device_t;
00060 
00061 
00062 #ifndef OS_linux
00063 #define BOOTSIZE 512
00064 #else
00065 #define BOOTSIZE 256
00066 #endif
00067 
00068 #include "stream.h"
00069 
00070 
00071 extern const char *short_illegals, *long_illegals;
00072 
00073 #define maximize(target, max) do { \
00074   if(max < 0) { \
00075     if(target > 0) \
00076       target = 0; \
00077   } else if(target > max) { \
00078     target = max; \
00079   } \
00080 } while(0)
00081 
00082 #define minimize(target, min) do { \
00083   if(target < min) \
00084     target = min; \
00085 } while(0) 
00086 
00087 int init_geom(int fd, struct device *dev, struct device *orig_dev,
00088               struct stat *stat);
00089 
00090 int readwrite_sectors(int fd, /* file descriptor */
00091                       int *drive,
00092                       int rate,
00093                       int seektrack,
00094                       int track, int head, int sector, int size, /* address */
00095                       char *data, 
00096                       int bytes,
00097                       int direction,
00098                       int retries);
00099 
00100 int lock_dev(int fd, int mode, struct device *dev);
00101 
00102 char *unix_normalize (char *ans, char *name, char *ext);
00103 char *dos_name(char *filename, int verbose, int *mangled, char *buffer);
00104 struct directory *mk_entry(const char *filename, char attr,
00105                            unsigned int fat, size_t size, time_t date,
00106                            struct directory *ndir);
00107 int copyfile(Stream_t *Source, Stream_t *Target);
00108 int getfreeMinClusters(Stream_t *Stream, size_t ref);
00109 
00110 FILE *opentty(int mode);
00111 
00112 int is_dir(Stream_t *Dir, char *path);
00113 void bufferize(Stream_t **Dir);
00114 
00115 int dir_grow(Stream_t *Dir, int size);
00116 int match(const char *, const char *, char *, int, int);
00117 
00118 char *unix_name(char *name, char *ext, char Case, char *answer);
00119 void *safe_malloc(size_t size);
00120 Stream_t *open_filter(Stream_t *Next);
00121 
00122 extern int got_signal;
00123 /* int do_gotsignal(char *, int);
00124 #define got_signal do_gotsignal(__FILE__, __LINE__) */
00125 
00126 void setup_signal(void);
00127 
00128 
00129 #define SET_INT(target, source) \
00130 if(source)target=source
00131 
00132 
00133 UNUSED(static inline int compare (long ref, long testee))
00134 {
00135         return (ref && ref != testee);
00136 }
00137 
00138 Stream_t *GetFs(Stream_t *Fs);
00139 
00140 char *label_name(char *filename, int verbose, 
00141                  int *mangled, char *ans);
00142 
00143 /* environmental variables */
00144 extern unsigned int mtools_skip_check;
00145 extern unsigned int mtools_fat_compatibility;
00146 extern unsigned int mtools_ignore_short_case;
00147 extern unsigned int mtools_no_vfat;
00148 extern unsigned int mtools_numeric_tail;
00149 extern unsigned int mtools_dotted_dir;
00150 extern unsigned int mtools_twenty_four_hour_clock;
00151 extern char *mtools_date_string;
00152 extern unsigned int mtools_rate_0, mtools_rate_any;
00153 extern int mtools_raw_tty;
00154 
00155 extern int batchmode;
00156 
00157 void read_config(void);
00158 extern struct device *devices;
00159 extern struct device const_devices[];
00160 extern const int nr_const_devices;
00161 
00162 #define New(type) ((type*)(malloc(sizeof(type))))
00163 #define Grow(adr,n,type) ((type*)(realloc((char *)adr,n*sizeof(type))))
00164 #define Free(adr) (free((char *)adr));
00165 #define NewArray(size,type) ((type*)(calloc((size),sizeof(type))))
00166 
00167 void mattrib(int argc, char **argv, int type);
00168 void mbadblocks(int argc, char **argv, int type);
00169 void mcat(int argc, char **argv, int type);
00170 void mcd(int argc, char **argv, int type);
00171 void mcopy(int argc, char **argv, int type);
00172 void mdel(int argc, char **argv, int type);
00173 void mdir(int argc, char **argv, int type);
00174 void mdoctorfat(int argc, char **argv, int type);
00175 void mdu(int argc, char **argv, int type);
00176 void mformat(int argc, char **argv, int type);
00177 void minfo(int argc, char **argv, int type);
00178 void mlabel(int argc, char **argv, int type);
00179 void mmd(int argc, char **argv, int type);
00180 void mmount(int argc, char **argv, int type);
00181 void mmove(int argc, char **argv, int type);
00182 void mpartition(int argc, char **argv, int type);
00183 void mshowfat(int argc, char **argv, int mtype);
00184 void mtoolstest(int argc, char **argv, int type);
00185 void mzip(int argc, char **argv, int type);
00186 
00187 extern int noPrivileges;
00188 void init_privs(void);
00189 void reclaim_privs(void);
00190 void drop_privs(void);
00191 void destroy_privs(void);
00192 uid_t get_real_uid(void);
00193 void closeExec(int fd);
00194 
00195 extern const char *progname;
00196 
00197 void precmd(struct device *dev);
00198 
00199 void print_sector(char *message, unsigned char *data, int size);
00200 time_t getTimeNow(time_t *now);
00201 
00202 #ifdef USING_NEW_VOLD
00203 char *getVoldName(struct device *dev, char *name);
00204 #endif
00205 
00206 
00207 Stream_t *OpenDir(Stream_t *Parent, const char *filename);
00208 /* int unix_dir_loop(Stream_t *Stream, MainParam_t *mp); 
00209 int unix_loop(MainParam_t *mp, char *arg); */
00210 
00211 struct dirCache_t **getDirCacheP(Stream_t *Stream);
00212 int isRootDir(Stream_t *Stream);
00213 unsigned int getStart(Stream_t *Dir, struct directory *dir);
00214 unsigned int countBlocks(Stream_t *Dir, unsigned int block);
00215 char *getDrive(Stream_t *Stream);
00216 
00217 
00218 void printOom(void);
00219 int ask_confirmation(const char *, const char *, const char *);
00220 char *get_homedir(void);
00221 #define EXPAND_BUF 2048
00222 const char *expand(const char *, char *);
00223 const char *fix_mcwd(char *);
00224 FILE *open_mcwd(const char *mode);
00225 void unlink_mcwd(void);
00226 char *skip_drive(const char *path);
00227 char *get_drive(const char *path, const char *def);
00228 
00229 int safePopenOut(char **command, char *output, int len);
00230 
00231 #define ROUND_DOWN(value, grain) ((value) - (value) % (grain))
00232 #define ROUND_UP(value, grain) ROUND_DOWN((value) + (grain)-1, (grain))
00233 
00234 #endif

Generated on Fri Apr 14 22:56:56 2006 for minix by  doxygen 1.4.6