1
0
forked from pool/util-linux
util-linux/mkfs.bfs_cleanup_endian.patch

77 lines
2.5 KiB
Diff
Raw Normal View History

--- util-linux-2.21.2/disk-utils/mkfs.bfs.c.old 2013-05-28 19:26:05.000000000 +0200
+++ util-linux-2.21.2/disk-utils/mkfs.bfs.c 2013-05-28 19:39:28.000000000 +0200
@@ -98,6 +98,7 @@
unsigned long long user_specified_total_blocks = 0;
int verbose = 0;
int fd;
+ uint32_t first_block;
struct bfssb sb;
struct bfsi ri;
struct bfsde de;
@@ -224,9 +224,9 @@
ino_blocks + 33);
memset(&sb, 0, sizeof(sb));
- sb.s_magic = BFS_SUPER_MAGIC;
- sb.s_start = ino_bytes + sizeof(struct bfssb);
- sb.s_end = total_blocks * BFS_BLOCKSIZE - 1;
+ sb.s_magic = htole32(BFS_SUPER_MAGIC);
+ sb.s_start = htole32(ino_bytes + sizeof(struct bfssb));
+ sb.s_end = htole32(total_blocks * BFS_BLOCKSIZE - 1);
sb.s_from = sb.s_to = sb.s_backup_from = sb.s_backup_to = -1;
memcpy(sb.s_fsname, fsname, 6);
memcpy(sb.s_volume, volume, 6);
@@ -244,28 +244,29 @@
inodes, ino_blocks);
fprintf(stderr, _("Blocks: %lld\n"), total_blocks);
fprintf(stderr, _("Inode end: %d, Data end: %d\n"),
- sb.s_start - 1, sb.s_end);
+ htole32(sb.s_start) - 1, htole32(sb.s_end));
}
if (write(fd, &sb, sizeof(sb)) != sizeof(sb))
err(EXIT_FAILURE, _("error writing superblock"));
memset(&ri, 0, sizeof(ri));
- ri.i_ino = BFS_ROOT_INO;
- ri.i_first_block = 1 + ino_blocks;
- ri.i_last_block = ri.i_first_block +
- (inodes * sizeof(de) - 1) / BFS_BLOCKSIZE;
- ri.i_bytes_to_end = ri.i_first_block * BFS_BLOCKSIZE
- + 2 * sizeof(struct bfsde) - 1;
- ri.i_type = BFS_DIR_TYPE;
- ri.i_mode = S_IFDIR | 0755; /* or just 0755 */
- ri.i_uid = 0;
- ri.i_gid = 1; /* random */
+ ri.i_ino = htole16(BFS_ROOT_INO);
+ first_block = 1 + ino_blocks;
+ ri.i_first_block = htole32(first_block);
+ ri.i_last_block = htole32(first_block +
+ (inodes * sizeof(de) - 1) / BFS_BLOCKSIZE);
+ ri.i_bytes_to_end = htole32(first_block * BFS_BLOCKSIZE
+ + 2 * sizeof(struct bfsde) - 1);
+ ri.i_type = htole32(BFS_DIR_TYPE);
+ ri.i_mode = htole32(S_IFDIR | 0755); /* or just 0755 */
+ ri.i_uid = htole32(0);
+ ri.i_gid = htole32(1); /* random */
ri.i_nlinks = 2;
time(&now);
- ri.i_atime = now;
- ri.i_mtime = now;
- ri.i_ctime = now;
+ ri.i_atime = htole32(now);
+ ri.i_mtime = htole32(now);
+ ri.i_ctime = htole32(now);
if (write(fd, &ri, sizeof(ri)) != sizeof(ri))
err(EXIT_FAILURE, _("error writing root inode"));
@@ -279,7 +280,7 @@
err(EXIT_FAILURE, _("seek error"));
memset(&de, 0, sizeof(de));
- de.d_ino = BFS_ROOT_INO;
+ de.d_ino = htole16(BFS_ROOT_INO);
memcpy(de.d_name, ".", 1);
if (write(fd, &de, sizeof(de)) != sizeof(de))
err(EXIT_FAILURE, _("error writing . entry"));