vbox的更動 30496 路徑 trunk/src/VBox/Additions/solaris
- 時間撮記:
- 2010-6-29 下午12:47:13 (14 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_prov.c
r30446 r30496 793 793 int mask_size; 794 794 sfp_file_t *fp; 795 static char infobuff[2 * MAXNAMELEN]; /* not on stack!! */796 SHFLDIRINFO *info = (SHFLDIRINFO *)&infobuff;795 uint32_t infobuff_alloc = 16384; 796 SHFLDIRINFO *infobuff = NULL, *info; 797 797 uint32_t numbytes; 798 uint32_t justone; 798 uint32_t nents; 799 uint32_t size; 799 800 uint32_t cnt; 800 801 sffs_dirents_t *cur_buf; … … 836 837 837 838 /* 838 * Now loop using vboxCallDirInfo to get one file name at a time839 * Now loop using vboxCallDirInfo 839 840 */ 841 infobuff = kmem_alloc(infobuff_alloc, KM_SLEEP); 842 if (infobuff == NULL) { 843 error = (ENOSPC); 844 goto done; 845 } 846 840 847 cnt = 0; 841 848 for (;;) { 842 justone = 1; 843 numbytes = sizeof (infobuff); 849 numbytes = infobuff_alloc; 844 850 error = vboxCallDirInfo(&vbox_client, &fp->map, fp->handle, 845 mask_str, SHFL_LIST_RETURN_ONE, 0, &numbytes, info, 846 &justone); 847 if (error == VERR_NO_MORE_FILES) { 851 mask_str, 0, 0, &numbytes, infobuff, &nents); 852 switch (error) { 853 854 case VINF_SUCCESS: 855 /* fallthrough */ 856 case VERR_NO_MORE_FILES: 848 857 break; 858 859 case VERR_NO_TRANSLATION: 860 /* XXX ??? */ 861 break; 862 863 default: 864 error = RTErrConvertToErrno(error); 865 goto done; 849 866 } 850 else if (error == VERR_NO_TRANSLATION) { 851 continue; /* ?? just skip this one */ 867 868 /* 869 * Create the dirent_t's for each name 870 */ 871 for (info = infobuff; (char *) info < (char *) infobuff + numbytes; nents--) { 872 /* expand buffer if we need more space */ 873 reclen = DIRENT64_RECLEN(strlen(info->name.String.utf8)); 874 if (SFFS_DIRENTS_OFF + cur_buf->sf_len + reclen > SFFS_DIRENTS_SIZE) { 875 cur_buf->sf_next = kmem_alloc(SFFS_DIRENTS_SIZE, KM_SLEEP); 876 if (cur_buf->sf_next == NULL) { 877 error = ENOSPC; 878 goto done; 879 } 880 cur_buf = cur_buf->sf_next; 881 cur_buf->sf_next = NULL; 882 cur_buf->sf_len = 0; 883 } 884 885 /* create the dirent with the name, offset, and len */ 886 dirent = (dirent64_t *) 887 (((char *) &cur_buf->sf_entries[0]) + cur_buf->sf_len); 888 strcpy(&dirent->d_name[0], info->name.String.utf8); 889 dirent->d_reclen = reclen; 890 dirent->d_off = cnt; 891 892 cur_buf->sf_len += reclen; 893 ++cnt; 894 895 size = offsetof (SHFLDIRINFO, name.String) + info->name.u16Size; 896 info = (SHFLDIRINFO *) ((uintptr_t) info + size); 852 897 } 853 else if (error != VINF_SUCCESS || justone != 1) { 854 error = EINVAL; 855 goto done; 856 } 857 858 /* 859 * Put this name in the buffer, expand if we run out of room. 860 */ 861 reclen = DIRENT64_RECLEN(strlen(info->name.String.utf8)); 862 if (SFFS_DIRENTS_OFF + cur_buf->sf_len + reclen > SFFS_DIRENTS_SIZE) { 863 cur_buf->sf_next = kmem_alloc(SFFS_DIRENTS_SIZE, KM_SLEEP); 864 if (cur_buf->sf_next == NULL) { 865 error = ENOSPC; 866 goto done; 867 } 868 cur_buf = cur_buf->sf_next; 869 cur_buf->sf_next = NULL; 870 cur_buf->sf_len = 0; 871 } 872 873 dirent = (dirent64_t *) 874 (((char *) &cur_buf->sf_entries[0]) + cur_buf->sf_len); 875 strcpy(&dirent->d_name[0], info->name.String.utf8); 876 dirent->d_reclen = reclen; 877 dirent->d_off = cnt; 878 879 cur_buf->sf_len += reclen; 880 ++cnt; 898 ASSERT(nents == 0); 899 ASSERT((char *) info == (char *) infobuff + numbytes); 900 901 if (error == VERR_NO_MORE_FILES) 902 break; 881 903 } 882 904 error = 0; … … 890 912 } 891 913 } 914 if (infobuff != NULL) 915 kmem_free(infobuff, infobuff_alloc); 892 916 if (mask_str != NULL) 893 917 kmem_free(mask_str, mask_size);
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器