Get dinode/inode of directory/file by name in XV6 - inode

I am trying to traverse all of the allocated inodes in the filesystem for xv6 and I want to get the dinode of the root directory and go from there, but I have had trouble getting this to work. I tried using 'dirlookup()' but no matter what I imported I would get errors saying that that the function is not defined.

I know i'm late to the answer but here goes. An inode number can be gotten from the stat() command, and the root directory that you are currently in is referenced by "." just as your parent directory is ".."
here is a short example of how you should be able to get the inode number of root directory. Keep in mind I don't have time to test this right but it is what I remember from using xv6
uint getRootInode() {
struct stat sb;
stat(".", &sb);
return sb.ino;
}
EDIT:
Also dirlookup() is defined defs.h and implemented in fs.c

Related

KDB generating ERROR:file/path/location/sym os reports: No such file or directory

I am trying to save table as partition using .Q.dpt[hdbroot;.z.d;`tablename].
But it's generating No such file or directory error, but the directory is present.
can you please help me on this.
I have created blank folder to store the data but it's checking for sym file while storing data.
I have created one blank folder and gave that folder path to hdbroot variable, but it's not working.
I could replicate your error by trying to save to a location that doesn't exist on the machine.
q).Q.dpt[`:/does/not/exist;.z.d;`t]
'/does/not/exist/sym. OS reports: No such file or directory
[0] .Q.dpt[`:/does/not/exist;.z.d;`t]
Like I mentioned in my comment, make sure that the hdbroot variable is exactly the location you're expecting. key can help you determine this, here is a quick helper function for you.
q)exists:{"Folder/file ",$[11=abs type key x;"exists";"does not exist"]}
q)exists`:/does/not/exist
"Folder/file does not exist"
q)exists`:/tmp
"Folder/file exists"

Where to find userdefaults.plist file when values written by a root process?

I have a CLI executable(running in root context).It's sole purpose is to writeUserDefaults and read UserDefaults, and its working fine as it supposed to but I am unable to find the plist file created/modified by this process. I tried running same process in user context and was able to find the plist file created by it in ~/Library/Preference/ServiceCheckOne.plist
UserDefaults.init(suiteName: 'ServiceCheckOne')?.set(100, forKey: 'check1')
let value = UserDefaults.init(suiteName: suiteName)?.integer(forKey: key)!
After using this functions i am getting value = 100
I searched for plist from all the locations mentioned in these answer and the build
Where is a Mac Application's NSUserDefaults Data Stored?
locate command didn't help either.
I checked recently modified files still not able to find file.
In short
Need help locating the ServiceCheckOne.plist file when u userDefaults.set is used by root process.\
Or am I getting value back because of caching of defaults and file actually didn't exist?
Thank you
Xcode 12.3
MacOs 10.15
Tried defaults read | grep ServiceCheckOne got no hits here too

How to get the extreme root directory of a storage in Flutter?

I am currently using "path_provider package" of Flutter for getting the desired directories.
But as far as I am aware about this package. It only provides path to specific directories like :
TempDirectory.
AppLibraryDirectory.
etc ......
But what if I want a custom path ..... like the extreme root directory of a storage.( Whose child will be internal memory an sdcard kindoff). How can I get the path of this directory ? I thought of hardcoding specific paths like this one manually in my project but then won't the names of the directories vary based on the device manufacturer ?
I thought getExternalStorageDirectory() function might provide me the extreme root of external storage. But it provided me with this instead.
"/storage/emulated/0/Android/data/com.example.file_test/files".
when I wanted something like this : "/storage".
How can I do this ?
Thankyou for answering in advance.

Roblox ModuleScript reporting Infinite yield possible on

Helping my kid learn to develop. Using Roblox as the tool.
We are in the ServerScriptService folder and in a file called OverheadRankScript. I have a line of code like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataModule = require(ReplicatedStorage:WaitForChild("DataModule"))
My ModuleScript is in ReplicatedStorage folder and it is new and looks like this.
local module = {}
return module
I get the following error
Infinite yield possible on
'ReplicatedStorage:WaitForChild("DataModule")'
I copied the example from this link
https://developer.roblox.com/en-us/articles/Scope
Does ModuleScript script need to be in Replicated Storage or is Server Script Service the correct area?
Not sure what I am doing wrong should the file name be DataModule or is ModuleScript ok?
Does the variable need to change not sure the example provided in the documentation does not seem to work.
It's just a warning, but you can add a timeout to it for the warning to stop showing up.
local DataModule = require(ReplicatedStorage:WaitForChild("DataModule", 10))
The 10 is the optional timeout parameter that you can change to whatever you'd like to.
Actually what I found out was the DataModule needs to be renamed to ModuleScript. That Is the file name and it is referencing the file name. The example referenced in the link does not mention this at all. Infinite yield possible was misleading and it could not find the file.

How to resolve Unable to find file.cpp in path(s) in Marmalade?

I'm just trying to begin develop a game in Marmalade (6.3). But when I have made my new sources (.cpp, and .h) and added them to the mkb, and then trying to run my program, then I got an error which says that Unable to find file.cpp in path(s). It's for all of my files except the files (game.h, game.cpp, main.cpp) which were made by Marmalade when I have chosen the new 2D game project. Should I add my .cpp and .h files to anywhere else?
Thanks
It is difficult to give a categorical answer without more info. However my guess is that you've copied and pasted from an example and not understood about the syntax of the files section. Basically:
files
{
(foo)
humbug.cpp
)
The "(foo)" might look very innocent, but it actually says that humbug.cpp is actually in directory foo - relative to the mkb file. It is common practice to actually use "(source)" and put all the source files in a directory of that name - making the source layout a bit neater.
Naturally if you have (source) and don't put the files actually in directory source, they won't be found. My guess is that is what you are seeing.
Just to clarify previous answer, The format of files directive is like this -
files
{
(<Path relative to MKB>,<Alternate Path>)
["Name of the parent Group in VS/XCode project","Name of the subparent group"]
fileName.cpp
fileName.h
}
for example I have two files SoundManager.h and SoundManager.cpp in System folder of Source, while MainMenu.h and MainMenu.cpp in Source/UI. Now the files directive would be -
files
{
(Source/System)
["Source","System"] #This part is not required, it's just to arrange your files in IDE project
SoundManager.h
SoundManager.cpp
(Source/UI)
("Source","UI")
MainMenu.h
ManinMenu.cpp
}