Changeset 16099 in vbox for trunk/src/VBox/Additions/linux/sharedfolders
- Timestamp:
- Jan 20, 2009 8:42:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
r14598 r16099 57 57 } while (0) 58 58 59 struct opts { 59 struct opts 60 { 60 61 int uid; 61 62 int gid; … … 106 107 long long int val = strtoll (s, &endptr, base); 107 108 108 if (val < INT_MIN || val > INT_MAX || endptr < s + size) { 109 if (val < INT_MIN || val > INT_MAX || endptr < s + size) 110 { 109 111 errno = ERANGE; 110 112 panic_err ("could not convert %.*s to integer, result = %d", … … 139 141 HONOSUID, 140 142 HOSUID, 141 HOREMOUNT 143 HOREMOUNT, 144 HONOAUTO 142 145 } handler_opt; 143 struct { 146 struct 147 { 144 148 const char *name; 145 149 handler_opt opt; 146 150 int has_arg; 147 151 const char *desc; 148 } handlers[] = { 152 } handlers[] 153 = 154 { 149 155 {"rw", HORW, 0, "mount read write (default)"}, 150 156 {"ro", HORO, 0, "mount read only"}, … … 166 172 {"suid", HOSUID, 0, 0 }, 167 173 {"remount", HOREMOUNT, 0, 0 }, 174 {"noauto", HONOAUTO, 0, 0 }, 168 175 {NULL, 0, 0, NULL} 169 176 }, *handler; 170 177 171 while (next) { 178 while (next) 179 { 172 180 const char *val; 173 181 size_t key_len, val_len; … … 175 183 s = next; 176 184 next = strchr (s, ','); 177 if (!next) { 185 if (!next) 186 { 178 187 len = strlen (s); 179 188 } 180 else { 189 else 190 { 181 191 len = next - s; 182 192 next += 1; 183 if (!*next) {193 if (!*next) 184 194 next = 0; 185 }186 195 } 187 196 188 197 val = NULL; 189 198 val_len = 0; 190 for (key_len = 0; key_len < len; ++key_len) { 191 if (s[key_len] == '=') { 192 if (key_len + 1 < len) { 199 for (key_len = 0; key_len < len; ++key_len) 200 { 201 if (s[key_len] == '=') 202 { 203 if (key_len + 1 < len) 204 { 193 205 val = s + key_len + 1; 194 206 val_len = len - key_len - 1; … … 198 210 } 199 211 200 for (handler = handlers; handler->name; ++handler) { 212 for (handler = handlers; handler->name; ++handler) 213 { 201 214 size_t j; 202 215 for (j = 0; j < key_len && handler->name[j] == s[j]; ++j) 203 216 ; 204 217 205 if (j == key_len && !handler->name[j]) { 206 if (handler->has_arg) { 207 if (!(val && *val)) { 218 if (j == key_len && !handler->name[j]) 219 { 220 if (handler->has_arg) 221 { 222 if (!(val && *val)) 223 { 208 224 panic ("%.*s requires an argument (i.e. %.*s=<arg>)\n", 209 225 (int)len, s, (int)len, s); … … 265 281 break; 266 282 case HOIOCHARSET: 267 if (val_len + 1 > sizeof (opts->nls_name)) { 283 if (val_len + 1 > sizeof (opts->nls_name)) 284 { 268 285 panic ("iocharset name too long\n"); 269 286 } … … 273 290 case HOCONVERTCP: 274 291 opts->convertcp = malloc (val_len + 1); 275 if (!opts->convertcp) { 292 if (!opts->convertcp) 293 { 276 294 panic_err ("could not allocate memory"); 277 295 } … … 279 297 opts->convertcp[val_len] = 0; 280 298 break; 299 case HONOAUTO: 300 break; 281 301 } 282 302 break; … … 285 305 } 286 306 287 if (!handler->name) { 307 if (!handler->name) 308 { 288 309 fprintf (stderr, "unknown mount option `%.*s'\n", (int)len, s); 289 310 fprintf (stderr, "valid options:\n"); 290 311 291 for (handler = handlers; handler->name; ++handler) { 312 for (handler = handlers; handler->name; ++handler) 313 { 292 314 if (handler->desc) 293 315 fprintf (stderr, " %-10s%s %s\n", handler->name, … … 374 396 375 397 cd = iconv_open ("UTF-8", in_codeset); 376 if (cd == (iconv_t) -1) { 398 if (cd == (iconv_t) -1) 399 { 377 400 panic_err ("could not convert share name, iconv_open `%s' failed", 378 401 in_codeset); 379 402 } 380 403 381 while (ib) { 404 while (ib) 405 { 382 406 size_t c = iconv (cd, &i, &ib, &o, &ob); 383 if (c == (size_t) -1) { 407 if (c == (size_t) -1) 408 { 384 409 panic_err ("could not convert share name(%s) at %d", 385 410 host_name, (int)(strlen (host_name) - ib)); … … 469 494 CT_ASSERT(sizeof(gid_t) == sizeof(int)); 470 495 471 while ((c = getopt (argc, argv, "rwno:h")) != -1) { 472 switch (c) { 496 while ((c = getopt (argc, argv, "rwno:h")) != -1) 497 { 498 switch (c) 499 { 473 500 default: 474 501 fprintf (stderr, "unknown option `%c:%#x'\n", c, c);
Note:
See TracChangeset
for help on using the changeset viewer.