MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / cellSysCacheMount

Function cellSysCacheMount

ps3fw/cellSysCache.cpp:196–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196error_code cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
197{
198 cellSysutil.notice("cellSysCacheMount(param=*0x%x ('%s'))", param,
199 param.ptr(&CellSysCacheParam::cacheId));
200
201 auto& cache = g_fxo->get<syscache_info>();
202
203 if (!param)
204 {
205 return CELL_SYSCACHE_ERROR_PARAM;
206 }
207
208 std::string cache_name;
209
210 ensure(vm::read_string(param.ptr(&CellSysCacheParam::cacheId).addr(),
211 sizeof(param->cacheId), cache_name),
212 "Access violation");
213
214 if (!cache_name.empty() &&
215 sysutil_check_name_string(cache_name.data(), 1, CELL_SYSCACHE_ID_SIZE) !=
216 0)
217 {
218 return CELL_SYSCACHE_ERROR_PARAM;
219 }
220
221 // Full virtualized cache id (with title id included)
222 std::string cache_id = vfs::escape(Emu.GetTitleID() + '_' + cache_name);
223
224 // Full path to virtual cache root (/dev_hdd1)
225 std::string new_path = cache.cache_root + cache_id + '/';
226
227 // Set fixed VFS path
228 strcpy_trunc(param->getCachePath, "/dev_hdd1");
229
230 // Lock pseudo-mutex
231 const auto lock = cache.init.init_always([&] {});
232
233 std::lock_guard lock0(g_mp_sys_dev_hdd1.mutex);
234
235 // Check if can reuse existing cache (won't if cache id is an empty string or
236 // cache is damaged/incomplete)
237 if (!cache_name.empty() && cache_id == cache.cache_id)
238 {
239 // Isn't mounted yet on first call to cellSysCacheMount
240 if (vfs::mount("/dev_hdd1", new_path))
241 g_fxo->get<lv2_fs_mount_info_map>().add("/dev_hdd1", &g_mp_sys_dev_hdd1);
242
243 cellSysutil.success("Mounted existing cache at %s", new_path);
244 return not_an_error(CELL_SYSCACHE_RET_OK_RELAYED);
245 }
246
247 const bool can_create = cache.cache_id != cache_id || !cache.cache_id.empty();
248
249 if (!cache.cache_id.empty())
250 {
251 // Clear previous cache
252 cache.clear(true);
253 }

Callers

nothing calls this directly

Calls 14

read_stringFunction · 0.85
strcpy_truncFunction · 0.85
throw_exceptionClass · 0.85
init_alwaysMethod · 0.80
successMethod · 0.80
ensureFunction · 0.50
ptrMethod · 0.45
addrMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected