File Interface and Practical Implementation Issues - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

File Interface and Practical Implementation Issues

Description:

File Interface and Practical Implementation Issues. File Interface. Modeled on the ... void truncate(in file_id_t filehandle) raises(invalid_handle, io_error) ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 30
Provided by: kevinelp
Category:

less

Transcript and Presenter's Notes

Title: File Interface and Practical Implementation Issues


1
File Interface and Practical Implementation Issues
2
File Interface
  • Modeled on the UNIX interface
  • uuid(3)
  • interface file
  • exception io_error
  • exception invalid_attr
  • exception invalid_arguments
  • exception eof
  • exception not_supported
  • exception invalid_handle
  • exception no_mem
  • exception generic_error

3
Open and Close
  • // type and constants for file opening
  • typedef long fopen_attr_t
  • const fopen_attr_t OPEN_READ 1
  • const fopen_attr_t OPEN_WRITE 2
  • const fopen_attr_t OPEN_APPEND 4
  • void open(in handle_t handle, in fopen_attr_t
    attr, out file_id_t filehandle)
  • raises (invalid_handle, no_mem, invalid_attr,
    io_error)
  • void close(in file_id_t filehandle)
  • raises(invalid_handle, io_error)

4
Seek and Tell
  • // type and constants for seeking
  • typedef long seek_mode_t
  • const seek_mode_t SEEK_BEGIN 1
  • const seek_mode_t SEEK_END 2
  • const seek_mode_t SEEK_REL 3
  • const long seek_pos_end -1
  • void seek(in file_id_t filehandle, in long
    to_pos,
  • in seek_mode_t mode)
  • raises(invalid_handle, eof, io_error,
    invalid_arguments)
  • void tell(in file_id_t filehandle, out long
    cur_pos)
  • raises(invalid_handle)

5
File Attributes
  • // type and constants for file attributes
  • typedef long attr_type_t
  • const attr_type_t attr_size 1
  • const attr_type_t attr_time 2
  • void get_attr(in file_id_t filehandle, in
    attr_type_t which,
  • out buffer_t buffer)
  • raises(invalid_handle, io_error,
    invalid_arguments, not_supported)
  • void set_attr(in file_id_t filehandle, in
    attr_type_t which,
  • in buffer_t buffer)
  • raises(invalid_handle, io_error,
    invalid_arguments, not_supported)

6
Object Attributes
  • Should the interface to objects be generalized to
    have attributes?
  • We currently can get the type only!!
  • Can then use more specific interface get object
    specific attributes.

7
Read Write
  • void read(in file_id_t filehandle, in long
    length,
  • prealloc out buffer_t buffer)
  • raises(invalid_handle, eof, io_error,
    invalid_arguments)
  • void write(in file_id_t filehandle,
  • in buffer_t buffer, out long result)
  • raises(invalid_handle, io_error,
    invalid_arguments)

8
Buffer_t ???
  • In IDL
  • typedef sequenceltchargt buffer_t
  • In C
  • typedef struct
  • CORBA_unsigned_long _maximum
  • CORBA_unsigned_long _length
  • CORBA_char _buffer
  • buffer_t

9
Background to prealloc
  • Normally for out sequence parameters CORBA
    allocates storage for the parameter in the stub
  • Stub calls CORBA_alloc()
  • After receiving the, user must call CORBA_free()
  • Source of a memory leak for the unwary
  • Make is difficult to implement a read with UNIX
    semantics
  • Cant directly specify the receive buffer

10
prealloc
  • Specifies that the client should allocate the
    buffer explicitly and pass it to the stub
  • Allows specification of a particular buffer
  • Can implement read semantics
  • Can explicitly control buffer usage

11
For a prealloc buffer_t
  • typedef struct
  • // maximum size of buffer to receive in
  • CORBA_unsigned_long _maximum
  • // actual length of data received
  • CORBA_unsigned_long _length
  • // pointer to start of the buffer
  • CORBA_char _buffer
  • buffer_t

12
Misc
  • void truncate(in file_id_t filehandle)
  • raises(invalid_handle, io_error)
  • void eof(in file_id_t filehandle, out long end)
  • raises(invalid_handle)
  • // end 0 not end of file
  • // end !0 end of file

13
Service Type and Idl
  • We need a type to represent services
  • Example the logserver
  • Given a new type, we need a method to manipulate
    it
  • The naming interface can find, identify, create,
    and delete service objects.
  • Service interface needed to initialize the
    service object

14
Service IDL
  • include "types.idl"
  • uuid(4)
  • interface service
  • exception generic_error
  • void register(in handle_t service_object, in
    server_t service_thread)

15
How to get started
  • Modify the Root Task
  • Implement parts of the naming interface
  • Implement the service interface
  • Modify the test task
  • Use the interfaces in servers to test them.
  • Example test client available
  • Implement a Read-only file server task

Test Client
Read-only File Server
Name Server
Simple Pager
Log Server
Sigma0
L4 Micro kernel
16
Notes on the build environment
  • Run make in the ./sdios directory
  • The following are valid targets
  • Distclean removes al intermediate files
    including IDL generated header files and
    dependency files
  • Clean removes .o files
  • Idl build the idl header files and installs them
    in include/services/
  • Install builds everything and copies the
    binaries to the boot directory
  • You should only need to run IDL4 manually to
    generate server templates.

17
Build notes
  • To avoid problems
  • Delete the old nameservice.idl and run make
    distclean
  • Link the root_task and test_client at higher
    addresses
  • Edit Makefile in src/root_task etc
  • Change LINK_ADDR to something sensible
  • Make the stacks bigger in x86-crt0.S
  • 64K should be sufficient

18
Things to do in the root task
  • File name conventions
  • / is root of file system
  • /services contains services
  • /services/log logserver
  • /services/name name server
  • /tasks task server
  • /modules read-only file server

19
Restrict address space access
  • Modify the pager to do memory bounds checking
  • restrict access to paged tasks to a range of
    memory suitable
  • Can get this from ELF header etc.

20
Modify log_service thread
  • Need to use new naming and service interface
  • Include services-client and naming-client header
  • Mkobject a service log in /services
  • Register me as log service thread using service
    interface

21
Problem!!
  • Name service must implement both naming and
    service interface
  • Using multiple inheritance to contruct a root
    interface in server
  • Transparent to client
  • Client uses previous naming and service
    interfaces as before

22
Multiple inheritance
  • Construct a root interface
  • include "naming.idl"
  • include "service.idl"
  • interface root name, service
  • Generate the root template used to implement the
    root service thread
  • New templates are needed if interfaces change
    their inheritance
  • Copy it to another file name

23
  • Rename nameserver.c into .old
  • See make file to see why
  • Fix the includes
  • Server should include root-server.h
  • In the template
  • Can remove templates related to name_server() and
    service_server(), and the associated vtables
  • Implement only root
  • Use interface numbers provided

24
In template
  • Fix the malloc calls
  • Replace with
  • Int root_server_buffsROOT_STRBUF_SIZEMAX_STR_BU
    FF_SIZE
  • for (w0 0w0 lt ROOT_STRBUF_SIZEw0)
  • buffer.strw0.rcv_addr
    root_server_buffsw00
  • buffer.strw0.rcv_size
    MAX_STR_BUFF_SIZE4
  • Fix the includes
  • include ltl4/l4.hgt
  • include ltdebug.hgt
  • include ltidl4.hgt

25
This to do in name server
  • Create a services directory
  • Remember the root dir is defined as object 1
  • Have following constant in naming headers
  • name_root_dir_handle

26
N_pts are awkward to use
  • How many parts are in
  • ////abc///cde/f///g
  • Define
  • The first / is part of a name (if present)
  • Remaining /s divide the name into parts
  • Remain /s not considered parts of the name
    itself
  • Example has 5 parts

27
To get basic system up
  • Without the file server, you need to implement
  • Name_resolve
  • Name_mkobject (for the service type)
  • service_register

28
With the file server
  • Need to derive a fileserver interface
  • Inherit from naming and file
  • Need to implement a mount point
  • Mount server at /modules
  • Need to implement client resolve that handles
    mount points
  • Write a library routine

29
Tasks and VM to come
Write a Comment
User Comments (0)
About PowerShow.com