-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcreate_hdd_region.sh
executable file
·127 lines (93 loc) · 3.77 KB
/
create_hdd_region.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
#
# Copyright (C) 2011 glevand ([email protected])
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
PS3HVC_DEV=/dev/ps3hvc
PS3HVC_HVCALL=ps3hvc_hvcall
PS3STORMGR_DEV=/dev/ps3stormgr
PS3STOR_REGION=ps3stor_region
LPAR_ID=1
LAID=0x1070000002000001
RNV_BUS4=0x0000000062757304
RNV_NUM_DEV=0x6e756d5f64657600
RNV_DEV=0x6465760000000000
RNV_ID=0x6964000000000000
RNV_TYPE=0x7479706500000000
RNV_DEV_TYPE_DISK=0x0000000000000000
RNV_N_BLOCKS=0x6e5f626c6f636b73
RNV_N_REGS=0x6e5f726567730000
RNV_REGION=0x726567696f6e0000
RNV_START=0x7374617274000000
RNV_SIZE=0x73697a6500000000
# get number of storage devices
num_dev=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $RNV_NUM_DEV 0 0 |
awk '{ printf $1 }'`
num_dev=`printf "%d" $num_dev`
echo "number of storage devices $num_dev"
# get index of disk storage device
echo "searching for disk storage device ..."
dev_idx=0
found=0
while [ $dev_idx -lt $num_dev -a $found -eq 0 ]; do
rnv_dev="`expr substr $RNV_DEV 1 17`${dev_idx}"
type=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $rnv_dev $RNV_TYPE 0 |
awk '{ printf $1 }'`
if [ "$type" = "$RNV_DEV_TYPE_DISK" ]; then
found=1
else
dev_idx=`expr $dev_idx + 1`
fi
done
if [ $found -eq 0 ]; then
echo "disk storage device was not found"
exit 1
fi
echo "found disk storage device"
echo "device index $dev_idx"
# get id of disk storage device
dev_id=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $rnv_dev $RNV_ID 0 |
awk '{ printf $1 }'`
echo "device id $dev_id"
# get number of regions on disk storage device
n_regs=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $rnv_dev $RNV_N_REGS 0 |
awk '{ printf $1 }'`
n_regs=`printf "%d" $n_regs`
echo "number of regions $n_regs"
# get total size of disk storage device
n_blocks=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $rnv_dev $RNV_N_BLOCKS 0 |
awk '{ printf $1 }'`
n_blocks=`printf "%d" $n_blocks`
echo "total number of blocks $n_blocks"
# calculate start sector and sector count for new region on disk storage device
last_reg_idx=`expr $n_regs - 1`
rnv_reg="`expr substr $RNV_REGION 1 17`${last_reg_idx}"
last_reg_start_sector=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $rnv_dev \
$rnv_reg $RNV_START | awk '{ printf $1 }'`
last_reg_start_sector=`printf "%d" $last_reg_start_sector`
echo "last region start sector $last_reg_start_sector"
last_reg_sector_count=`$PS3HVC_HVCALL $PS3HVC_DEV get_repo_node_val $LPAR_ID $RNV_BUS4 $rnv_dev \
$rnv_reg $RNV_SIZE | awk '{ printf $1 }'`
last_reg_sector_count=`printf "%d" $last_reg_sector_count`
echo "last region sector count $last_reg_sector_count"
new_reg_start_sector=`expr $last_reg_start_sector + $last_reg_sector_count + 8`
free_sector_count=`expr $n_blocks - $new_reg_start_sector`
new_reg_sector_count=`expr $free_sector_count - 8`
echo "number of free sectors $free_sector_count"
# create new region on disk storage device
echo "creating new storage region ($new_reg_start_sector, $new_reg_sector_count) ..."
new_reg_id=`$PS3STOR_REGION $PS3STORMGR_DEV create $dev_id $new_reg_start_sector $new_reg_sector_count $LAID`
echo "new storage region id $new_reg_id"