All pastes #82776 Raw Edit

Someone

public text v1 · immutable
·published 2006-07-08 22:22 UTC
rendered paste body
[tom@saltandvinegar mkdosfs]$ more mkdosfs.o 
# 1 "mkdosfs.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "mkdosfs.c"
# 60 "mkdosfs.c"
# 1 "../version.h" 1
# 61 "mkdosfs.c" 2

# 1 "/usr/include/fcntl.h" 1 3 4
# 27 "/usr/include/fcntl.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 329 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 313 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 314 "/usr/include/sys/cdefs.h" 2 3 4
# 330 "/usr/include/features.h" 2 3 4
# 352 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4



# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 5 "/usr/include/gnu/stubs.h" 2 3 4




# 1 "/usr/include/gnu/stubs-64.h" 1 3 4
# 10 "/usr/include/gnu/stubs.h" 2 3 4
# 353 "/usr/include/features.h" 2 3 4
# 28 "/usr/include/fcntl.h" 2 3 4






# 1 "/usr/include/bits/fcntl.h" 1 3 4
# 25 "/usr/include/bits/fcntl.h" 3 4
# 1 "/usr/include/sys/types.h" 1 3 4
# 29 "/usr/include/sys/types.h" 3 4


# 1 "/usr/include/bits/types.h" 1 3 4
# 28 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 29 "/usr/include/bits/types.h" 2 3 4


# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 214 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 32 "/usr/include/bits/types.h" 2 3 4


typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;


typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;

typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;







typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
# 134 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/typesizes.h" 1 3 4
# 135 "/usr/include/bits/types.h" 2 3 4


typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;

typedef int __daddr_t;
typedef long int __swblk_t;
typedef int __key_t;


typedef int __clockid_t;


typedef void * __timer_t;


typedef long int __blksize_t;




typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;


typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;


typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;

typedef long int __ssize_t;



typedef __off64_t __loff_t;
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;


typedef long int __intptr_t;


typedef unsigned int __socklen_t;
# 32 "/usr/include/sys/types.h" 2 3 4



typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;




typedef __loff_t loff_t;



typedef __ino_t ino_t;
# 62 "/usr/include/sys/types.h" 3 4
typedef __dev_t dev_t;




typedef __gid_t gid_t;




typedef __mode_t mode_t;




typedef __nlink_t nlink_t;




typedef __uid_t uid_t;





typedef __off_t off_t;
# 100 "/usr/include/sys/types.h" 3 4
typedef __pid_t pid_t;




typedef __id_t id_t;




typedef __ssize_t ssize_t;





typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;





typedef __key_t key_t;
# 133 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/time.h" 1 3 4
# 75 "/usr/include/time.h" 3 4


typedef __time_t time_t;



# 93 "/usr/include/time.h" 3 4
typedef __clockid_t clockid_t;
# 105 "/usr/include/time.h" 3 4
typedef __timer_t timer_t;
# 134 "/usr/include/sys/types.h" 2 3 4
# 147 "/usr/include/sys/types.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 148 "/usr/include/sys/types.h" 2 3 4



typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
# 195 "/usr/include/sys/types.h" 3 4
typedef int int8_t __attribute__ ((__mode__ (__QI__)));
typedef int int16_t __attribute__ ((__mode__ (__HI__)));
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef int int64_t __attribute__ ((__mode__ (__DI__)));


typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));

typedef int register_t __attribute__ ((__mode__ (__word__)));
# 217 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/endian.h" 1 3 4
# 37 "/usr/include/endian.h" 3 4
# 1 "/usr/include/bits/endian.h" 1 3 4
# 38 "/usr/include/endian.h" 2 3 4
# 218 "/usr/include/sys/types.h" 2 3 4


# 1 "/usr/include/sys/select.h" 1 3 4
# 31 "/usr/include/sys/select.h" 3 4
# 1 "/usr/include/bits/select.h" 1 3 4
# 32 "/usr/include/sys/select.h" 2 3 4


# 1 "/usr/include/bits/sigset.h" 1 3 4
# 23 "/usr/include/bits/sigset.h" 3 4
typedef int __sig_atomic_t;




typedef struct
  {
    unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
  } __sigset_t;
# 35 "/usr/include/sys/select.h" 2 3 4



typedef __sigset_t sigset_t;





# 1 "/usr/include/time.h" 1 3 4
# 121 "/usr/include/time.h" 3 4
struct timespec
  {
    __time_t tv_sec;
    long int tv_nsec;
  };
# 45 "/usr/include/sys/select.h" 2 3 4

# 1 "/usr/include/bits/time.h" 1 3 4
# 69 "/usr/include/bits/time.h" 3 4
struct timeval
  {
    __time_t tv_sec;
    __suseconds_t tv_usec;
  };
# 47 "/usr/include/sys/select.h" 2 3 4


typedef __suseconds_t suseconds_t;





typedef long int __fd_mask;
# 67 "/usr/include/sys/select.h" 3 4
typedef struct
  {






    __fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask))];


  } fd_set;






typedef __fd_mask fd_mask;
# 99 "/usr/include/sys/select.h" 3 4

# 109 "/usr/include/sys/select.h" 3 4
extern int select (int __nfds, fd_set *__restrict __readfds,
     fd_set *__restrict __writefds,
     fd_set *__restrict __exceptfds,
     struct timeval *__restrict __timeout);
# 121 "/usr/include/sys/select.h" 3 4
extern int pselect (int __nfds, fd_set *__restrict __readfds,
      fd_set *__restrict __writefds,
      fd_set *__restrict __exceptfds,
      const struct timespec *__restrict __timeout,
      const __sigset_t *__restrict __sigmask);



# 221 "/usr/include/sys/types.h" 2 3 4


# 1 "/usr/include/sys/sysmacros.h" 1 3 4
# 29 "/usr/include/sys/sysmacros.h" 3 4
__extension__
extern __inline unsigned int gnu_dev_major (unsigned long long int __dev)
     __attribute__ ((__nothrow__));
__extension__
extern __inline unsigned int gnu_dev_minor (unsigned long long int __dev)
     __attribute__ ((__nothrow__));
__extension__
extern __inline unsigned long long int gnu_dev_makedev (unsigned int __major,
       unsigned int __minor)
     __attribute__ ((__nothrow__));


__extension__ extern __inline unsigned int
__attribute__ ((__nothrow__)) gnu_dev_major (unsigned long long int __dev)
{
  return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
}

__extension__ extern __inline unsigned int
__attribute__ ((__nothrow__)) gnu_dev_minor (unsigned long long int __dev)
{
  return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
}

__extension__ extern __inline unsigned long long int
__attribute__ ((__nothrow__)) gnu_dev_makedev (unsigned int __major, unsigned int __minor)
{
  return ((__minor & 0xff) | ((__major & 0xfff) << 8)
   | (((unsigned long long int) (__minor & ~0xff)) << 12)
   | (((unsigned long long int) (__major & ~0xfff)) << 32));
}
# 224 "/usr/include/sys/types.h" 2 3 4
# 235 "/usr/include/sys/types.h" 3 4
typedef __blkcnt_t blkcnt_t;



typedef __fsblkcnt_t fsblkcnt_t;



typedef __fsfilcnt_t fsfilcnt_t;
# 270 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/bits/pthreadtypes.h" 1 3 4
# 23 "/usr/include/bits/pthreadtypes.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 24 "/usr/include/bits/pthreadtypes.h" 2 3 4
# 50 "/usr/include/bits/pthreadtypes.h" 3 4
typedef unsigned long int pthread_t;


typedef union
{
  char __size[56];
  long int __align;
} pthread_attr_t;



typedef struct __pthread_internal_list
{
  struct __pthread_internal_list *__prev;
  struct __pthread_internal_list *__next;
} __pthread_list_t;
# 76 "/usr/include/bits/pthreadtypes.h" 3 4
typedef union
{
  struct __pthread_mutex_s
  {
    int __lock;
    unsigned int __count;
    int __owner;

    unsigned int __nusers;



    int __kind;

    int __spins;
    __pthread_list_t __list;
# 101 "/usr/include/bits/pthreadtypes.h" 3 4
  } __data;
  char __size[40];
  long int __align;
} pthread_mutex_t;

typedef union
{
  char __size[4];
  int __align;
} pthread_mutexattr_t;




typedef union
{
  struct
  {
    int __lock;
    unsigned int __futex;
    __extension__ unsigned long long int __total_seq;
    __extension__ unsigned long long int __wakeup_seq;
    __extension__ unsigned long long int __woken_seq;
    void *__mutex;
    unsigned int __nwaiters;
    unsigned int __broadcast_seq;
  } __data;
  char __size[48];
  __extension__ long long int __align;
} pthread_cond_t;

typedef union
{
  char __size[4];
  int __align;
} pthread_condattr_t;



typedef unsigned int pthread_key_t;



typedef int pthread_once_t;





typedef union
{

  struct
  {
    int __lock;
    unsigned int __nr_readers;
    unsigned int __readers_wakeup;
    unsigned int __writer_wakeup;
    unsigned int __nr_readers_queued;
    unsigned int __nr_writers_queued;
    int __writer;
    int __pad1;
    unsigned long int __pad2;
    unsigned long int __pad3;


    unsigned int __flags;
  } __data;
# 184 "/usr/include/bits/pthreadtypes.h" 3 4
  char __size[56];
  long int __align;
} pthread_rwlock_t;

typedef union
{
  char __size[8];
  long int __align;
} pthread_rwlockattr_t;





typedef volatile int pthread_spinlock_t;




typedef union
{
  char __size[32];
  long int __align;
} pthread_barrier_t;

typedef union
{
  char __size[4];
  int __align;
} pthread_barrierattr_t;
# 271 "/usr/include/sys/types.h" 2 3 4



# 26 "/usr/include/bits/fcntl.h" 2 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 27 "/usr/include/bits/fcntl.h" 2 3 4
# 152 "/usr/include/bits/fcntl.h" 3 4
struct flock
  {
    short int l_type;
    short int l_whence;

    __off_t l_start;
    __off_t l_len;




    __pid_t l_pid;
  };
# 197 "/usr/include/bits/fcntl.h" 3 4



extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
    __attribute__ ((__nothrow__));


# 35 "/usr/include/fcntl.h" 2 3 4
# 76 "/usr/include/fcntl.h" 3 4
extern int fcntl (int __fd, int __cmd, ...);
# 85 "/usr/include/fcntl.h" 3 4
extern int open (__const char *__file, int __oflag, ...) __attribute__ ((__nonnull__ (1)));
# 130 "/usr/include/fcntl.h" 3 4
extern int creat (__const char *__file, __mode_t __mode) __attribute__ ((__nonnull__ (1)));
# 159 "/usr/include/fcntl.h" 3 4
extern int lockf (int __fd, int __cmd, __off_t __len);
# 176 "/usr/include/fcntl.h" 3 4
extern int posix_fadvise (int __fd, __off_t __offset, __off_t __len,
     int __advise) __attribute__ ((__nothrow__));
# 198 "/usr/include/fcntl.h" 3 4
extern int posix_fallocate (int __fd, __off_t __offset, __off_t __len);
# 213 "/usr/include/fcntl.h" 3 4

# 63 "mkdosfs.c" 2
# 1 "/usr/include/linux/hdreg.h" 1 3 4
# 168 "/usr/include/linux/hdreg.h" 3 4
struct hd_geometry {
      unsigned char heads;
      unsigned char sectors;
      unsigned short cylinders;
      unsigned long start;
};
# 216 "/usr/include/linux/hdreg.h" 3 4
enum {
 BUSSTATE_OFF = 0,
 BUSSTATE_ON,
 BUSSTATE_TRISTATE
};


struct hd_big_geometry {
 unsigned char heads;
 unsigned char sectors;
 unsigned int cylinders;
 unsigned long start;
};







struct hd_driveid {
 unsigned short config;
 unsigned short cyls;
 unsigned short reserved2;
 unsigned short heads;
 unsigned short track_bytes;
 unsigned short sector_bytes;
 unsigned short sectors;
 unsigned short vendor0;
 unsigned short vendor1;
 unsigned short vendor2;
 unsigned char serial_no[20];
 unsigned short buf_type;
 unsigned short buf_size;
 unsigned short ecc_bytes;
 unsigned char fw_rev[8];
 unsigned char model[40];
 unsigned char max_multsect;
 unsigned char vendor3;
 unsigned short dword_io;
 unsigned char vendor4;
 unsigned char capability;
 unsigned short reserved50;
 unsigned char vendor5;
 unsigned char tPIO;
 unsigned char vendor6;
 unsigned char tDMA;
 unsigned short field_valid;
 unsigned short cur_cyls;
 unsigned short cur_heads;
 unsigned short cur_sectors;
 unsigned short cur_capacity0;
 unsigned short cur_capacity1;
 unsigned char multsect;
 unsigned char multsect_valid;
 unsigned int lba_capacity;
 unsigned short dma_1word;
 unsigned short dma_mword;
 unsigned short eide_pio_modes;
 unsigned short eide_dma_min;
 unsigned short eide_dma_time;
 unsigned short eide_pio;
 unsigned short eide_pio_iordy;
 unsigned short words69_70[2];

 unsigned short words71_74[4];
 unsigned short queue_depth;
 unsigned short words76_79[4];
 unsigned short major_rev_num;
 unsigned short minor_rev_num;
 unsigned short command_set_1;
 unsigned short command_set_2;
 unsigned short cfsse;
 unsigned short cfs_enable_1;
 unsigned short cfs_enable_2;
 unsigned short csf_default;
 unsigned short dma_ultra;
 unsigned short word89;
 unsigned short word90;
 unsigned short CurAPMvalues;
 unsigned short word92;
 unsigned short hw_config;
 unsigned short words94_125[32];
 unsigned short last_lun;
 unsigned short word127;
 unsigned short dlf;
# 312 "/usr/include/linux/hdreg.h" 3 4
 unsigned short csfo;






 unsigned short words130_155[26];
 unsigned short word156;
 unsigned short words157_159[3];
 unsigned short words160_255[95];
};
# 64 "mkdosfs.c" 2
# 1 "/usr/include/linux/fs.h" 1 3 4
# 65 "mkdosfs.c" 2
# 1 "/usr/include/linux/fd.h" 1 3 4



# 1 "/usr/include/linux/ioctl.h" 1 3 4



# 1 "/usr/include/asm/ioctl.h" 1 3 4



# 1 "/usr/include/asm-x86_64/ioctl.h" 1 3 4
# 5 "/usr/include/asm/ioctl.h" 2 3 4
# 5 "/usr/include/linux/ioctl.h" 2 3 4
# 5 "/usr/include/linux/fd.h" 2 3 4







struct floppy_struct {
 unsigned int size,
   sect,
   head,
   track,
   stretch;



 unsigned char gap,

   rate,







   spec1,
   fmt_gap;
 const char * name;
};
# 64 "/usr/include/linux/fd.h" 3 4
struct format_descr {
 unsigned int device,head,track;
};
# 79 "/usr/include/linux/fd.h" 3 4
struct floppy_max_errors {
 unsigned int
   abort,
   read_track,

   reset,
   recal,







   reporting;

};
# 110 "/usr/include/linux/fd.h" 3 4
typedef char floppy_drive_name[16];







struct floppy_drive_params {
 signed char cmos;




 unsigned long max_dtr;
 unsigned long hlt;
 unsigned long hut;

 unsigned long srt;

 unsigned long spinup;

 unsigned long spindown;
 unsigned char spindown_offset;

 unsigned char select_delay;
 unsigned char rps;
 unsigned char tracks;
 unsigned long timeout;

 unsigned char interleave_sect;


 struct floppy_max_errors max_errors;

 char flags;
# 159 "/usr/include/linux/fd.h" 3 4
 char read_track;






 short autodetect[8];

 int checkfreq;

 int native_format;
};

enum {
 FD_NEED_TWADDLE_BIT,
 FD_VERIFY_BIT,
 FD_DISK_NEWCHANGE_BIT,

 FD_UNUSED_BIT,
 FD_DISK_CHANGED_BIT,
 FD_DISK_WRITABLE_BIT
};
# 191 "/usr/include/linux/fd.h" 3 4
struct floppy_drive_struct {
 unsigned long flags;







 unsigned long spinup_date;
 unsigned long select_date;
 unsigned long first_read_date;
 short probed_format;
 short track;
 short maxblock;
 short maxtrack;
 int generation;






 int keep_data;


 int fd_ref;
 int fd_device;
 unsigned long last_checked;


 char *dmabuf;
 int bufblocks;
};
# 234 "/usr/include/linux/fd.h" 3 4
enum reset_mode {
 FD_RESET_IF_NEEDED,
 FD_RESET_IF_RAWCMD,
 FD_RESET_ALWAYS
};






struct floppy_fdc_state {
 int spec1;
 int spec2;
 int dtr;
 unsigned char version;
 unsigned char dor;
 unsigned long address;
 unsigned int rawcmd:2;
 unsigned int reset:1;
 unsigned int need_configure:1;
 unsigned int perp_mode:2;
 unsigned int has_fifo:1;
 unsigned int driver_version;
# 266 "/usr/include/linux/fd.h" 3 4
 unsigned char track[4];
# 275 "/usr/include/linux/fd.h" 3 4
};







struct floppy_write_errors {
# 292 "/usr/include/linux/fd.h" 3 4
 unsigned int write_errors;



 unsigned long first_error_sector;
 int first_error_generation;
 unsigned long last_error_sector;
 int last_error_generation;

 unsigned int badness;

};
# 317 "/usr/include/linux/fd.h" 3 4
struct floppy_raw_cmd {
 unsigned int flags;
# 341 "/usr/include/linux/fd.h" 3 4
 void *data;
 char *kernel_data;
 struct floppy_raw_cmd *next;

 long length;
 long phys_length;
 int buffer_length;

 unsigned char rate;
 unsigned char cmd_count;
 unsigned char cmd[16];
 unsigned char reply_count;
 unsigned char reply[16];
 int track;
 int resultcode;

 int reserved1;
 int reserved2;
};
# 66 "mkdosfs.c" 2

# 1 "/usr/include/mntent.h" 1 3 4
# 25 "/usr/include/mntent.h" 3 4
# 1 "/usr/include/stdio.h" 1 3 4
# 44 "/usr/include/stdio.h" 3 4


typedef struct _IO_FILE FILE;





# 26 "/usr/include/mntent.h" 2 3 4
# 1 "/usr/include/paths.h" 1 3 4
# 27 "/usr/include/mntent.h" 2 3 4
# 51 "/usr/include/mntent.h" 3 4



struct mntent
  {
    char *mnt_fsname;
    char *mnt_dir;
    char *mnt_type;
    char *mnt_opts;
    int mnt_freq;
    int mnt_passno;
  };




extern FILE *setmntent (__const char *__file, __const char *__mode) __attribute__ ((__nothrow__));




extern struct mntent *getmntent (FILE *__stream) __attribute__ ((__nothrow__));



extern struct mntent *getmntent_r (FILE *__restrict __stream,
       struct mntent *__restrict __result,
       char *__restrict __buffer,
       int __bufsize) __attribute__ ((__nothrow__));




extern int addmntent (FILE *__restrict __stream,
        __const struct mntent *__restrict __mnt) __attribute__ ((__nothrow__));


extern int endmntent (FILE *__stream) __attribute__ ((__nothrow__));



extern char *hasmntopt (__const struct mntent *__mnt,
   __const char *__opt) __attribute__ ((__nothrow__));



# 68 "mkdosfs.c" 2
# 1 "/usr/include/signal.h" 1 3 4
# 31 "/usr/include/signal.h" 3 4


# 1 "/usr/include/bits/sigset.h" 1 3 4
# 103 "/usr/include/bits/sigset.h" 3 4
extern int __sigismember (__const __sigset_t *, int);
extern int __sigaddset (__sigset_t *, int);
extern int __sigdelset (__sigset_t *, int);
# 117 "/usr/include/bits/sigset.h" 3 4
extern __inline int __sigismember (__const __sigset_t *__set, int __sig) { unsigned long int __mask = (((unsigned long int) 1) << (((__s
ig) - 1) % (8 * sizeof (unsigned long int)))); unsigned long int __word = (((__sig) - 1) / (8 * sizeof (unsigned long int))); return (__
set->__val[__word] & __mask) ? 1 : 0; }
extern __inline int __sigaddset ( __sigset_t *__set, int __sig) { unsigned long int __mask = (((unsigned long int) 1) << (((__sig) - 1) 
% (8 * sizeof (unsigned long int)))); unsigned long int __word = (((__sig) - 1) / (8 * sizeof (unsigned long int))); return ((__set->__v
al[__word] |= __mask), 0); }
extern __inline int __sigdelset ( __sigset_t *__set, int __sig) { unsigned long int __mask = (((unsigned long int) 1) << (((__sig) - 1) 
% (8 * sizeof (unsigned long int)))); unsigned long int __word = (((__sig) - 1) / (8 * sizeof (unsigned long int))); return ((__set->__v
al[__word] &= ~__mask), 0); }
# 34 "/usr/include/signal.h" 2 3 4







typedef __sig_atomic_t sig_atomic_t;

# 58 "/usr/include/signal.h" 3 4
# 1 "/usr/include/bits/signum.h" 1 3 4
# 59 "/usr/include/signal.h" 2 3 4
# 75 "/usr/include/signal.h" 3 4
typedef void (*__sighandler_t) (int);




extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
     __attribute__ ((__nothrow__));
# 90 "/usr/include/signal.h" 3 4


extern __sighandler_t signal (int __sig, __sighandler_t __handler)
     __attribute__ ((__nothrow__));
# 104 "/usr/include/signal.h" 3 4

# 117 "/usr/include/signal.h" 3 4
extern int kill (__pid_t __pid, int __sig) __attribute__ ((__nothrow__));






extern int killpg (__pid_t __pgrp, int __sig) __attribute__ ((__nothrow__));




extern int raise (int __sig) __attribute__ ((__nothrow__));




extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
     __attribute__ ((__nothrow__));
extern int gsignal (int __sig) __attribute__ ((__nothrow__));




extern void psignal (int __sig, __const char *__s);
# 153 "/usr/include/signal.h" 3 4
extern int __sigpause (int __sig_or_mask, int __is_sig);
# 181 "/usr/include/signal.h" 3 4
extern int sigblock (int __mask) __attribute__ ((__nothrow__)) __attribute__ ((__deprecated__));


extern int sigsetmask (int __mask) __attribute__ ((__nothrow__)) __attribute__ ((__deprecated__));


extern int siggetmask (void) __attribute__ ((__nothrow__)) __attribute__ ((__deprecated__));
# 201 "/usr/include/signal.h" 3 4
typedef __sighandler_t sig_t;







# 1 "/usr/include/time.h" 1 3 4
# 210 "/usr/include/signal.h" 2 3 4


# 1 "/usr/include/bits/siginfo.h" 1 3 4
# 25 "/usr/include/bits/siginfo.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 26 "/usr/include/bits/siginfo.h" 2 3 4







typedef union sigval
  {
    int sival_int;
    void *sival_ptr;
  } sigval_t;
# 51 "/usr/include/bits/siginfo.h" 3 4
typedef struct siginfo
  {
    int si_signo;
    int si_errno;

    int si_code;

    union
      {
 int _pad[((128 / sizeof (int)) - 4)];


 struct
   {
     __pid_t si_pid;
     __uid_t si_uid;
   } _kill;


 struct
   {
     int si_tid;
     int si_overrun;
     sigval_t si_sigval;
   } _timer;


 struct
   {
     __pid_t si_pid;
     __uid_t si_uid;
     sigval_t si_sigval;
   } _rt;


 struct
   {
     __pid_t si_pid;
     __uid_t si_uid;
     int si_status;
     __clock_t si_utime;
     __clock_t si_stime;
   } _sigchld;


 struct
   {
     void *si_addr;
   } _sigfault;


 struct
   {
     long int si_band;
     int si_fd;
   } _sigpoll;
      } _sifields;
  } siginfo_t;
# 129 "/usr/include/bits/siginfo.h" 3 4
enum
{
  SI_ASYNCNL = -60,

  SI_TKILL = -6,

  SI_SIGIO,

  SI_ASYNCIO,

  SI_MESGQ,

  SI_TIMER,

  SI_QUEUE,

  SI_USER,

  SI_KERNEL = 0x80

};



enum
{
  ILL_ILLOPC = 1,

  ILL_ILLOPN,

  ILL_ILLADR,

  ILL_ILLTRP,

  ILL_PRVOPC,

  ILL_PRVREG,

  ILL_COPROC,

  ILL_BADSTK

};


enum
{
  FPE_INTDIV = 1,

  FPE_INTOVF,

  FPE_FLTDIV,

  FPE_FLTOVF,

  FPE_FLTUND,

  FPE_FLTRES,

  FPE_FLTINV,

  FPE_FLTSUB

};


enum
{
  SEGV_MAPERR = 1,

  SEGV_ACCERR

};


enum
{
  BUS_ADRALN = 1,

  BUS_ADRERR,

  BUS_OBJERR

};


enum
{
  TRAP_BRKPT = 1,

  TRAP_TRACE

};


enum
{
  CLD_EXITED = 1,

  CLD_KILLED,

  CLD_DUMPED,

  CLD_TRAPPED,

  CLD_STOPPED,

  CLD_CONTINUED

};


enum
{
  POLL_IN = 1,

  POLL_OUT,

  POLL_MSG,

  POLL_ERR,

  POLL_PRI,

  POLL_HUP

};
# 273 "/usr/include/bits/siginfo.h" 3 4
typedef struct sigevent
  {
    sigval_t sigev_value;
    int sigev_signo;
    int sigev_notify;

    union
      {
 int _pad[((64 / sizeof (int)) - 4)];



 __pid_t _tid;

 struct
   {
     void (*_function) (sigval_t);
     void *_attribute;
   } _sigev_thread;
      } _sigev_un;
  } sigevent_t;






enum
{
  SIGEV_SIGNAL = 0,

  SIGEV_NONE,

  SIGEV_THREAD,


  SIGEV_THREAD_ID = 4

};
# 213 "/usr/include/signal.h" 2 3 4



extern int sigemptyset (sigset_t *__set) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern int sigfillset (sigset_t *__set) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern int sigaddset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern int sigdelset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern int sigismember (__const sigset_t *__set, int __signo)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 246 "/usr/include/signal.h" 3 4
# 1 "/usr/include/bits/sigaction.h" 1 3 4
# 25 "/usr/include/bits/sigaction.h" 3 4
struct sigaction
  {


    union
      {

 __sighandler_t sa_handler;

 void (*sa_sigaction) (int, siginfo_t *, void *);
      }
    __sigaction_handler;







    __sigset_t sa_mask;


    int sa_flags;


    void (*sa_restorer) (void);
  };
# 247 "/usr/include/signal.h" 2 3 4


extern int sigprocmask (int __how, __const sigset_t *__restrict __set,
   sigset_t *__restrict __oset) __attribute__ ((__nothrow__));






extern int sigsuspend (__const sigset_t *__set) __attribute__ ((__nonnull__ (1)));


extern int sigaction (int __sig, __const struct sigaction *__restrict __act,
        struct sigaction *__restrict __oact) __attribute__ ((__nothrow__));


extern int sigpending (sigset_t *__set) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));






extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
     __attribute__ ((__nonnull__ (1, 2)));






extern int sigwaitinfo (__const sigset_t *__restrict __set,
   siginfo_t *__restrict __info) __attribute__ ((__nonnull__ (1)));






extern int sigtimedwait (__const sigset_t *__restrict __set,
    siginfo_t *__restrict __info,
    __const struct timespec *__restrict __timeout)
     __attribute__ ((__nonnull__ (1)));



extern int sigqueue (__pid_t __pid, int __sig, __const union sigval __val)
     __attribute__ ((__nothrow__));
# 304 "/usr/include/signal.h" 3 4
extern __const char *__const _sys_siglist[65];
extern __const char *__const sys_siglist[65];


struct sigvec
  {
    __sighandler_t sv_handler;
    int sv_mask;

    int sv_flags;

  };
# 328 "/usr/include/signal.h" 3 4
extern int sigvec (int __sig, __const struct sigvec *__vec,
     struct sigvec *__ovec) __attribute__ ((__nothrow__));



# 1 "/usr/include/bits/sigcontext.h" 1 3 4
# 26 "/usr/include/bits/sigcontext.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 27 "/usr/include/bits/sigcontext.h" 2 3 4

struct _fpreg
{
  unsigned short significand[4];
  unsigned short exponent;
};

struct _fpxreg
{
  unsigned short significand[4];
  unsigned short exponent;
  unsigned short padding[3];
};

struct _xmmreg
{
  __uint32_t element[4];
};
# 109 "/usr/include/bits/sigcontext.h" 3 4
struct _fpstate
{

  __uint16_t cwd;
  __uint16_t swd;
  __uint16_t ftw;
  __uint16_t fop;
  __uint64_t rip;
  __uint64_t rdp;
  __uint32_t mxcsr;
  __uint32_t mxcr_mask;
  struct _fpxreg _st[8];
  struct _xmmreg _xmm[16];
  __uint32_t padding[24];
};

struct sigcontext
{
  unsigned long r8;
  unsigned long r9;
  unsigned long r10;
  unsigned long r11;
  unsigned long r12;
  unsigned long r13;
  unsigned long r14;
  unsigned long r15;
  unsigned long rdi;
  unsigned long rsi;
  unsigned long rbp;
  unsigned long rbx;
  unsigned long rdx;
  unsigned long rax;
  unsigned long rcx;
  unsigned long rsp;
  unsigned long rip;
  unsigned long eflags;
  unsigned short cs;
  unsigned short gs;
  unsigned short fs;
  unsigned short __pad0;
  unsigned long err;
  unsigned long trapno;
  unsigned long oldmask;
  unsigned long cr2;
  struct _fpstate * fpstate;
  unsigned long __reserved1 [8];
};
# 334 "/usr/include/signal.h" 2 3 4


extern int sigreturn (struct sigcontext *__scp) __attribute__ ((__nothrow__));
# 346 "/usr/include/signal.h" 3 4
extern int siginterrupt (int __sig, int __interrupt) __attribute__ ((__nothrow__));

# 1 "/usr/include/bits/sigstack.h" 1 3 4
# 26 "/usr/include/bits/sigstack.h" 3 4
struct sigstack
  {
    void *ss_sp;
    int ss_onstack;
  };



enum
{
  SS_ONSTACK = 1,

  SS_DISABLE

};
# 50 "/usr/include/bits/sigstack.h" 3 4
typedef struct sigaltstack
  {
    void *ss_sp;
    int ss_flags;
    size_t ss_size;
  } stack_t;
# 349 "/usr/include/signal.h" 2 3 4
# 357 "/usr/include/signal.h" 3 4
extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
     __attribute__ ((__nothrow__)) __attribute__ ((__deprecated__));



extern int sigaltstack (__const struct sigaltstack *__restrict __ss,
   struct sigaltstack *__restrict __oss) __attribute__ ((__nothrow__));
# 387 "/usr/include/signal.h" 3 4
# 1 "/usr/include/bits/sigthread.h" 1 3 4
# 31 "/usr/include/bits/sigthread.h" 3 4
extern int pthread_sigmask (int __how,
       __const __sigset_t *__restrict __newmask,
       __sigset_t *__restrict __oldmask)__attribute__ ((__nothrow__));


extern int pthread_kill (pthread_t __threadid, int __signo) __attribute__ ((__nothrow__));
# 388 "/usr/include/signal.h" 2 3 4






extern int __libc_current_sigrtmin (void) __attribute__ ((__nothrow__));

extern int __libc_current_sigrtmax (void) __attribute__ ((__nothrow__));




# 69 "mkdosfs.c" 2
# 1 "/usr/include/string.h" 1 3 4
# 28 "/usr/include/string.h" 3 4





# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 34 "/usr/include/string.h" 2 3 4




extern void *memcpy (void *__restrict __dest,
       __const void *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern void *memmove (void *__dest, __const void *__src, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));






extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
        int __c, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));





extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern void *memchr (__const void *__s, int __c, size_t __n)
      __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));

# 82 "/usr/include/string.h" 3 4


extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

extern char *strncpy (char *__restrict __dest,
        __const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
        size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern int strcmp (__const char *__s1, __const char *__s2)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));

extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern int strcoll (__const char *__s1, __const char *__s2)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));

extern size_t strxfrm (char *__restrict __dest,
         __const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));

# 130 "/usr/include/string.h" 3 4
extern char *strdup (__const char *__s)
     __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
# 165 "/usr/include/string.h" 3 4


extern char *strchr (__const char *__s, int __c)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));

extern char *strrchr (__const char *__s, int __c)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));

# 181 "/usr/include/string.h" 3 4



extern size_t strcspn (__const char *__s, __const char *__reject)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern size_t strspn (__const char *__s, __const char *__accept)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));

extern char *strpbrk (__const char *__s, __const char *__accept)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));

extern char *strstr (__const char *__haystack, __const char *__needle)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));



extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));




extern char *__strtok_r (char *__restrict __s,
    __const char *__restrict __delim,
    char **__restrict __save_ptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));

extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
         char **__restrict __save_ptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
# 240 "/usr/include/string.h" 3 4


extern size_t strlen (__const char *__s)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));

# 254 "/usr/include/string.h" 3 4


extern char *strerror (int __errnum) __attribute__ ((__nothrow__));

# 270 "/usr/include/string.h" 3 4
extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__)) __attri
bute__ ((__nonnull__ (2)));
# 288 "/usr/include/string.h" 3 4
extern void __bzero (void *__s, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));



extern void bcopy (__const void *__src, void *__dest, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern char *index (__const char *__s, int __c)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));


extern char *rindex (__const char *__s, int __c)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));



extern int ffs (int __i) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
# 325 "/usr/include/string.h" 3 4
extern int strcasecmp (__const char *__s1, __const char *__s2)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
# 348 "/usr/include/string.h" 3 4
extern char *strsep (char **__restrict __stringp,
       __const char *__restrict __delim)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
# 414 "/usr/include/string.h" 3 4
# 1 "/usr/include/bits/string.h" 1 3 4
# 415 "/usr/include/string.h" 2 3 4


# 1 "/usr/include/bits/string2.h" 1 3 4
# 394 "/usr/include/bits/string2.h" 3 4
extern void *__rawmemchr (const void *__s, int __c);
# 969 "/usr/include/bits/string2.h" 3 4
extern __inline size_t __strcspn_c1 (__const char *__s, int __reject);
extern __inline size_t
__strcspn_c1 (__const char *__s, int __reject)
{
  register size_t __result = 0;
  while (__s[__result] != '\0' && __s[__result] != __reject)
    ++__result;
  return __result;
}

extern __inline size_t __strcspn_c2 (__const char *__s, int __reject1,
         int __reject2);
extern __inline size_t
__strcspn_c2 (__const char *__s, int __reject1, int __reject2)
{
  register size_t __result = 0;
  while (__s[__result] != '\0' && __s[__result] != __reject1
  && __s[__result] != __reject2)
    ++__result;
  return __result;
}

extern __inline size_t __strcspn_c3 (__const char *__s, int __reject1,
         int __reject2, int __reject3);
extern __inline size_t
__strcspn_c3 (__const char *__s, int __reject1, int __reject2,
       int __reject3)
{
  register size_t __result = 0;
  while (__s[__result] != '\0' && __s[__result] != __reject1
  && __s[__result] != __reject2 && __s[__result] != __reject3)
    ++__result;
  return __result;
}
# 1045 "/usr/include/bits/string2.h" 3 4
extern __inline size_t __strspn_c1 (__const char *__s, int __accept);
extern __inline size_t
__strspn_c1 (__const char *__s, int __accept)
{
  register size_t __result = 0;

  while (__s[__result] == __accept)
    ++__result;
  return __result;
}

extern __inline size_t __strspn_c2 (__const char *__s, int __accept1,
        int __accept2);
extern __inline size_t
__strspn_c2 (__const char *__s, int __accept1, int __accept2)
{
  register size_t __result = 0;

  while (__s[__result] == __accept1 || __s[__result] == __accept2)
    ++__result;
  return __result;
}

extern __inline size_t __strspn_c3 (__const char *__s, int __accept1,
        int __accept2, int __accept3);
extern __inline size_t
__strspn_c3 (__const char *__s, int __accept1, int __accept2, int __accept3)
{
  register size_t __result = 0;

  while (__s[__result] == __accept1 || __s[__result] == __accept2
  || __s[__result] == __accept3)
    ++__result;
  return __result;
}
# 1121 "/usr/include/bits/string2.h" 3 4
extern __inline char *__strpbrk_c2 (__const char *__s, int __accept1,
         int __accept2);
extern __inline char *
__strpbrk_c2 (__const char *__s, int __accept1, int __accept2)
{

  while (*__s != '\0' && *__s != __accept1 && *__s != __accept2)
    ++__s;
  return *__s == '\0' ? ((void *)0) : (char *) (size_t) __s;
}

extern __inline char *__strpbrk_c3 (__const char *__s, int __accept1,
         int __accept2, int __accept3);
extern __inline char *
__strpbrk_c3 (__const char *__s, int __accept1, int __accept2,
       int __accept3)
{

  while (*__s != '\0' && *__s != __accept1 && *__s != __accept2
  && *__s != __accept3)
    ++__s;
  return *__s == '\0' ? ((void *)0) : (char *) (size_t) __s;
}
# 1173 "/usr/include/bits/string2.h" 3 4
extern __inline char *__strtok_r_1c (char *__s, char __sep, char **__nextp);
extern __inline char *
__strtok_r_1c (char *__s, char __sep, char **__nextp)
{
  char *__result;
  if (__s == ((void *)0))
    __s = *__nextp;
  while (*__s == __sep)
    ++__s;
  __result = ((void *)0);
  if (*__s != '\0')
    {
      __result = __s++;
      while (*__s != '\0')
 if (*__s++ == __sep)
   {
     __s[-1] = '\0';
     break;
   }
      *__nextp = __s;
    }
  return __result;
}
# 1205 "/usr/include/bits/string2.h" 3 4
extern char *__strsep_g (char **__stringp, __const char *__delim);
# 1223 "/usr/include/bits/string2.h" 3 4
extern __inline char *__strsep_1c (char **__s, char __reject);
extern __inline char *
__strsep_1c (char **__s, char __reject)
{
  register char *__retval = *__s;
  if (__retval != ((void *)0) && (*__s = (__extension__ (__builtin_constant_p (__reject) && !__builtin_constant_p (__retval) && (__rejec
t) == '\0' ? (char *) __rawmemchr (__retval, __reject) : __builtin_strchr (__retval, __reject)))) != ((void *)0))
    *(*__s)++ = '\0';
  return __retval;
}

extern __inline char *__strsep_2c (char **__s, char __reject1, char __reject2);
extern __inline char *
__strsep_2c (char **__s, char __reject1, char __reject2)
{
  register char *__retval = *__s;
  if (__retval != ((void *)0))
    {
      register char *__cp = __retval;
      while (1)
 {
   if (*__cp == '\0')
     {
       __cp = ((void *)0);
   break;
     }
   if (*__cp == __reject1 || *__cp == __reject2)
     {
       *__cp++ = '\0';
       break;
     }
   ++__cp;
 }
      *__s = __cp;
    }
  return __retval;
}

extern __inline char *__strsep_3c (char **__s, char __reject1, char __reject2,
       char __reject3);
extern __inline char *
__strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
{
  register char *__retval = *__s;
  if (__retval != ((void *)0))
    {
      register char *__cp = __retval;
      while (1)
 {
   if (*__cp == '\0')
     {
       __cp = ((void *)0);
   break;
     }
   if (*__cp == __reject1 || *__cp == __reject2 || *__cp == __reject3)
     {
       *__cp++ = '\0';
       break;
     }
   ++__cp;
 }
      *__s = __cp;
    }
  return __retval;
}
# 1299 "/usr/include/bits/string2.h" 3 4
# 1 "/usr/include/stdlib.h" 1 3 4
# 33 "/usr/include/stdlib.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 34 "/usr/include/stdlib.h" 2 3 4


# 587 "/usr/include/stdlib.h" 3 4


extern void *malloc (size_t __size) __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) ;

extern void *calloc (size_t __nmemb, size_t __size)
     __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) ;

# 978 "/usr/include/stdlib.h" 3 4

# 1300 "/usr/include/bits/string2.h" 2 3 4




extern char *__strdup (__const char *__string) __attribute__ ((__nothrow__)) __attribute__ ((__malloc__));
# 1323 "/usr/include/bits/string2.h" 3 4
extern char *__strndup (__const char *__string, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__malloc__));
# 418 "/usr/include/string.h" 2 3 4
# 426 "/usr/include/string.h" 3 4

# 70 "mkdosfs.c" 2
# 1 "/usr/include/stdio.h" 1 3 4
# 30 "/usr/include/stdio.h" 3 4




# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 35 "/usr/include/stdio.h" 2 3 4
# 62 "/usr/include/stdio.h" 3 4
typedef struct _IO_FILE __FILE;
# 72 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/libio.h" 1 3 4
# 32 "/usr/include/libio.h" 3 4
# 1 "/usr/include/_G_config.h" 1 3 4
# 14 "/usr/include/_G_config.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 326 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 3 4
typedef int wchar_t;
# 355 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 15 "/usr/include/_G_config.h" 2 3 4
# 24 "/usr/include/_G_config.h" 3 4
# 1 "/usr/include/wchar.h" 1 3 4
# 48 "/usr/include/wchar.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 49 "/usr/include/wchar.h" 2 3 4

# 1 "/usr/include/bits/wchar.h" 1 3 4
# 51 "/usr/include/wchar.h" 2 3 4
# 76 "/usr/include/wchar.h" 3 4
typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    char __wchb[4];
  } __value;
} __mbstate_t;
# 25 "/usr/include/_G_config.h" 2 3 4

typedef struct
{
  __off_t __pos;
  __mbstate_t __state;
} _G_fpos_t;
typedef struct
{
  __off64_t __pos;
  __mbstate_t __state;
} _G_fpos64_t;
# 44 "/usr/include/_G_config.h" 3 4
# 1 "/usr/include/gconv.h" 1 3 4
# 28 "/usr/include/gconv.h" 3 4
# 1 "/usr/include/wchar.h" 1 3 4
# 48 "/usr/include/wchar.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 49 "/usr/include/wchar.h" 2 3 4
# 29 "/usr/include/gconv.h" 2 3 4


# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 32 "/usr/include/gconv.h" 2 3 4





enum
{
  __GCONV_OK = 0,
  __GCONV_NOCONV,
  __GCONV_NODB,
  __GCONV_NOMEM,

  __GCONV_EMPTY_INPUT,
  __GCONV_FULL_OUTPUT,
  __GCONV_ILLEGAL_INPUT,
  __GCONV_INCOMPLETE_INPUT,

  __GCONV_ILLEGAL_DESCRIPTOR,
  __GCONV_INTERNAL_ERROR
};



enum
{
  __GCONV_IS_LAST = 0x0001,
  __GCONV_IGNORE_ERRORS = 0x0002
};



struct __gconv_step;
struct __gconv_step_data;
struct __gconv_loaded_object;
struct __gconv_trans_data;



typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *,
       __const unsigned char **, __const unsigned char *,
       unsigned char **, size_t *, int, int);


typedef wint_t (*__gconv_btowc_fct) (struct __gconv_step *, unsigned char);


typedef int (*__gconv_init_fct) (struct __gconv_step *);
typedef void (*__gconv_end_fct) (struct __gconv_step *);



typedef int (*__gconv_trans_fct) (struct __gconv_step *,
      struct __gconv_step_data *, void *,
      __const unsigned char *,
      __const unsigned char **,
      __const unsigned char *, unsigned char **,
      size_t *);


typedef int (*__gconv_trans_context_fct) (void *, __const unsigned char *,
       __const unsigned char *,
       unsigned char *, unsigned char *);


typedef int (*__gconv_trans_query_fct) (__const char *, __const char ***,
     size_t *);


typedef int (*__gconv_trans_init_fct) (void **, const char *);
typedef void (*__gconv_trans_end_fct) (void *);

struct __gconv_trans_data
{

  __gconv_trans_fct __trans_fct;
  __gconv_trans_context_fct __trans_context_fct;
  __gconv_trans_end_fct __trans_end_fct;
  void *__data;
  struct __gconv_trans_data *__next;
};



struct __gconv_step
{
  struct __gconv_loaded_object *__shlib_handle;
  __const char *__modname;

  int __counter;

  char *__from_name;
  char *__to_name;

  __gconv_fct __fct;
  __gconv_btowc_fct __btowc_fct;
  __gconv_init_fct __init_fct;
  __gconv_end_fct __end_fct;



  int __min_needed_from;
  int __max_needed_from;
  int __min_needed_to;
  int __max_needed_to;


  int __stateful;

  void *__data;
};



struct __gconv_step_data
{
  unsigned char *__outbuf;
  unsigned char *__outbufend;



  int __flags;



  int __invocation_counter;



  int __internal_use;

  __mbstate_t *__statep;
  __mbstate_t __state;



  struct __gconv_trans_data *__trans;
};



typedef struct __gconv_info
{
  size_t __nsteps;
  struct __gconv_step *__steps;
  __extension__ struct __gconv_step_data __data [];
} *__gconv_t;
# 45 "/usr/include/_G_config.h" 2 3 4
typedef union
{
  struct __gconv_info __cd;
  struct
  {
    struct __gconv_info __cd;
    struct __gconv_step_data __data;
  } __combined;
} _G_iconv_t;

typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
# 33 "/usr/include/libio.h" 2 3 4
# 53 "/usr/include/libio.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stdarg.h" 1 3 4
# 43 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 54 "/usr/include/libio.h" 2 3 4
# 166 "/usr/include/libio.h" 3 4
struct _IO_jump_t; struct _IO_FILE;
# 176 "/usr/include/libio.h" 3 4
typedef void _IO_lock_t;





struct _IO_marker {
  struct _IO_marker *_next;
  struct _IO_FILE *_sbuf;



  int _pos;
# 199 "/usr/include/libio.h" 3 4
};


enum __codecvt_result
{
  __codecvt_ok,
  __codecvt_partial,
  __codecvt_error,
  __codecvt_noconv
};
# 267 "/usr/include/libio.h" 3 4
struct _IO_FILE {
  int _flags;




  char* _IO_read_ptr;
  char* _IO_read_end;
  char* _IO_read_base;
  char* _IO_write_base;
  char* _IO_write_ptr;
  char* _IO_write_end;
  char* _IO_buf_base;
  char* _IO_buf_end;

  char *_IO_save_base;
  char *_IO_backup_base;
  char *_IO_save_end;

  struct _IO_marker *_markers;

  struct _IO_FILE *_chain;

  int _fileno;



  int _flags2;

  __off_t _old_offset;



  unsigned short _cur_column;
  signed char _vtable_offset;
  char _shortbuf[1];



  _IO_lock_t *_lock;
# 315 "/usr/include/libio.h" 3 4
  __off64_t _offset;
# 324 "/usr/include/libio.h" 3 4
  void *__pad1;
  void *__pad2;
  void *__pad3;
  void *__pad4;
  size_t __pad5;

  int _mode;

  char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];

};


typedef struct _IO_FILE _IO_FILE;


struct _IO_FILE_plus;

extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
# 360 "/usr/include/libio.h" 3 4
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);







typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
     size_t __n);







typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);


typedef int __io_close_fn (void *__cookie);
# 412 "/usr/include/libio.h" 3 4
extern int __underflow (_IO_FILE *) __attribute__ ((__nothrow__));
extern int __uflow (_IO_FILE *) __attribute__ ((__nothrow__));
extern int __overflow (_IO_FILE *, int) __attribute__ ((__nothrow__));
extern wint_t __wunderflow (_IO_FILE *) __attribute__ ((__nothrow__));
extern wint_t __wuflow (_IO_FILE *) __attribute__ ((__nothrow__));
extern wint_t __woverflow (_IO_FILE *, wint_t) __attribute__ ((__nothrow__));
# 450 "/usr/include/libio.h" 3 4
extern int _IO_getc (_IO_FILE *__fp) __attribute__ ((__nothrow__));
extern int _IO_putc (int __c, _IO_FILE *__fp) __attribute__ ((__nothrow__));
extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__));
extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__));

extern int _IO_peekc_locked (_IO_FILE *__fp) __attribute__ ((__nothrow__));





extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__));
extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__));
extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__));
# 480 "/usr/include/libio.h" 3 4
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
   __gnuc_va_list, int *__restrict);
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
    __gnuc_va_list);
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t) __attribute__ ((__nothrow__));
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t) __attribute__ ((__nothrow__));

extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int) __attribute__ ((__nothrow__));
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int) __attribute__ ((__nothrow__));

extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__));
# 73 "/usr/include/stdio.h" 2 3 4
# 86 "/usr/include/stdio.h" 3 4


typedef _G_fpos_t fpos_t;




# 138 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/bits/stdio_lim.h" 1 3 4
# 139 "/usr/include/stdio.h" 2 3 4



extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;









extern int remove (__const char *__filename) __attribute__ ((__nothrow__));

extern int rename (__const char *__old, __const char *__new) __attribute__ ((__nothrow__));














extern FILE *tmpfile (void);
# 185 "/usr/include/stdio.h" 3 4
extern char *tmpnam (char *__s) __attribute__ ((__nothrow__));





extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__));
# 203 "/usr/include/stdio.h" 3 4
extern char *tempnam (__const char *__dir, __const char *__pfx)
     __attribute__ ((__nothrow__)) __attribute__ ((__malloc__));








extern int fclose (FILE *__stream);




extern int fflush (FILE *__stream);

# 228 "/usr/include/stdio.h" 3 4
extern int fflush_unlocked (FILE *__stream);
# 242 "/usr/include/stdio.h" 3 4






extern FILE *fopen (__const char *__restrict __filename,
      __const char *__restrict __modes);




extern FILE *freopen (__const char *__restrict __filename,
        __const char *__restrict __modes,
        FILE *__restrict __stream);
# 269 "/usr/include/stdio.h" 3 4

# 280 "/usr/include/stdio.h" 3 4
extern FILE *fdopen (int __fd, __const char *__modes) __attribute__ ((__nothrow__));
# 306 "/usr/include/stdio.h" 3 4



extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__));



extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
      int __modes, size_t __n) __attribute__ ((__nothrow__));





extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
         size_t __size) __attribute__ ((__nothrow__));


extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__));








extern int fprintf (FILE *__restrict __stream,
      __const char *__restrict __format, ...);




extern int printf (__const char *__restrict __format, ...);

extern int sprintf (char *__restrict __s,
      __const char *__restrict __format, ...) __attribute__ ((__nothrow__));





extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
       __gnuc_va_list __arg);




extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);

extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
       __gnuc_va_list __arg) __attribute__ ((__nothrow__));





extern int snprintf (char *__restrict __s, size_t __maxlen,
       __const char *__restrict __format, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));

extern int vsnprintf (char *__restrict __s, size_t __maxlen,
        __const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));

# 400 "/usr/include/stdio.h" 3 4





extern int fscanf (FILE *__restrict __stream,
     __const char *__restrict __format, ...) ;




extern int scanf (__const char *__restrict __format, ...) ;

extern int sscanf (__const char *__restrict __s,
     __const char *__restrict __format, ...) __attribute__ ((__nothrow__));

# 442 "/usr/include/stdio.h" 3 4





extern int fgetc (FILE *__stream);
extern int getc (FILE *__stream);





extern int getchar (void);

# 466 "/usr/include/stdio.h" 3 4
extern int getc_unlocked (FILE *__stream);
extern int getchar_unlocked (void);
# 477 "/usr/include/stdio.h" 3 4
extern int fgetc_unlocked (FILE *__stream);











extern int fputc (int __c, FILE *__stream);
extern int putc (int __c, FILE *__stream);





extern int putchar (int __c);

# 510 "/usr/include/stdio.h" 3 4
extern int fputc_unlocked (int __c, FILE *__stream);







extern int putc_unlocked (int __c, FILE *__stream);
extern int putchar_unlocked (int __c);






extern int getw (FILE *__stream);


extern int putw (int __w, FILE *__stream);








extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
     ;






extern char *gets (char *__s) ;

# 591 "/usr/include/stdio.h" 3 4





extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);





extern int puts (__const char *__s);






extern int ungetc (int __c, FILE *__stream);






extern size_t fread (void *__restrict __ptr, size_t __size,
       size_t __n, FILE *__restrict __stream) ;




extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
        size_t __n, FILE *__restrict __s) ;

# 644 "/usr/include/stdio.h" 3 4
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
         size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
          size_t __n, FILE *__restrict __stream) ;








extern int fseek (FILE *__stream, long int __off, int __whence);




extern long int ftell (FILE *__stream) ;




extern void rewind (FILE *__stream);

# 680 "/usr/include/stdio.h" 3 4
extern int fseeko (FILE *__stream, __off_t __off, int __whence);




extern __off_t ftello (FILE *__stream) ;
# 699 "/usr/include/stdio.h" 3 4






extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);




extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
# 722 "/usr/include/stdio.h" 3 4

# 731 "/usr/include/stdio.h" 3 4


extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__));

extern int feof (FILE *__stream) __attribute__ ((__nothrow__)) ;

extern int ferror (FILE *__stream) __attribute__ ((__nothrow__)) ;




extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__));
extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__)) ;
extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__)) ;








extern void perror (__const char *__s);






# 1 "/usr/include/bits/sys_errlist.h" 1 3 4
# 27 "/usr/include/bits/sys_errlist.h" 3 4
extern int sys_nerr;
extern __const char *__const sys_errlist[];
# 761 "/usr/include/stdio.h" 2 3 4




extern int fileno (FILE *__stream) __attribute__ ((__nothrow__)) ;




extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__)) ;
# 780 "/usr/include/stdio.h" 3 4
extern FILE *popen (__const char *__command, __const char *__modes) ;





extern int pclose (FILE *__stream);





extern char *ctermid (char *__s) __attribute__ ((__nothrow__));
# 820 "/usr/include/stdio.h" 3 4
extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__));



extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__)) ;


extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__));
# 841 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/bits/stdio.h" 1 3 4
# 33 "/usr/include/bits/stdio.h" 3 4
extern __inline int
vprintf (__const char *__restrict __fmt, __gnuc_va_list __arg)
{
  return vfprintf (stdout, __fmt, __arg);
}


extern __inline int
getchar (void)
{
  return _IO_getc (stdin);
}




extern __inline int
getc_unlocked (FILE *__fp)
{
  return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_pt
r++);
}


extern __inline int
getchar_unlocked (void)
{
  return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_rea
d_ptr++);
}




extern __inline int
putchar (int __c)
{
  return _IO_putc (__c, stdout);
}




extern __inline int
fputc_unlocked (int __c, FILE *__stream)
{
  return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) 
: (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
}





extern __inline int
putc_unlocked (int __c, FILE *__stream)
{
  return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) 
: (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
}


extern __inline int
putchar_unlocked (int __c)
{
  return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (uns
igned char) (*(stdout)->_IO_write_ptr++ = (__c)));
}
# 111 "/usr/include/bits/stdio.h" 3 4
extern __inline int
__attribute__ ((__nothrow__)) feof_unlocked (FILE *__stream)
{
  return (((__stream)->_flags & 0x10) != 0);
}


extern __inline int
__attribute__ ((__nothrow__)) ferror_unlocked (FILE *__stream)
{
  return (((__stream)->_flags & 0x20) != 0);
}
# 842 "/usr/include/stdio.h" 2 3 4
# 850 "/usr/include/stdio.h" 3 4

# 71 "mkdosfs.c" 2
# 1 "/usr/include/stdlib.h" 1 3 4
# 33 "/usr/include/stdlib.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 34 "/usr/include/stdlib.h" 2 3 4


# 96 "/usr/include/stdlib.h" 3 4


typedef struct
  {
    int quot;
    int rem;
  } div_t;



typedef struct
  {
    long int quot;
    long int rem;
  } ldiv_t;



# 140 "/usr/include/stdlib.h" 3 4
extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__)) ;




extern double atof (__const char *__nptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;

extern int atoi (__const char *__nptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;

extern long int atol (__const char *__nptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;





__extension__ extern long long int atoll (__const char *__nptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;





extern double strtod (__const char *__restrict __nptr,
        char **__restrict __endptr)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;

# 182 "/usr/include/stdlib.h" 3 4


extern long int strtol (__const char *__restrict __nptr,
   char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;

extern unsigned long int strtoul (__const char *__restrict __nptr,
      char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;




__extension__
extern long long int strtoq (__const char *__restrict __nptr,
        char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;

__extension__
extern unsigned long long int strtouq (__const char *__restrict __nptr,
           char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;





__extension__
extern long long int strtoll (__const char *__restrict __nptr,
         char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;

__extension__
extern unsigned long long int strtoull (__const char *__restrict __nptr,
     char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;

# 279 "/usr/include/stdlib.h" 3 4
extern double __strtod_internal (__const char *__restrict __nptr,
     char **__restrict __endptr, int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
extern float __strtof_internal (__const char *__restrict __nptr,
    char **__restrict __endptr, int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
extern long double __strtold_internal (__const char *__restrict __nptr,
           char **__restrict __endptr,
           int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;

extern long int __strtol_internal (__const char *__restrict __nptr,
       char **__restrict __endptr,
       int __base, int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;



extern unsigned long int __strtoul_internal (__const char *__restrict __nptr,
          char **__restrict __endptr,
          int __base, int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;




__extension__
extern long long int __strtoll_internal (__const char *__restrict __nptr,
      char **__restrict __endptr,
      int __base, int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;



__extension__
extern unsigned long long int __strtoull_internal (__const char *
         __restrict __nptr,
         char **__restrict __endptr,
         int __base, int __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;








extern __inline double
__attribute__ ((__nothrow__)) strtod (__const char *__restrict __nptr, char **__restrict __endptr)
{
  return __strtod_internal (__nptr, __endptr, 0);
}
extern __inline long int
__attribute__ ((__nothrow__)) strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base)

{
  return __strtol_internal (__nptr, __endptr, __base, 0);
}
extern __inline unsigned long int
__attribute__ ((__nothrow__)) strtoul (__const char *__restrict __nptr, char **__restrict __endptr, int __base)

{
  return __strtoul_internal (__nptr, __endptr, __base, 0);
}

# 364 "/usr/include/stdlib.h" 3 4
__extension__ extern __inline long long int
__attribute__ ((__nothrow__)) strtoq (__const char *__restrict __nptr, char **__restrict __endptr, int __base)

{
  return __strtoll_internal (__nptr, __endptr, __base, 0);
}
__extension__ extern __inline unsigned long long int
__attribute__ ((__nothrow__)) strtouq (__const char *__restrict __nptr, char **__restrict __endptr, int __base)

{
  return __strtoull_internal (__nptr, __endptr, __base, 0);
}




__extension__ extern __inline long long int
__attribute__ ((__nothrow__)) strtoll (__const char *__restrict __nptr, char **__restrict __endptr, int __base)

{
  return __strtoll_internal (__nptr, __endptr, __base, 0);
}
__extension__ extern __inline unsigned long long int
__attribute__ ((__nothrow__)) strtoull (__const char * __restrict __nptr, char **__restrict __endptr, int __base)

{
  return __strtoull_internal (__nptr, __endptr, __base, 0);
}




extern __inline double
__attribute__ ((__nothrow__)) atof (__const char *__nptr)
{
  return strtod (__nptr, (char **) ((void *)0));
}
extern __inline int
__attribute__ ((__nothrow__)) atoi (__const char *__nptr)
{
  return (int) strtol (__nptr, (char **) ((void *)0), 10);
}
extern __inline long int
__attribute__ ((__nothrow__)) atol (__const char *__nptr)
{
  return strtol (__nptr, (char **) ((void *)0), 10);
}




__extension__ extern __inline long long int
__attribute__ ((__nothrow__)) atoll (__const char *__nptr)
{
  return strtoll (__nptr, (char **) ((void *)0), 10);
}

# 429 "/usr/include/stdlib.h" 3 4
extern char *l64a (long int __n) __attribute__ ((__nothrow__)) ;


extern long int a64l (__const char *__s)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
# 445 "/usr/include/stdlib.h" 3 4
extern long int random (void) __attribute__ ((__nothrow__));


extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__));





extern char *initstate (unsigned int __seed, char *__statebuf,
   size_t __statelen) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));



extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));







struct random_data
  {
    int32_t *fptr;
    int32_t *rptr;
    int32_t *state;
    int rand_type;
    int rand_deg;
    int rand_sep;
    int32_t *end_ptr;
  };

extern int random_r (struct random_data *__restrict __buf,
       int32_t *__restrict __result) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

extern int srandom_r (unsigned int __seed, struct random_data *__buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));

extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
   size_t __statelen,
   struct random_data *__restrict __buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 4)));

extern int setstate_r (char *__restrict __statebuf,
         struct random_data *__restrict __buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));






extern int rand (void) __attribute__ ((__nothrow__));

extern void srand (unsigned int __seed) __attribute__ ((__nothrow__));




extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__));







extern double drand48 (void) __attribute__ ((__nothrow__));
extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern long int lrand48 (void) __attribute__ ((__nothrow__));
extern long int nrand48 (unsigned short int __xsubi[3])
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern long int mrand48 (void) __attribute__ ((__nothrow__));
extern long int jrand48 (unsigned short int __xsubi[3])
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern void srand48 (long int __seedval) __attribute__ ((__nothrow__));
extern unsigned short int *seed48 (unsigned short int __seed16v[3])
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





struct drand48_data
  {
    unsigned short int __x[3];
    unsigned short int __old_x[3];
    unsigned short int __c;
    unsigned short int __init;
    unsigned long long int __a;
  };


extern int drand48_r (struct drand48_data *__restrict __buffer,
        double *__restrict __result) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
extern int erand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        double *__restrict __result) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern int lrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
extern int nrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern int mrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
extern int jrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));


extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));

extern int seed48_r (unsigned short int __seed16v[3],
       struct drand48_data *__buffer) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

extern int lcong48_r (unsigned short int __param[7],
        struct drand48_data *__buffer)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
# 597 "/usr/include/stdlib.h" 3 4



extern void *realloc (void *__ptr, size_t __size)
     __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));

extern void free (void *__ptr) __attribute__ ((__nothrow__));




extern void cfree (void *__ptr) __attribute__ ((__nothrow__));



# 1 "/usr/include/alloca.h" 1 3 4
# 25 "/usr/include/alloca.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 26 "/usr/include/alloca.h" 2 3 4







extern void *alloca (size_t __size) __attribute__ ((__nothrow__));






# 613 "/usr/include/stdlib.h" 2 3 4




extern void *valloc (size_t __size) __attribute__ ((__nothrow__)) __attribute__ ((__malloc__)) ;




extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;




extern void abort (void) __attribute__ ((__nothrow__)) __attribute__ ((__noreturn__));



extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));






extern void exit (int __status) __attribute__ ((__nothrow__)) __attribute__ ((__noreturn__));

# 658 "/usr/include/stdlib.h" 3 4


extern char *getenv (__const char *__name) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;




extern char *__secure_getenv (__const char *__name)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;





extern int putenv (char *__string) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





extern int setenv (__const char *__name, __const char *__value, int __replace)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));


extern int unsetenv (__const char *__name) __attribute__ ((__nothrow__));






extern int clearenv (void) __attribute__ ((__nothrow__));
# 698 "/usr/include/stdlib.h" 3 4
extern char *mktemp (char *__template) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
# 709 "/usr/include/stdlib.h" 3 4
extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ;
# 729 "/usr/include/stdlib.h" 3 4
extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;








extern int system (__const char *__command) ;

# 757 "/usr/include/stdlib.h" 3 4
extern char *realpath (__const char *__restrict __name,
         char *__restrict __resolved) __attribute__ ((__nothrow__)) ;






typedef int (*__compar_fn_t) (__const void *, __const void *);









extern void *bsearch (__const void *__key, __const void *__base,
        size_t __nmemb, size_t __size, __compar_fn_t __compar)
     __attribute__ ((__nonnull__ (1, 2, 5))) ;



extern void qsort (void *__base, size_t __nmemb, size_t __size,
     __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));



extern int abs (int __x) __attribute__ ((__nothrow__)) __attribute__ ((__const__)) ;
extern long int labs (long int __x) __attribute__ ((__nothrow__)) __attribute__ ((__const__)) ;












extern div_t div (int __numer, int __denom)
     __attribute__ ((__nothrow__)) __attribute__ ((__const__)) ;
extern ldiv_t ldiv (long int __numer, long int __denom)
     __attribute__ ((__nothrow__)) __attribute__ ((__const__)) ;

# 822 "/usr/include/stdlib.h" 3 4
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4))) ;




extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4))) ;




extern char *gcvt (double __value, int __ndigit, char *__buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3))) ;




extern char *qecvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qfcvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3))) ;




extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4, 5)));

extern int qecvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int qfcvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4, 5)));







extern int mblen (__const char *__s, size_t __n) __attribute__ ((__nothrow__)) ;


extern int mbtowc (wchar_t *__restrict __pwc,
     __const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__)) ;


extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__)) ;



extern size_t mbstowcs (wchar_t *__restrict __pwcs,
   __const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__));

extern size_t wcstombs (char *__restrict __s,
   __const wchar_t *__restrict __pwcs, size_t __n)
     __attribute__ ((__nothrow__));








extern int rpmatch (__const char *__response) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
# 927 "/usr/include/stdlib.h" 3 4
extern int posix_openpt (int __oflag) ;
# 962 "/usr/include/stdlib.h" 3 4
extern int getloadavg (double __loadavg[], int __nelem)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 978 "/usr/include/stdlib.h" 3 4

# 72 "mkdosfs.c" 2
# 1 "/usr/include/sys/ioctl.h" 1 3 4
# 24 "/usr/include/sys/ioctl.h" 3 4



# 1 "/usr/include/bits/ioctls.h" 1 3 4
# 24 "/usr/include/bits/ioctls.h" 3 4
# 1 "/usr/include/asm/ioctls.h" 1 3 4



# 1 "/usr/include/asm-x86_64/ioctls.h" 1 3 4
# 5 "/usr/include/asm/ioctls.h" 2 3 4
# 25 "/usr/include/bits/ioctls.h" 2 3 4
# 28 "/usr/include/sys/ioctl.h" 2 3 4


# 1 "/usr/include/bits/ioctl-types.h" 1 3 4
# 28 "/usr/include/bits/ioctl-types.h" 3 4
struct winsize
  {
    unsigned short int ws_row;
    unsigned short int ws_col;
    unsigned short int ws_xpixel;
    unsigned short int ws_ypixel;
  };


struct termio
  {
    unsigned short int c_iflag;
    unsigned short int c_oflag;
    unsigned short int c_cflag;
    unsigned short int c_lflag;
    unsigned char c_line;
    unsigned char c_cc[8];
};
# 31 "/usr/include/sys/ioctl.h" 2 3 4






# 1 "/usr/include/sys/ttydefaults.h" 1 3 4
# 38 "/usr/include/sys/ioctl.h" 2 3 4




extern int ioctl (int __fd, unsigned long int __request, ...) __attribute__ ((__nothrow__));


# 73 "mkdosfs.c" 2
# 1 "/usr/include/sys/stat.h" 1 3 4
# 37 "/usr/include/sys/stat.h" 3 4
# 1 "/usr/include/time.h" 1 3 4
# 38 "/usr/include/sys/stat.h" 2 3 4
# 103 "/usr/include/sys/stat.h" 3 4


# 1 "/usr/include/bits/stat.h" 1 3 4
# 43 "/usr/include/bits/stat.h" 3 4
struct stat
  {
    __dev_t st_dev;




    __ino_t st_ino;







    __nlink_t st_nlink;
    __mode_t st_mode;

    __uid_t st_uid;
    __gid_t st_gid;

    int pad0;

    __dev_t st_rdev;




    __off_t st_size;



    __blksize_t st_blksize;

    __blkcnt_t st_blocks;
# 88 "/usr/include/bits/stat.h" 3 4
    struct timespec st_atim;
    struct timespec st_mtim;
    struct timespec st_ctim;
# 103 "/usr/include/bits/stat.h" 3 4
    long int __unused[3];
# 112 "/usr/include/bits/stat.h" 3 4
  };
# 106 "/usr/include/sys/stat.h" 2 3 4
# 207 "/usr/include/sys/stat.h" 3 4
extern int stat (__const char *__restrict __file,
   struct stat *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));



extern int fstat (int __fd, struct stat *__buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2)));
# 259 "/usr/include/sys/stat.h" 3 4
extern int lstat (__const char *__restrict __file,
    struct stat *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
# 280 "/usr/include/sys/stat.h" 3 4
extern int chmod (__const char *__file, __mode_t __mode)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





extern int lchmod (__const char *__file, __mode_t __mode)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));




extern int fchmod (int __fd, __mode_t __mode) __attribute__ ((__nothrow__));
# 307 "/usr/include/sys/stat.h" 3 4
extern __mode_t umask (__mode_t __mask) __attribute__ ((__nothrow__));
# 316 "/usr/include/sys/stat.h" 3 4
extern int mkdir (__const char *__path, __mode_t __mode)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 331 "/usr/include/sys/stat.h" 3 4
extern int mknod (__const char *__path, __mode_t __mode, __dev_t __dev)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 345 "/usr/include/sys/stat.h" 3 4
extern int mkfifo (__const char *__path, __mode_t __mode)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 380 "/usr/include/sys/stat.h" 3 4
extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3)));
extern int __xstat (int __ver, __const char *__filename,
      struct stat *__stat_buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
extern int __lxstat (int __ver, __const char *__filename,
       struct stat *__stat_buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));
extern int __fxstatat (int __ver, int __fildes, __const char *__filename,
         struct stat *__stat_buf, int __flag)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 4)));
# 423 "/usr/include/sys/stat.h" 3 4
extern int __xmknod (int __ver, __const char *__path, __mode_t __mode,
       __dev_t *__dev) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 4)));

extern int __xmknodat (int __ver, int __fd, __const char *__path,
         __mode_t __mode, __dev_t *__dev)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (3, 5)));




extern __inline__ int
__attribute__ ((__nothrow__)) stat (__const char *__path, struct stat *__statbuf)
{
  return __xstat (1, __path, __statbuf);
}


extern __inline__ int
__attribute__ ((__nothrow__)) lstat (__const char *__path, struct stat *__statbuf)
{
  return __lxstat (1, __path, __statbuf);
}


extern __inline__ int
__attribute__ ((__nothrow__)) fstat (int __fd, struct stat *__statbuf)
{
  return __fxstat (1, __fd, __statbuf);
}
# 463 "/usr/include/sys/stat.h" 3 4
extern __inline__ int
__attribute__ ((__nothrow__)) mknod (__const char *__path, __mode_t __mode, __dev_t __dev)
{
  return __xmknod (0, __path, __mode, &__dev);
}
# 515 "/usr/include/sys/stat.h" 3 4

# 74 "mkdosfs.c" 2

# 1 "/usr/include/unistd.h" 1 3 4
# 28 "/usr/include/unistd.h" 3 4

# 171 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/bits/posix_opt.h" 1 3 4
# 172 "/usr/include/unistd.h" 2 3 4
# 195 "/usr/include/unistd.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 196 "/usr/include/unistd.h" 2 3 4
# 224 "/usr/include/unistd.h" 3 4
typedef __useconds_t useconds_t;
# 236 "/usr/include/unistd.h" 3 4
typedef __intptr_t intptr_t;






typedef __socklen_t socklen_t;
# 256 "/usr/include/unistd.h" 3 4
extern int access (__const char *__name, int __type) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 299 "/usr/include/unistd.h" 3 4
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __attribute__ ((__nothrow__));
# 318 "/usr/include/unistd.h" 3 4
extern int close (int __fd);






extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ;





extern ssize_t write (int __fd, __const void *__buf, size_t __n) ;
# 382 "/usr/include/unistd.h" 3 4
extern int pipe (int __pipedes[2]) __attribute__ ((__nothrow__)) ;
# 391 "/usr/include/unistd.h" 3 4
extern unsigned int alarm (unsigned int __seconds) __attribute__ ((__nothrow__));
# 403 "/usr/include/unistd.h" 3 4
extern unsigned int sleep (unsigned int __seconds);






extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
     __attribute__ ((__nothrow__));






extern int usleep (__useconds_t __useconds);
# 427 "/usr/include/unistd.h" 3 4
extern int pause (void);



extern int chown (__const char *__file, __uid_t __owner, __gid_t __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;



extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __attribute__ ((__nothrow__)) ;




extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
# 455 "/usr/include/unistd.h" 3 4
extern int chdir (__const char *__path) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;



extern int fchdir (int __fd) __attribute__ ((__nothrow__)) ;
# 469 "/usr/include/unistd.h" 3 4
extern char *getcwd (char *__buf, size_t __size) __attribute__ ((__nothrow__)) ;
# 482 "/usr/include/unistd.h" 3 4
extern char *getwd (char *__buf)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) ;




extern int dup (int __fd) __attribute__ ((__nothrow__)) ;


extern int dup2 (int __fd, int __fd2) __attribute__ ((__nothrow__));


extern char **__environ;







extern int execve (__const char *__path, char *__const __argv[],
     char *__const __envp[]) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 514 "/usr/include/unistd.h" 3 4
extern int execv (__const char *__path, char *__const __argv[])
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));



extern int execle (__const char *__path, __const char *__arg, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));



extern int execl (__const char *__path, __const char *__arg, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));



extern int execvp (__const char *__file, char *__const __argv[])
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));




extern int execlp (__const char *__file, __const char *__arg, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));




extern int nice (int __inc) __attribute__ ((__nothrow__)) ;




extern void _exit (int __status) __attribute__ ((__noreturn__));





# 1 "/usr/include/bits/confname.h" 1 3 4
# 26 "/usr/include/bits/confname.h" 3 4
enum
  {
    _PC_LINK_MAX,

    _PC_MAX_CANON,

    _PC_MAX_INPUT,

    _PC_NAME_MAX,

    _PC_PATH_MAX,

    _PC_PIPE_BUF,

    _PC_CHOWN_RESTRICTED,

    _PC_NO_TRUNC,

    _PC_VDISABLE,

    _PC_SYNC_IO,

    _PC_ASYNC_IO,

    _PC_PRIO_IO,

    _PC_SOCK_MAXBUF,

    _PC_FILESIZEBITS,

    _PC_REC_INCR_XFER_SIZE,

    _PC_REC_MAX_XFER_SIZE,

    _PC_REC_MIN_XFER_SIZE,

    _PC_REC_XFER_ALIGN,

    _PC_ALLOC_SIZE_MIN,

    _PC_SYMLINK_MAX,

    _PC_2_SYMLINKS

  };


enum
  {
    _SC_ARG_MAX,

    _SC_CHILD_MAX,

    _SC_CLK_TCK,

    _SC_NGROUPS_MAX,

    _SC_OPEN_MAX,

    _SC_STREAM_MAX,

    _SC_TZNAME_MAX,

    _SC_JOB_CONTROL,

    _SC_SAVED_IDS,

    _SC_REALTIME_SIGNALS,

    _SC_PRIORITY_SCHEDULING,

    _SC_TIMERS,

    _SC_ASYNCHRONOUS_IO,

    _SC_PRIORITIZED_IO,

    _SC_SYNCHRONIZED_IO,

    _SC_FSYNC,

    _SC_MAPPED_FILES,

    _SC_MEMLOCK,

    _SC_MEMLOCK_RANGE,

    _SC_MEMORY_PROTECTION,

    _SC_MESSAGE_PASSING,

    _SC_SEMAPHORES,

    _SC_SHARED_MEMORY_OBJECTS,

    _SC_AIO_LISTIO_MAX,

    _SC_AIO_MAX,

    _SC_AIO_PRIO_DELTA_MAX,

    _SC_DELAYTIMER_MAX,

    _SC_MQ_OPEN_MAX,

    _SC_MQ_PRIO_MAX,

    _SC_VERSION,

    _SC_PAGESIZE,


    _SC_RTSIG_MAX,

    _SC_SEM_NSEMS_MAX,

    _SC_SEM_VALUE_MAX,

    _SC_SIGQUEUE_MAX,

    _SC_TIMER_MAX,




    _SC_BC_BASE_MAX,

    _SC_BC_DIM_MAX,

    _SC_BC_SCALE_MAX,

    _SC_BC_STRING_MAX,

    _SC_COLL_WEIGHTS_MAX,

    _SC_EQUIV_CLASS_MAX,

    _SC_EXPR_NEST_MAX,

    _SC_LINE_MAX,

    _SC_RE_DUP_MAX,

    _SC_CHARCLASS_NAME_MAX,


    _SC_2_VERSION,

    _SC_2_C_BIND,

    _SC_2_C_DEV,

    _SC_2_FORT_DEV,

    _SC_2_FORT_RUN,

    _SC_2_SW_DEV,

    _SC_2_LOCALEDEF,


    _SC_PII,

    _SC_PII_XTI,

    _SC_PII_SOCKET,

    _SC_PII_INTERNET,

    _SC_PII_OSI,

    _SC_POLL,

    _SC_SELECT,

    _SC_UIO_MAXIOV,

    _SC_IOV_MAX = _SC_UIO_MAXIOV,

    _SC_PII_INTERNET_STREAM,

    _SC_PII_INTERNET_DGRAM,

    _SC_PII_OSI_COTS,

    _SC_PII_OSI_CLTS,

    _SC_PII_OSI_M,

    _SC_T_IOV_MAX,



    _SC_THREADS,

    _SC_THREAD_SAFE_FUNCTIONS,

    _SC_GETGR_R_SIZE_MAX,

    _SC_GETPW_R_SIZE_MAX,

    _SC_LOGIN_NAME_MAX,

    _SC_TTY_NAME_MAX,

    _SC_THREAD_DESTRUCTOR_ITERATIONS,

    _SC_THREAD_KEYS_MAX,

    _SC_THREAD_STACK_MIN,

    _SC_THREAD_THREADS_MAX,

    _SC_THREAD_ATTR_STACKADDR,

    _SC_THREAD_ATTR_STACKSIZE,

    _SC_THREAD_PRIORITY_SCHEDULING,

    _SC_THREAD_PRIO_INHERIT,

    _SC_THREAD_PRIO_PROTECT,

    _SC_THREAD_PROCESS_SHARED,


    _SC_NPROCESSORS_CONF,

    _SC_NPROCESSORS_ONLN,

    _SC_PHYS_PAGES,

    _SC_AVPHYS_PAGES,

    _SC_ATEXIT_MAX,

    _SC_PASS_MAX,


    _SC_XOPEN_VERSION,

    _SC_XOPEN_XCU_VERSION,

    _SC_XOPEN_UNIX,

    _SC_XOPEN_CRYPT,

    _SC_XOPEN_ENH_I18N,

    _SC_XOPEN_SHM,


    _SC_2_CHAR_TERM,

    _SC_2_C_VERSION,

    _SC_2_UPE,


    _SC_XOPEN_XPG2,

    _SC_XOPEN_XPG3,

    _SC_XOPEN_XPG4,


    _SC_CHAR_BIT,

    _SC_CHAR_MAX,

    _SC_CHAR_MIN,

    _SC_INT_MAX,

    _SC_INT_MIN,

    _SC_LONG_BIT,

    _SC_WORD_BIT,

    _SC_MB_LEN_MAX,

    _SC_NZERO,

    _SC_SSIZE_MAX,

    _SC_SCHAR_MAX,

    _SC_SCHAR_MIN,

    _SC_SHRT_MAX,

    _SC_SHRT_MIN,

    _SC_UCHAR_MAX,

    _SC_UINT_MAX,

    _SC_ULONG_MAX,

    _SC_USHRT_MAX,


    _SC_NL_ARGMAX,

    _SC_NL_LANGMAX,

    _SC_NL_MSGMAX,

    _SC_NL_NMAX,

    _SC_NL_SETMAX,

    _SC_NL_TEXTMAX,


    _SC_XBS5_ILP32_OFF32,

    _SC_XBS5_ILP32_OFFBIG,

    _SC_XBS5_LP64_OFF64,

    _SC_XBS5_LPBIG_OFFBIG,


    _SC_XOPEN_LEGACY,

    _SC_XOPEN_REALTIME,

    _SC_XOPEN_REALTIME_THREADS,


    _SC_ADVISORY_INFO,

    _SC_BARRIERS,

    _SC_BASE,

    _SC_C_LANG_SUPPORT,

    _SC_C_LANG_SUPPORT_R,

    _SC_CLOCK_SELECTION,

    _SC_CPUTIME,

    _SC_THREAD_CPUTIME,

    _SC_DEVICE_IO,

    _SC_DEVICE_SPECIFIC,

    _SC_DEVICE_SPECIFIC_R,

    _SC_FD_MGMT,

    _SC_FIFO,

    _SC_PIPE,

    _SC_FILE_ATTRIBUTES,

    _SC_FILE_LOCKING,

    _SC_FILE_SYSTEM,

    _SC_MONOTONIC_CLOCK,

    _SC_MULTI_PROCESS,

    _SC_SINGLE_PROCESS,

    _SC_NETWORKING,

    _SC_READER_WRITER_LOCKS,

    _SC_SPIN_LOCKS,

    _SC_REGEXP,

    _SC_REGEX_VERSION,

    _SC_SHELL,

    _SC_SIGNALS,

    _SC_SPAWN,

    _SC_SPORADIC_SERVER,

    _SC_THREAD_SPORADIC_SERVER,

    _SC_SYSTEM_DATABASE,

    _SC_SYSTEM_DATABASE_R,

    _SC_TIMEOUTS,

    _SC_TYPED_MEMORY_OBJECTS,

    _SC_USER_GROUPS,

    _SC_USER_GROUPS_R,

    _SC_2_PBS,

    _SC_2_PBS_ACCOUNTING,

    _SC_2_PBS_LOCATE,

    _SC_2_PBS_MESSAGE,

    _SC_2_PBS_TRACK,

    _SC_SYMLOOP_MAX,

    _SC_STREAMS,

    _SC_2_PBS_CHECKPOINT,


    _SC_V6_ILP32_OFF32,

    _SC_V6_ILP32_OFFBIG,

    _SC_V6_LP64_OFF64,

    _SC_V6_LPBIG_OFFBIG,


    _SC_HOST_NAME_MAX,

    _SC_TRACE,

    _SC_TRACE_EVENT_FILTER,

    _SC_TRACE_INHERIT,

    _SC_TRACE_LOG,


    _SC_LEVEL1_ICACHE_SIZE,

    _SC_LEVEL1_ICACHE_ASSOC,

    _SC_LEVEL1_ICACHE_LINESIZE,

    _SC_LEVEL1_DCACHE_SIZE,

    _SC_LEVEL1_DCACHE_ASSOC,

    _SC_LEVEL1_DCACHE_LINESIZE,

    _SC_LEVEL2_CACHE_SIZE,

    _SC_LEVEL2_CACHE_ASSOC,

    _SC_LEVEL2_CACHE_LINESIZE,

    _SC_LEVEL3_CACHE_SIZE,

    _SC_LEVEL3_CACHE_ASSOC,

    _SC_LEVEL3_CACHE_LINESIZE,

    _SC_LEVEL4_CACHE_SIZE,

    _SC_LEVEL4_CACHE_ASSOC,

    _SC_LEVEL4_CACHE_LINESIZE,



    _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,

    _SC_RAW_SOCKETS

  };


enum
  {
    _CS_PATH,


    _CS_V6_WIDTH_RESTRICTED_ENVS,


    _CS_GNU_LIBC_VERSION,

    _CS_GNU_LIBPTHREAD_VERSION,


    _CS_LFS_CFLAGS = 1000,

    _CS_LFS_LDFLAGS,

    _CS_LFS_LIBS,

    _CS_LFS_LINTFLAGS,

    _CS_LFS64_CFLAGS,

    _CS_LFS64_LDFLAGS,

    _CS_LFS64_LIBS,

    _CS_LFS64_LINTFLAGS,


    _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,

    _CS_XBS5_ILP32_OFF32_LDFLAGS,

    _CS_XBS5_ILP32_OFF32_LIBS,

    _CS_XBS5_ILP32_OFF32_LINTFLAGS,

    _CS_XBS5_ILP32_OFFBIG_CFLAGS,

    _CS_XBS5_ILP32_OFFBIG_LDFLAGS,

    _CS_XBS5_ILP32_OFFBIG_LIBS,

    _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,

    _CS_XBS5_LP64_OFF64_CFLAGS,

    _CS_XBS5_LP64_OFF64_LDFLAGS,

    _CS_XBS5_LP64_OFF64_LIBS,

    _CS_XBS5_LP64_OFF64_LINTFLAGS,

    _CS_XBS5_LPBIG_OFFBIG_CFLAGS,

    _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,

    _CS_XBS5_LPBIG_OFFBIG_LIBS,

    _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,


    _CS_POSIX_V6_ILP32_OFF32_CFLAGS,

    _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,

    _CS_POSIX_V6_ILP32_OFF32_LIBS,

    _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,

    _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,

    _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,

    _CS_POSIX_V6_ILP32_OFFBIG_LIBS,

    _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,

    _CS_POSIX_V6_LP64_OFF64_CFLAGS,

    _CS_POSIX_V6_LP64_OFF64_LDFLAGS,

    _CS_POSIX_V6_LP64_OFF64_LIBS,

    _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,

    _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,

    _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,

    _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,

    _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS

  };
# 553 "/usr/include/unistd.h" 2 3 4


extern long int pathconf (__const char *__path, int __name)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern long int fpathconf (int __fd, int __name) __attribute__ ((__nothrow__));


extern long int sysconf (int __name) __attribute__ ((__nothrow__)) __attribute__ ((__const__));



extern size_t confstr (int __name, char *__buf, size_t __len) __attribute__ ((__nothrow__));




extern __pid_t getpid (void) __attribute__ ((__nothrow__));


extern __pid_t getppid (void) __attribute__ ((__nothrow__));




extern __pid_t getpgrp (void) __attribute__ ((__nothrow__));
# 589 "/usr/include/unistd.h" 3 4
extern __pid_t __getpgid (__pid_t __pid) __attribute__ ((__nothrow__));
# 598 "/usr/include/unistd.h" 3 4
extern int setpgid (__pid_t __pid, __pid_t __pgid) __attribute__ ((__nothrow__));
# 615 "/usr/include/unistd.h" 3 4
extern int setpgrp (void) __attribute__ ((__nothrow__));
# 632 "/usr/include/unistd.h" 3 4
extern __pid_t setsid (void) __attribute__ ((__nothrow__));







extern __uid_t getuid (void) __attribute__ ((__nothrow__));


extern __uid_t geteuid (void) __attribute__ ((__nothrow__));


extern __gid_t getgid (void) __attribute__ ((__nothrow__));


extern __gid_t getegid (void) __attribute__ ((__nothrow__));




extern int getgroups (int __size, __gid_t __list[]) __attribute__ ((__nothrow__)) ;
# 665 "/usr/include/unistd.h" 3 4
extern int setuid (__uid_t __uid) __attribute__ ((__nothrow__));




extern int setreuid (__uid_t __ruid, __uid_t __euid) __attribute__ ((__nothrow__));




extern int seteuid (__uid_t __uid) __attribute__ ((__nothrow__));






extern int setgid (__gid_t __gid) __attribute__ ((__nothrow__));




extern int setregid (__gid_t __rgid, __gid_t __egid) __attribute__ ((__nothrow__));




extern int setegid (__gid_t __gid) __attribute__ ((__nothrow__));
# 721 "/usr/include/unistd.h" 3 4
extern __pid_t fork (void) __attribute__ ((__nothrow__));






extern __pid_t vfork (void) __attribute__ ((__nothrow__));





extern char *ttyname (int __fd) __attribute__ ((__nothrow__));



extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2))) ;



extern int isatty (int __fd) __attribute__ ((__nothrow__));





extern int ttyslot (void) __attribute__ ((__nothrow__));




extern int link (__const char *__from, __const char *__to)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))) ;
# 767 "/usr/include/unistd.h" 3 4
extern int symlink (__const char *__from, __const char *__to)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))) ;




extern ssize_t readlink (__const char *__restrict __path,
    char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))) ;
# 790 "/usr/include/unistd.h" 3 4
extern int unlink (__const char *__name) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 799 "/usr/include/unistd.h" 3 4
extern int rmdir (__const char *__path) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));



extern __pid_t tcgetpgrp (int __fd) __attribute__ ((__nothrow__));


extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __attribute__ ((__nothrow__));






extern char *getlogin (void);
# 826 "/usr/include/unistd.h" 3 4
extern int setlogin (__const char *__name) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
# 835 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/getopt.h" 1 3 4
# 59 "/usr/include/getopt.h" 3 4
extern char *optarg;
# 73 "/usr/include/getopt.h" 3 4
extern int optind;




extern int opterr;



extern int optopt;
# 152 "/usr/include/getopt.h" 3 4
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
       __attribute__ ((__nothrow__));
# 836 "/usr/include/unistd.h" 2 3 4







extern int gethostname (char *__name, size_t __len) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));






extern int sethostname (__const char *__name, size_t __len)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;



extern int sethostid (long int __id) __attribute__ ((__nothrow__)) ;





extern int getdomainname (char *__name, size_t __len)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
extern int setdomainname (__const char *__name, size_t __len)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;





extern int vhangup (void) __attribute__ ((__nothrow__));


extern int revoke (__const char *__file) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;







extern int profil (unsigned short int *__sample_buffer, size_t __size,
     size_t __offset, unsigned int __scale)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





extern int acct (__const char *__name) __attribute__ ((__nothrow__));



extern char *getusershell (void) __attribute__ ((__nothrow__));
extern void endusershell (void) __attribute__ ((__nothrow__));
extern void setusershell (void) __attribute__ ((__nothrow__));





extern int daemon (int __nochdir, int __noclose) __attribute__ ((__nothrow__)) ;






extern int chroot (__const char *__path) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;



extern char *getpass (__const char *__prompt) __attribute__ ((__nonnull__ (1)));
# 921 "/usr/include/unistd.h" 3 4
extern int fsync (int __fd);






extern long int gethostid (void);


extern void sync (void) __attribute__ ((__nothrow__));




extern int getpagesize (void) __attribute__ ((__nothrow__)) __attribute__ ((__const__));




extern int getdtablesize (void) __attribute__ ((__nothrow__));




extern int truncate (__const char *__file, __off_t __length)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))) ;
# 968 "/usr/include/unistd.h" 3 4
extern int ftruncate (int __fd, __off_t __length) __attribute__ ((__nothrow__)) ;
# 988 "/usr/include/unistd.h" 3 4
extern int brk (void *__addr) __attribute__ ((__nothrow__)) ;





extern void *sbrk (intptr_t __delta) __attribute__ ((__nothrow__));
# 1009 "/usr/include/unistd.h" 3 4
extern long int syscall (long int __sysno, ...) __attribute__ ((__nothrow__));
# 1063 "/usr/include/unistd.h" 3 4
extern int fdatasync (int __fildes) __attribute__ ((__nothrow__));
# 1101 "/usr/include/unistd.h" 3 4

# 76 "mkdosfs.c" 2
# 1 "/usr/include/time.h" 1 3 4
# 31 "/usr/include/time.h" 3 4








# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 40 "/usr/include/time.h" 2 3 4



# 1 "/usr/include/bits/time.h" 1 3 4
# 44 "/usr/include/time.h" 2 3 4
# 59 "/usr/include/time.h" 3 4


typedef __clock_t clock_t;



# 132 "/usr/include/time.h" 3 4


struct tm
{
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_wday;
  int tm_yday;
  int tm_isdst;


  long int tm_gmtoff;
  __const char *tm_zone;




};








struct itimerspec
  {
    struct timespec it_interval;
    struct timespec it_value;
  };


struct sigevent;
# 181 "/usr/include/time.h" 3 4



extern clock_t clock (void) __attribute__ ((__nothrow__));


extern time_t time (time_t *__timer) __attribute__ ((__nothrow__));


extern double difftime (time_t __time1, time_t __time0)
     __attribute__ ((__nothrow__)) __attribute__ ((__const__));


extern time_t mktime (struct tm *__tp) __attribute__ ((__nothrow__));





extern size_t strftime (char *__restrict __s, size_t __maxsize,
   __const char *__restrict __format,
   __const struct tm *__restrict __tp) __attribute__ ((__nothrow__));

# 229 "/usr/include/time.h" 3 4



extern struct tm *gmtime (__const time_t *__timer) __attribute__ ((__nothrow__));



extern struct tm *localtime (__const time_t *__timer) __attribute__ ((__nothrow__));





extern struct tm *gmtime_r (__const time_t *__restrict __timer,
       struct tm *__restrict __tp) __attribute__ ((__nothrow__));



extern struct tm *localtime_r (__const time_t *__restrict __timer,
          struct tm *__restrict __tp) __attribute__ ((__nothrow__));





extern char *asctime (__const struct tm *__tp) __attribute__ ((__nothrow__));


extern char *ctime (__const time_t *__timer) __attribute__ ((__nothrow__));







extern char *asctime_r (__const struct tm *__restrict __tp,
   char *__restrict __buf) __attribute__ ((__nothrow__));


extern char *ctime_r (__const time_t *__restrict __timer,
        char *__restrict __buf) __attribute__ ((__nothrow__));




extern char *__tzname[2];
extern int __daylight;
extern long int __timezone;




extern char *tzname[2];



extern void tzset (void) __attribute__ ((__nothrow__));



extern int daylight;
extern long int timezone;





extern int stime (__const time_t *__when) __attribute__ ((__nothrow__));
# 312 "/usr/include/time.h" 3 4
extern time_t timegm (struct tm *__tp) __attribute__ ((__nothrow__));


extern time_t timelocal (struct tm *__tp) __attribute__ ((__nothrow__));


extern int dysize (int __year) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
# 327 "/usr/include/time.h" 3 4
extern int nanosleep (__const struct timespec *__requested_time,
        struct timespec *__remaining);



extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __attribute__ ((__nothrow__));


extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __attribute__ ((__nothrow__));


extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
     __attribute__ ((__nothrow__));






extern int clock_nanosleep (clockid_t __clock_id, int __flags,
       __const struct timespec *__req,
       struct timespec *__rem);


extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __attribute__ ((__nothrow__));




extern int timer_create (clockid_t __clock_id,
    struct sigevent *__restrict __evp,
    timer_t *__restrict __timerid) __attribute__ ((__nothrow__));


extern int timer_delete (timer_t __timerid) __attribute__ ((__nothrow__));


extern int timer_settime (timer_t __timerid, int __flags,
     __const struct itimerspec *__restrict __value,
     struct itimerspec *__restrict __ovalue) __attribute__ ((__nothrow__));


extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
     __attribute__ ((__nothrow__));


extern int timer_getoverrun (timer_t __timerid) __attribute__ ((__nothrow__));
# 416 "/usr/include/time.h" 3 4

# 77 "mkdosfs.c" 2
# 1 "/usr/include/errno.h" 1 3 4
# 32 "/usr/include/errno.h" 3 4




# 1 "/usr/include/bits/errno.h" 1 3 4
# 25 "/usr/include/bits/errno.h" 3 4
# 1 "/usr/include/linux/errno.h" 1 3 4



# 1 "/usr/include/asm/errno.h" 1 3 4



# 1 "/usr/include/asm-x86_64/errno.h" 1 3 4
# 5 "/usr/include/asm/errno.h" 2 3 4
# 5 "/usr/include/linux/errno.h" 2 3 4
# 26 "/usr/include/bits/errno.h" 2 3 4
# 43 "/usr/include/bits/errno.h" 3 4
extern int *__errno_location (void) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
# 37 "/usr/include/errno.h" 2 3 4
# 59 "/usr/include/errno.h" 3 4

# 78 "mkdosfs.c" 2
# 1 "/usr/include/libgen.h" 1 3 4
# 24 "/usr/include/libgen.h" 3 4



extern char *dirname (char *__path) __attribute__ ((__nothrow__));







extern char *__xpg_basename (char *__path) __attribute__ ((__nothrow__));



# 79 "mkdosfs.c" 2
# 1 "/usr/include/dirent.h" 1 3 4
# 28 "/usr/include/dirent.h" 3 4

# 62 "/usr/include/dirent.h" 3 4
# 1 "/usr/include/bits/dirent.h" 1 3 4
# 23 "/usr/include/bits/dirent.h" 3 4
struct dirent
  {

    __ino_t d_ino;
    __off_t d_off;




    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];
  };
# 63 "/usr/include/dirent.h" 2 3 4
# 98 "/usr/include/dirent.h" 3 4
enum
  {
    DT_UNKNOWN = 0,

    DT_FIFO = 1,

    DT_CHR = 2,

    DT_DIR = 4,

    DT_BLK = 6,

    DT_REG = 8,

    DT_LNK = 10,

    DT_SOCK = 12,

    DT_WHT = 14

  };
# 128 "/usr/include/dirent.h" 3 4
typedef struct __dirstream DIR;






extern DIR *opendir (__const char *__name) __attribute__ ((__nonnull__ (1)));
# 150 "/usr/include/dirent.h" 3 4
extern int closedir (DIR *__dirp) __attribute__ ((__nonnull__ (1)));
# 163 "/usr/include/dirent.h" 3 4
extern struct dirent *readdir (DIR *__dirp) __attribute__ ((__nonnull__ (1)));
# 184 "/usr/include/dirent.h" 3 4
extern int readdir_r (DIR *__restrict __dirp,
        struct dirent *__restrict __entry,
        struct dirent **__restrict __result)
     __attribute__ ((__nonnull__ (1, 2, 3)));
# 209 "/usr/include/dirent.h" 3 4
extern void rewinddir (DIR *__dirp) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





extern void seekdir (DIR *__dirp, long int __pos) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));


extern long int telldir (DIR *__dirp) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));





extern int dirfd (DIR *__dirp) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));







# 1 "/usr/include/bits/posix1_lim.h" 1 3 4
# 153 "/usr/include/bits/posix1_lim.h" 3 4
# 1 "/usr/include/bits/local_lim.h" 1 3 4
# 36 "/usr/include/bits/local_lim.h" 3 4
# 1 "/usr/include/linux/limits.h" 1 3 4
# 37 "/usr/include/bits/local_lim.h" 2 3 4
# 154 "/usr/include/bits/posix1_lim.h" 2 3 4
# 233 "/usr/include/dirent.h" 2 3 4
# 243 "/usr/include/dirent.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h" 1 3 4
# 244 "/usr/include/dirent.h" 2 3 4






extern int scandir (__const char *__restrict __dir,
      struct dirent ***__restrict __namelist,
      int (*__selector) (__const struct dirent *),
      int (*__cmp) (__const void *, __const void *))
     __attribute__ ((__nonnull__ (1, 2)));
# 280 "/usr/include/dirent.h" 3 4
extern int alphasort (__const void *__e1, __const void *__e2)
     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
# 324 "/usr/include/dirent.h" 3 4
extern __ssize_t getdirentries (int __fd, char *__restrict __buf,
    size_t __nbytes,
    __off_t *__restrict __basep)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 4)));
# 349 "/usr/include/dirent.h" 3 4

# 80 "mkdosfs.c" 2

# 1 "/usr/include/linux/version.h" 1 3 4
# 82 "mkdosfs.c" 2
# 117 "mkdosfs.c"
# 1 "/usr/include/linux/unistd.h" 1 3 4







# 1 "/usr/include/asm/unistd.h" 1 3 4



# 1 "/usr/include/asm-x86_64/unistd.h" 1 3 4
# 5 "/usr/include/asm/unistd.h" 2 3 4
# 9 "/usr/include/linux/unistd.h" 2 3 4
# 1 "/usr/include/sys/syscall.h" 1 3 4
# 32 "/usr/include/sys/syscall.h" 3 4
# 1 "/usr/include/bits/syscall.h" 1 3 4






# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 8 "/usr/include/bits/syscall.h" 2 3 4
# 33 "/usr/include/sys/syscall.h" 2 3 4
# 10 "/usr/include/linux/unistd.h" 2 3 4
# 118 "mkdosfs.c" 2


static loff_t llseek( int fd, loff_t offset, int whence )
{
    return lseek(fd, offset, whence);
}
# 165 "mkdosfs.c"
inline int
cdiv (int a, int b)
{
  return (a + b - 1) / b;
}
# 218 "mkdosfs.c"
struct msdos_volume_info {
  __u8 drive_number;
  __u8 RESERVED;
  __u8 ext_boot_sign;
  __u8 volume_id[4];
  __u8 volume_label[11];
  __u8 fs_type[8];
} __attribute__ ((packed));

struct msdos_boot_sector
{
  __u8 boot_jump[3];
  __u8 system_id[8];

  __u8 sector_size[2];
  __u8 cluster_size;
  __u16 reserved;
  __u8 fats;
  __u8 dir_entries[2];
  __u8 sectors[2];
  __u8 media;
  __u16 fat_length;
  __u16 secs_track;
  __u16 heads;
  __u32 hidden;
  __u32 total_sect;
  union {
    struct {
      struct msdos_volume_info vi;
      __u8 boot_code[448];
    } __attribute__ ((packed)) _oldfat;
    struct {
      __u32 fat32_length;
      __u16 flags;
      __u8 version[2];
      __u32 root_cluster;
      __u16 info_sector;
      __u16 backup_boot;
      __u16 reserved2[6];
      struct msdos_volume_info vi;
      __u8 boot_code[420];
    } __attribute__ ((packed)) _fat32;
  } __attribute__ ((packed)) fstype;
  __u16 boot_sign;
} __attribute__ ((packed));



struct fat32_fsinfo {
  __u32 reserved1;
  __u32 signature;
  __u32 free_clusters;
  __u32 next_cluster;

  __u32 reserved2[4];
};



struct msdos_dir_slot {
        __u8 id;
        __u8 name0_4[10];
        __u8 attr;
        __u8 reserved;
        __u8 alias_checksum;
        __u8 name5_10[12];
        __u16 start;
        __u8 name11_12[4];
};

struct msdos_dir_entry
  {
    char name[8], ext[3];
    __u8 attr;
    __u8 lcase;
    __u8 ctime_ms;
    __u16 ctime;
    __u16 cdate;
    __u16 adate;
    __u16 starthi;
    __u16 time, date, start;
    __u32 size;
  } __attribute__ ((packed));




char dummy_boot_jump[3] = { 0xeb, 0x3c, 0x90 };

char dummy_boot_jump_m68k[2] = { 0x60, 0x1c };


char dummy_boot_code[448] =
  "\x0e"
  "\x1f"
  "\xbe\x5b\x7c"

  "\xac"
  "\x22\xc0"
  "\x74\x0b"
  "\x56"
  "\xb4\x0e"
  "\xbb\x07\x00"
  "\xcd\x10"
  "\x5e"
  "\xeb\xf0"

  "\x32\xe4"
  "\xcd\x16"
  "\xcd\x19"
  "\xeb\xfe"


  "This is not a bootable disk.  Please insert a bootable floppy and\r\n"
  "press any key to try again ... \r\n";





struct dir_entry {
  int root;
  int count;
  int entries;
  struct msdos_dir_entry *table;
};



static char *template_boot_code;
static int use_template = 0;
static char *program_name = "mkdosfs";
static char *device_name = ((void *)0);
static int atari_format = 0;
static int check = 0;
static int verbose = 0;
static long volume_id;
static time_t create_time;
static char volume_name[] = "           ";
static int blocks;
static int sector_size = 512;
static int sector_size_set = 0;
static int backup_boot = 0;
static int reserved_sectors = 0;
static int badblocks = 0;
static int nr_fats = 2;
static int size_fat = 0;
static int size_fat_by_user = 0;
static int dev = -1;
static int ignore_full_disk = 0;
static unsigned int currently_testing = 0;
static struct msdos_boot_sector bs;
static int start_data_sector;
static int start_data_block;
static unsigned char *fat;
static unsigned char *info_sector;
static struct msdos_dir_entry *root_dir;
static int size_root_dir;
static int sectors_per_cluster = 0;
static int root_dir_entries = 0;
static int root_dir_num_entries = 0;
static int last_cluster_written = 0;

static char *blank_sector;




static void fatal_error (const char *fmt_string) __attribute__((noreturn));
static void mark_FAT_cluster (int cluster, unsigned int value);
static void mark_FAT_sector (int sector, unsigned int value);
static long do_check (char *buffer, int try, unsigned int current_block);
static void alarm_intr (int alnum);
static void check_blocks (void);
static void get_list_blocks (char *filename);
static int valid_offset (int fd, loff_t offset);
static int count_blocks (char *filename);
static void check_mount (char *device_name);
static void establish_params (int device_num, int size);
static void setup_tables (void);
static void write_tables (void);






static void
fatal_error (const char *fmt_string)
{
  fprintf (stderr, fmt_string, program_name, device_name);
  exit (1);
}




static void
mark_FAT_cluster (int cluster, unsigned int value)
{
  switch( size_fat ) {
    case 12:
      value &= 0x0fff;
      if (((cluster * 3) & 0x1) == 0)
 {
   fat[3 * cluster / 2] = (unsigned char) (value & 0x00ff);
   fat[(3 * cluster / 2) + 1] = (unsigned char) ((fat[(3 * cluster / 2) + 1] & 0x00f0)
       | ((value & 0x0f00) >> 8));
 }
      else
 {
   fat[3 * cluster / 2] = (unsigned char) ((fat[3 * cluster / 2] & 0x000f) | ((value & 0x000f) << 4));
   fat[(3 * cluster / 2) + 1] = (unsigned char) ((value & 0x0ff0) >> 4);
 }
      break;

    case 16:
      value &= 0xffff;
      fat[2 * cluster] = (unsigned char) (value & 0x00ff);
      fat[(2 * cluster) + 1] = (unsigned char) (value >> 8);
      break;

    case 32:
      value &= 0xfffffff;
      fat[4 * cluster] = (unsigned char) (value & 0x000000ff);
      fat[(4 * cluster) + 1] = (unsigned char) ((value & 0x0000ff00) >> 8);
      fat[(4 * cluster) + 2] = (unsigned char) ((value & 0x00ff0000) >> 16);
      fat[(4 * cluster) + 3] = (unsigned char) ((value & 0xff000000) >> 24);
      break;

    default:
      fatal_error( "%s: " "Bad FAT size (not 12, 16, or 32)" "\n" );
  }
}



static void
mark_FAT_sector (int sector, unsigned int value)
{
  int cluster;

  cluster = (sector - start_data_sector) / (int) (bs.cluster_size) /
     (sector_size/512);
  if (cluster < 0)
    fatal_error( "%s: " "Invalid cluster number in mark_FAT_sector: probably bug!" "\n" );

  mark_FAT_cluster (cluster, value);
}




static long
do_check (char *buffer, int try, unsigned int current_block)
{
  long got;

  if (llseek (dev, (loff_t)current_block * (1<<10), 0)
      != (loff_t)current_block * (1<<10))
    fatal_error( "%s: " "seek failed during testing for blocks" "\n" );

  got = read (dev, buffer, try * (1<<10));
  if (got < 0)
    got = 0;

  if (got & ((1<<10) - 1))
    printf ("Unexpected values in do_check: probably bugs\n");
  got /= (1<<10);

  return got;
}





static void
alarm_intr (int alnum)
{
  if (currently_testing >= blocks)
    return;

  signal (14, alarm_intr);
  alarm (5);
  if (!currently_testing)
    return;

  printf ("%d... ", currently_testing);
  fflush (stdout);
}


static void
check_blocks (void)
{
  int try, got;
  int i;
  static char blkbuf[(1<<10) * 16];

  if (verbose)
    {
      printf ("Searching for bad blocks ");
      fflush (stdout);
    }
  currently_testing = 0;
  if (verbose)
    {
      signal (14, alarm_intr);
      alarm (5);
    }
  try = 16;
  while (currently_testing < blocks)
    {
      if (currently_testing + try > blocks)
 try = blocks - currently_testing;
      got = do_check (blkbuf, try, currently_testing);
      currently_testing += got;
      if (got == try)
 {
   try = 16;
   continue;
 }
      else
 try = 1;
      if (currently_testing < start_data_block)
 fatal_error( "%s: " "bad blocks before data-area: cannot make fs" "\n" );

      for (i = 0; i < ( (1<<10) / 512 ); i++)
 mark_FAT_sector( currently_testing * ( (1<<10) / 512 ) + i, 0x0ffffff7 );
      badblocks++;
      currently_testing++;
    }

  if (verbose)
    printf ("\n");

  if (badblocks)
    printf ("%d bad block%s\n", badblocks,
     (badblocks > 1) ? "s" : "");
}


static void
get_list_blocks (char *filename)
{
  int i;
  FILE *listfile;
  unsigned long blockno;

  listfile = fopen (filename, "r");
  if (listfile == (FILE *) ((void *)0))
    fatal_error( "%s: " "Can't open file of bad blocks" "\n" );

  while (!feof (listfile))
    {
      fscanf (listfile, "%ld\n", &blockno);
      for (i = 0; i < ( (1<<10) / 512 ); i++)
 mark_FAT_sector( blockno * ( (1<<10) / 512 ) + i, 0x0ffffff7 );
      badblocks++;
    }
  fclose (listfile);

  if (badblocks)
    printf ("%d bad block%s\n", badblocks,
     (badblocks > 1) ? "s" : "");
}





static int
valid_offset (int fd, loff_t offset)
{
  char ch;

  if (llseek (fd, offset, 0) < 0)
    return 0;
  if (read (fd, &ch, 1) < 1)
    return 0;
  return 1;
}




static int
count_blocks (char *filename)
{
  loff_t high, low;
  int fd;

  if ((fd = open (filename, 00)) < 0)
    {
      perror (filename);
      exit (1);
    }


  if ((low = llseek(fd, 0, 2)) <= 0) {
      low = 0;
      for (high = 1; valid_offset (fd, high); high *= 2)
   low = high;
      while (low < high - 1) {
   const loff_t mid = (low + high) / 2;
   if (valid_offset (fd, mid))
       low = mid;
   else
       high = mid;
      }
      ++low;
  }

  close (fd);
  return low / (1<<10);
}




static void
check_mount (char *device_name)
{
  FILE *f;
  struct mntent *mnt;

  if ((f = setmntent ("/etc/mtab", "r")) == ((void *)0))
    return;
  while ((mnt = getmntent (f)) != ((void *)0))
    if (__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (device_name) && __builtin_constant_p (mnt->mnt_fsname) && (__
s1_len = strlen (device_name), __s2_len = strlen (mnt->mnt_fsname), (!((size_t)(const void *)((device_name) + 1) - (size_t)(const void *
)(device_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((mnt->mnt_fsname) + 1) - (size_t)(const void *)(mnt->mnt_fsname) == 
1) || __s2_len >= 4)) ? __builtin_strcmp (device_name, mnt->mnt_fsname) : (__builtin_constant_p (device_name) && ((size_t)(const void *)
((device_name) + 1) - (size_t)(const void *)(device_name) == 1) && (__s1_len = strlen (device_name), __s1_len < 4) ? (__builtin_constant
_p (mnt->mnt_fsname) && ((size_t)(const void *)((mnt->mnt_fsname) + 1) - (size_t)(const void *)(mnt->mnt_fsname) == 1) ? __builtin_strcm
p (device_name, mnt->mnt_fsname) : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) (mnt->mnt_
fsname); register int __result = (((__const unsigned char *) (__const char *) (device_name))[0] - __s2[0]); if (__s1_len > 0 && __result
 == 0) { __result = (((__const unsigned char *) (__const char *) (device_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __re
sult = (((__const unsigned char *) (__const char *) (device_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__con
st unsigned char *) (__const char *) (device_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (mnt->mnt_fsname) && ((siz
e_t)(const void *)((mnt->mnt_fsname) + 1) - (size_t)(const void *)(mnt->mnt_fsname) == 1) && (__s2_len = strlen (mnt->mnt_fsname), __s2_
len < 4) ? (__builtin_constant_p (device_name) && ((size_t)(const void *)((device_name) + 1) - (size_t)(const void *)(device_name) == 1)
 ? __builtin_strcmp (device_name, mnt->mnt_fsname) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const 
char *) (device_name); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (mnt->mnt_fsname))[0]; if (__s2_len
 > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) (mnt->mnt_fsname))[1]); if (__s2_len > 1 && _
_result == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) (mnt->mnt_fsname))[2]); if (__s2_len > 2 && __result =
= 0) __result = (__s1[3] - ((__const unsigned char *) (__const char *) (mnt->mnt_fsname))[3]); } } __result; }))) : __builtin_strcmp (de
vice_name, mnt->mnt_fsname)))); }) == 0)
      fatal_error( "%s: " "%s contains a mounted file system." "\n" );
  endmntent (f);
}




static void
establish_params (int device_num,int size)
{
  long loop_size;
  struct hd_geometry geometry;
  struct floppy_struct param;

  if ((0 == device_num) || ((device_num & 0xff00) == 0x0200))

    {
      if (0 == device_num)
 {
   param.size = size/512;
   switch(param.size)
     {
     case 720:
       param.sect = 9 ;
       param.head = 2;
       break;
     case 1440:
       param.sect = 9;
       param.head = 2;
       break;
     case 2400:
       param.sect = 15;
       param.head = 2;
       break;
     case 2880:
       param.sect = 18;
       param.head = 2;
       break;
     case 5760:
       param.sect = 36;
       param.head = 2;
       break;
     default:

       param.sect = 32;
       param.head = 64;
       break;
     }

 }
      else
 {
   if (ioctl (dev, (((2U) << (((0 +8)+8)+14)) | (((2)) << (0 +8)) | (((0x04)) << 0) | ((sizeof(struct floppy_struct)) << ((0 +8)+8))), &
param))
     fatal_error( "%s: " "unable to get diskette geometry for '%s'" "\n" );
 }
      bs.secs_track = (param.sect);
      bs.heads = (param.head);
      switch (param.size)
 {
 case 720:
   bs.media = (char) 0xfd;
   bs.cluster_size = (char) 2;
   bs.dir_entries[0] = (char) 112;
   bs.dir_entries[1] = (char) 0;
   break;

 case 1440:
   bs.media = (char) 0xf9;
   bs.cluster_size = (char) 2;
   bs.dir_entries[0] = (char) 112;
   bs.dir_entries[1] = (char) 0;
   break;

 case 2400:
   bs.media = (char) 0xf9;
   bs.cluster_size = (char)(atari_format ? 2 : 1);
   bs.dir_entries[0] = (char) 224;
   bs.dir_entries[1] = (char) 0;
   break;

 case 5760:
   bs.media = (char) 0xf0;
   bs.cluster_size = (char) 2;
   bs.dir_entries[0] = (char) 224;
   bs.dir_entries[1] = (char) 0;
   break;

 case 2880:
 floppy_default:
   bs.media = (char) 0xf0;
   bs.cluster_size = (char)(atari_format ? 2 : 1);
   bs.dir_entries[0] = (char) 224;
   bs.dir_entries[1] = (char) 0;
   break;

 default:
   if (0 == device_num)
       goto def_hd_params;
   else
       goto floppy_default;
 }
    }
  else if ((device_num & 0xff00) == 0x0700)
    {

      if (ioctl (dev, (((0U) << (((0 +8)+8)+14)) | (((0x12)) << (0 +8)) | (((96)) << 0) | ((0) << ((0 +8)+8))), &loop_size))
 fatal_error( "%s: " "unable to get loop geometry for '%s'" "\n" );
      loop_size = loop_size >> 1;

      switch (loop_size)
 {
 case 720:
   bs.secs_track = (9);
   bs.heads = (2);
   bs.media = (char) 0xfd;
   bs.cluster_size = (char) 2;
   bs.dir_entries[0] = (char) 112;
   bs.dir_entries[1] = (char) 0;
   break;

 case 1440:
   bs.secs_track = (9);
   bs.heads = (2);
   bs.media = (char) 0xf9;
   bs.cluster_size = (char) 2;
   bs.dir_entries[0] = (char) 112;
   bs.dir_entries[1] = (char) 0;
   break;

 case 2400:
   bs.secs_track = (15);
   bs.heads = (2);
   bs.media = (char) 0xf9;
   bs.cluster_size = (char)(atari_format ? 2 : 1);
   bs.dir_entries[0] = (char) 224;
   bs.dir_entries[1] = (char) 0;
   break;

 case 5760:
   bs.secs_track = (36);
   bs.heads = (2);
   bs.media = (char) 0xf0;
   bs.cluster_size = (char) 2;
   bs.dir_entries[0] = (char) 224;
   bs.dir_entries[1] = (char) 0;
   break;

 case 2880:
   bs.secs_track = (18);
   bs.heads = (2);
   bs.media = (char) 0xf0;
   bs.cluster_size = (char)(atari_format ? 2 : 1);
   bs.dir_entries[0] = (char) 224;
   bs.dir_entries[1] = (char) 0;
   break;

 default:
   printf("Loop device does not match a floppy size, using "
   "default hd params\n");
   bs.secs_track = (32);
   bs.heads = (64);
   goto def_hd_params;
 }
    }
  else

    {


      if (ioctl (dev, 0x0301, &geometry))
 fatal_error( "%s: " "unable to get drive geometry for '%s'" "\n" );
      bs.secs_track = (geometry.sectors);
      bs.heads = (geometry.heads);
    def_hd_params:
      bs.media = (char) 0xf8;
      bs.dir_entries[0] = (char) 0;
      bs.dir_entries[1] = (char) 2;
      if (size_fat == 32) {






   unsigned long sz_mb =
       (blocks+(1<<(20-10))-1) >> (20-10);
   bs.cluster_size = sz_mb >= 16*1024 ? 32 :
       sz_mb >= 8*1024 ? 16 :
       sz_mb >= 256 ? 8 :
             1;
      }
      else {

   bs.cluster_size = (char) 4;
      }
    }
}




static void
setup_tables (void)
{
  unsigned num_sectors;
  unsigned cluster_count = 0, fat_length;
  unsigned fatdata;
  struct tm *ctime;
  struct msdos_volume_info *vi = (size_fat == 32 ? &bs.fstype._fat32.vi : &bs.fstype._oldfat.vi);

  if (atari_format)



    __builtin_strncpy (bs.system_id-1, "mkdosf", 6);
  else
    strcpy (bs.system_id, "mkdosfs");
  if (sectors_per_cluster)
    bs.cluster_size = (char) sectors_per_cluster;
  if (size_fat == 32)
    {


      bs.dir_entries[0] = bs.dir_entries[1] = (char) 0;
      root_dir_entries = 0;
    }
  else if (root_dir_entries)
    {

      bs.dir_entries[0] = (char) (root_dir_entries & 0x00ff);
      bs.dir_entries[1] = (char) ((root_dir_entries & 0xff00) >> 8);
    }
  else
    root_dir_entries = bs.dir_entries[0] + (bs.dir_entries[1] << 8);

  if (atari_format) {
    bs.system_id[5] = (unsigned char) (volume_id & 0x000000ff);
    bs.system_id[6] = (unsigned char) ((volume_id & 0x0000ff00) >> 8);
    bs.system_id[7] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
  }
  else {
    vi->volume_id[0] = (unsigned char) (volume_id & 0x000000ff);
    vi->volume_id[1] = (unsigned char) ((volume_id & 0x0000ff00) >> 8);
    vi->volume_id[2] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
    vi->volume_id[3] = (unsigned char) (volume_id >> 24);
  }
  if (bs.media == 0xf8) {
      vi->drive_number = 0x80;
  }
  else {
      vi->drive_number = 0x00;
  }

  if (!atari_format) {
    memcpy(vi->volume_label, volume_name, 11);

    memcpy(bs.boot_jump, dummy_boot_jump, 3);

    bs.boot_jump[1] = ((size_fat == 32 ?
   (char *)&bs.fstype._fat32.boot_code :
   (char *)&bs.fstype._oldfat.boot_code) -
         (char *)&bs) - 2;

    if (size_fat == 32) {
 int offset = (char *)&bs.fstype._fat32.boot_code -
       (char *)&bs + 29 + 0x7c00;
 if (dummy_boot_code[420 -1])
   printf ("Warning: message too long; truncated\n");
 dummy_boot_code[420 -1] = 0;
 memcpy(bs.fstype._fat32.boot_code, dummy_boot_code, 420);
 bs.fstype._fat32.boot_code[3] = offset & 0xff;
 bs.fstype._fat32.boot_code[3 +1] = offset >> 8;
    }
    else {
 memcpy(bs.fstype._oldfat.boot_code, dummy_boot_code, 448);
    }
    bs.boot_sign = (0xAA55);
  }
  else {
    memcpy(bs.boot_jump, dummy_boot_jump_m68k, 2);
  }
  if (verbose >= 2)
    printf( "Boot jump code is %02x %02x\n",
     bs.boot_jump[0], bs.boot_jump[1] );

  if (!reserved_sectors)
      reserved_sectors = (size_fat == 32) ? 32 : 1;
  else {
      if (size_fat == 32 && reserved_sectors < 2)
   fatal_error( "%s: " "On FAT32 at least 2 reserved sectors are needed." "\n" );
  }
  bs.reserved = (reserved_sectors);
  if (verbose >= 2)
    printf( "Using %d reserved sectors\n", reserved_sectors );
  bs.fats = (char) nr_fats;
  if (!atari_format || size_fat == 32)
    bs.hidden = bs.secs_track;
  else

    memset( &bs.hidden, 0, 2 );

  num_sectors = (long long)blocks*(1<<10)/sector_size;
  if (!atari_format) {
    unsigned fatlength12, fatlength16, fatlength32;
    unsigned maxclust12, maxclust16, maxclust32;
    unsigned clust12, clust16, clust32;
    int maxclustsize;

    fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) -
       reserved_sectors;

    if (sectors_per_cluster)
      bs.cluster_size = maxclustsize = sectors_per_cluster;
    else

      maxclustsize = 128;

    if (verbose >= 2)
      printf( "%d sectors for FAT+data, starting with %d sectors/cluster\n",
       fatdata, bs.cluster_size );
    do {
      if (verbose >= 2)
 printf( "Trying with %d sectors/cluster:\n", bs.cluster_size );



      clust12 = 2*((long long) fatdata *sector_size + nr_fats*3) /
 (2*(int) bs.cluster_size * sector_size + nr_fats*3);
      fatlength12 = cdiv (((clust12+2) * 3 + 1) >> 1, sector_size);



      clust12 = (fatdata - nr_fats*fatlength12)/bs.cluster_size;
      maxclust12 = (fatlength12 * 2 * sector_size) / 3;
      if (maxclust12 > ((1 << 12) - 16))
 maxclust12 = ((1 << 12) - 16);
      if (verbose >= 2)
 printf( "FAT12: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
  clust12, fatlength12, maxclust12, ((1 << 12) - 16) );
      if (clust12 > maxclust12-2) {
 clust12 = 0;
 if (verbose >= 2)
   printf( "FAT12: too much clusters\n" );
      }

      clust16 = ((long long) fatdata *sector_size + nr_fats*4) /
 ((int) bs.cluster_size * sector_size + nr_fats*2);
      fatlength16 = cdiv ((clust16+2) * 2, sector_size);



      clust16 = (fatdata - nr_fats*fatlength16)/bs.cluster_size;
      maxclust16 = (fatlength16 * sector_size) / 2;
      if (maxclust16 > ((1 << 16) - 16))
 maxclust16 = ((1 << 16) - 16);
      if (verbose >= 2)
 printf( "FAT16: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
  clust16, fatlength16, maxclust16, ((1 << 16) - 16) );
      if (clust16 > maxclust16-2) {
 if (verbose >= 2)
   printf( "FAT16: too much clusters\n" );
 clust16 = 0;
      }


      if (clust16 < 4078 && !(size_fat_by_user && size_fat == 16)) {
 if (verbose >= 2)
   printf( clust16 < 4078 ?
    "FAT16: would be misdetected as FAT12\n" :
    "FAT16: too much clusters\n" );
 clust16 = 0;
      }

      clust32 = ((long long) fatdata *sector_size + nr_fats*8) /
 ((int) bs.cluster_size * sector_size + nr_fats*4);
      fatlength32 = cdiv ((clust32+2) * 4, sector_size);



      clust32 = (fatdata - nr_fats*fatlength32)/bs.cluster_size;
      maxclust32 = (fatlength32 * sector_size) / 4;
      if (maxclust32 > ((1 << 28) - 16))
 maxclust32 = ((1 << 28) - 16);
      if (verbose >= 2)
 printf( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
  clust32, fatlength32, maxclust32, ((1 << 28) - 16) );
      if (clust32 > maxclust32) {
 clust32 = 0;
 if (verbose >= 2)
   printf( "FAT32: too much clusters\n" );
      }

      if ((clust12 && (size_fat == 0 || size_fat == 12)) ||
   (clust16 && (size_fat == 0 || size_fat == 16)) ||
   (clust32 && size_fat == 32))
 break;

      bs.cluster_size <<= 1;
    } while (bs.cluster_size && bs.cluster_size <= maxclustsize);



    if (!size_fat) {
 size_fat = (clust16 > clust12) ? 16 : 12;
 if (verbose >= 2)
   printf( "Choosing %d bits for FAT\n", size_fat );
    }

    switch (size_fat) {
      case 12:
 cluster_count = clust12;
 fat_length = fatlength12;
 bs.fat_length = (fatlength12);
 memcpy(vi->fs_type, "FAT12   ", 8);
 break;

      case 16:
 if (clust16 < 4078) {
     if (size_fat_by_user) {
  fprintf( stderr, "WARNING: Not enough clusters for a "
    "16 bit FAT! The filesystem will be\n"
    "misinterpreted as having a 12 bit FAT without "
    "mount option \"fat=16\".\n" );
     }
     else {
  fprintf( stderr, "This filesystem has an unfortunate size. "
    "A 12 bit FAT cannot provide\n"
    "enough clusters, but a 16 bit FAT takes up a little "
    "bit more space so that\n"
    "the total number of clusters becomes less than the "
    "threshold value for\n"
    "distinction between 12 and 16 bit FATs.\n" );
  fatal_error( "%s: " "Make the file system a bit smaller manually." "\n" );
     }
 }
 cluster_count = clust16;
 fat_length = fatlength16;
 bs.fat_length = (fatlength16);
 memcpy(vi->fs_type, "FAT16   ", 8);
 break;

      case 32:
 cluster_count = clust32;
 fat_length = fatlength32;
 bs.fat_length = (0);
 bs.fstype._fat32.fat32_length = (fatlength32);
 memcpy(vi->fs_type, "FAT32   ", 8);
 break;

      default:
 fatal_error( "%s: " "FAT not 12, 16 or 32 bits" "\n" );
    }
  }
  else {
    unsigned clusters, maxclust;






    if (!size_fat)
      size_fat = (num_sectors == 1440 || num_sectors == 2400 ||
    num_sectors == 2880 || num_sectors == 5760) ? 12 : 16;
    if (verbose >= 2)
      printf( "Choosing %d bits for FAT\n", size_fat );





    bs.cluster_size = sectors_per_cluster ? sectors_per_cluster : 2;
    if (!sector_size_set) {
      while( num_sectors > 65531 ) {
 num_sectors >>= 1;
 sector_size <<= 1;
      }
    }
    if (verbose >= 2)
      printf( "Sector size must be %d to have less than %d log. sectors\n",
       sector_size, 65531 );


    do {
      fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) -
  reserved_sectors;




      clusters = (2*((long long)fatdata*sector_size - 2*nr_fats*size_fat/8)) /
   (2*((int)bs.cluster_size*sector_size + nr_fats*size_fat/8));
      fat_length = cdiv( (clusters+2)*size_fat/8, sector_size );



      clusters = (fatdata - nr_fats*fat_length)/bs.cluster_size;
      maxclust = (fat_length*sector_size*8)/size_fat;
      if (verbose >= 2)
 printf( "ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n",
  sector_size, clusters, fat_length, maxclust );



      if (maxclust <= (size_fat == 32 ? ((1 << 28) - 16) : (1<<size_fat)-0x10) &&
   clusters <= maxclust-2)
 break;
      if (verbose >= 2)
 printf( clusters > maxclust-2 ?
  "Too many clusters\n" : "FAT too big\n" );


      if (sector_size_set)
   fatal_error( "%s: " "With this sector size, the maximum number of FAT entries " "would be exceeded." "\n" );

      num_sectors >>= 1;
      sector_size <<= 1;
    } while( sector_size <= (16*1024) );

    if (sector_size > (16*1024))
      fatal_error( "%s: " "Would need a sector size > 16k, which GEMDOS can't work with" "\n" );

    cluster_count = clusters;
    if (size_fat != 32)
 bs.fat_length = (fat_length);
    else {
 bs.fat_length = 0;
 bs.fstype._fat32.fat32_length = (fat_length);
    }
  }

  bs.sector_size[0] = (char) (sector_size & 0x00ff);
  bs.sector_size[1] = (char) ((sector_size & 0xff00) >> 8);

  if (size_fat == 32)
    {

      bs.fstype._fat32.flags = (0);
      bs.fstype._fat32.version[0] = 0;
      bs.fstype._fat32.version[1] = 0;
      bs.fstype._fat32.root_cluster = (2);
      bs.fstype._fat32.info_sector = (1);
      if (!backup_boot)
 backup_boot = (reserved_sectors >= 7) ? 6 :
        (reserved_sectors >= 2) ? reserved_sectors-1 : 0;
      else
 {
   if (backup_boot == 1)
     fatal_error( "%s: " "Backup boot sector must be after sector 1" "\n" );
   else if (backup_boot >= reserved_sectors)
     fatal_error( "%s: " "Backup boot sector must be a reserved sector" "\n" );
 }
      if (verbose >= 2)
 printf( "Using sector %d as backup boot sector (0 = none)\n",
  backup_boot );
      bs.fstype._fat32.backup_boot = (backup_boot);
      memset( &bs.fstype._fat32.reserved2, 0, sizeof(bs.fstype._fat32.reserved2) );
    }

  if (atari_format) {

      if (num_sectors >= 65531)
   fatal_error( "%s: " "GEMDOS can't handle more than 65531 sectors" "\n" );
      else if (num_sectors >= 32765)
   printf( "Warning: More than 32765 sector need TOS 1.04 "
    "or higher.\n" );
  }
  if (num_sectors >= 65536)
    {
      bs.sectors[0] = (char) 0;
      bs.sectors[1] = (char) 0;
      bs.total_sect = (num_sectors);
    }
  else
    {
      bs.sectors[0] = (char) (num_sectors & 0x00ff);
      bs.sectors[1] = (char) ((num_sectors & 0xff00) >> 8);
      if (!atari_format)
   bs.total_sect = (0);
    }

  if (!atari_format)
    vi->ext_boot_sign = 0x29;

  if (!cluster_count)
    {
      if (sectors_per_cluster)
 fatal_error( "%s: " "Too many clusters for file system - try more sectors per cluster" "\n" );
      else
 fatal_error( "%s: " "Attempting to create a too large file system" "\n" );
    }



  start_data_sector = (reserved_sectors + nr_fats * fat_length) *
        (sector_size/512);
  start_data_block = (start_data_sector + ( (1<<10) / 512 ) - 1) /
       ( (1<<10) / 512 );

  if (blocks < start_data_block + 32)
    fatal_error( "%s: " "Too few blocks for viable file system" "\n" );

  if (verbose)
    {
      printf("%s has %d head%s and %d sector%s per track,\n",
      device_name, (bs.heads), ((bs.heads) != 1) ? "s" : "",
      (bs.secs_track), ((bs.secs_track) != 1) ? "s" : "");
      printf("logical sector size is %d,\n",sector_size);
      printf("using 0x%02x media descriptor, with %d sectors;\n",
      (int) (bs.media), num_sectors);
      printf("file system has %d %d-bit FAT%s and %d sector%s per cluster.\n",
      (int) (bs.fats), size_fat, (bs.fats != 1) ? "s" : "",
      (int) (bs.cluster_size), (bs.cluster_size != 1) ? "s" : "");
      printf ("FAT size is %d sector%s, and provides %d cluster%s.\n",
       fat_length, (fat_length != 1) ? "s" : "",
       cluster_count, (cluster_count != 1) ? "s" : "");
      if (size_fat != 32)
 printf ("Root directory contains %d slots.\n",
  (int) (bs.dir_entries[0]) + (int) (bs.dir_entries[1]) * 256);
      printf ("Volume ID is %08lx, ", volume_id &
       (atari_format ? 0x00ffffff : 0xffffffff));
      if ( __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (volume_name) && __builtin_constant_p ("           ") && (_
_s1_len = strlen (volume_name), __s2_len = strlen ("           "), (!((size_t)(const void *)((volume_name) + 1) - (size_t)(const void *)
(volume_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("           ") + 1) - (size_t)(const void *)("           ") == 1) ||
 __s2_len >= 4)) ? __builtin_strcmp (volume_name, "           ") : (__builtin_constant_p (volume_name) && ((size_t)(const void *)((volum
e_name) + 1) - (size_t)(const void *)(volume_name) == 1) && (__s1_len = strlen (volume_name), __s1_len < 4) ? (__builtin_constant_p ("  
         ") && ((size_t)(const void *)(("           ") + 1) - (size_t)(const void *)("           ") == 1) ? __builtin_strcmp (volume_nam
e, "           ") : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) ("           "); register
 int __result = (((__const unsigned char *) (__const char *) (volume_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result
 = (((__const unsigned char *) (__const char *) (volume_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const
 unsigned char *) (__const char *) (volume_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char 
*) (__const char *) (volume_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("           ") && ((size_t)(const void *)(
("           ") + 1) - (size_t)(const void *)("           ") == 1) && (__s2_len = strlen ("           "), __s2_len < 4) ? (__builtin_con
stant_p (volume_name) && ((size_t)(const void *)((volume_name) + 1) - (size_t)(const void *)(volume_name) == 1) ? __builtin_strcmp (volu
me_name, "           ") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *) (volume_name); regi
ster int __result = __s1[0] - ((__const unsigned char *) (__const char *) ("           "))[0]; if (__s2_len > 0 && __result == 0) { __re
sult = (__s1[1] - ((__const unsigned char *) (__const char *) ("           "))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s
1[2] - ((__const unsigned char *) (__const char *) ("           "))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__co
nst unsigned char *) (__const char *) ("           "))[3]); } } __result; }))) : __builtin_strcmp (volume_name, "           ")))); }) )
 printf("volume label %s.\n", volume_name);
      else
 printf("no volume label.\n");
    }



  if ((fat = (unsigned char *) malloc (fat_length * sector_size)) == ((void *)0))
    fatal_error( "%s: " "unable to allocate space for FAT image in memory" "\n" );

  memset( fat, 0, fat_length * sector_size );

  mark_FAT_cluster (0, 0xffffffff);
  mark_FAT_cluster (1, 0xffffffff);
  fat[0] = (unsigned char) bs.media;
  if (size_fat == 32) {

    mark_FAT_cluster (2, (atari_format ? 0x0fffffff : 0x0ffffff8));
  }



  size_root_dir = (size_fat == 32) ?
    bs.cluster_size*sector_size :
    (((int)bs.dir_entries[1]*256+(int)bs.dir_entries[0]) *
     sizeof (struct msdos_dir_entry));
  if ((root_dir = (struct msdos_dir_entry *) malloc (size_root_dir)) == ((void *)0))
    {
      free (fat);
      fatal_error( "%s: " "unable to allocate space for root directory in memory" "\n" );
    }


  last_cluster_written = 2;

  memset(root_dir, 0, size_root_dir);
  if ( memcmp(volume_name, "           ", 11) )
    {
      struct msdos_dir_entry *de = &root_dir[0];
      memcpy(de->name, volume_name, 11);
      de->attr = 8;
      ctime = localtime(&create_time);
      de->time = ((unsigned short)((ctime->tm_sec >> 1) + (ctime->tm_min << 5) + (ctime->tm_hour << 11)));

      de->date = ((unsigned short)(ctime->tm_mday + ((ctime->tm_mon+1) << 5) + ((ctime->tm_year-80) << 9)));


      de->ctime_ms = 0;
      de->ctime = de->time;
      de->cdate = de->date;
      de->adate = de->date;
      de->starthi = (0);
      de->start = (0);
      de->size = (0);
    }

  if (size_fat == 32) {

    struct fat32_fsinfo *info;

    if (!(info_sector = malloc( sector_size )))
      fatal_error( "%s: " "Out of memory" "\n" );
    memset(info_sector, 0, sector_size);

    info = (struct fat32_fsinfo *)(info_sector + 0x1e0);


    info_sector[0] = 'R';
    info_sector[1] = 'R';
    info_sector[2] = 'a';
    info_sector[3] = 'A';


    info->signature = (0x61417272);

    info->free_clusters = (cluster_count - 1);
    info->next_cluster = (2);


    *(__u16 *)(info_sector + 0x1fe) = (0xAA55);
  }

  if (!(blank_sector = malloc( sector_size )))
    fatal_error( "%s: " "Out of memory" "\n" );

  memset(blank_sector, 0, sector_size);
}
# 1384 "mkdosfs.c"
static void
write_tables (void)
{
  int x;
  int fat_length;

  fat_length = (size_fat == 32) ?
        (bs.fstype._fat32.fat32_length) : (bs.fat_length);

  do { loff_t __pos = (0); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_dir); f
atal_error( "%s: " "seek to " "start of device" " failed whilst writing tables" "\n" ); } while(0); } while(0);

  for( x = 0; x < reserved_sectors; ++x )
    do { int __size = (sector_size); if (write (dev, blank_sector, __size) != __size) do { free (fat); if (info_sector) free (info_secto
r); free (root_dir); fatal_error( "%s: " "failed whilst writing " "reserved sector" "\n" ); } while(0); } while(0);

  do { loff_t __pos = (0); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_dir); f
atal_error( "%s: " "seek to " "boot sector" " failed whilst writing tables" "\n" ); } while(0); } while(0);
  do { int __size = (sizeof (struct msdos_boot_sector)); if (write (dev, (char *) &bs, __size) != __size) do { free (fat); if (info_sect
or) free (info_sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "boot sector" "\n" ); } while(0); } while(0);

  if (size_fat == 32)
    {
      do { loff_t __pos = ((bs.fstype._fat32.info_sector)*sector_size); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_s
ector) free (info_sector); free (root_dir); fatal_error( "%s: " "seek to " "info sector" " failed whilst writing tables" "\n" ); } while
(0); } while(0);
      do { int __size = (512); if (write (dev, info_sector, __size) != __size) do { free (fat); if (info_sector) free (info_sector); fre
e (root_dir); fatal_error( "%s: " "failed whilst writing " "info sector" "\n" ); } while(0); } while(0);
      if (backup_boot != 0)
 {
   do { loff_t __pos = (backup_boot*sector_size); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sect
or); free (root_dir); fatal_error( "%s: " "seek to " "backup boot sector" " failed whilst writing tables" "\n" ); } while(0); } while(0)
;
   do { int __size = (sizeof (struct msdos_boot_sector)); if (write (dev, (char *) &bs, __size) != __size) do { free (fat); if (info_sec
tor) free (info_sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "backup boot sector" "\n" ); } while(0); } while(
0);

 }
    }

  do { loff_t __pos = (reserved_sectors*sector_size); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_
sector); free (root_dir); fatal_error( "%s: " "seek to " "first FAT" " failed whilst writing tables" "\n" ); } while(0); } while(0);
  for (x = 1; x <= nr_fats; x++)
    do { int __size = (fat_length * sector_size); if (write (dev, fat, __size) != __size) do { free (fat); if (info_sector) free (info_s
ector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "FAT" "\n" ); } while(0); } while(0);


  do { int __size = (size_root_dir); if (write (dev, (char *) root_dir, __size) != __size) do { free (fat); if (info_sector) free (info_
sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "root directory" "\n" ); } while(0); } while(0);

  if (use_template == 1) {

    do { loff_t __pos = (0); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_dir);
 fatal_error( "%s: " "seek to " "Start of partition" " failed whilst writing tables" "\n" ); } while(0); } while(0);
    if (size_fat == 32) {
      do { int __size = (3); if (write (dev, template_boot_code, __size) != __size) do { free (fat); if (info_sector) free (info_sector)
; free (root_dir); fatal_error( "%s: " "failed whilst writing " "backup jmpBoot" "\n" ); } while(0); } while(0);
      do { loff_t __pos = (0x5a); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_
dir); fatal_error( "%s: " "seek to " "sector 1 boot area" " failed whilst writing tables" "\n" ); } while(0); } while(0);
      do { int __size = (420); if (write (dev, template_boot_code+0x5a, __size) != __size) do { free (fat); if (info_sector) free (info_
sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "sector 1 boot area" "\n" ); } while(0); } while(0);
      do { loff_t __pos = (512*2); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root
_dir); fatal_error( "%s: " "seek to " "third sector" " failed whilst writing tables" "\n" ); } while(0); } while(0);
      if (backup_boot != 0) {
        do { int __size = (backup_boot*sector_size - 512*2); if (write (dev, template_boot_code+512*2, __size) != __size) do { free (fat
); if (info_sector) free (info_sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "data to backup boot" "\n" ); } wh
ile(0); } while(0);
 do { loff_t __pos = (backup_boot*sector_size); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector
); free (root_dir); fatal_error( "%s: " "seek to " "backup boot sector" " failed whilst writing tables" "\n" ); } while(0); } while(0);
        do { int __size = (3); if (write (dev, template_boot_code, __size) != __size) do { free (fat); if (info_sector) free (info_secto
r); free (root_dir); fatal_error( "%s: " "failed whilst writing " "backup jmpBoot" "\n" ); } while(0); } while(0);
 do { loff_t __pos = (backup_boot*sector_size+0x5a); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_s
ector); free (root_dir); fatal_error( "%s: " "seek to " "backup boot sector boot area" " failed whilst writing tables" "\n" ); } while(0
); } while(0);
        do { int __size = (420); if (write (dev, template_boot_code+0x5a, __size) != __size) do { free (fat); if (info_sector) free (inf
o_sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "backup boot sector boot area" "\n" ); } while(0); } while(0);
        do { loff_t __pos = ((backup_boot+2)*sector_size); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (
info_sector); free (root_dir); fatal_error( "%s: " "seek to " "sector following backup code" " failed whilst writing tables" "\n" ); } w
hile(0); } while(0);
        do { int __size = ((reserved_sectors-backup_boot-2)*512); if (write (dev, template_boot_code+(backup_boot+2)*sector_size, __size
) != __size) do { free (fat); if (info_sector) free (info_sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "remain
ing data" "\n" ); } while(0); } while(0);
      } else {
        do { int __size = ((reserved_sectors-2)*512); if (write (dev, template_boot_code+512*2, __size) != __size) do { free (fat); if (
info_sector) free (info_sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "remaining data" "\n" ); } while(0); } wh
ile(0);
      }
    } else {
      do { int __size = (3); if (write (dev, template_boot_code, __size) != __size) do { free (fat); if (info_sector) free (info_sector)
; free (root_dir); fatal_error( "%s: " "failed whilst writing " "jmpBoot" "\n" ); } while(0); } while(0);
      do { loff_t __pos = (0x3e); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_
dir); fatal_error( "%s: " "seek to " "sector 1 boot area" " failed whilst writing tables" "\n" ); } while(0); } while(0);
      do { int __size = (448); if (write (dev, template_boot_code+0x3e, __size) != __size) do { free (fat); if (info_sector) free (info_
sector); free (root_dir); fatal_error( "%s: " "failed whilst writing " "boot code" "\n" ); } while(0); } while(0);
    }
  }

  if (info_sector) free( info_sector );
  free (root_dir);
  free (fat);
}



static void copy_filename(char *filename, char *base, char *ext) {

  char *ch = filename;
  int i, len;

  memset(base, 0x20, 8);
  memset(ext, 0x20, 3);

  for(len = 0 ; *ch && *ch != '.'; ch++) {
    base[len++] = toupper(*ch);
    if (len == 8) break;
  }

  for ( ; *ch && *ch != '.'; ch++);
  if (*ch) ch++;

  for(len = 0 ; *ch; ch++) {
    ext[len++] = toupper(*ch);
    if (len == 3) break;
  }
}
# 1490 "mkdosfs.c"
unsigned char check_attrib_file(char *dir, char *filename) {

  char attrib[4] = { '-', '-', '-' };
  unsigned char *buffer = 0;
  int ret = 0;
  int fd = -1;

  buffer = (char *) calloc(1, strlen(dir) + strlen(filename) + 10);
  if (!buffer) return 0;

  sprintf(buffer, "%s/.attrib.%s", dir, filename);

  if (access(buffer, 4))
    goto exit_attrib;

  if ((fd = open(buffer, 00, 0)) < 0)
    goto exit_attrib;

  if (read(fd, attrib, 3) < 0)
    goto exit_attrib;

  if (attrib[0] == 'H') ret |= 2;
  if (attrib[1] == 'S') ret |= 4;
  if (attrib[2] == 'A') ret |= 32;

  printf("%s: Setting atrribute %x\n", filename, ret);

 exit_attrib:
  if (fd >= 0) close(fd);
  if (buffer) free(buffer);

  return ret;
}

static void copy_name(char *buffer, int size, char **pointer) {
  int i;

  for(i = 0; i < size; i += 2) {
    if (*pointer) {
      buffer[i] = **pointer;
      buffer[i + 1] = 0x00;
      *pointer = **pointer ? *pointer + 1 : 0;
    }
    else {
      buffer[i] = 0xFF;
      buffer[i + 1] = 0xFF;
    }
  }
}

static int add_file(char *filename, struct dir_entry *dir, unsigned char attr)
{
  struct stat stat;
  struct msdos_dir_entry *entry;
  int infile = 0;
  int sectors, clusters;
  struct tm *ctime;
  int c, s;
  int ptr;
  char *buffer, *base;
  int start;
  int usedsec, totalsec;

  char name83[8], ext83[3];

  struct msdos_dir_slot *slot;
  int i;
  char *p;



  if (dir->root) {
    if (dir->count == dir->entries) {
      printf("Error - too many directory entries\n");
    }
  }
  else {
    if (dir->count == dir->entries) {
      if (!dir->table)
 dir->table =
   (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
      else {
 dir->table =
   (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
          sizeof(struct msdos_dir_entry));

 memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
      }

      dir->entries++;
    }
  }

  infile = open(filename, 00, 0);
  if (!infile) return;

  if (fstat(infile, &stat))
    goto exit_add;

  if (((((stat.st_mode)) & 0170000) == (0020000)) ||((((stat.st_mode)) & 0170000) == (0060000)) ||
      ((((stat.st_mode)) & 0170000) == (0010000)) || ((((stat.st_mode)) & 0170000) == (0120000))) {
    printf("Error - cannot create a special file in a FATFS\n");
    goto exit_add;
  }



  usedsec = start_data_sector + (size_root_dir / sector_size) +
    (last_cluster_written * bs.cluster_size);

  totalsec = blocks * (1<<10) / sector_size;



  sectors = (stat.st_size + (sector_size - (stat.st_size % sector_size))) / sector_size;
  clusters = (sectors + ((int) bs.cluster_size - (sectors % (int) bs.cluster_size))) / (int) bs.cluster_size;

  if (usedsec + sectors > totalsec) {
    printf("Error - %s is too big (%d vs %d)\n", filename, sectors, totalsec - usedsec);
    close(infile);
    return -1;
  }

  printf("ADD %s\n", filename);


  base = __xpg_basename(filename);


  copy_filename(base, name83, ext83);



  slot = (struct msdos_dir_slot *) &dir->table[dir->count++];
  slot->id = 'A';
  slot->attr = 0x0F;
  slot->reserved = 0;
  slot->start = 0;

  slot->alias_checksum = 0;

  for(i = 0; i < 8; i++)
    slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + name83[i];

  for(i = 0; i < 3; i++)
    slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + ext83[i];

  p = base;

  copy_name(slot->name0_4, 10, &p);
  copy_name(slot->name5_10, 12, &p);
  copy_name(slot->name11_12, 4, &p);



  entry = &dir->table[dir->count++];

  __builtin_strncpy (entry->name, name83, 8);
  __builtin_strncpy (entry->ext, ext83, 3);





  if (!(stat.st_mode & 0200)) attr |= 1;
  entry->attr = attr;


  ctime = localtime(&create_time);

  entry->time = ((unsigned short)((ctime->tm_sec >> 1) + (ctime->tm_min << 5) + (ctime->tm_hour << 11)));


  entry->date = ((unsigned short)(ctime->tm_mday + ((ctime->tm_mon+1) << 5) + ((ctime->tm_year-80) << 9)));



  entry->ctime_ms = 0;
  entry->ctime = entry->time;
  entry->cdate = entry->date;
  entry->adate = entry->date;
  entry->size = stat.st_size;

  start = last_cluster_written;

  entry->start = (start);
  entry->starthi = ((start & 0xFFFF0000) >> 16);



  for(c = 0; c < clusters; c++ ) {
    int free;
    int next = c == (clusters - 1) ? (atari_format ? 0x0fffffff : 0x0ffffff8) : start + c + 1;
    mark_FAT_cluster(start + c, next);
    last_cluster_written++;
  }




  ptr = (start_data_sector * sector_size) + size_root_dir;
  ptr += (start - 2) * bs.cluster_size * sector_size;

  buffer = (char *) malloc(sector_size);

  if (!buffer) {
    printf("Error - couldn't allocate memory\n");
    goto exit_add;
  }



  do { loff_t __pos = (ptr); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_dir);
 fatal_error( "%s: " "seek to " "datafile" " failed whilst writing tables" "\n" ); } while(0); } while(0);

  while(1) {
    int size = read(infile, buffer, sector_size);
    if (size <= 0) break;

    do { int __size = (size); if (write (dev, buffer, __size) != __size) do { free (fat); if (info_sector) free (info_sector); free (roo
t_dir); fatal_error( "%s: " "failed whilst writing " "data" "\n" ); } while(0); } while(0);
  }

 exit_add:
  if (infile) close(infile);
}






static void add_directory(char *filename, struct dir_entry *dir) {

  struct dir_entry *newdir = 0;
  struct msdos_dir_entry *entry;
  struct tm *ctime;
  DIR *rddir = opendir(filename);
  struct dirent *dentry = 0;
  int remain;
  char *data;


  if (!rddir) return;

  if (dir->root) {
    if (dir->count == dir->entries) {
      printf("Error - too many directory entries\n");
      goto exit_add_dir;
    }
  }
  else {
    if (dir->count == dir->entries) {
      if (!dir->table)
 dir->table = (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
      else {
 dir->table = (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
       sizeof(struct msdos_dir_entry));


 memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
      }
 dir->entries++;
    }
  }


  newdir = (struct dir_entry *) calloc(1, sizeof(struct dir_entry));
  if (!newdir) goto exit_add_dir;

  entry = &dir->table[dir->count++];

  __builtin_strncpy (entry->name, __xpg_basename(filename), sizeof(entry->name));

  entry->attr = 16;
  ctime = localtime(&create_time);

  entry->time = ((unsigned short)((ctime->tm_sec >> 1) + (ctime->tm_min << 5) + (ctime->tm_hour << 11)));


  entry->date = ((unsigned short)(ctime->tm_mday + ((ctime->tm_mon+1) << 5) + ((ctime->tm_year-80) << 9)));



  entry->ctime_ms = 0;
  entry->ctime = entry->time;
  entry->cdate = entry->date;
  entry->adate = entry->date;



  while((dentry = readdir(rddir))) {
    struct stat st;
    char *buffer;

    if (!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (dentry->d_name) && __builtin_constant_p (".") && (__s1_len =
 strlen (dentry->d_name), __s2_len = strlen ("."), (!((size_t)(const void *)((dentry->d_name) + 1) - (size_t)(const void *)(dentry->d_na
me) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) || __s2_len >= 4)) ? __builtin_s
trcmp (dentry->d_name, ".") : (__builtin_constant_p (dentry->d_name) && ((size_t)(const void *)((dentry->d_name) + 1) - (size_t)(const v
oid *)(dentry->d_name) == 1) && (__s1_len = strlen (dentry->d_name), __s1_len < 4) ? (__builtin_constant_p (".") && ((size_t)(const void
 *)((".") + 1) - (size_t)(const void *)(".") == 1) ? __builtin_strcmp (dentry->d_name, ".") : (__extension__ ({ __const unsigned char *_
_s2 = (__const unsigned char *) (__const char *) ("."); register int __result = (((__const unsigned char *) (__const char *) (dentry->d_
name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (dentry->d_name))[1] 
- __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (dentry->d_name))[2] - __s2[2])
; if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (dentry->d_name))[3] - __s2[3]); } } __resu
lt; }))) : (__builtin_constant_p (".") && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) && (__s2_len = strlen (
"."), __s2_len < 4) ? (__builtin_constant_p (dentry->d_name) && ((size_t)(const void *)((dentry->d_name) + 1) - (size_t)(const void *)(d
entry->d_name) == 1) ? __builtin_strcmp (dentry->d_name, ".") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *
) (__const char *) (dentry->d_name); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) ("."))[0]; if (__s2_l
en > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) ("."))[1]); if (__s2_len > 1 && __result ==
 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) ("."))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[
3] - ((__const unsigned char *) (__const char *) ("."))[3]); } } __result; }))) : __builtin_strcmp (dentry->d_name, ".")))); }) || !__ex
tension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (dentry->d_name) && __builtin_constant_p ("..") && (__s1_len = strlen (den
try->d_name), __s2_len = strlen (".."), (!((size_t)(const void *)((dentry->d_name) + 1) - (size_t)(const void *)(dentry->d_name) == 1) |
| __s1_len >= 4) && (!((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) || __s2_len >= 4)) ? __builtin_strcmp (de
ntry->d_name, "..") : (__builtin_constant_p (dentry->d_name) && ((size_t)(const void *)((dentry->d_name) + 1) - (size_t)(const void *)(d
entry->d_name) == 1) && (__s1_len = strlen (dentry->d_name), __s1_len < 4) ? (__builtin_constant_p ("..") && ((size_t)(const void *)((".
.") + 1) - (size_t)(const void *)("..") == 1) ? __builtin_strcmp (dentry->d_name, "..") : (__extension__ ({ __const unsigned char *__s2 
= (__const unsigned char *) (__const char *) (".."); register int __result = (((__const unsigned char *) (__const char *) (dentry->d_nam
e))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (dentry->d_name))[1] - _
_s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (dentry->d_name))[2] - __s2[2]); i
f (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (dentry->d_name))[3] - __s2[3]); } } __result;
 }))) : (__builtin_constant_p ("..") && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) && (__s2_len = strlen (
".."), __s2_len < 4) ? (__builtin_constant_p (dentry->d_name) && ((size_t)(const void *)((dentry->d_name) + 1) - (size_t)(const void *)(
dentry->d_name) == 1) ? __builtin_strcmp (dentry->d_name, "..") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char
 *) (__const char *) (dentry->d_name); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (".."))[0]; if (__s
2_len > 0 && __result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) (".."))[1]); if (__s2_len > 1 && __resul
t == 0) { __result = (__s1[2] - ((__const unsigned char *) (__const char *) (".."))[2]); if (__s2_len > 2 && __result == 0) __result = (
__s1[3] - ((__const unsigned char *) (__const char *) (".."))[3]); } } __result; }))) : __builtin_strcmp (dentry->d_name, "..")))); }))
      continue;


    if (dentry->d_name[0] == '.') continue;

    buffer = malloc(strlen(filename) + strlen(dentry->d_name) + 3);
    if (!buffer) continue;

    sprintf(buffer, "%s/%s", filename, dentry->d_name);
    if (!stat(buffer, &st)) {
      if (((((st.st_mode)) & 0170000) == (0040000)))
 add_directory(buffer, newdir);
      else if (((((st.st_mode)) & 0170000) == (0100000))) {
 unsigned char attrib = check_attrib_file(filename, dentry->d_name);
 add_file(buffer, newdir, attrib);
      }
    }

    free(buffer);
  }




  entry->start = (last_cluster_written);
  entry->starthi = ((last_cluster_written & 0xFFFF0000) >> 16);
  entry->size = newdir->count * sizeof(struct msdos_dir_entry);

  remain = entry->size;
  data = (char *) newdir->table;

  while(remain) {
    int size =
      remain > bs.cluster_size * sector_size ? bs.cluster_size * sector_size : remain;

    int pos = (start_data_sector * sector_size) + size_root_dir;
    pos += (last_cluster_written - 2) * bs.cluster_size * sector_size;

    do { loff_t __pos = (pos); if (llseek (dev, __pos, 0) != __pos) do { free (fat); if (info_sector) free (info_sector); free (root_dir
); fatal_error( "%s: " "seek to " "add_dir" " failed whilst writing tables" "\n" ); } while(0); } while(0);
    do { int __size = (size); if (write (dev, data, __size) != __size) do { free (fat); if (info_sector) free (info_sector); free (root_
dir); fatal_error( "%s: " "failed whilst writing " "add_dir" "\n" ); } while(0); } while(0);

    remain -= size;
    data += size;

    mark_FAT_cluster(last_cluster_written, remain ? last_cluster_written + 1 : (atari_format ? 0x0fffffff : 0x0ffffff8));
    last_cluster_written++;
  }

 exit_add_dir:
  if (rddir) closedir(rddir);
  if (newdir->table) free(newdir->table);
  if (newdir) free(newdir);
}





static void add_root_directory(char *dirname)
{
  DIR *dir = opendir(dirname);
  struct dirent *entry = 0;
  struct dir_entry *newdir = 0;

  if (!dir) {
    printf("Error - directory %s does not exist\n", dirname);
    return;
  }




  newdir = (struct dir_entry *) calloc(1,sizeof(struct dir_entry));

  if (!newdir) {
    closedir(dir);
    return;
  }

  newdir->entries = root_dir_entries;
  newdir->root = 1;
  newdir->count = 0;
  newdir->table = root_dir;

  while((entry = readdir(dir))) {
    struct stat st;
    char *buffer;

    if (!__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (entry->d_name) && __builtin_constant_p (".") && (__s1_len = 
strlen (entry->d_name), __s2_len = strlen ("."), (!((size_t)(const void *)((entry->d_name) + 1) - (size_t)(const void *)(entry->d_name) 
== 1) || __s1_len >= 4) && (!((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) || __s2_len >= 4)) ? __builtin_strcm
p (entry->d_name, ".") : (__builtin_constant_p (entry->d_name) && ((size_t)(const void *)((entry->d_name) + 1) - (size_t)(const void *)(
entry->d_name) == 1) && (__s1_len = strlen (entry->d_name), __s1_len < 4) ? (__builtin_constant_p (".") && ((size_t)(const void *)((".")
 + 1) - (size_t)(const void *)(".") == 1) ? __builtin_strcmp (entry->d_name, ".") : (__extension__ ({ __const unsigned char *__s2 = (__c
onst unsigned char *) (__const char *) ("."); register int __result = (((__const unsigned char *) (__const char *) (entry->d_name))[0] -
 __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (entry->d_name))[1] - __s2[1]); 
if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (entry->d_name))[2] - __s2[2]); if (__s1_le
n > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (entry->d_name))[3] - __s2[3]); } } __result; }))) : (__
builtin_constant_p (".") && ((size_t)(const void *)((".") + 1) - (size_t)(const void *)(".") == 1) && (__s2_len = strlen ("."), __s2_len
 < 4) ? (__builtin_constant_p (entry->d_name) && ((size_t)(const void *)((entry->d_name) + 1) - (size_t)(const void *)(entry->d_name) ==
 1) ? __builtin_strcmp (entry->d_name, ".") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *)
 (entry->d_name); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) ("."))[0]; if (__s2_len > 0 && __result 
== 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) ("."))[1]); if (__s2_len > 1 && __result == 0) { __result = (_
_s1[2] - ((__const unsigned char *) (__const char *) ("."))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsi
gned char *) (__const char *) ("."))[3]); } } __result; }))) : __builtin_strcmp (entry->d_name, ".")))); }) || !__extension__ ({ size_t 
__s1_len, __s2_len; (__builtin_constant_p (entry->d_name) && __builtin_constant_p ("..") && (__s1_len = strlen (entry->d_name), __s2_len
 = strlen (".."), (!((size_t)(const void *)((entry->d_name) + 1) - (size_t)(const void *)(entry->d_name) == 1) || __s1_len >= 4) && (!((
size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) || __s2_len >= 4)) ? __builtin_strcmp (entry->d_name, "..") : (__
builtin_constant_p (entry->d_name) && ((size_t)(const void *)((entry->d_name) + 1) - (size_t)(const void *)(entry->d_name) == 1) && (__s
1_len = strlen (entry->d_name), __s1_len < 4) ? (__builtin_constant_p ("..") && ((size_t)(const void *)(("..") + 1) - (size_t)(const voi
d *)("..") == 1) ? __builtin_strcmp (entry->d_name, "..") : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (_
_const char *) (".."); register int __result = (((__const unsigned char *) (__const char *) (entry->d_name))[0] - __s2[0]); if (__s1_len
 > 0 && __result == 0) { __result = (((__const unsigned char *) (__const char *) (entry->d_name))[1] - __s2[1]); if (__s1_len > 1 && __r
esult == 0) { __result = (((__const unsigned char *) (__const char *) (entry->d_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0)
 __result = (((__const unsigned char *) (__const char *) (entry->d_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("..
") && ((size_t)(const void *)(("..") + 1) - (size_t)(const void *)("..") == 1) && (__s2_len = strlen (".."), __s2_len < 4) ? (__builtin_
constant_p (entry->d_name) && ((size_t)(const void *)((entry->d_name) + 1) - (size_t)(const void *)(entry->d_name) == 1) ? __builtin_str
cmp (entry->d_name, "..") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const char *) (entry->d_name); 
register int __result = __s1[0] - ((__const unsigned char *) (__const char *) (".."))[0]; if (__s2_len > 0 && __result == 0) { __result 
= (__s1[1] - ((__const unsigned char *) (__const char *) (".."))[1]); if (__s2_len > 1 && __result == 0) { __result = (__s1[2] - ((__con
st unsigned char *) (__const char *) (".."))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsigned char *) (_
_const char *) (".."))[3]); } } __result; }))) : __builtin_strcmp (entry->d_name, "..")))); }))
      continue;


    if (entry->d_name[0] == '.') continue;

    buffer = malloc(strlen(dirname) + strlen(entry->d_name) + 3);
    if (!buffer) continue;

    sprintf(buffer, "%s/%s", dirname, entry->d_name);
    if (!stat(buffer, &st)) {
      if (((((st.st_mode)) & 0170000) == (0040000)))
 add_directory(buffer, newdir);
      else if (((((st.st_mode)) & 0170000) == (0100000))) {
 unsigned char attrib = check_attrib_file(dirname, entry->d_name);
 add_file(buffer, newdir, attrib);
      }
    }

    free(buffer);
  }

  closedir(dir);
  if (newdir) free(newdir);
}



void
usage (void)
{
  fatal_error("Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n       [-m boot-msg-file] [-n volume
-name] [-i volume-id] [-B bootcode]\n       [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n       [-F fat-size] 
[-r root-dir-entries] [-R reserved-sectors]\n       [-d directory] /dev/name [blocks]\n");





}





static void check_atari( void )
{
# 1937 "mkdosfs.c"
}




int
main (int argc, char **argv)
{
  int c;
  char *tmp;
  char *listfile = ((void *)0);
  char *dirname = ((void *)0);

  FILE *msgfile;
  struct stat statbuf;
  int i = 0, pos, ch;
  int create = 0;

  if (argc && *argv) {
    char *p;
    program_name = *argv;
    if ((p = strrchr( program_name, '/' )))
 program_name = p+1;
  }

  time(&create_time);
  volume_id = (long)create_time;
  check_atari();

  printf ("%s " "2.10" " (" "22 Sep 2003" ")\n",
    program_name);

  while ((c = getopt (argc, argv, "AcCd:f:F:Ii:l:m:n:r:R:s:S:v:B:b")) != (-1))

    switch (c)
      {
      case 'A':
 atari_format = !atari_format;
 break;

      case 'b':
 backup_boot = (int) strtol (optarg, &tmp, 0);
 if (*tmp || backup_boot < 2 || backup_boot > 0xffff)
   {
     printf ("Bad location for backup boot sector : %s\n", optarg);
     usage ();
   }
 break;

      case 'c':
 check = 1;
 break;

      case 'C':
 create = 1;
 break;

      case 'd':
 dirname = optarg;
 break;

      case 'f':
 nr_fats = (int) strtol (optarg, &tmp, 0);
 if (*tmp || nr_fats < 1 || nr_fats > 4)
   {
     printf ("Bad number of FATs : %s\n", optarg);
     usage ();
   }
 break;

      case 'F':
 size_fat = (int) strtol (optarg, &tmp, 0);
 if (*tmp || (size_fat != 12 && size_fat != 16 && size_fat != 32))
   {
     printf ("Bad FAT type : %s\n", optarg);
     usage ();
   }
 size_fat_by_user = 1;
 break;

      case 'I':
 ignore_full_disk = 1;
 break;

      case 'i':
 volume_id = strtol(optarg, &tmp, 16);
 if ( *tmp )
   {
     printf("Volume ID must be a hexadecimal number\n");
     usage();
   }
 break;

      case 'l':
 listfile = optarg;
 break;

      case 'B':
        if ( __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (optarg) && __builtin_constant_p ("-") && (__s1_len = str
len (optarg), __s2_len = strlen ("-"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) 
&& (!((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "-") : (__bui
ltin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) && (__s1_len = strlen (optarg),
 __s1_len < 4) ? (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) ? __builtin_strcm
p (optarg, "-") : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) ("-"); register int __resul
t = (((__const unsigned char *) (__const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const uns
igned char *) (__const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__c
onst char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (optarg
))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") =
= 1) && (__s2_len = strlen ("-"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(con
st void *)(optarg) == 1) ? __builtin_strcmp (optarg, "-") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (_
_const char *) (optarg); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) ("-"))[0]; if (__s2_len > 0 && __
result == 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) ("-"))[1]); if (__s2_len > 1 && __result == 0) { __resu
lt = (__s1[2] - ((__const unsigned char *) (__const char *) ("-"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__con
st unsigned char *) (__const char *) ("-"))[3]); } } __result; }))) : __builtin_strcmp (optarg, "-")))); }) )
   {
     msgfile = fopen(optarg, "r");
     if ( !msgfile )
       perror(optarg);
   }
 else
   msgfile = stdin;

 if ( msgfile )
   {
            if (!(template_boot_code = malloc( 0xFFFF )))
                fatal_error( "%s: " "Out of memory" "\n" );

            use_template = 1;
     i = 0;
     do
       {
  ch = _IO_getc (msgfile);
  switch (ch)
    {
    case (-1):
      break;

    default:
      template_boot_code[i++] = ch;
      break;
    }
       }
     while ( ch != (-1) && i < 0xFFFF );
     ch = _IO_getc (msgfile);


     while( i < 0xFFFF )
  template_boot_code[i++] = '\0';

     if ( ch != (-1) )
       printf ("Warning: template too long; truncated after %d bytes\n", i);

     if ( msgfile != stdin )
       fclose(msgfile);
   }
 break;

      case 'm':
 if ( __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (optarg) && __builtin_constant_p ("-") && (__s1_len = strlen (op
targ), __s2_len = strlen ("-"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((
size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "-") : (__builtin_co
nstant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) && (__s1_len = strlen (optarg), __s1_l
en < 4) ? (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) ? __builtin_strcmp (opta
rg, "-") : (__extension__ ({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *) ("-"); register int __result = (((
__const unsigned char *) (__const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((__const unsigned c
har *) (__const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *) (__const ch
ar *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((__const unsigned char *) (__const char *) (optarg))[3] -
 __s2[3]); } } __result; }))) : (__builtin_constant_p ("-") && ((size_t)(const void *)(("-") + 1) - (size_t)(const void *)("-") == 1) &&
 (__s2_len = strlen ("-"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void
 *)(optarg) == 1) ? __builtin_strcmp (optarg, "-") : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) (__const 
char *) (optarg); register int __result = __s1[0] - ((__const unsigned char *) (__const char *) ("-"))[0]; if (__s2_len > 0 && __result 
== 0) { __result = (__s1[1] - ((__const unsigned char *) (__const char *) ("-"))[1]); if (__s2_len > 1 && __result == 0) { __result = (_
_s1[2] - ((__const unsigned char *) (__const char *) ("-"))[2]); if (__s2_len > 2 && __result == 0) __result = (__s1[3] - ((__const unsi
gned char *) (__const char *) ("-"))[3]); } } __result; }))) : __builtin_strcmp (optarg, "-")))); }) )
   {
     msgfile = fopen(optarg, "r");
     if ( !msgfile )
       perror(optarg);
   }
 else
   msgfile = stdin;

 if ( msgfile )
   {

     i = 29;
     pos = 0;
     do
       {
  ch = _IO_getc (msgfile);
  switch (ch)
    {
    case '\r':
    case '\0':
      break;

    case '\n':
      if ( pos )
        {
   dummy_boot_code[i++] = '\r';
   pos = 0;
        }
      dummy_boot_code[i++] = '\n';
      break;

    case '\t':
      do
        {
   dummy_boot_code[i++] = ' ';
   pos++;
        }
      while ( pos % 8 && i < 448 -1 );
      break;

    case (-1):
      dummy_boot_code[i++] = '\0';
      break;

    default:
      dummy_boot_code[i++] = ch;
      pos++;
      break;
    }
       }
     while ( ch != (-1) && i < 448 -1 );


     while( i < 448 -1 )
  dummy_boot_code[i++] = '\0';
     dummy_boot_code[448 -1] = '\0';

     if ( ch != (-1) )
       printf ("Warning: message too long; truncated\n");

     if ( msgfile != stdin )
       fclose(msgfile);
   }
 break;

      case 'n':
 sprintf(volume_name, "%-11.11s", optarg);
 break;

      case 'r':
 root_dir_entries = (int) strtol (optarg, &tmp, 0);
 if (*tmp || root_dir_entries < 16 || root_dir_entries > 32768)
   {
     printf ("Bad number of root directory entries : %s\n", optarg);
     usage ();
   }
 break;

      case 'R':
 reserved_sectors = (int) strtol (optarg, &tmp, 0);
 if (*tmp || reserved_sectors < 1 || reserved_sectors > 0xffff)
   {
     printf ("Bad number of reserved sectors : %s\n", optarg);
     usage ();
   }
 break;

      case 's':
 sectors_per_cluster = (int) strtol (optarg, &tmp, 0);
 if (*tmp || (sectors_per_cluster != 1 && sectors_per_cluster != 2
       && sectors_per_cluster != 4 && sectors_per_cluster != 8
     && sectors_per_cluster != 16 && sectors_per_cluster != 32
  && sectors_per_cluster != 64 && sectors_per_cluster != 128))
   {
     printf ("Bad number of sectors per cluster : %s\n", optarg);
     usage ();
   }
 break;

      case 'S':
 sector_size = (int) strtol (optarg, &tmp, 0);
 if (*tmp || (sector_size != 512 && sector_size != 1024 &&
       sector_size != 2048 && sector_size != 4096 &&
       sector_size != 8192 && sector_size != 16384 &&
       sector_size != 32768))
   {
     printf ("Bad logical sector size : %s\n", optarg);
     usage ();
   }
 sector_size_set = 1;
 break;

      case 'v':
 ++verbose;
 break;

      default:
 printf( "Unknown option: %c\n", c );
 usage ();
      }
  if (optind < argc)
    {
      device_name = argv[optind];
      if (!create)
         i = count_blocks (device_name);
    }
  if (optind == argc - 2)
    {
      blocks = (int) strtol (argv[optind + 1], &tmp, 0);
      if (!create && blocks != i)
 {
   fprintf (stderr, "Warning: block count mismatch: ");
   fprintf (stderr, "found %d but assuming %d.\n",i,blocks);
 }
    }
  else if (optind == argc - 1)
    {
      if (create)
 fatal_error( "%s: " "Need intended size with -C." "\n" );
      blocks = i;
      tmp = "";
    }
  else
    {
      fprintf (stderr, "No device specified!\n");
      usage ();
    }
  if (*tmp)
    {
      printf ("Bad block count : %s\n", argv[optind + 1]);
      usage ();
    }

  if (check && listfile)
    fatal_error( "%s: " "-c and -l are incompatible" "\n" );

  if (!create) {
    check_mount (device_name);
    dev = open (device_name, 02);
    if (dev < 0)
      fatal_error( "%s: " "unable to open %s" "\n" );
  }
  else {
      loff_t offset = blocks*(1<<10) - 1;
      char null = 0;

      dev = open( device_name, 02|0100|01000, 0775 );
      if (dev < 0)
 fatal_error( "%s: " "unable to create %s" "\n" );


      if (llseek( dev, offset, 0 ) != offset)
 fatal_error( "%s: " "seek failed" "\n" );
      if (write( dev, &null, 1 ) < 0)
 fatal_error( "%s: " "write failed" "\n" );
      if (llseek( dev, 0, 0 ) != 0)
 fatal_error( "%s: " "seek failed" "\n" );
  }

  if (fstat (dev, &statbuf) < 0)
    fatal_error( "%s: " "unable to stat %s" "\n" );
  if (!((((statbuf.st_mode)) & 0170000) == (0060000))) {
    statbuf.st_rdev = 0;
    check = 0;
  }
  else







    if (!ignore_full_disk && (
 (statbuf.st_rdev & 0xff3f) == 0x0300 ||
 (statbuf.st_rdev & 0xff0f) == 0x0800 ||
 (statbuf.st_rdev & 0xff3f) == 0x0d00 ||
 (statbuf.st_rdev & 0xff3f) == 0x1600 )
 )
      fatal_error( "%s: " "Will not try to make filesystem on full-disk device '%s' (use -I if wanted)" "\n" );

  establish_params (statbuf.st_rdev,statbuf.st_size);


  setup_tables ();

  if (check)
    check_blocks ();
  else if (listfile)
    get_list_blocks (listfile);


  if (dirname) add_root_directory(dirname);

  write_tables ();
  exit (0);
}