- Timestamp:
- Aug 20, 2008 9:39:18 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 35028
- Location:
- trunk/src/VBox/Additions/linux/sharedfolders
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/sharedfolders/dirops.c
r8155 r11507 118 118 1 end reached 119 119 -errno some form of error*/ 120 int120 static int 121 121 sf_getdent (struct file *dir, char d_name[NAME_MAX]) 122 122 { -
trunk/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c
r8155 r11507 58 58 59 59 struct opts { 60 int uid; 61 int gid; 62 int ttl; 63 int ronly; 64 int noexec; 65 int nodev; 66 int nosuid; 67 int remount; 60 int uid; 61 int gid; 62 int ttl; 63 int dmode; 64 int fmode; 65 int dmask; 66 int fmask; 67 int ronly; 68 int noexec; 69 int nodev; 70 int nosuid; 71 int remount; 68 72 char nls_name[MAX_NLS_NAME]; 69 73 char *convertcp; … … 97 101 98 102 static int 99 safe_atoi (const char *s, size_t size )103 safe_atoi (const char *s, size_t size, int base) 100 104 { 101 105 char *endptr; 102 long long int val = strtoll (s, &endptr, 10);106 long long int val = strtoll (s, &endptr, base); 103 107 104 108 if (val < INT_MIN || val > INT_MAX || endptr < s + size) { … … 122 126 HOGID, 123 127 HOTTL, 128 HODMODE, 129 HOFMODE, 130 HOUMASK, 131 HODMASK, 132 HOFMASK, 124 133 HOIOCHARSET, 125 134 HOCONVERTCP, … … 145 154 {"iocharset", HOIOCHARSET, 1, "i/o charset (default utf8)"}, 146 155 {"convertcp", HOCONVERTCP, 1, "convert share name from given charset to utf8"}, 156 {"dmode", HODMODE, 1, "mode of all directories"}, 157 {"fmode", HOFMODE, 1, "mode of all regular files"}, 158 {"umask", HOUMASK, 1, "umask of directories and regular files"}, 159 {"dmask", HODMASK, 1, "umask of directories"}, 160 {"fmask", HOFMASK, 1, "umask of regular files"}, 147 161 {"noexec", HONOEXEC, 0, 0 }, /* don't document these options directly here */ 148 162 {"exec", HOEXEC, 0, 0 }, /* as they are well known and described in the */ … … 227 241 break; 228 242 case HOUID: 229 opts->uid = safe_atoi (val, val_len );243 opts->uid = safe_atoi (val, val_len, 10); 230 244 break; 231 245 case HOGID: 232 opts->gid = safe_atoi (val, val_len );246 opts->gid = safe_atoi (val, val_len, 10); 233 247 break; 234 248 case HOTTL: 235 opts->ttl = safe_atoi (val, val_len); 249 opts->ttl = safe_atoi (val, val_len, 10); 250 break; 251 case HODMODE: 252 opts->dmode = safe_atoi (val, val_len, 8); 253 break; 254 case HOFMODE: 255 opts->fmode = safe_atoi (val, val_len, 8); 256 break; 257 case HOUMASK: 258 opts->dmask = opts->fmask = safe_atoi (val, val_len, 8); 259 break; 260 case HODMASK: 261 opts->dmask = safe_atoi (val, val_len, 8); 262 break; 263 case HOFMASK: 264 opts->fmask = safe_atoi (val, val_len, 8); 236 265 break; 237 266 case HOIOCHARSET: … … 336 365 337 366 static void 338 convertcp (char *in_codeset, char *host_name, struct vbsf_mount_info *info)367 convertcp (char *in_codeset, char *host_name, struct vbsf_mount_info_new *info) 339 368 { 340 369 char *i = host_name; … … 373 402 " -w mount the shared folder writably (the default)\n" 374 403 " -r mount the shared folder read-only\n" 375 " -n do not add information about the folder to the mtab file\n"404 " -n do not create an mtab entry\n" 376 405 " -o OPTION[,OPTION...] use the mount options specified\n" 377 406 "\n", name); 378 407 printf("Available mount options are:\n" 379 "\n"380 408 " rw mount writably (the default)\n" 381 409 " ro mount read only\n" 382 410 " uid=UID set the default file owner user id to UID\n" 383 411 " gid=GID set the default file owner group id to GID\n" 384 " ttl=TTL set the \"time to live\" to TID for the dentry\n" 385 " iocharset CHARSET use the character set CHARSET for i/o operations (default utf8)\n" 386 " convertcp CHARSET convert the shared folder name from the character set CHARSET to utf8\n"); 412 " ttl=TTL set the \"time to live\" to TID for the dentry\n"); 413 printf(" dmode=MODE override the mode of all directories to (octal) MODE\n" 414 " fmode=MODE override the mode of all regular files to (octal) MODE\n" 415 " umask=UMASK set the umask to (octal) UMASK\n"); 416 printf(" dmask=UMASK set the umask applied to directories only\n" 417 " fmask=UMASK set the umask applied to regular files only\n" 418 " iocharset CHARSET use the character set CHARSET for I/O operations\n" 419 " (default set is utf8)\n" 420 " convertcp CHARSET convert the folder name from CHARSET to utf8\n" 421 "\n"); 387 422 printf("Less common used options:\n" 388 423 " noexec,exec,nodev,dev,nosuid,suid\n"); … … 399 434 char *host_name; 400 435 char *mount_point; 401 struct vbsf_mount_info mntinf; 402 struct opts opts = { 436 struct vbsf_mount_info_new mntinf; 437 struct opts opts = 438 { 403 439 0, /* uid */ 404 440 0, /* gid */ 405 441 0, /* ttl */ 442 ~0, /* dmode */ 443 ~0, /* fmode*/ 444 0, /* dmask */ 445 0, /* fmask */ 406 446 0, /* ronly */ 407 447 0, /* noexec */ … … 413 453 }; 414 454 455 mntinf.nullchar = '\0'; 456 mntinf.signature[0] = VBSF_MOUNT_SIGNATURE_BYTE_0; 457 mntinf.signature[1] = VBSF_MOUNT_SIGNATURE_BYTE_1; 458 mntinf.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2; 459 415 460 if (getuid ()) 416 461 panic ("Only root can mount shared folders from the host.\n"); … … 476 521 flags |= MS_NODEV; 477 522 478 mntinf.uid = opts.uid; 479 mntinf.gid = opts.gid; 480 mntinf.ttl = opts.ttl; 523 mntinf.uid = opts.uid; 524 mntinf.gid = opts.gid; 525 mntinf.ttl = opts.ttl; 526 mntinf.dmode = opts.dmode; 527 mntinf.fmode = opts.fmode; 528 mntinf.dmask = opts.dmask; 529 mntinf.fmask = opts.fmask; 481 530 482 531 err = mount (NULL, mount_point, "vboxsf", flags, &mntinf); 532 if (err == -1 && errno == EPROTO) 533 { 534 /* New mount tool with old vboxsf module? Try again using the old 535 * vbsf_mount_info_old structure. */ 536 struct vbsf_mount_info_old mntinf_old; 537 memcpy(&mntinf_old.name, &mntinf.name, MAX_HOST_NAME); 538 memcpy(&mntinf_old.nls_name, mntinf.nls_name, MAX_NLS_NAME); 539 mntinf_old.uid = mntinf.uid; 540 mntinf_old.gid = mntinf.gid; 541 mntinf_old.ttl = mntinf.ttl; 542 err = mount (NULL, mount_point, "vboxsf", flags, &mntinf_old); 543 } 483 544 if (err) 484 545 panic_err ("%s: mounting failed with the error", argv[0]); -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r9179 r11507 63 63 } 64 64 65 /** XXX Check read permission accoring to inode->i_mode! */ 66 65 67 if (!size) { 66 68 return 0; … … 133 135 } 134 136 137 /** XXX Check write permission accoring to inode->i_mode! */ 138 135 139 if (!size) { 136 140 return 0; … … 139 143 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 140 144 if (!tmp) { 141 LogRelFunc(("could not allocate bounce buffer memory %d \n", CHUNK_SIZE));145 LogRelFunc(("could not allocate bounce buffer memory %d bytes\n", CHUNK_SIZE)); 142 146 return -ENOMEM; 143 147 } -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r8155 r11507 111 111 112 112 if (is_dir) { 113 inode->i_mode = S_IFDIR | mode; 114 inode->i_op = &sf_dir_iops; 115 inode->i_fop = &sf_dir_fops; 113 inode->i_mode = sf_g->dmode != ~0 ? (sf_g->dmode & 0777) : mode; 114 inode->i_mode &= ~sf_g->dmask; 115 inode->i_mode |= S_IFDIR; 116 inode->i_op = &sf_dir_iops; 117 inode->i_fop = &sf_dir_fops; 116 118 /* XXX: this probably should be set to the number of entries 117 119 in the directory plus two (. ..) */ … … 119 121 } 120 122 else { 121 inode->i_mode = S_IFREG | mode; 122 inode->i_op = &sf_reg_iops; 123 inode->i_fop = &sf_reg_fops; 123 inode->i_mode = sf_g->fmode != ~0 ? (sf_g->fmode & 0x777): mode; 124 inode->i_mode &= ~sf_g->fmask; 125 inode->i_mode |= S_IFREG; 126 inode->i_op = &sf_reg_iops; 127 inode->i_fop = &sf_reg_fops; 124 128 inode->i_nlink = 1; 125 129 } -
trunk/src/VBox/Additions/linux/sharedfolders/vbsfmount.h
r8155 r11507 22 22 #define VBFS_MOUNT_H 23 23 24 #define MAX_HOST_NAME 25625 #define MAX_NLS_NAME 3224 #define MAX_HOST_NAME 256 25 #define MAX_NLS_NAME 32 26 26 27 27 /* Linux constraints the size of data mount argument to PAGE_SIZE - 1 */ 28 struct vbsf_mount_info { 28 struct vbsf_mount_info_old 29 { 29 30 char name[MAX_HOST_NAME]; 30 31 char nls_name[MAX_NLS_NAME]; 31 int uid; 32 int gid; 33 int ttl; 32 int uid; 33 int gid; 34 int ttl; 35 }; 36 37 #define VBSF_MOUNT_SIGNATURE_BYTE_0 '\377' 38 #define VBSF_MOUNT_SIGNATURE_BYTE_1 '\376' 39 #define VBSF_MOUNT_SIGNATURE_BYTE_2 '\375' 40 41 struct vbsf_mount_info_new 42 { 43 char nullchar; /* name cannot be '\0' -- we use this field 44 to distinguish between the old structure 45 and the new structure */ 46 char signature[3]; /* signature */ 47 int length; /* length of the whole structure */ 48 char name[MAX_HOST_NAME]; /* share name */ 49 char nls_name[MAX_NLS_NAME];/* name of an I/O charset */ 50 int uid; /* user ID for all entries, default 0=root */ 51 int gid; /* group ID for all entries, default 0=root */ 52 int ttl; /* time to live */ 53 int dmode; /* mode for directories if != 0xffffffff */ 54 int fmode; /* mode for regular files if != 0xffffffff */ 55 int dmask; /* umask applied to directories */ 56 int fmask; /* umask applied to regular files */ 34 57 }; 35 58 -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r8155 r11507 69 69 /* allocate global info, try to map host share */ 70 70 static int 71 sf_glob_alloc (struct vbsf_mount_info *info, struct sf_glob_info **sf_gp)71 sf_glob_alloc (struct vbsf_mount_info_new *info, struct sf_glob_info **sf_gp) 72 72 { 73 73 int err, rc; … … 82 82 LogRelFunc(("could not allocate memory for global info\n")); 83 83 goto fail0; 84 } 85 86 memset(sf_g, sizeof(*sf_g), 0); 87 88 if ( info->nullchar != '\0' 89 || info->signature[0] != VBSF_MOUNT_SIGNATURE_BYTE_0 90 || info->signature[1] != VBSF_MOUNT_SIGNATURE_BYTE_1 91 || info->signature[2] != VBSF_MOUNT_SIGNATURE_BYTE_2) 92 { 93 /* An old version of mount.vboxsf made the syscall. Translate the 94 * old parameters to the new structure. */ 95 struct vbsf_mount_info_old *info_old = (struct vbsf_mount_info_old *)info; 96 static struct vbsf_mount_info_new info_compat; 97 98 info = &info_compat; 99 memset(info, sizeof(*info), 0); 100 memcpy(&info->name, &info_old->name, MAX_HOST_NAME); 101 memcpy(&info->nls_name, &info_old->nls_name, MAX_NLS_NAME); 102 info->length = offsetof(struct vbsf_mount_info_new, dmode); 103 info->uid = info_old->uid; 104 info->gid = info_old->gid; 105 info->ttl = info_old->ttl; 84 106 } 85 107 … … 127 149 } 128 150 129 sf_g->ttl = info->ttl; 130 sf_g->uid = info->uid; 131 sf_g->gid = info->gid; 151 sf_g->ttl = info->ttl; 152 sf_g->uid = info->uid; 153 sf_g->gid = info->gid; 154 155 if (info->length >= sizeof(struct vbsf_mount_info_new)) 156 { 157 /* new fields */ 158 sf_g->dmode = info->dmode; 159 sf_g->fmode = info->fmode; 160 sf_g->dmask = info->dmask; 161 sf_g->fmask = info->fmask; 162 } 163 else 164 { 165 sf_g->dmode = ~0; 166 sf_g->fmode = ~0; 167 } 132 168 133 169 *sf_gp = sf_g; … … 180 216 struct sf_glob_info *sf_g; 181 217 RTFSOBJINFO fsinfo; 182 struct vbsf_mount_info *info;218 struct vbsf_mount_info_new *info; 183 219 184 220 TRACE (); … … 415 451 TRACE (); 416 452 417 if (sizeof (struct vbsf_mount_info ) > PAGE_SIZE) {453 if (sizeof (struct vbsf_mount_info_old) > PAGE_SIZE) { 418 454 printk (KERN_ERR 419 455 "Mount information structure is too large %lu\n" 420 456 "Must be less than or equal to %lu\n", 421 (unsigned long)sizeof (struct vbsf_mount_info ),457 (unsigned long)sizeof (struct vbsf_mount_info_old), 422 458 PAGE_SIZE); 423 459 return -EINVAL; -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r8155 r11507 36 36 int uid; 37 37 int gid; 38 int dmode; 39 int fmode; 40 int dmask; 41 int fmask; 38 42 }; 39 43
Note:
See TracChangeset
for help on using the changeset viewer.