1.1. Purpose The
purpose of this SDS is to describe the design and function of our
software. The software is designed in a modular way. This
document describes the various modules of the software and their
functionalities. This document also gives the relationships between
the various modules.
1.2. Document
conventions All level 1, 2 and 3 headings are written using
font “Times New Roman” font size 14. All textual matter using
“Times new Roman” font size “12”.
1.3. Scope of the
development Project The main purpose of the Autoficon is to
make the process of file conversion simpler. The file type can be
converted by just renaming the file i.e. changing the extension. It
runs as a daemon which monitors for any file system alteration event
in the users HOME directory. When a file system alteration event
occurs the file type conversions will be made based on the extension.
Presently our aim is to support conversion for image types. As and
when the user renames a file (currently only image files) the daemon
automatically detects it and carries out the necessary conversion.
The user need not intervene in the conversion process.
1.4. Definitions,
Acronyms and Abbreviations FAM
File Alteration Monitor PID
Process ID PPID
Parent Process ID UID
User ID
These modules also
have sub-modules which will also be discussed.
2.1.1.
The Spy:
The Spy module can be considered
as a server module.
The main work of the Spy is to
monitor the file system for changes and inform it to the
transformer.
Parent Spy:
The Parent Spy keeps track of
the user logins and logouts.
It forks a child Spy when new
user logs in.
It kills a child spy when no
instance of an user exist.
Informs the Transformer about
file creation details that is obtained from the Child Spy.
Child Spy:
Each user has a corresponding
Child Spy.
The Child Spy monitors the
user’s home directories for any file create and delete events.
It maintains the list of user
directories being monitored.
In case of any events it informs
to the Parent Spy.
The Spy module can
again be split in to following modules
User Information Module:
Maintains the list of users who
have logged in and their instance count(ie number of logins).
It keeps track of user logins
using the Subscriber module.
It finds the user logout by
monitoring the proc file system
File Monitoring Module:
·
This module is responsible for monitoring the file system.
2.1.2.
The Transformer:
·
The Transformer module takes care of the file type
transformation.
·
It maintains a list of plug-ins available to carry out the
conversion
2.1.3.
The Subscriber
·
It is a simple module which registers to the Spy when the use
logs in.
·
It sends the Process ID and the Users Home directory to the
Spy.
2.2. Structure
and Relationships
Fig
(2) User Registration
Fig (3) File
Monitoring
Fig (4) File Monitoring –
2
Fig (5) File Transformation
2.3. User
Interface issues
The users are
3.
Detailed Description of the Components
3.1. Spy Module
Type
This is the module for monitoring and informing file system
changes. It has two sub-modules as mentioned before
Purpose
The purpose of this module is
Monitor the file System
Maintain the user information
Function
The functions of this modules are
Maintaining a user list
Monitoring the file system and reporting it to the Transformer
Monitoring for user logins and logouts
Subordinates
The subordinate of this modules are
User Information Module
File Monitoring Module
Dependencies
This module depends on the Subscriber module to identify a user
login.
Interfaces
The Spy module communicates with other modules using Unix IPC
(Message queues).
Resources
The module uses all the resources used by the sub-ordinate modules
Processing
The processing of the module is the sum processing of the
subordinatemodules
Data
-- NA --
3.1.1.
User Information Module
Type
This module is a part of the Spy module
Purpose
The purpose of this module is to maintain the user information
.i.e. users who have logged in and are using the service by
running the Subscriber
Function
The functions of this module are
To monitor for user login and logout
To maintain the user instance count
Subordinates
-- NA --
Dependencies
This module requires the Subscriber module to know about a user
login
Interfaces
-- NA --
Resources
This module makes use of the information available in the /proc
file system
Processing
This module does the following
When a user logs in the subscriber module is invoked. The
subscriber module contacts this module with the use information
such as UID, PPID of the Subscriber, Home directory of the user
etc.
The module checks whether the user is already logged in. If the
user is new a Child spy is forked.
When a user logout is detected, it reduces the user instance
count. If the user instance count becomes zero, it terminates the
child spy running for that user.
Data
User Information Structure
UID
Home directory
Number of user instances
Linked list of PPID of Subscribers
3.1.2.
File Monitoring Module
Type
This is a part of the Spy module
Purpose
The purpose of this module is to monitor the file system and
report it to the Parent Spy or Transformer
Function
The functions done by this module are
Maintain a list of directories being monitored
Monitoring and informing the file system events (FILE_CREATION &
FILE_DELETION)
Subordinates
-- NA --
Dependencies
-- NA --
Interfaces
-- NA --
Resources
The module uses FAM to monitor the files. ( inotify and gamin are
also in consideration)
Processing
The module does the following processing
When a new user is logging, it recursively travels into the
user’s home directory and register them with FAM.
When a new file is created inside user’s home directory, it
checks if it is a directory. If it is a directory, the newly
created directory is registered. If it is an ordinary file it
informs the Parent Spy which in turn informs the Transformer.
Data
The structure of the file information is:
File name ( with full path )
FAM connection number
Each Child Spy maintains a list of above information for the
corresponding user.
3.2. Transformer
Module
Type
This module carries out the file type conversion, if
necessary
Purpose
The purpose of this module is to convert the file type of the file
reported by the Spy
Function
The functions performed by the module are
Identify the file type to check for possible conversion
If file type conversion is necessary and it is possible carry out
the conversion
Subordinates
-- NA --
Dependencies
-- NA --
Interfaces
-- NA --
Resources
The Transformer requires image handling libraries such as libtiff,
libjpeg, libpng, DevIL etc.
The module uses a plug-in list file.
Processing
The module does the following processing
When the Transformer is run it creates a list of available
plug-ins
When a FILE_CREATED is reported by the Spy, fork a Child
Transformer
The following are done in the child process
The current file type is identified.
The current extension is identified
The following take place when the extension and file format do not
match
The Transformer searches for a matching plug-in to carry out the
conversion.
If a plug-in is found it carries out the conversion.
Data
The Transformer maintains a list of plug-ins. The information
stored about the plug-ins are
Plug-in version
Source format
Target format
Location of the plug-in library
3.3. Subscriber
Module
Type
This module register a user with the Spy, when he user logs in.
Purpose
The purpose of this module is to inform the Spy about a user login
Function
The functions of this module are
Inform the Spy the User’s home directory
Inform the spy its PPID
Subordinates
-- NA --
Dependencies
-- NA --
Interfaces
Uses Unix IPC to communicate with the Spy.
Resources
-- NA --
Processing
The processing done by this module is
Obtain the User Information and inform it to the Spy
Data
-- NA --
4.
Reuse and Relationship with other products The modules used
in this software can be reused with any other software. The plugins
used for converting a file from one type to another can be made use
by other softwares. The software uses some
open source code and libraries for image conversion and file system
monitoring.
5.
Design Decisions and Tradeoffs The number of directories
that can be monitored in a Users home directory is limited by the
capability of FAM. FAM allows a maximum of 1000 active requests at a
time for each process. Hence it was decided to fork a Child Spy for
each new user.
6.
Pseudocode for components 6.1 Spy if
( UserLoginDetected )
if ( NewUser )
CreateNewUserInfo();
fork();
endif else
IncreaseUserInstanceCount(); endif if ( UserLogoutDetected
)
DecreaseUserInstanceCount();
if ( UserInstanceCount == 0 )
KillChildSpy();
endif endif
// Inside the child
spy RegisterAllUserDirectories(); WaitForEvent(); if (
FileCreated )
if ( FileIsDirectory )
AddToMonitorList();
else
ReportToParentSpy();
endif endif if ( SIGTERM )
UnregisterAllDirectories();
Exit(); endif
6.2
Transformer BuildPluginList(); WaitForEvent(); if
( FileCreated ) //message sent by the Spy
filetype=CheckForFiletype();
fileext=GetFileExtension();
if ( filetype != fileext )
FindPlugin();
if ( PluginFound )
ConvertFiletype();
endif
endif endif