Rev 3541 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3541 | Rev 3545 | ||
---|---|---|---|
Line 53... | Line 53... | ||
53 | files = 2 |
53 | files = 2 |
54 | 54 | ||
55 | for name in os.listdir(root): |
55 | for name in os.listdir(root): |
56 | canon = os.path.join(root, name) |
56 | canon = os.path.join(root, name) |
57 | 57 | ||
58 | if (os.path.isfile(canon)): |
58 | if (os.path.isfile(canon) and (not name in exclude_names)): |
59 | size += align_up(os.path.getsize(canon), cluster_size) |
59 | size += align_up(os.path.getsize(canon), cluster_size) |
60 | files += 1 |
60 | files += 1 |
61 | 61 | ||
62 | if (os.path.isdir(canon)): |
62 | if (os.path.isdir(canon) and (not name in exclude_names)): |
63 | size += subtree_size(canon, cluster_size, dirent_size) |
63 | size += subtree_size(canon, cluster_size, dirent_size) |
64 | files += 1 |
64 | files += 1 |
65 | 65 | ||
66 | return size + align_up(files * dirent_size, cluster_size) |
66 | return size + align_up(files * dirent_size, cluster_size) |
67 | 67 | ||
Line 351... | Line 351... | ||
351 | if (not os.path.isdir(path)): |
351 | if (not os.path.isdir(path)): |
352 | print "<PATH> must be a directory" |
352 | print "<PATH> must be a directory" |
353 | return |
353 | return |
354 | 354 | ||
355 | fat16_clusters = 4096 |
355 | fat16_clusters = 4096 |
356 | min_cluster_size = 1024 |
- | |
357 | 356 | ||
358 | sector_size = 512 |
357 | sector_size = 512 |
359 | cluster_size = 4096 |
358 | cluster_size = 4096 |
360 | dirent_size = 32 |
359 | dirent_size = 32 |
361 | fatent_size = 2 |
360 | fatent_size = 2 |
Line 363... | Line 362... | ||
363 | reserved_clusters = 2 |
362 | reserved_clusters = 2 |
364 | 363 | ||
365 | # Make sure the filesystem is large enought for FAT16 |
364 | # Make sure the filesystem is large enought for FAT16 |
366 | size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size |
365 | size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size |
367 | while (size / cluster_size < fat16_clusters): |
366 | while (size / cluster_size < fat16_clusters): |
368 | if (cluster_size > min_cluster_size): |
367 | if (cluster_size > sector_size): |
369 | cluster_size /= 2 |
368 | cluster_size /= 2 |
370 | size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size |
369 | size = subtree_size(path, cluster_size, dirent_size) + reserved_clusters * cluster_size |
371 | else: |
370 | else: |
372 | size = fat16_clusters * cluster_size + reserved_clusters * cluster_size |
371 | size = fat16_clusters * cluster_size + reserved_clusters * cluster_size |
373 | 372 |