~ubuntu-branches/ubuntu/wily/dosfstools/wily-proposed

« back to all changes in this revision

Viewing changes to src/mkfs.fat.c

  • Committer: Package Import Robot
  • Author(s): Daniel Baumann
  • Date: 2014-01-17 07:14:46 UTC
  • mfrom: (4.3.13 experimental)
  • Revision ID: package-import@ubuntu.com-20140117071446-rs9c3tpoyh7z17ta
Tags: 3.0.25-1
MergingĀ upstreamĀ versionĀ 3.0.25.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
   Copyright (C) 1993-1994 David Hudson <dave@humbug.demon.co.uk>
6
6
   Copyright (C) 1998 H. Peter Anvin <hpa@zytor.com>
7
7
   Copyright (C) 1998-2005 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
8
 
   Copyright (C) 2008-2013 Daniel Baumann <mail@daniel-baumann.ch>
 
8
   Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
9
9
 
10
10
   This program is free software: you can redistribute it and/or modify
11
11
   it under the terms of the GNU General Public License as published by
64
64
#include <time.h>
65
65
#include <errno.h>
66
66
#include <ctype.h>
 
67
#include <stdint.h>
67
68
#include <endian.h>
68
69
 
69
70
#include <asm/types.h>
257
258
static time_t create_time;      /* Creation time */
258
259
static struct timeval create_timeval;   /* Creation time */
259
260
static char volume_name[] = NO_NAME;    /* Volume name */
260
 
static unsigned long long blocks;       /* Number of blocks in filesystem */
 
261
static uint64_t blocks; /* Number of blocks in filesystem */
261
262
static int sector_size = 512;   /* Size of a logical sector */
262
263
static int sector_size_set = 0; /* User selected sector size */
263
264
static int backup_boot = 0;     /* Sector# of backup boot sector */
299
300
static void check_blocks(void);
300
301
static void get_list_blocks(char *filename);
301
302
static int valid_offset(int fd, loff_t offset);
302
 
static unsigned long long count_blocks(char *filename, int *remainder);
 
303
static uint64_t count_blocks(char *filename, int *remainder);
303
304
static void check_mount(char *device_name);
304
305
static void establish_params(int device_num, int size);
305
306
static void setup_tables(void);
454
455
{
455
456
    int i;
456
457
    FILE *listfile;
457
 
    unsigned long blockno;
 
458
    long blockno;
458
459
 
459
460
    listfile = fopen(filename, "r");
460
461
    if (listfile == (FILE *) NULL)
488
489
 
489
490
/* Given a filename, look to see how many blocks of BLOCK_SIZE are present, returning the answer */
490
491
 
491
 
static unsigned long long count_blocks(char *filename, int *remainder)
 
492
static uint64_t count_blocks(char *filename, int *remainder)
492
493
{
493
494
    loff_t high, low;
494
495
    int fd;
704
705
             * fs size <  32G: 16k clusters
705
706
             * fs size >= 32G: 32k clusters
706
707
             */
707
 
            unsigned long sz_mb =
 
708
            uint32_t sz_mb =
708
709
                (blocks + (1 << (20 - BLOCK_SIZE_BITS)) - 1) >> (20 -
709
710
                                                                 BLOCK_SIZE_BITS);
710
711
            bs.cluster_size =
1408
1409
    struct stat statbuf;
1409
1410
    int i = 0, pos, ch;
1410
1411
    int create = 0;
1411
 
    unsigned long long cblocks = 0;
 
1412
    uint64_t cblocks = 0;
1412
1413
    int min_sector_size;
1413
1414
 
1414
1415
    if (argc && *argv) {        /* What's the program name? */
1649
1650
        blocks = strtoull(argv[optind + 1], &tmp, 0);
1650
1651
        if (!create && blocks != cblocks) {
1651
1652
            fprintf(stderr, "Warning: block count mismatch: ");
1652
 
            fprintf(stderr, "found %llu but assuming %llu.\n", cblocks, blocks);
 
1653
            fprintf(stderr, "found %llu but assuming %llu.\n", (unsigned long long)cblocks, (unsigned long long)blocks);
1653
1654
        }
1654
1655
    } else if (optind == argc - 1) {    /*  Or use value found */
1655
1656
        if (create)