forked from bd-group/dservice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
111 lines (93 loc) · 3.67 KB
/
common.h
File metadata and controls
111 lines (93 loc) · 3.67 KB
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
/**
* Copyright (c) 2012 IIE, all rights reserved.
*
* Ma Can <ml.macana@gmail.com> OR <macan@iie.ac.cn>
*
* Armed with EMACS.
* Time-stamp: <2013-10-31 20:15:26 macan>
*
*/
#ifndef __COMMON_H__
#define __COMMON_H__
#define HVFS_TRACING
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <getopt.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <getopt.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include "lib/lib.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <limits.h>
HVFS_TRACING_INIT();
#define GET_GL_DISK_SN "find /dev/disk/by-id/ -iregex '.*%s-[^-]*$' -exec stat -c '%%N' {} \\; | sed -e 's/.*%s-\\([0-9a-zA-Z_]*\\).*..\\/..\\/\\([a-z]*\\).*/OK \\1 \\2/g'"
#define GET_SCSI_DISK_SN "find /dev/disk/by-id/ -iregex '.*scsi-[^-]*$' -exec stat -c '%N' {} \\; | sed -e 's/.*scsi-\\([0-9a-zA-Z_]*\\).*..\\/..\\/\\([a-z]*\\).*/OK \\1 \\2/g'"
struct disk_info
{
char *dev_sn; /* global unique SN */
char *dev_id; /* local sd* */
};
#define GET_GL_DISKPART_SN "find /dev/disk/by-id/ -iregex '.*%s-.*part.*' -exec stat -c '%%N' {} \\; | sed -e 's/.*%s-\\([0-9a-zA-Z_-]*\\).*..\\/..\\/\\([a-z0-9]*\\).*/\\1 \\2/g' | sort | awk '{cmd = \"mount -l | grep \\\"\" $2 \" \\\"\"; while ((cmd | getline result) > 0) {print $0\" \"result} }' | awk 'BEGIN{FS=\" type\"} {print \"OK\",$1}' | cut -d\" \" -f1,2,3,6-"
#define GET_GL_DISK_SN_EXT "find /dev/disk/by-id/ -iregex '.*%s-.*$' -exec stat -c '%%N' {} \\; | grep -v '\\-part' | sed -e 's/.*%s-\\([0-9a-zA-Z_-]*\\).*..\\/..\\/\\([a-z0-9]*\\).*/\\1 \\2/g' | sort | awk '{cmd = \"mount -l | grep \\\"\" $2 \" \\\"\"; while ((cmd | getline result) > 0) {print $0\" \"result} }' | awk 'BEGIN{FS=\" type\"} {print \"OK\",$1}' | cut -d\" \" -f1,2,3,6-"
#define GET_SCSI_DISKPART_SN "find /dev/disk/by-id/ -iregex '.*scsi-.*part.*' -exec stat -c '%N' {} \\; | sed -e 's/.*scsi-\\([0-9a-zA-Z_-]*\\).*..\\/..\\/\\([a-z0-9]*\\).*/\\1 \\2/g' | sort | awk '{cmd = \"mount -l | grep \\\"\" $2 \" \\\"\"; while ((cmd | getline result) > 0) {print $0\" \"result} }' | awk 'BEGIN{FS=\" type\"} {print \"OK\",$1}' | cut -d\" \" -f1,2,3,6-"
#define GET_SCSI_DISK_SN_EXT "find /dev/disk/by-id/ -iregex '.*scsi-[^-]*$' -exec stat -c '%N' {} \\; | sed -e 's/.*scsi-\\([0-9a-zA-Z_-]*\\).*..\\/..\\/\\([a-z0-9]*\\).*/\\1 \\2/g' | sort | awk '{cmd = \"mount -l | grep \\\"\" $2 \" \\\"\"; while ((cmd | getline result) > 0) {print $0\" \"result} }' | awk 'BEGIN{FS=\" type\"} {print \"OK\",$1}' | cut -d\" \" -f1,2,3,6-"
struct disk_part_info
{
char *dev_sn; /* global unique SN-partX */
char *dev_id; /* local sd*X */
char *mount_path; /* current mount path */
long read_nr;
long write_nr;
long err_nr;
long used;
long free;
};
struct floc_desc
{
char *node;
char *devid;
char *mp;
char *location;
};
struct rep_args
{
struct list_head list;
struct floc_desc to, from;
time_t ttl;
char *digest;
int retries;
#define REP_STATE_INIT 0
#define REP_STATE_DOING 1
#define REP_STATE_DONE 2
#define REP_STATE_ERROR 3
#define REP_STATE_ERROR_DONE 4
int status;
};
struct del_args
{
struct list_head list;
struct floc_desc target;
time_t ttl;
int retries;
#define DEL_STATE_INIT 0
#define DEL_STATE_DOING 1
#define DEL_STATE_DONE 2
#define DEL_STATE_ERROR 3
#define DEL_STATE_ERROR_DONE 4
int status;
};
#define DEV_MAPPING "/DEV_MAPPING"
#define _GNU_SOURCE
#endif