Changeset 19f24fd in mainline for uspace/lib/libc/generic/vfs/vfs.c
- Timestamp:
- 2010-02-05T22:25:52Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dafa2d04
- Parents:
- 83349b03 (diff), d42976c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/vfs/vfs.c
r83349b03 r19f24fd 120 120 const char *opts, unsigned int flags) 121 121 { 122 int res; 122 int null_id = -1; 123 char null[DEVMAP_NAME_MAXLEN]; 124 125 if (str_cmp(fqdn, "") == 0) { 126 /* No device specified, create a fresh 127 null/%d device instead */ 128 null_id = devmap_null_create(); 129 130 if (null_id == -1) 131 return ENOMEM; 132 133 snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id); 134 fqdn = null; 135 } 136 137 dev_handle_t dev_handle; 138 int res = devmap_device_get_handle(fqdn, &dev_handle, flags); 139 if (res != EOK) { 140 if (null_id != -1) 141 devmap_null_destroy(null_id); 142 143 return res; 144 } 145 146 size_t mpa_size; 147 char *mpa = absolutize(mp, &mpa_size); 148 if (!mpa) { 149 if (null_id != -1) 150 devmap_null_destroy(null_id); 151 152 return ENOMEM; 153 } 154 155 futex_down(&vfs_phone_futex); 156 async_serialize_start(); 157 vfs_connect(); 158 159 ipcarg_t rc_orig; 160 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL); 161 ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 162 if (rc != EOK) { 163 async_wait_for(req, &rc_orig); 164 async_serialize_end(); 165 futex_up(&vfs_phone_futex); 166 free(mpa); 167 168 if (null_id != -1) 169 devmap_null_destroy(null_id); 170 171 if (rc_orig == EOK) 172 return (int) rc; 173 else 174 return (int) rc_orig; 175 } 176 177 rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts)); 178 if (rc != EOK) { 179 async_wait_for(req, &rc_orig); 180 async_serialize_end(); 181 futex_up(&vfs_phone_futex); 182 free(mpa); 183 184 if (null_id != -1) 185 devmap_null_destroy(null_id); 186 187 if (rc_orig == EOK) 188 return (int) rc; 189 else 190 return (int) rc_orig; 191 } 192 193 rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); 194 if (rc != EOK) { 195 async_wait_for(req, &rc_orig); 196 async_serialize_end(); 197 futex_up(&vfs_phone_futex); 198 free(mpa); 199 200 if (null_id != -1) 201 devmap_null_destroy(null_id); 202 203 if (rc_orig == EOK) 204 return (int) rc; 205 else 206 return (int) rc_orig; 207 } 208 209 /* Ask VFS whether it likes fs_name. */ 210 rc = async_req_0_0(vfs_phone, IPC_M_PING); 211 if (rc != EOK) { 212 async_wait_for(req, &rc_orig); 213 async_serialize_end(); 214 futex_up(&vfs_phone_futex); 215 free(mpa); 216 217 if (null_id != -1) 218 devmap_null_destroy(null_id); 219 220 if (rc_orig == EOK) 221 return (int) rc; 222 else 223 return (int) rc_orig; 224 } 225 226 async_wait_for(req, &rc); 227 async_serialize_end(); 228 futex_up(&vfs_phone_futex); 229 free(mpa); 230 231 if ((rc != EOK) && (null_id != -1)) 232 devmap_null_destroy(null_id); 233 234 return (int) rc; 235 } 236 237 int unmount(const char *mp) 238 { 123 239 ipcarg_t rc; 124 240 ipcarg_t rc_orig; 125 241 aid_t req; 126 dev_handle_t dev_handle;127 128 res = devmap_device_get_handle(fqdn, &dev_handle, flags);129 if (res != EOK)130 return res;131 132 242 size_t mpa_size; 133 char *mpa = absolutize(mp, &mpa_size); 243 char *mpa; 244 245 mpa = absolutize(mp, &mpa_size); 134 246 if (!mpa) 135 247 return ENOMEM; … … 139 251 vfs_connect(); 140 252 141 req = async_send_ 2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL);253 req = async_send_0(vfs_phone, VFS_IN_UNMOUNT, NULL); 142 254 rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 143 255 if (rc != EOK) { … … 152 264 } 153 265 154 rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts)); 155 if (rc != EOK) { 156 async_wait_for(req, &rc_orig); 157 async_serialize_end(); 158 futex_up(&vfs_phone_futex); 159 free(mpa); 160 if (rc_orig == EOK) 161 return (int) rc; 162 else 163 return (int) rc_orig; 164 } 165 166 rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); 167 if (rc != EOK) { 168 async_wait_for(req, &rc_orig); 169 async_serialize_end(); 170 futex_up(&vfs_phone_futex); 171 free(mpa); 172 if (rc_orig == EOK) 173 return (int) rc; 174 else 175 return (int) rc_orig; 176 } 177 178 /* Ask VFS whether it likes fs_name. */ 179 rc = async_req_0_0(vfs_phone, IPC_M_PING); 180 if (rc != EOK) { 181 async_wait_for(req, &rc_orig); 182 async_serialize_end(); 183 futex_up(&vfs_phone_futex); 184 free(mpa); 185 if (rc_orig == EOK) 186 return (int) rc; 187 else 188 return (int) rc_orig; 189 } 190 266 191 267 async_wait_for(req, &rc); 192 268 async_serialize_end();
Note:
See TracChangeset
for help on using the changeset viewer.