next up previous
Next: CORBA bindings for User-space Up: File system IDLs Previous: File system IDLs


CORBA bindings to Kernel VFS (Virtual FileSystem) interface

// -----------------------------------------------------------------------------
// FileSystem.idl
// -----------------------------------------------------------------------------
//
// This file is used to define the Kernel CORBA API for accessing the filesystem
// on a machine.  This defines mappings both to access the files in the kernel
// and to implement a filesystem for the kernel.  This should probably be split
// into two files eventually.
//
// Currently unimplemented: KernelAccessAPI::FileSystem::ReadDirectory
//                          KernelAccessAPI::FileSystem::Select
//                          KernelImplementationAPI::SuperBlock::getDiskQuotaOps
//
// -----------------------------------------------------------------------------


// These are the exceptions that may be thrown and what they map to in the 
// Linux kernel.  This interface is extended by other interfaces so that the
// names don't have to be typedef'd into each interface that wants to use these
// errors.
//
interface Errors {
    exception IsDirectory {};              // EISDIR
    exception PermissionDenied {};         // EACCES
    exception FileExists {};               // EEXIST
    exception FileNotFound {};             // ENOENT
    exception IsNotDirectory {};           // ENOTDIR
    exception ReadOnlyFile {};             // EROFS, ETXTBSY
    exception RecursiveSymlink {};         // ELOOP
    exception IsBusy {};                   // EBUSY
    exception OtherError{};                // Misc other ones...
};


// -----------------------------------------------------------------------------
// KernelAccessAPI Module - Allow user level programs to call into the kernel
// -----------------------------------------------------------------------------

module KernelAccessAPI {
  struct FileStatus {           // Corba equilivant of struct stat
    long  DeviceNum;            // st_dev
    long  InodeNum;             // st_ino
    short Mode;                 // st_mode
    short NumLinks;             // st_nlink
    long  UserID;               // st_uid
    long  GroupID;              // st_gid
    long  DeviceType;           // st_rdev
    unsigned long Size;         // st_size
    unsigned long BlockSize;    // st_blksize
    unsigned long NumBlocks;    // st_blocks;
    unsigned long AccessTime;   // st_blocks;
    unsigned long ModifiedTime; // st_blocks;
    unsigned long ChangeTime;   // st_blocks;
  };

  // ---------------------------------------------------------------------------
  // FileSystem Interface - Access to filesystem and File object factory
  // ---------------------------------------------------------------------------
  
  interface File : Errors {
    void Read(out string buffer) raises (IsDirectory, OtherError);
    void Write(in string buffer) raises (OtherError);
    void Close();

    long FileControl(in long command) raises (OtherError);

    FileStatus GetStatus() raises (OtherError);

    void ChangeDirectoryTo()    // This implements fchdir...
      raises (IsNotDirectory, PermissionDenied, OtherError);

    enum SeekDirection { FromStart, FromCurrent, FromEnd };
    long Seek(in long Offset, in SeekDirection Direction) raises (OtherError);

    // DuplicateAs is very gross (FD #), but we need it for dup2
    File Duplicate() raises (OtherError);
    File DuplicateAs(in long NewFD) raises (OtherError);
  };



  // ---------------------------------------------------------------------------
  // FileSystem Interface - Access to filesystem and File object factory
  // ---------------------------------------------------------------------------

  interface FileSystem : Errors {

    // -------------------------------------------------------------------------
    // File Manipulation Routines
    // -------------------------------------------------------------------------

    File Open(in string Filename, in long openFlags, in short mode) 
      raises (FileExists, IsDirectory, PermissionDenied, FileNotFound, 
	      IsNotDirectory, ReadOnlyFile, RecursiveSymlink, OtherError);
	      
    File Create(in string Filename, in short mode)
      raises (FileExists, IsDirectory, PermissionDenied, FileNotFound, 
	      IsNotDirectory, ReadOnlyFile, RecursiveSymlink, OtherError);

    void Link(in string FromPath, in string ToPath) 
      raises (PermissionDenied, IsNotDirectory, RecursiveSymlink, FileExists);

    void Unlink(in string Filename) 
      raises (PermissionDenied, FileNotFound, IsNotDirectory, IsDirectory);

    void Rename(in string OldName, in string NewName) 
      raises (IsDirectory, FileExists, IsBusy, IsNotDirectory, PermissionDenied,
	      RecursiveSymlink);

    void ReadLink(in string Linkname, out string LinkValue) 
      raises (FileNotFound, PermissionDenied, RecursiveSymlink, OtherError);


    FileStatus GetStatus(in string Filename) 
      raises (FileNotFound, PermissionDenied, RecursiveSymlink, IsNotDirectory, 
	      OtherError);

    FileStatus GetLinkStatus(in string Filename) 
      raises (FileNotFound, PermissionDenied, RecursiveSymlink, IsNotDirectory, 
	      OtherError);


    // -------------------------------------------------------------------------
    // Directory Manipulation Routines
    // -------------------------------------------------------------------------

    void MakeDirectory(in string PathName)
      raises (FileExists, PermissionDenied, FileNotFound, IsNotDirectory, 
	      ReadOnlyFile, RecursiveSymlink, OtherError);

    void RemoveDirectory(in string PathName)
      raises (PermissionDenied, FileNotFound, IsNotDirectory);

    // ChangeDirectory returns CWD so that you can implement getcwd as
    //  { return ChangeDirectory("."); }
    string ChangeDirectory(in string PathName) 
      raises (IsNotDirectory, PermissionDenied, FileNotFound, RecursiveSymlink);


    // -------------------------------------------------------------------------
    // Special Purpose Routines...
    // -------------------------------------------------------------------------

    void MakeNode(in string FileName, in short Mode, in long DeviceNum)
      raises (PermissionDenied, FileExists, FileNotFound, IsNotDirectory, 
	      RecursiveSymlink);
    
    void Mount(in string DeviceFile, in string Location, in string FSType,
	       in long Flags)
      raises (PermissionDenied, FileNotFound, IsBusy, IsNotDirectory);

    void Unmount(in string Filename)
      raises (PermissionDenied, FileNotFound, IsBusy);
  };

};