diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 19:43:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 19:43:47 -0500 |
commit | 6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83 (patch) | |
tree | 9c83c87a8670ef678d95f8d6f76a07f24a09a49f /tools | |
parent | e6b5be2be4e30037eb551e0ed09dd97bd00d85d3 (diff) | |
parent | 91905b6f4afe51e23a3f58df93e4cdc5e49cf40c (diff) |
Merge tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH:
"Here's the big char/misc driver update for 3.19-rc1
Lots of little things all over the place in different drivers, and a
new subsystem, "coresight" has been added. Full details are in the
shortlog"
* tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (73 commits)
parport: parport_pc, do not remove parent devices early
spmi: Remove shutdown/suspend/resume kernel-doc
carma-fpga-program: drop videobuf dependency
carma-fpga: drop videobuf dependency
carma-fpga-program.c: fix compile errors
i8k: Fix temperature bug handling in i8k_get_temp()
cxl: Name interrupts in /proc/interrupt
CXL: Return error to PSL if IRQ demultiplexing fails & print clearer warning
coresight-replicator: remove .owner field for driver
coresight: fixed comments in coresight.h
coresight: fix typo in comment in coresight-priv.h
coresight: bindings for coresight drivers
coresight: Adding ABI documentation
w1: support auto-load of w1_bq27000 module.
w1: avoid potential u16 overflow
cn: verify msg->len before making callback
mei: export fw status registers through sysfs
mei: read and print all six FW status registers
mei: txe: add cherrytrail device id
mei: kill cached host and me csr values
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/hv/hv_fcopy_daemon.c | 33 | ||||
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 48 | ||||
-rw-r--r-- | tools/hv/hv_vss_daemon.c | 95 |
3 files changed, 159 insertions, 17 deletions
diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c index 8f96b3ee0724..f437d739f37d 100644 --- a/tools/hv/hv_fcopy_daemon.c +++ b/tools/hv/hv_fcopy_daemon.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | #include <fcntl.h> | 34 | #include <fcntl.h> |
35 | #include <dirent.h> | 35 | #include <dirent.h> |
36 | #include <getopt.h> | ||
36 | 37 | ||
37 | static int target_fd; | 38 | static int target_fd; |
38 | static char target_fname[W_MAX_PATH]; | 39 | static char target_fname[W_MAX_PATH]; |
@@ -126,15 +127,43 @@ static int hv_copy_cancel(void) | |||
126 | 127 | ||
127 | } | 128 | } |
128 | 129 | ||
129 | int main(void) | 130 | void print_usage(char *argv[]) |
131 | { | ||
132 | fprintf(stderr, "Usage: %s [options]\n" | ||
133 | "Options are:\n" | ||
134 | " -n, --no-daemon stay in foreground, don't daemonize\n" | ||
135 | " -h, --help print this help\n", argv[0]); | ||
136 | } | ||
137 | |||
138 | int main(int argc, char *argv[]) | ||
130 | { | 139 | { |
131 | int fd, fcopy_fd, len; | 140 | int fd, fcopy_fd, len; |
132 | int error; | 141 | int error; |
142 | int daemonize = 1, long_index = 0, opt; | ||
133 | int version = FCOPY_CURRENT_VERSION; | 143 | int version = FCOPY_CURRENT_VERSION; |
134 | char *buffer[4096 * 2]; | 144 | char *buffer[4096 * 2]; |
135 | struct hv_fcopy_hdr *in_msg; | 145 | struct hv_fcopy_hdr *in_msg; |
136 | 146 | ||
137 | if (daemon(1, 0)) { | 147 | static struct option long_options[] = { |
148 | {"help", no_argument, 0, 'h' }, | ||
149 | {"no-daemon", no_argument, 0, 'n' }, | ||
150 | {0, 0, 0, 0 } | ||
151 | }; | ||
152 | |||
153 | while ((opt = getopt_long(argc, argv, "hn", long_options, | ||
154 | &long_index)) != -1) { | ||
155 | switch (opt) { | ||
156 | case 'n': | ||
157 | daemonize = 0; | ||
158 | break; | ||
159 | case 'h': | ||
160 | default: | ||
161 | print_usage(argv); | ||
162 | exit(EXIT_FAILURE); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | if (daemonize && daemon(1, 0)) { | ||
138 | syslog(LOG_ERR, "daemon() failed; error: %s", strerror(errno)); | 167 | syslog(LOG_ERR, "daemon() failed; error: %s", strerror(errno)); |
139 | exit(EXIT_FAILURE); | 168 | exit(EXIT_FAILURE); |
140 | } | 169 | } |
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 4088b816a3ee..6a6432a20a1d 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <fcntl.h> | 43 | #include <fcntl.h> |
44 | #include <dirent.h> | 44 | #include <dirent.h> |
45 | #include <net/if.h> | 45 | #include <net/if.h> |
46 | #include <getopt.h> | ||
46 | 47 | ||
47 | /* | 48 | /* |
48 | * KVP protocol: The user mode component first registers with the | 49 | * KVP protocol: The user mode component first registers with the |
@@ -1417,7 +1418,15 @@ netlink_send(int fd, struct cn_msg *msg) | |||
1417 | return sendmsg(fd, &message, 0); | 1418 | return sendmsg(fd, &message, 0); |
1418 | } | 1419 | } |
1419 | 1420 | ||
1420 | int main(void) | 1421 | void print_usage(char *argv[]) |
1422 | { | ||
1423 | fprintf(stderr, "Usage: %s [options]\n" | ||
1424 | "Options are:\n" | ||
1425 | " -n, --no-daemon stay in foreground, don't daemonize\n" | ||
1426 | " -h, --help print this help\n", argv[0]); | ||
1427 | } | ||
1428 | |||
1429 | int main(int argc, char *argv[]) | ||
1421 | { | 1430 | { |
1422 | int fd, len, nl_group; | 1431 | int fd, len, nl_group; |
1423 | int error; | 1432 | int error; |
@@ -1435,9 +1444,30 @@ int main(void) | |||
1435 | struct hv_kvp_ipaddr_value *kvp_ip_val; | 1444 | struct hv_kvp_ipaddr_value *kvp_ip_val; |
1436 | char *kvp_recv_buffer; | 1445 | char *kvp_recv_buffer; |
1437 | size_t kvp_recv_buffer_len; | 1446 | size_t kvp_recv_buffer_len; |
1447 | int daemonize = 1, long_index = 0, opt; | ||
1448 | |||
1449 | static struct option long_options[] = { | ||
1450 | {"help", no_argument, 0, 'h' }, | ||
1451 | {"no-daemon", no_argument, 0, 'n' }, | ||
1452 | {0, 0, 0, 0 } | ||
1453 | }; | ||
1454 | |||
1455 | while ((opt = getopt_long(argc, argv, "hn", long_options, | ||
1456 | &long_index)) != -1) { | ||
1457 | switch (opt) { | ||
1458 | case 'n': | ||
1459 | daemonize = 0; | ||
1460 | break; | ||
1461 | case 'h': | ||
1462 | default: | ||
1463 | print_usage(argv); | ||
1464 | exit(EXIT_FAILURE); | ||
1465 | } | ||
1466 | } | ||
1438 | 1467 | ||
1439 | if (daemon(1, 0)) | 1468 | if (daemonize && daemon(1, 0)) |
1440 | return 1; | 1469 | return 1; |
1470 | |||
1441 | openlog("KVP", 0, LOG_USER); | 1471 | openlog("KVP", 0, LOG_USER); |
1442 | syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); | 1472 | syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); |
1443 | 1473 | ||
@@ -1529,8 +1559,15 @@ int main(void) | |||
1529 | addr_p, &addr_l); | 1559 | addr_p, &addr_l); |
1530 | 1560 | ||
1531 | if (len < 0) { | 1561 | if (len < 0) { |
1562 | int saved_errno = errno; | ||
1532 | syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s", | 1563 | syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s", |
1533 | addr.nl_pid, errno, strerror(errno)); | 1564 | addr.nl_pid, errno, strerror(errno)); |
1565 | |||
1566 | if (saved_errno == ENOBUFS) { | ||
1567 | syslog(LOG_ERR, "receive error: ignored"); | ||
1568 | continue; | ||
1569 | } | ||
1570 | |||
1534 | close(fd); | 1571 | close(fd); |
1535 | return -1; | 1572 | return -1; |
1536 | } | 1573 | } |
@@ -1733,8 +1770,15 @@ kvp_done: | |||
1733 | 1770 | ||
1734 | len = netlink_send(fd, incoming_cn_msg); | 1771 | len = netlink_send(fd, incoming_cn_msg); |
1735 | if (len < 0) { | 1772 | if (len < 0) { |
1773 | int saved_errno = errno; | ||
1736 | syslog(LOG_ERR, "net_link send failed; error: %d %s", errno, | 1774 | syslog(LOG_ERR, "net_link send failed; error: %d %s", errno, |
1737 | strerror(errno)); | 1775 | strerror(errno)); |
1776 | |||
1777 | if (saved_errno == ENOMEM || saved_errno == ENOBUFS) { | ||
1778 | syslog(LOG_ERR, "send error: ignored"); | ||
1779 | continue; | ||
1780 | } | ||
1781 | |||
1738 | exit(EXIT_FAILURE); | 1782 | exit(EXIT_FAILURE); |
1739 | } | 1783 | } |
1740 | } | 1784 | } |
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c index 6a213b8cd7b9..5e63f70bd956 100644 --- a/tools/hv/hv_vss_daemon.c +++ b/tools/hv/hv_vss_daemon.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/hyperv.h> | 36 | #include <linux/hyperv.h> |
37 | #include <linux/netlink.h> | 37 | #include <linux/netlink.h> |
38 | #include <syslog.h> | 38 | #include <syslog.h> |
39 | #include <getopt.h> | ||
39 | 40 | ||
40 | static struct sockaddr_nl addr; | 41 | static struct sockaddr_nl addr; |
41 | 42 | ||
@@ -44,35 +45,51 @@ static struct sockaddr_nl addr; | |||
44 | #endif | 45 | #endif |
45 | 46 | ||
46 | 47 | ||
47 | static int vss_do_freeze(char *dir, unsigned int cmd, char *fs_op) | 48 | /* Don't use syslog() in the function since that can cause write to disk */ |
49 | static int vss_do_freeze(char *dir, unsigned int cmd) | ||
48 | { | 50 | { |
49 | int ret, fd = open(dir, O_RDONLY); | 51 | int ret, fd = open(dir, O_RDONLY); |
50 | 52 | ||
51 | if (fd < 0) | 53 | if (fd < 0) |
52 | return 1; | 54 | return 1; |
55 | |||
53 | ret = ioctl(fd, cmd, 0); | 56 | ret = ioctl(fd, cmd, 0); |
54 | syslog(LOG_INFO, "VSS: %s of %s: %s\n", fs_op, dir, strerror(errno)); | 57 | |
58 | /* | ||
59 | * If a partition is mounted more than once, only the first | ||
60 | * FREEZE/THAW can succeed and the later ones will get | ||
61 | * EBUSY/EINVAL respectively: there could be 2 cases: | ||
62 | * 1) a user may mount the same partition to differnt directories | ||
63 | * by mistake or on purpose; | ||
64 | * 2) The subvolume of btrfs appears to have the same partition | ||
65 | * mounted more than once. | ||
66 | */ | ||
67 | if (ret) { | ||
68 | if ((cmd == FIFREEZE && errno == EBUSY) || | ||
69 | (cmd == FITHAW && errno == EINVAL)) { | ||
70 | close(fd); | ||
71 | return 0; | ||
72 | } | ||
73 | } | ||
74 | |||
55 | close(fd); | 75 | close(fd); |
56 | return !!ret; | 76 | return !!ret; |
57 | } | 77 | } |
58 | 78 | ||
59 | static int vss_operate(int operation) | 79 | static int vss_operate(int operation) |
60 | { | 80 | { |
61 | char *fs_op; | ||
62 | char match[] = "/dev/"; | 81 | char match[] = "/dev/"; |
63 | FILE *mounts; | 82 | FILE *mounts; |
64 | struct mntent *ent; | 83 | struct mntent *ent; |
65 | unsigned int cmd; | 84 | unsigned int cmd; |
66 | int error = 0, root_seen = 0; | 85 | int error = 0, root_seen = 0, save_errno = 0; |
67 | 86 | ||
68 | switch (operation) { | 87 | switch (operation) { |
69 | case VSS_OP_FREEZE: | 88 | case VSS_OP_FREEZE: |
70 | cmd = FIFREEZE; | 89 | cmd = FIFREEZE; |
71 | fs_op = "freeze"; | ||
72 | break; | 90 | break; |
73 | case VSS_OP_THAW: | 91 | case VSS_OP_THAW: |
74 | cmd = FITHAW; | 92 | cmd = FITHAW; |
75 | fs_op = "thaw"; | ||
76 | break; | 93 | break; |
77 | default: | 94 | default: |
78 | return -1; | 95 | return -1; |
@@ -85,7 +102,7 @@ static int vss_operate(int operation) | |||
85 | while ((ent = getmntent(mounts))) { | 102 | while ((ent = getmntent(mounts))) { |
86 | if (strncmp(ent->mnt_fsname, match, strlen(match))) | 103 | if (strncmp(ent->mnt_fsname, match, strlen(match))) |
87 | continue; | 104 | continue; |
88 | if (strcmp(ent->mnt_type, "iso9660") == 0) | 105 | if (hasmntopt(ent, MNTOPT_RO) != NULL) |
89 | continue; | 106 | continue; |
90 | if (strcmp(ent->mnt_type, "vfat") == 0) | 107 | if (strcmp(ent->mnt_type, "vfat") == 0) |
91 | continue; | 108 | continue; |
@@ -93,14 +110,30 @@ static int vss_operate(int operation) | |||
93 | root_seen = 1; | 110 | root_seen = 1; |
94 | continue; | 111 | continue; |
95 | } | 112 | } |
96 | error |= vss_do_freeze(ent->mnt_dir, cmd, fs_op); | 113 | error |= vss_do_freeze(ent->mnt_dir, cmd); |
114 | if (error && operation == VSS_OP_FREEZE) | ||
115 | goto err; | ||
97 | } | 116 | } |
98 | endmntent(mounts); | ||
99 | 117 | ||
100 | if (root_seen) { | 118 | if (root_seen) { |
101 | error |= vss_do_freeze("/", cmd, fs_op); | 119 | error |= vss_do_freeze("/", cmd); |
120 | if (error && operation == VSS_OP_FREEZE) | ||
121 | goto err; | ||
102 | } | 122 | } |
103 | 123 | ||
124 | goto out; | ||
125 | err: | ||
126 | save_errno = errno; | ||
127 | vss_operate(VSS_OP_THAW); | ||
128 | /* Call syslog after we thaw all filesystems */ | ||
129 | if (ent) | ||
130 | syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s", | ||
131 | ent->mnt_dir, save_errno, strerror(save_errno)); | ||
132 | else | ||
133 | syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno, | ||
134 | strerror(save_errno)); | ||
135 | out: | ||
136 | endmntent(mounts); | ||
104 | return error; | 137 | return error; |
105 | } | 138 | } |
106 | 139 | ||
@@ -131,7 +164,15 @@ static int netlink_send(int fd, struct cn_msg *msg) | |||
131 | return sendmsg(fd, &message, 0); | 164 | return sendmsg(fd, &message, 0); |
132 | } | 165 | } |
133 | 166 | ||
134 | int main(void) | 167 | void print_usage(char *argv[]) |
168 | { | ||
169 | fprintf(stderr, "Usage: %s [options]\n" | ||
170 | "Options are:\n" | ||
171 | " -n, --no-daemon stay in foreground, don't daemonize\n" | ||
172 | " -h, --help print this help\n", argv[0]); | ||
173 | } | ||
174 | |||
175 | int main(int argc, char *argv[]) | ||
135 | { | 176 | { |
136 | int fd, len, nl_group; | 177 | int fd, len, nl_group; |
137 | int error; | 178 | int error; |
@@ -143,8 +184,28 @@ int main(void) | |||
143 | struct hv_vss_msg *vss_msg; | 184 | struct hv_vss_msg *vss_msg; |
144 | char *vss_recv_buffer; | 185 | char *vss_recv_buffer; |
145 | size_t vss_recv_buffer_len; | 186 | size_t vss_recv_buffer_len; |
187 | int daemonize = 1, long_index = 0, opt; | ||
188 | |||
189 | static struct option long_options[] = { | ||
190 | {"help", no_argument, 0, 'h' }, | ||
191 | {"no-daemon", no_argument, 0, 'n' }, | ||
192 | {0, 0, 0, 0 } | ||
193 | }; | ||
194 | |||
195 | while ((opt = getopt_long(argc, argv, "hn", long_options, | ||
196 | &long_index)) != -1) { | ||
197 | switch (opt) { | ||
198 | case 'n': | ||
199 | daemonize = 0; | ||
200 | break; | ||
201 | case 'h': | ||
202 | default: | ||
203 | print_usage(argv); | ||
204 | exit(EXIT_FAILURE); | ||
205 | } | ||
206 | } | ||
146 | 207 | ||
147 | if (daemon(1, 0)) | 208 | if (daemonize && daemon(1, 0)) |
148 | return 1; | 209 | return 1; |
149 | 210 | ||
150 | openlog("Hyper-V VSS", 0, LOG_USER); | 211 | openlog("Hyper-V VSS", 0, LOG_USER); |
@@ -249,8 +310,16 @@ int main(void) | |||
249 | case VSS_OP_FREEZE: | 310 | case VSS_OP_FREEZE: |
250 | case VSS_OP_THAW: | 311 | case VSS_OP_THAW: |
251 | error = vss_operate(op); | 312 | error = vss_operate(op); |
252 | if (error) | 313 | syslog(LOG_INFO, "VSS: op=%s: %s\n", |
314 | op == VSS_OP_FREEZE ? "FREEZE" : "THAW", | ||
315 | error ? "failed" : "succeeded"); | ||
316 | |||
317 | if (error) { | ||
253 | error = HV_E_FAIL; | 318 | error = HV_E_FAIL; |
319 | syslog(LOG_ERR, "op=%d failed!", op); | ||
320 | syslog(LOG_ERR, "report it with these files:"); | ||
321 | syslog(LOG_ERR, "/etc/fstab and /proc/mounts"); | ||
322 | } | ||
254 | break; | 323 | break; |
255 | default: | 324 | default: |
256 | syslog(LOG_ERR, "Illegal op:%d\n", op); | 325 | syslog(LOG_ERR, "Illegal op:%d\n", op); |