Results 1 to 2 of 2
Hi,
We have this following request.
In the setup of 2 hosts with shared disks array, we have following requirement.
The program should take host number ( 1 or 2 ...
- 01-19-2010 #1Just Joined!
- Join Date
- Jul 2004
- Posts
- 44
RAW Devices
Hi,
We have this following request.
In the setup of 2 hosts with shared disks array, we have following requirement.
The program should take host number ( 1 or 2 ) , device name as input parameters.
In the first step :
The program should write the current timestamp to the first or second block (2k) of the raw device.
Please note that writes to a raw device need to be aligned to sector borders an need to be in 512 byte chunks in aligned memory.
(The dd command can not be used for testing unfortunately since it "does not currently align its buffers correctly and so cannot be used on raw devices.") (man 8 raw).
In the second step :
create a loop to execute the following every second:
- write a current timestamp
- read and output the current timestamp written by the other node.
Please excuse as I am a newbie.
Any response would be appreciated.
Thanx in adv.
Admin
- 01-19-2010 #2Just Joined!
- Join Date
- Jul 2004
- Posts
- 44
Is this code ok??
char timestamp[100];
hostnumber = <passed as input>
device_name = "/dev/raw/raw<hostnumber>"
timestamp = <timestamp>
fd_write = open (device_name_write, O_DIRECT|O_WRONLY);
if (fd_write < 0) error;
/*write timestamp*/
if (write(fd_write, timestamp, 512) != 512) error;
close(fd_write);
fd_read = open (device_name_read, O_DIRECT|O_RDONLY);
if (fd_read < 0) error;
/* read timestamp written on other node*/
while (true) {
read(fd_read, &buff, 512);
sleep(1);
re-position the file pointer to beginning
}
close(fd_read);


Reply With Quote