Discussion:
struct File & GOSFS_Dir_Entry
(too old to reply)
cs412050
2005-04-24 19:06:09 UTC
Permalink
When I create a file, I use Allocate_File() and store the
file pointer to **pFile passed from Sys_Open.

At this point, (struct File *)file and (struct GOSFS_Dir_Entry *)entry
are not related each other. It is fine at this point, but,
Beginning to write blocks and putting block number in entry->blockList
is confusing without knowing each other.

How can open file knows its dir_entry is *entry without having any
information in it? In other words, struct File doesn't have member
as a back pointer to Dir_Entry and struct Dir_Entry doesn't have
struct File * either. How can I map FS_Buffer to this file,
and update when I sync() or close() the file?

I tried to solve this by filename, but struct File doesn't have name
member either. Anybody considered this? Or am I in the wrong direction
again, as I did last project?
William Francis Cladek
2005-04-24 21:22:29 UTC
Permalink
The short answer to your question is, you can use the fsData pointer in
the File struct to point to whatever you want, including the directory
entry.

I've been turning strategies over in my head for some time now, and the
difficulty, as you said, is that whenever you manipulate a file, you have
to do something with its directory entry. While a file is open, its
directory entry can either be in a FS_Buffer of the whole directory, or
just on disk somewhere. The
problem with the former strategy is that if you have two files open from
the same directory, that means you need to have two things accessing the same
directory buffer. However, the provided buffer cache implementation is
fairly adverse to multiple things using the same buffer.

Right now I'm leaning towards the latter. Namely, keeping my open files
on a "need to know" basis. If a file is being read from, written to,
etc., at that point (in the syscall) it will acquire a buffer of its
directory, access its directory entry, do what it needs to do, then
sync and release the buffer.

Getting back to what you said, there needs to be a way of getting the
directory entry based on the File struct. As mentioned in a previous
post, one way of doing that would be to store in fsData a struct
containing the directory entry's block number and index. I'm not sure
what's best, though. If anyone else has any better strategies, I'd be
glad to hear 'em.

Will
Post by cs412050
When I create a file, I use Allocate_File() and store the
file pointer to **pFile passed from Sys_Open.
At this point, (struct File *)file and (struct GOSFS_Dir_Entry *)entry
are not related each other. It is fine at this point, but,
Beginning to write blocks and putting block number in entry->blockList
is confusing without knowing each other.
How can open file knows its dir_entry is *entry without having any
information in it? In other words, struct File doesn't have member
as a back pointer to Dir_Entry and struct Dir_Entry doesn't have
struct File * either. How can I map FS_Buffer to this file,
and update when I sync() or close() the file?
I tried to solve this by filename, but struct File doesn't have name
member either. Anybody considered this? Or am I in the wrong direction
again, as I did last project?
Raymond Chung
2005-04-25 12:56:02 UTC
Permalink
Thank you for replying.
Actually, I didn't think about binding *fsData to something
other than *instance.
Thanks for the advice.

Loading...