LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-28-2020, 10:05 PM   #1
donky1989
LQ Newbie
 
Registered: Jan 2020
Posts: 1

Rep: Reputation: Disabled
Path lookup in linux kernel 4.15


Hi, this is my first thread, so I'll take this opportunity to say hello.
I'm trying to write a simple kernel module, just for didactic purpose. In particular, what is giving me headaches is the path lookup. I'd like to have a sysfs entry and in the store operation I want to receive a buffer and I want to save it only if it's a valid path. So I tried to use the vfs_path_lookup Exported Symbols from here namei.c. But even inserting a valid path, it prints me the ENOENT error.

This is my code:

Into the header:

Code:
extern int vfs_path_lookup(struct dentry *, struct vfsmount *, const char *, unsigned int, struct path *path);
Code:
ssize_t path_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count){

            int err = vfs_path_lookup(current->fs->root.dentry, current->fs->root.mnt, buf, LOOKUP_DIRECTORY, base_path);
            printk(KERN_DEBUG "%s\n", __FUNCTION__);
            printk(KERN_DEBUG "Received: %s err is %d\n", buf, err);        

            strncpy(base_addr, buf, MAX_FILENAME_SIZE);
            printk(KERN_DEBUG "Base Addr: %s\n", base_addr);
            return strlen(base_addr);
        }
What I tried to write into the file is the string "/home/osboxes/Documents" that is an existing directory. I suspect that I didn't get the real usage of the function, maybe something with flags. Thank you in advance for your help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BIND DNS forward lookup zone functions, but no idea how to set up a reverse lookup zone MrRichBOB Linux - Newbie 3 01-29-2019 04:29 PM
get_exports: lookup(hosts): exports lookup failed for $HOSTNAME bluepinky Linux - Networking 4 02-19-2018 09:56 AM
Installation Path lookup? nyheat Linux - Newbie 5 12-21-2007 06:16 PM
Linux Path Lookup: php where command jCash Linux - Newbie 1 04-15-2007 05:24 PM
Traceroute, Ping, Domain Name Server (DNS) Lookup, WHOIS, and DNS Records Lookup netoknet General 1 05-09-2005 03:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration