Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3152924
create.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
create.c
View Options
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
//#include <fcntl.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <linux/dm-csnap.h>
#include "csnap.h"
#include "trace.h"
#include "sock.h"
#ifdef DELETE
# define THIS_CODE DELETE_SNAPSHOT
# define THIS_REPLY REPLY_DELETE_SNAPSHOT
#else
# define THIS_CODE CREATE_SNAPSHOT
# define THIS_REPLY REPLY_CREATE_SNAPSHOT
#endif
int main(int argc, char *argv[])
{
int sock, err;
if (argc < 3)
error("usage: %s host:port snapshot", argv[0]);
int snap = atoi(argv[2]);
char *host = argv[1];
int len = strlen(host), port = parse_port(host, &len);
if (port < 0)
error("expected host:port, not %s", host);
host[len] = 0;
if (!(sock = open_socket(host, port)))
error("Can't connect to %s:%i", host, port);
outbead(sock, THIS_CODE, struct create_snapshot, snap);
struct head head;
unsigned maxbuf = 500;
char buf[maxbuf];
if ((err = readpipe(sock, &head, sizeof(head))))
goto pipe_error;
assert(head.length < maxbuf); // !!! don't die
if ((err = readpipe(sock, buf, head.length)))
goto pipe_error;
trace_on(printf("reply = %x\n", head.code);)
err = head.code != THIS_REPLY;
if (head.code == REPLY_ERROR)
error("%.*s", head.length - 4, buf + 4);
pipe_error:
close(sock);
return err;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Feb 25, 6:07 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1463248
Default Alt Text
create.c (1 KB)
Attached To
Mode
rF Fence Agents
Attached
Detach File
Event Timeline
Log In to Comment