compare_ether_addr was removed in 3.14
[ps3linux_kernel_patches_314.git] / 0035-ps3-partition.patch
bloba92764a3143fabfe58cc42dec6da08816fde6847
1 --- a/block/partitions/Kconfig 2013-10-01 14:29:39.166124545 +0200
2 +++ b/block/partitions/Kconfig 2013-10-01 14:30:10.646126376 +0200
3 @@ -261,6 +261,12 @@
4 sysv68).
5 Otherwise, say N.
7 +config PS3_PARTITION
8 + bool "PS3 Partition support"
9 + depends on PARTITION_ADVANCED
10 + help
11 + Say Y here if you would like to use PS3 hard disks under Linux.
13 config CMDLINE_PARTITION
14 bool "Command line partition support" if PARTITION_ADVANCED
15 select CMDLINE_PARSER
16 --- a/block/partitions/Makefile 2012-09-06 18:41:11.858905657 +0200
17 +++ b/block/partitions/Makefile 2012-09-06 18:56:12.622291395 +0200
18 @@ -18,3 +18,4 @@
19 obj-$(CONFIG_EFI_PARTITION) += efi.o
20 obj-$(CONFIG_KARMA_PARTITION) += karma.o
21 obj-$(CONFIG_SYSV68_PARTITION) += sysv68.o
22 +obj-$(CONFIG_PS3_PARTITION) += ps3.o
23 --- a/block/partitions/check.c 2013-10-01 14:33:08.996136753 +0200
24 +++ b/block/partitions/check.c 2013-10-01 14:32:17.909467114 +0200
25 @@ -34,6 +34,7 @@
26 #include "efi.h"
27 #include "karma.h"
28 #include "sysv68.h"
29 +#include "ps3.h"
30 #include "cmdline.h"
32 int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
33 @@ -108,6 +109,9 @@
34 #ifdef CONFIG_SYSV68_PARTITION
35 sysv68_partition,
36 #endif
37 +#ifdef CONFIG_PS3_PARTITION
38 + ps3_partition,
39 +#endif
40 NULL
43 --- /dev/null 2012-09-06 18:32:42.202209340 +0200
44 +++ b/block/partitions/ps3.h 2012-09-06 18:41:52.025574661 +0200
45 @@ -0,0 +1,5 @@
46 +/*
47 + * fs/partitions/ps3.h
48 + */
50 +int ps3_partition(struct parsed_partitions *state);
51 --- /dev/null 2012-09-06 18:32:42.202209340 +0200
52 +++ b/block/partitions/ps3.c 2012-09-06 20:56:28.612711200 +0200
53 @@ -0,0 +1,98 @@
54 +/*
55 + * fs/partitions/ps3.c
56 + *
57 + * Copyright (C) 2012 glevand <geoffrey.levand@mail.ru>
58 + */
60 +#include "check.h"
61 +#include "ps3.h"
63 +#define SECTOR_SIZE 512
64 +#define MAX_ACL_ENTRIES 8
65 +#define MAX_PARTITIONS 8
67 +#define MAGIC1 0x0FACE0FFULL
68 +#define MAGIC2 0xDEADFACEULL
70 +struct p_acl_entry {
71 + __be64 laid;
72 + __be64 rights;
73 +};
75 +struct d_partition {
76 + __be64 p_start;
77 + __be64 p_size;
78 + struct p_acl_entry p_acl[MAX_ACL_ENTRIES];
79 +};
81 +struct disklabel {
82 + u8 d_res1[16];
83 + __be64 d_magic1;
84 + __be64 d_magic2;
85 + __be64 d_res2;
86 + __be64 d_res3;
87 + struct d_partition d_partitions[MAX_PARTITIONS];
88 + u8 d_pad[0x600 - MAX_PARTITIONS * sizeof(struct d_partition)- 0x30];
89 +};
91 +static bool ps3_read_disklabel(struct parsed_partitions *state, struct disklabel *label)
93 + Sector sect;
94 + unsigned char *data;
95 + int i;
97 + for (i = 0; i < sizeof(struct disklabel) / SECTOR_SIZE; i++) {
98 + data = read_part_sector(state, i, &sect);
99 + if (!data)
100 + return (false);
102 + memcpy((unsigned char *) label + i * SECTOR_SIZE, data, SECTOR_SIZE);
104 + put_dev_sector(sect);
107 + return (true);
110 +int ps3_partition(struct parsed_partitions *state)
112 + struct disklabel *label = NULL;
113 + int slot = 1;
114 + int result = -1;
115 + int i;
117 + label = kmalloc(sizeof(struct disklabel), GFP_KERNEL);
118 + if (!label)
119 + goto out;
121 + if (!ps3_read_disklabel(state, label))
122 + goto out;
124 + result = 0;
126 + if ((be64_to_cpu(label->d_magic1) != MAGIC1) ||
127 + (be64_to_cpu(label->d_magic2) != MAGIC2))
128 + goto out;
130 + for (i = 0; i < MAX_PARTITIONS; i++) {
131 + if (label->d_partitions[i].p_start && label->d_partitions[i].p_size) {
132 + put_partition(state, slot,
133 + be64_to_cpu(label->d_partitions[i].p_start),
134 + be64_to_cpu(label->d_partitions[i].p_size));
135 + slot++;
139 + strlcat(state->pp_buf, "\n", PAGE_SIZE);
141 + kfree(label);
143 + return (1);
145 +out:
147 + if (label)
148 + kfree(label);
150 + return (result);