nxt_fs.c (1489:4a3ec07f4b19) nxt_fs.c (1580:f1aefdf995d4)
1/*
2 * Copyright (C) NGINX, Inc.
3 */
4
5#include <nxt_main.h>
6
7#if (NXT_HAVE_FREEBSD_NMOUNT)
8#include <sys/param.h>

--- 26 unchanged lines hidden (view full) ---

35}
36
37
38#elif (NXT_HAVE_FREEBSD_NMOUNT)
39
40nxt_int_t
41nxt_fs_mount(nxt_task_t *task, nxt_fs_mount_t *mnt)
42{
1/*
2 * Copyright (C) NGINX, Inc.
3 */
4
5#include <nxt_main.h>
6
7#if (NXT_HAVE_FREEBSD_NMOUNT)
8#include <sys/param.h>

--- 26 unchanged lines hidden (view full) ---

35}
36
37
38#elif (NXT_HAVE_FREEBSD_NMOUNT)
39
40nxt_int_t
41nxt_fs_mount(nxt_task_t *task, nxt_fs_mount_t *mnt)
42{
43 u_char *data, *p, *end;
44 size_t iovlen;
45 nxt_int_t ret;
43 const char *fstype;
46 const char *fstype;
44 uint8_t is_bind, is_proc;
45 struct iovec iov[8];
47 struct iovec iov[128];
46 char errmsg[256];
47
48 char errmsg[256];
49
48 is_bind = nxt_strncmp(mnt->fstype, "bind", 4) == 0;
49 is_proc = nxt_strncmp(mnt->fstype, "proc", 4) == 0;
50 if (nxt_strncmp(mnt->fstype, "bind", 4) == 0) {
51 fstype = "nullfs";
50
52
51 if (nxt_slow_path(!is_bind && !is_proc)) {
52 nxt_alert(task, "mount type \"%s\" not implemented.", mnt->fstype);
53 return NXT_ERROR;
54 }
53 } else if (nxt_strncmp(mnt->fstype, "proc", 4) == 0) {
54 fstype = "procfs";
55
55
56 if (is_bind) {
57 fstype = "nullfs";
56 } else if (nxt_strncmp(mnt->fstype, "tmpfs", 5) == 0) {
57 fstype = "tmpfs";
58
59 } else {
58
59 } else {
60 fstype = "procfs";
60 nxt_alert(task, "mount type \"%s\" not implemented.", mnt->fstype);
61 return NXT_ERROR;
61 }
62
63 iov[0].iov_base = (void *) "fstype";
64 iov[0].iov_len = 7;
65 iov[1].iov_base = (void *) fstype;
62 }
63
64 iov[0].iov_base = (void *) "fstype";
65 iov[0].iov_len = 7;
66 iov[1].iov_base = (void *) fstype;
66 iov[1].iov_len = strlen(fstype) + 1;
67 iov[1].iov_len = nxt_strlen(fstype) + 1;
67 iov[2].iov_base = (void *) "fspath";
68 iov[2].iov_len = 7;
69 iov[3].iov_base = (void *) mnt->dst;
70 iov[3].iov_len = nxt_strlen(mnt->dst) + 1;
71 iov[4].iov_base = (void *) "target";
72 iov[4].iov_len = 7;
73 iov[5].iov_base = (void *) mnt->src;
74 iov[5].iov_len = nxt_strlen(mnt->src) + 1;
75 iov[6].iov_base = (void *) "errmsg";
76 iov[6].iov_len = 7;
77 iov[7].iov_base = (void *) errmsg;
78 iov[7].iov_len = sizeof(errmsg);
79
68 iov[2].iov_base = (void *) "fspath";
69 iov[2].iov_len = 7;
70 iov[3].iov_base = (void *) mnt->dst;
71 iov[3].iov_len = nxt_strlen(mnt->dst) + 1;
72 iov[4].iov_base = (void *) "target";
73 iov[4].iov_len = 7;
74 iov[5].iov_base = (void *) mnt->src;
75 iov[5].iov_len = nxt_strlen(mnt->src) + 1;
76 iov[6].iov_base = (void *) "errmsg";
77 iov[6].iov_len = 7;
78 iov[7].iov_base = (void *) errmsg;
79 iov[7].iov_len = sizeof(errmsg);
80
80 if (nxt_slow_path(nmount(iov, 8, 0) < 0)) {
81 nxt_alert(task, "nmount(%p, 8, 0) %s", errmsg);
82 return NXT_ERROR;
81 iovlen = 8;
82
83 data = NULL;
84
85 if (mnt->data != NULL) {
86 data = (u_char *) nxt_strdup(mnt->data);
87 if (nxt_slow_path(data == NULL)) {
88 return NXT_ERROR;
89 }
90
91 end = data - 1;
92
93 do {
94 p = end + 1;
95 end = nxt_strchr(p, '=');
96 if (end == NULL) {
97 break;
98 }
99
100 *end = '\0';
101
102 iov[iovlen++].iov_base = (void *) p;
103 iov[iovlen++].iov_len = (end - p) + 1;
104
105 p = end + 1;
106
107 end = nxt_strchr(p, ',');
108 if (end != NULL) {
109 *end = '\0';
110 }
111
112 iov[iovlen++].iov_base = (void *) p;
113 iov[iovlen++].iov_len = nxt_strlen(p) + 1;
114
115 } while (end != NULL && nxt_nitems(iov) > (iovlen + 2));
83 }
84
116 }
117
85 return NXT_OK;
118 ret = NXT_OK;
119
120 if (nxt_slow_path(nmount(iov, iovlen, 0) < 0)) {
121 nxt_alert(task, "nmount(%p, %d, 0) %s", iov, iovlen, errmsg);
122 ret = NXT_ERROR;
123 }
124
125 if (data != NULL) {
126 free(data);
127 }
128
129 return ret;
86}
87
88#endif
89
90
91#if (NXT_HAVE_LINUX_UMOUNT2)
92
93void

--- 70 unchanged lines hidden ---
130}
131
132#endif
133
134
135#if (NXT_HAVE_LINUX_UMOUNT2)
136
137void

--- 70 unchanged lines hidden ---