static void update_firmware_status(void) { char s[PATH_MAX_LENGTH]; core_info_ctx_firmware_t firmware_info; core_info_t *core_info = NULL; settings_t *settings = config_get_ptr(); core_info_get_current_core(&core_info); if (!core_info || !settings) return; firmware_info.path = core_info->path; if (!string_is_empty(settings->directory.system)) firmware_info.directory.system = settings->directory.system; else { strlcpy(s, path_get(RARCH_PATH_CONTENT) ,sizeof(s)); path_basedir_wrapper(s); firmware_info.directory.system = s; } RARCH_LOG("Updating firmware status for: %s on %s\n", core_info->path, firmware_info.directory.system); core_info_list_update_missing_firmware(&firmware_info); }
/* * Get the current working directory for the current process. * Returns the pointer to the string, which is NOT going to be at the beginning * of buf. * Buf must be at least 1 page in size. */ char *npm_getcwd(char *buf, unsigned long bufsize) { struct path pwd; char *res; ASSERT(bufsize >= PAGE_SIZE - 1); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || defined CONFIG_VE get_fs_pwd(current->fs, &pwd); #else read_lock(¤t->fs->lock); pwd = current->fs->pwd; path_get(&pwd); read_unlock(¤t->fs->lock); #endif res = d_path(&pwd, buf, bufsize); if (IS_ERR(res)) res = NULL; path_put(&pwd); return res; }
/* Find the topmost mount satisfying test() */ static int find_autofs_mount(const char *pathname, struct path *res, int test(const struct path *path, void *data), void *data) { struct path path; int err; err = kern_path_mountpoint(AT_FDCWD, pathname, &path, 0); if (err) return err; err = -ENOENT; while (path.dentry == path.mnt->mnt_root) { if (path.dentry->d_sb->s_magic == AUTOFS_SUPER_MAGIC) { if (test(&path, data)) { path_get(&path); *res = path; err = 0; break; } } if (!follow_up(&path)) break; } path_put(&path); return err; }
static int find_autofs_mount(const char *pathname, struct path *res, int test(struct path *path, void *data), void *data) { struct path path; int err = kern_path(pathname, 0, &path); if (err) return err; err = -ENOENT; while (path.dentry == path.mnt->mnt_root) { if (path.mnt->mnt_sb->s_magic == AUTOFS_SUPER_MAGIC) { if (test(&path, data)) { path_get(&path); if (!err) /* already found some */ path_put(res); *res = path; err = 0; } } if (!follow_up(&path)) break; } path_put(&path); return err; }
struct dentry *au_lkup_one(struct qstr *name, struct dentry *h_parent, struct au_branch *br, struct nameidata *nd) { struct dentry *h_dentry; int err; struct nameidata h_nd; if (au_test_fs_null_nd(h_parent->d_sb)) return vfsub_lookup_one_len(name->name, h_parent, name->len); au_h_nd(&h_nd, nd); h_nd.path.dentry = h_parent; h_nd.path.mnt = br->br_mnt; err = __lookup_one_len(name->name, &h_nd.last, NULL, name->len); h_dentry = ERR_PTR(err); if (!err) { path_get(&h_nd.path); h_dentry = vfsub_lookup_hash(&h_nd); path_put(&h_nd.path); } AuTraceErrPtr(h_dentry); return h_dentry; }
static int _xx_realpath_from_path(struct path *path, char *newname, int newname_len) { struct dentry *dentry = path->dentry; int error = -ENOMEM; char *sp; if (!dentry || !path->mnt || !newname || newname_len <= 2048) return -EINVAL; if (dentry->d_op && dentry->d_op->d_dname) { /* For "socket:[\$]" and "pipe:[\$]". */ static const int offset = 1536; sp = dentry->d_op->d_dname(dentry, newname + offset, newname_len - offset); } else { /* Taken from d_namespace_path(). */ struct path ns_root = { }; struct path root; struct path tmp; read_lock(¤t->fs->lock); root = current->fs->root; path_get(&root); read_unlock(¤t->fs->lock); spin_lock(&vfsmount_lock); if (root.mnt && root.mnt->mnt_ns) ns_root.mnt = mntget(root.mnt->mnt_ns->root); if (ns_root.mnt) ns_root.dentry = dget(ns_root.mnt->mnt_root); spin_unlock(&vfsmount_lock); spin_lock(&dcache_lock); tmp = ns_root; sp = __d_path(path, &tmp, newname, newname_len); spin_unlock(&dcache_lock); path_put(&root); path_put(&ns_root); } if (IS_ERR(sp)) { error = PTR_ERR(sp); } else { error = _xx_encode(newname, sp - newname, sp); } #if 1 /* Append trailing '/' if dentry is a directory. */ if (!error && dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode) && *newname) { sp = newname + strlen(newname); if (*(sp - 1) != '/') { if (sp < newname + newname_len - 4) { *sp++ = '/'; *sp = '\0'; } else { error = -ENOMEM; } } } #endif return error; }
/* * Preparse a big key */ int big_key_preparse(struct key_preparsed_payload *prep) { struct path *path = (struct path *)&prep->payload.data[big_key_path]; struct file *file; ssize_t written; size_t datalen = prep->datalen; int ret; ret = -EINVAL; if (datalen <= 0 || datalen > 1024 * 1024 || !prep->data) goto error; /* Set an arbitrary quota */ prep->quotalen = 16; prep->payload.data[big_key_len] = (void *)(unsigned long)datalen; if (datalen > BIG_KEY_FILE_THRESHOLD) { /* Create a shmem file to store the data in. This will permit the data * to be swapped out if needed. * * TODO: Encrypt the stored data with a temporary key. */ file = shmem_kernel_file_setup("", datalen, 0); if (IS_ERR(file)) { ret = PTR_ERR(file); goto error; } written = kernel_write(file, prep->data, prep->datalen, 0); if (written != datalen) { ret = written; if (written >= 0) ret = -ENOMEM; goto err_fput; } /* Pin the mount and dentry to the key so that we can open it again * later */ *path = file->f_path; path_get(path); fput(file); } else { /* Just store the data in a buffer */ void *data = kmalloc(datalen, GFP_KERNEL); if (!data) return -ENOMEM; prep->payload.data[big_key_data] = data; memcpy(data, prep->data, prep->datalen); } return 0; err_fput: fput(file); error: return ret; }
static struct fs_struct *__copy_fs_struct(struct fs_struct *old) { struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL); /* We don't need to lock fs - think why ;-) */ if (fs) { atomic_set(&fs->count, 1); rwlock_init(&fs->lock); fs->umask = old->umask; read_lock(&old->lock); fs->root = old->root; path_get(&old->root); fs->pwd = old->pwd; path_get(&old->pwd); read_unlock(&old->lock); } return fs; }
bool HashSet::store( ) const { OutputFile out; for ( const auto &id : _set ) id.store( out ); return out.rename( path_get( PathType::OBJ, "index" ).string( ) ); }
/* * Here the caller only guarantees locking for struct file and struct inode. * Locking must therefore be done in the probe to use the dentry. */ static void probe_subsys_event(struct inode *inode, struct file *file) { path_get(&file->f_path); dget(file->f_path.dentry); printk(KERN_INFO "Event is encountered with filename %s\n", file->f_path.dentry->d_name.name); dput(file->f_path.dentry); path_put(&file->f_path); }
static void menu_action_setting_disp_set_label_core_option_create( file_list_t* list, unsigned *w, unsigned type, unsigned i, const char *label, char *s, size_t len, const char *entry_label, const char *path, char *s2, size_t len2) { *s = '\0'; *w = 19; strlcpy(s, "", len); if (!string_is_empty(path_get(RARCH_PATH_BASENAME))) strlcpy(s, path_basename(path_get(RARCH_PATH_BASENAME)), len); strlcpy(s2, path, len2); }
static bool init_content_file_set_attribs( struct string_list *temporary_content, struct string_list *content, const struct retro_subsystem_info *special) { union string_list_elem_attr attr; struct string_list *subsystem = path_get_subsystem_list(); attr.i = 0; if (!path_is_empty(RARCH_PATH_SUBSYSTEM) && special) { unsigned i; for (i = 0; i < subsystem->size; i++) { attr.i = special->roms[i].block_extract; attr.i |= special->roms[i].need_fullpath << 1; attr.i |= special->roms[i].required << 2; string_list_append(content, subsystem->elems[i].data, attr); } } else { rarch_system_info_t *system = NULL; settings_t *settings = config_get_ptr(); runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) { attr.i = system->info.block_extract; attr.i |= system->info.need_fullpath << 1; } attr.i |= (!content_does_not_need_content()) << 2; if (path_is_empty(RARCH_PATH_CONTENT) && content_does_not_need_content() && settings->set_supports_no_game_enable) string_list_append(content, "", attr); else { if (!path_is_empty(RARCH_PATH_CONTENT)) string_list_append(content, path_get(RARCH_PATH_CONTENT), attr); } } #ifdef HAVE_COMPRESSION /* Try to extract all content we're going to load if appropriate. */ init_content_file_extract(temporary_content, content, special, &attr); #endif return true; }
static void frontend_xdk_exec(const char *path, bool should_load_game) { #ifndef IS_SALAMANDER bool original_verbose = verbosity_is_enabled(); #endif #if defined(_XBOX1) LAUNCH_DATA ptr; #elif defined(_XBOX360) char game_path[1024] = {0}; #endif (void)should_load_game; #ifdef IS_SALAMANDER if (!string_is_empty(path)) XLaunchNewImage(path, NULL); #else #if defined(_XBOX1) memset(&ptr, 0, sizeof(ptr)); if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", path_get(RARCH_PATH_CONTENT)); if (!string_is_empty(path)) XLaunchNewImage(path, !string_is_empty((const char*)ptr.Data) ? &ptr : NULL); #elif defined(_XBOX360) if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) { strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path)); XSetLaunchData(game_path, MAX_LAUNCH_DATA_SIZE); } if (!string_is_empty(path)) XLaunchNewImage(path, 0); #endif #endif #ifndef IS_SALAMANDER if (original_verbose) verbosity_enable(); else verbosity_disable(); #endif }
static void load_dynamic_core(void) { function_t sym = dylib_proc(NULL, "retro_init"); if (sym) { /* Try to verify that -lretro was not linked in from other modules * since loading it dynamically and with -l will fail hard. */ RARCH_ERR("Serious problem. RetroArch wants to load libretro cores" "dyamically, but it is already linked.\n"); RARCH_ERR("This could happen if other modules RetroArch depends on " "link against libretro directly.\n"); RARCH_ERR("Proceeding could cause a crash. Aborting ...\n"); retroarch_fail(1, "init_libretro_sym()"); } if (string_is_empty(path_get(RARCH_PATH_CORE))) { RARCH_ERR("RetroArch is built for dynamic libretro cores, but " "libretro_path is not set. Cannot continue.\n"); retroarch_fail(1, "init_libretro_sym()"); } /* Need to use absolute path for this setting. It can be * saved to content history, and a relative path would * break in that scenario. */ path_resolve_realpath( path_get_ptr(RARCH_PATH_CORE), path_get_realsize(RARCH_PATH_CORE)); RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n", path_get(RARCH_PATH_CORE)); lib_handle = dylib_load(path_get(RARCH_PATH_CORE)); if (!lib_handle) { RARCH_ERR("Failed to open libretro core: \"%s\"\n", path_get(RARCH_PATH_CORE)); RARCH_ERR("Error(s): %s\n", dylib_error()); retroarch_fail(1, "load_dynamic()"); } }
bool HashSet::load( ) { InputFile in( path_get( PathType::OBJ, "index" ).string( ) ); HashId id; while ( id.load( in ) ) _set.insert( id ); _old_size = _set.size( ); return true; }
// ARM10C 20160521 // current->fs: (&init_task)->fs, &root void set_fs_pwd(struct fs_struct *fs, const struct path *path) { struct path old_pwd; // path: &root path_get(path); // path_get에서 한일: // [pcp0] (kmem_cache#2-oX (struct mount))->mnt_pcp->mnt_count 을 1만큼 증가 시킴 // (&(kmem_cache#5-oX (struct dentry))->d_lockref)->count: 1 만큼 증가 시킴 // &fs->lock: &((&init_task)->fs)->lock spin_lock(&fs->lock); // spin_lock 에서 한일: // &((&init_task)->fs)->lock 을 사용하여 spin lock 을 수행 // &fs->seq: &((&init_task)->fs)->seq write_seqcount_begin(&fs->seq); // write_seqcount_begin에서 한일: // (&((&init_task)->fs)->seq)->sequence: 1 // 공유자원을 다른 cpu core가 사용할수 있게 메모리 적용 // fs->pwd: ((&init_task)->fs)->pwd: (&init_fs)->pwd: 맴버가 0 으로 초기화된 값 old_pwd = fs->pwd; // old_pwd: 맴버가 0 으로 초기화된 값 // root.mnt: &(kmem_cache#2-oX (struct mount))->mnt // root.dentry: kmem_cache#5-oX (struct dentry) // fs->pwd: ((&init_task)->fs)->pwd: (&init_fs)->pwd: 맴버가 0 으로 초기화된 값, *path: root fs->pwd = *path; // fs->pwd: ((&init_task)->fs)->pwd.mnt: &(kmem_cache#2-oX (struct mount))->mnt // fs->pwd: ((&init_task)->fs)->pwd.dentry: kmem_cache#5-oX (struct dentry) // &fs->seq: &((&init_task)->fs)->seq write_seqcount_end(&fs->seq); // write_seqcount_end에서 한일: // 공유자원을 다른 cpu core가 사용할수 있게 메모리 적용 // (&((&init_task)->fs)->seq)->sequence: 2 // &fs->lock: &((&init_task)->fs)->lock spin_unlock(&fs->lock); // spin_unlock 에서 한일: // &((&init_task)->fs)->lock 을 사용하여 spin unlock 을 수행 // old_pwd.dentry: NULL if (old_pwd.dentry) path_put(&old_pwd); }
static_fn char *nextdir(glob_t *gp, char *dir) { Shell_t *shp = sh_getinterp(); Pathcomp_t *pp = gp->gl_handle; if (!dir) { pp = path_get(shp, ""); } else { pp = pp->next; } gp->gl_handle = pp; if (pp) return pp->name; return NULL; }
/* * look for case-insensitive matching entry name. * Returns : * - char * of matching entry if found. * - NULL if no matching entry * - ERR_PTR on error * */ static void * find_case_insensitive(struct path * lower_parent_path, const char * name) { void * ret = NULL; struct file *lower_dirp = NULL; struct sdcardfs_dirent dirent; int err; /* * At the end of this function, filp_close or dentry_open (if fails) * will decrease refernce count of lower_parent_path. * (ie, path->dentry->d_count and path->mnt->mnt_count) * To prevent those counter from dropping to zero, * we increase the counters in advance. */ path_get(lower_parent_path); lower_dirp = dentry_open(lower_parent_path->dentry, lower_parent_path->mnt, O_RDONLY, current_cred()); if (IS_ERR(lower_dirp)) { return (void *)lower_dirp; } while (1) { err = sdcardfs_getdents(lower_dirp, &dirent); if (likely(err > 0)) { /* we got a direntry */ if (unlikely(!strcasecmp(dirent.d_name, name))) { int len; len = strlen(dirent.d_name) + 1; ret = kmalloc(len, GFP_KERNEL); if (ret == NULL) ret = ERR_PTR(-ENOMEM); else strcpy(ret, dirent.d_name); break; } } else if (err == 0) { /* end of directory */ ret = NULL; break; } else { /* err < 0 : error */ ret = ERR_PTR(err); break; } } filp_close(lower_dirp, NULL); return ret; }
/* * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. * It can block. */ void set_fs_pwd(struct fs_struct *fs, struct path *path) { struct path old_pwd; write_lock(&fs->lock); old_pwd = fs->pwd; fs->pwd = *path; path_get(path); write_unlock(&fs->lock); if (old_pwd.dentry) path_put(&old_pwd); }
/* * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. * It can block. */ void set_fs_root(struct fs_struct *fs, struct path *path) { struct path old_root; write_lock(&fs->lock); old_root = fs->root; fs->root = *path; path_get(path); gr_set_chroot_entries(current, path); write_unlock(&fs->lock); if (old_root.dentry) path_put(&old_root); }
char *getfullPath(const char *pathname, char *fullpath) { //char *fullpath = NULL; char *path = NULL; char *start = NULL; //struct dentry *pwd; //struct vfsmount *vfsmount; struct fs_struct *fs = current->fs; struct path pwd; /*fullpath = kmalloc(PATH_MAX, GFP_KERNEL); if (!fullpath) { // kmalloc error return fullpath; } memset(fullpath, 0, PATH_MAX);*/ path = kmalloc(PATH_MAX, GFP_KERNEL); if (!path) { return NULL; } // 2.4 // get dentry and vfsmnt //read_lock(&(fs->lock)); //pwd = dget(fs->pwd); //vfsmount = mntget(fs->pwdmnt); //read_unlock(&(fs->lock)); // get path //start = d_path(pwd, vfsmount, path, PATH_MAX); //strcat(fullpath, start); // 2.6.32 read_lock(&fs->lock); pwd = fs->pwd; path_get(&pwd); read_unlock(&fs->lock); //set_fs_pwd(fs, &pwd); start = d_path(&pwd, path, PATH_MAX); strcat(fullpath, start); strcat(fullpath, "/"); strcat(fullpath, pathname); // 2.6.35 // use spinlock kfree(path); return fullpath; }
struct file *vfsub_dentry_open(struct path *path, int flags) { struct file *file; path_get(path); file = dentry_open(path->dentry, path->mnt, flags /* | __FMODE_NONOTIFY */, current_cred()); if (!IS_ERR_OR_NULL(file) && (file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) i_readcount_inc(path->dentry->d_inode); return file; }
/* * Here the caller only guarantees locking for struct file and struct inode. * Locking must therefore be done in the probe to use the dentry. */ static void probe_subsys_event(void *ignore, struct inode *inode, struct file *file) { path_get(&file->f_path); dget(file->f_path.dentry); #ifdef CONFIG_DEBUG_PRINTK printk(KERN_INFO "Event is encountered with filename %s\n", file->f_path.dentry->d_name.name); #else ; #endif dput(file->f_path.dentry); path_put(&file->f_path); }
void get_physical_root(struct path *root) { struct krg_namespace *krg_ns = find_get_krg_ns(); BUG_ON(!krg_ns); root->mnt = krg_ns->root_nsproxy.mnt_ns->root; root->dentry = root->mnt->mnt_root; path_get(root); put_krg_ns(krg_ns); while (d_mountpoint(root->dentry) && follow_down(&root->mnt, &root->dentry)) ; }
int item_path_starts( item *it, char *p, char *fname ) { path *temp = it->paths; int plen = strlen(p); while ( temp != NULL ) { char *pt = path_get(temp); if ( strlen(pt)>=plen && strncmp(p,pt,plen)==0 ) return 1; else temp = path_next(temp); } return 0; }
/* * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. * It can block. */ void set_fs_root(struct fs_struct *fs, struct path *path) { struct path old_root; path_get(path); spin_lock(&fs->lock); write_seqcount_begin(&fs->seq); old_root = fs->root; fs->root = *path; write_seqcount_end(&fs->seq); spin_unlock(&fs->lock); if (old_root.dentry) path_put(&old_root); }
/** * Does the config path uniquely apply to a file in the current directory? * @param it the item * @param p the directory path * @param fname the full config file path * @return */ int item_path_unique( item *it, char *p, char *fname ) { path *temp = it->paths; int plen = strlen(p); while ( temp != NULL ) { char *pt = path_get(temp); if ( in_dir(pt,p,plen) && fnames_equal(fname,pt) ) return 1; else temp = path_next(temp); } return 0; }
/** * nameidata_to_filp - convert a nameidata to an open filp. * @nd: pointer to nameidata * @flags: open flags * * Note that this function destroys the original nameidata */ struct file *nameidata_to_filp(struct nameidata *nd) { const struct cred *cred = current_cred(); struct file *filp; /* Pick up the filp from the open intent */ filp = nd->intent.open.file; /* Has the filesystem initialised the file for us? */ if (filp->f_path.dentry == NULL) { path_get(&nd->path); filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp, NULL, cred); } return filp; }
int concat_path(char **buf){ char *cwd,*temp; struct path pwd, root; pwd = current->fs->pwd; path_get(&pwd); root= current->fs->root; path_get(&root); temp=kmalloc(GFP_KERNEL,MAX_PATH_SIZE); if(!temp){ return -ENOMEM; } cwd = d_path(&pwd,temp,MAX_PATH_SIZE); strcpy(*buf,cwd); path_put(&pwd); path_put(&root); kfree(temp); return 0; }
/* * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. * It can block. */ void set_fs_pwd(struct fs_struct *fs, struct path *path) { struct path old_pwd; path_get(path); spin_lock(&fs->lock); write_seqcount_begin(&fs->seq); old_pwd = fs->pwd; fs->pwd = *path; write_seqcount_end(&fs->seq); spin_unlock(&fs->lock); if (old_pwd.dentry) path_put(&old_pwd); }