libnfs_basic.c (11340:95eb5855f4f2) libnfs_basic.c (11291:80bdcd03e626)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

92 * host1:/path1 host2:/path2 host3:/path3
93 * and convert it to an fs_locations4 for the deref routine.
94 */
95static fs_locations4 *
96get_fs_locations(char *buf)
97{
98 fs_locations4 *result = NULL;
99 fs_location4 *fsl_array;
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

92 * host1:/path1 host2:/path2 host3:/path3
93 * and convert it to an fs_locations4 for the deref routine.
94 */
95static fs_locations4 *
96get_fs_locations(char *buf)
97{
98 fs_locations4 *result = NULL;
99 fs_location4 *fsl_array;
100 int i, gothost;
101 int fsl_count = 0, escape = 0, delimiter = 0;
100 int i = 0, fsl_count = 0, gothost = 0, escape = 0, delimiter = 0;
102 int len;
103 char *p, *sp, *dp, buf2[SYMLINK_MAX];
104
105 if (buf == NULL)
106 return (NULL);
107#ifdef DEBUG
108 printf("get_fs_locations: input %s\n", buf);
109#endif

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

141 fsl_count++;
142#ifdef DEBUG
143 printf("get_fs_locations: fsl_count %d\n", fsl_count);
144#endif
145 if (fsl_count == 0)
146 goto out;
147
148 /* Alloc space for everything */
101 int len;
102 char *p, *sp, *dp, buf2[SYMLINK_MAX];
103
104 if (buf == NULL)
105 return (NULL);
106#ifdef DEBUG
107 printf("get_fs_locations: input %s\n", buf);
108#endif

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

140 fsl_count++;
141#ifdef DEBUG
142 printf("get_fs_locations: fsl_count %d\n", fsl_count);
143#endif
144 if (fsl_count == 0)
145 goto out;
146
147 /* Alloc space for everything */
149 result = calloc(1, sizeof (fs_locations4));
148 result = malloc(sizeof (fs_locations4));
150 if (result == NULL)
151 goto out;
149 if (result == NULL)
150 goto out;
152 fsl_array = calloc(fsl_count, sizeof (fs_location4));
151 fsl_array = malloc(fsl_count * sizeof (fs_location4));
153 if (fsl_array == NULL) {
154 free(result);
155 result = NULL;
156 goto out;
157 }
158 result->locations.locations_len = fsl_count;
159 result->locations.locations_val = fsl_array;
160 result->fs_root.pathname4_len = 0;
161 result->fs_root.pathname4_val = NULL;
162
163 /*
164 * Copy input, removing escapes from host:/path/to/my\ files
165 */
166 sp = buf;
167 dp = buf2;
168 bzero(buf2, sizeof (buf2));
169
152 if (fsl_array == NULL) {
153 free(result);
154 result = NULL;
155 goto out;
156 }
157 result->locations.locations_len = fsl_count;
158 result->locations.locations_val = fsl_array;
159 result->fs_root.pathname4_len = 0;
160 result->fs_root.pathname4_val = NULL;
161
162 /*
163 * Copy input, removing escapes from host:/path/to/my\ files
164 */
165 sp = buf;
166 dp = buf2;
167 bzero(buf2, sizeof (buf2));
168
170 i = gothost = 0;
171 while ((sp && *sp && (sp - buf < len)) || gothost) {
172
173 if (!gothost) {
174 /* Drop leading spaces */
175 if (*sp == ' ') {
176 sp++;
177 continue;
178 }
179
180 /* Look for the rightmost colon for host */
181 p = strrchr(sp, ':');
182 if (!p) {
183#ifdef DEBUG
184 printf("get_fs_locations: skipping %s\n", sp);
185#endif
169 while ((sp && *sp && (sp - buf < len)) || gothost) {
170
171 if (!gothost) {
172 /* Drop leading spaces */
173 if (*sp == ' ') {
174 sp++;
175 continue;
176 }
177
178 /* Look for the rightmost colon for host */
179 p = strrchr(sp, ':');
180 if (!p) {
181#ifdef DEBUG
182 printf("get_fs_locations: skipping %s\n", sp);
183#endif
186 fsl_count--;
187 sp += strlen(sp) + 1;
188 } else {
189 bcopy(sp, dp, p - sp);
190 sp = p + 1;
191#ifdef DEBUG
192 printf("get_fs_locations: host %s\n", buf2);
193#endif
194 fsl_array[i].server.server_len = 1;

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

232 /* Skip a single escape character */
233 if (*sp == '\\')
234 sp++;
235
236 /* Plain char, just copy it */
237 *dp++ = *sp++;
238 }
239
184 sp += strlen(sp) + 1;
185 } else {
186 bcopy(sp, dp, p - sp);
187 sp = p + 1;
188#ifdef DEBUG
189 printf("get_fs_locations: host %s\n", buf2);
190#endif
191 fsl_array[i].server.server_len = 1;

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

229 /* Skip a single escape character */
230 if (*sp == '\\')
231 sp++;
232
233 /* Plain char, just copy it */
234 *dp++ = *sp++;
235 }
236
240 /*
241 * If we're still expecting a path name, we don't have a
242 * server:/path pair and should discard the server and
243 * note that we got fewer locations than expected.
244 */
245 if (gothost) {
246 fsl_count--;
247 free(fsl_array[i].server.server_val);
248 fsl_array[i].server.server_val = NULL;
249 fsl_array[i].server.server_len = 0;
250 }
251
252 /*
253 * If we have zero entries, we never got a whole server:/path
254 * pair, and so cannot have anything else allocated.
255 */
256 if (fsl_count <= 0) {
257 free(result);
258 free(fsl_array);
259 return (NULL);
260 }
261
262 /*
263 * Make sure we reflect the right number of locations.
264 */
265 if (fsl_count < result->locations.locations_len)
266 result->locations.locations_len = fsl_count;
267
268out:
269 return (result);
270}
271
272/*
273 * Deref function for nfs-basic service type returns an fs_locations4.
274 */
275int

--- 66 unchanged lines hidden ---
237out:
238 return (result);
239}
240
241/*
242 * Deref function for nfs-basic service type returns an fs_locations4.
243 */
244int

--- 66 unchanged lines hidden ---