FYP Complete

May 2nd, 2009

fyp is 95% complete,

all that is left is a 30 minute demo and presentation which is due to take place on tuesday.

uploaded all the documents here

http://www.neilcremins.com/FYP/DT228PROJ09/

dissertation folder contains the dissertation and source code written from October 2008-April 2009.

interim folder contains the interim report written in December 2008.

proposal folder contains the project proposal written in October 2008.

hope you enjoy reading.

FYP update 24/03/2009

March 24th, 2009

long time no update, too busy coding.

things added since last update:

1. added filename widget

2. added draw inode button

- this calls draw_directory_entry() which draws out the entry for the file in the directory.

- this also calls create_file(), which generates a file with random characters one character per block allocated.

- it also calls draw_inode_disk_blocks() which draws the direct block pointers that are associated with the file.

3. added  draw_directory_entry() which draws out how the file is stored in the directory, which an inode number and file name.

4. added draw_inode_disk_blocks() which draws the individual blocks that are asssigned to that file.

5. added a create_file() which creates a file with x number of characters in it to simulate the blocks being allocated.

6. created a separate program that allows the user to set key values like

- disk size

- block size

- file system

and simulates the formatting of a disk of the size specified above.

the program writes these values to a file called setup, which will hopefully be read into the main program so that the user will never have to re-compile code when they want to change a key variable.

–still to do.

1. get the values from the setup file into the main program, investigate if this can be done by XML.

2. simulate hard links

3. window which will show all disk blocks and whether they are free or allocated etc.

FYP Update 06/03/09

March 6th, 2009

ok so i’ve uploaded another weekly build up on to my site, check it out at http://www.neilcremins.com/esad/06032009

a lot has changed since that just today. i got into one of them coding moods and just got stuff done. again it’s more code tidying and bringing the code up to standard rather than progressing further.

changes i made.

1. instead of creating the block drawings on the fly, i now have a structure that contains all relevant information about a single block - like it’s (x,y) position, it’s width, it’s height, it’s colour and the block number it stores. the following code excert is the structure of the structure.

struct block
{
int x;
int y;
int w;
int h;
int num;
char* colour;
};

2. i made changes to the draw function so that it can now take in the colour as well and will draw a block with the colour that’s passed.

3. i added new controls to so that someone can allocate blocks for a file, it follows the layout of the previous “how many free inodes” spinner etc.

4. i implemented the functionality that the “allocate blocks” controls are disabled until “free blocks” have been created, this is purely to control the users input to the program so unexpected things don’t happen. the buttons get enabled once free blocks have been created.

5. got rid of the arrows, they were taken up way too much space.

6. i now sort the block numbers so that they are printed out in sequence, beforehand they were just random numbers.

that’s all i can think of at the moment, i’ve decided not to upload screen grabs every post maybe once every 2-3 post, as i want to just concentrate on my coding.

FYP Update 03/03/2009

March 3rd, 2009

got a good bit done over the weekend but it’s not real progress.

code was tidied up a lot, and hard coded values were taken out an substituted with #define’s.

#define SPIN_MIN     0
#define SPIN_MAX    20
#define SPIN_INC     1
#define DISKSIZE    100
#define BLOCKS       DISKSIZE / BLOCKSIZE
#define BLOCKSIZE  4

//window properties
#define WINDOW_WIDTH    800
#define WINDOW_HEIGHT    600
#define WINDOW_TITLE "ESAD Tool"
#define TITLE_ICON "icon.png"
 

above is an example of some of these values.

i have also started to upload weekly builds of the ESAD tool to my website for everyone to see. please bear in mind though that this software is still in beta/alpha phase, but it is free for you to download the source and reuse. also the executables for windows and osx are missing at the moment (mainly cause i haven’t used osx in ages, and gtk libs are being a pain in the butt on windows) so the linux executable is the only one available at the moment.

you can find them by clicking here

also jumping back to the code for a moment, i implemented a function to draw an horiztonal or vertical arrow using text symbols.

void draw_arrow(int x, int y, int fontsize, char direction)
{
cairo_select_font_face(cr, “Courier”, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, fontsize);

if(direction == ‘v’ || direction == ‘V’)
{
cairo_move_to(cr, x, y);
cairo_show_text(cr, “|”);

cairo_move_to(cr, x, y+10);
cairo_show_text(cr, “|”);

cairo_move_to(cr, x, y+20);
cairo_show_text(cr, “|”);

cairo_move_to(cr, x, y+30);
cairo_show_text(cr, “V”);
}
else if(direction == ‘h’ || direction == ‘H’)
{
cairo_move_to(cr, x, y);
cairo_show_text(cr, “-”);

cairo_move_to(cr, x+10, y);
cairo_show_text(cr, “-”);

cairo_move_to(cr, x+20, y);
cairo_show_text(cr, “-”);

cairo_move_to(cr, x+30, y);
cairo_show_text(cr, “>”);
}
else
{
}

//set the font back to the usual
cairo_select_font_face(cr, “Courier”, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 13);
}

i’ve also added an information panel over on the right hand side to tell users how many blocks etc. there are.

I will include some screenshots when i get home of the progress too.

FYP Update 26/02/2009

February 26th, 2009

not much has been done over the last two weeks due to me having a raging man-flu and that an assignment for advanced internet development was thrown upon me. it was billed as an easy assignment and would involve no coding as to allow us to focus on my final year project. i was to write a report about ubiquitous computing and how will it impact the future of the IT industry it also had to be 200 words. now i’ll be the first to admit i do not like writing english - you can probably tell from these postings :) - but i also find it extremely difficult to read someone elses research in a specific area and then re-word it to my own words with references included. i’d much rather get a coding assignment where i’m given x amount of tasks to do and i implement them, there’s a few reasons for this.

1. coding is easier to write with a good design.
2. if given 5 things to implement and i get 4 done perfectly i know i’ve gotten 4/5ths of the marks.

with a written paper you haven’t an iota what you’ve got, it is also down to how picky the person correcting is about grammar and spelling, which to be honest is rubbish if i know something but can’t write it in perfect and symatically correct english i should still get marks for it.

anyways one assignment is out of the way now, no more advanced internet development (using java) for me.

on to my FYP, as i mentioned earlier there is not a lot done since the last point. the following has been added since the last post.

1. block numbers are randomly generated (in a range 0-1000) and are placed inside the blocks (see screen shot).
2. the spinner is limited now to 12 as not to allow the user to go crazy when creating blocks.
3. the blocks now are laid out in perfect rows of 4. this took about 4-5 hours of solid thinking from myself, and i was kicking myself when i got the solution. i sat down with a piece of paper and a pen and drew out what i wanted and how i was going to do it. the pen is not dead as i’ve always thought. within 5 minutes of having written it out on paper i had coded the solution and tested it. i shall no doubt need this solution again.

here are some screens of what’s new:

click the images for larger versions.

here’s the code i used for the layout of the inodes.

for(i = 0 ; i < spin_value ; i++)

{

draw(xy_wh[0],xy_wh[1], xy_wh[2], xy_wh[3]);
xy_wh[0] += xy_wh[2];

if( (i+1) % 4 == 0)
{
xy_wh[1] += 50;
xy_wh[0] = 30;
}
}

i know the code segments don’t indent good here so if anyone knows of a better way to do it, please get in touch.

FYP Update 12/02/2009

February 12th, 2009

ok so three days have passed and bit more has been done. from here on in i’m only going to post code if it’s really really important or something i’ve never used before because i don’t want blog entries filled up with 1000’s of lines of code that most of ya’s probably don’t want to see. instead i’ll post up screenshots of any significant progress that are made.

no time like the present.

*click image for larger image or alternatively click here*

added in the above screen shot is a drawing of a simplified *NIX inode, for those who don’t know a inode is a structure that stores information about a file on a disk (like the user who owns the file/permissions/access and modification times).

that’s pretty much i have for now.

P.S i can still see who’s viewing my blogs, please leave comments :P

FYP Update 09/02/2009

February 9th, 2009

FYP Update 09/02/2009

Some ground was made today. Had a meeting with Paul Kelly on friday 6th feb - first after the christmas and exam break - and it went well. As seen in previous blog entries i had started to code some parts of the ESAD tool in fragments, i.e. picking out what i thought were difficult bits to code and trying to solve them.

At the meeting with Paul he set goals for me to hit and they were to start with a simple interface and work on drawing out a hardcoded superblock for EXT2. I have to admit i was a bit worried about the superblock part of this project as i thought it would be the most difficult to draw - famous last words - but after getting used to the cairo drawing library it doesn’t seem as daunting of a task. knowing me saying that though it will come back to bite me in the arse royally.

For my next meeting with Paul i need to have a hardcoded superblock displaying and i’m half way there. I’m having problems randomly generating the block numbers for the free blocks in the superblock. the image below shows how far i’ve gotten at of the time of this post. the text box is so that a user can enter in how many bytes they want to allocate although for the meeting next friday (13th feb) i may only have time to code it in terms of blocks so that 1 block is equal to 1 byte.

window before clicking go:

image after clicking go (note the 1024’s are hardcoded in for the time being to get positioning correct):

here is some of the code used to create the above.

//function the draw a simple rectangle.
void drawSB(GtkWidget *widget, gpointer darea)
{
GtkWidget *boxwidget;
g_return_if_fail(GTK_IS_WIDGET(darea));

boxwidget = GTK_WIDGET(darea);
cairo_t *cr;
cr = gdk_cairo_create(GDK_DRAWABLE(boxwidget->window));

cairo_set_line_width(cr, 2);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);

//superblock

cairo_select_font_face(cr, “Courier”, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, 13);

int i;
gchar* colour = “red”;

for(i = 30 ; i <= 190 ; i += 40)
{
//rectangle to draw
cairo_rectangle(cr, i, 60, 40, 30);

//set the first block to be red, and the rest green.
if( strcmp(colour, “red”) == 0 )
{
cairo_set_source_rgb(cr, 1.0, 0, 0);
cairo_fill(cr);
colour = “green”;
}
else
{
cairo_set_source_rgb(cr, 0, 1.0, 0);
cairo_fill(cr);
}

//black outline of each data block.
cairo_set_source_rgb(cr, 0.1, 0, 0);
cairo_rectangle(cr, i, 60, 40, 30);
cairo_stroke(cr);

}

//loop to add in the text for the blocks
for(i = 35 ; i <= 195 ; i += 40)
{
cairo_move_to(cr, i, 80);
//cairo_show_text(cr, "1024");
char* text = gen_random();
g_print(text);
cairo_show_text(cr, text);
}

cairo_move_to(cr,30,55);
cairo_show_text(cr, “SuperBlock”);

cairo_destroy(cr);
}

//function to return a string of a random number.
gchar* gen_random()
{
int n;
n = rand()%10000;

char text[10];
gchar* textreturn;
sprintf(text, “%d”, n);

textreturn = (gchar*)text;
g_print(“%s\n, textreturn);
return textreturn;
}

the above code has a bug in it, the gen_random() function doesn’t return the string properly so the numbers do not get put inside the data blocks as of yet.

overall i’m happy with the progress that i have made today, but i still have a long way to go with this project but i’m feeling somewhat happier about it now that i’ve stuck my teeth in a little.

FYP Update - 03/02/09

February 3rd, 2009

Ok today i got a good bit done.

first of all i was having a problem with file chooser and it’s corresponding signal callback.

the below line creates the file chooser widget.

filebutton = gtk_file_chooser_button_new(“Select a file:”, GTK_FILE_CHOOSER_ACTION_OPEN);

the next line connects the callback function to the go button widget.

g_signal_connect(G_OBJECT(go_button_a), “clicked”, G_CALLBACK(go_button_a), filebutton);

the reason i ended up getting segmentation faults was because i was using a depreciated function to create the file chooser button. it was fixed by the first line of code above.

here’s the callback function that is connected to the go button.

//widget refers to go button, fileselector is the fileselector button.
void go_clicked_a(GtkWidget* widget, gpointer fileselector)
{
const char* filename;
char line[1024];

//get the file name of the file chosen in the file chooser widget.
filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(fileselector));

//open the file for reading
FILE* fileptr;
fileptr = fopen(filename, “r”);

while(fgets(line, sizeof(line), fileptr) != NULL)
{
printf(“%s”, line);
}
}

i also had a look at doing simple regular expressions in a C program on simple files using the regex.h header file.

a good reference for this is this website here: http://www.osix.net/modules/article/?id=349

web server statistics…

January 28th, 2009

Are very interesting so they are.

For the month of January my web server has served up 27000+ files and averages 9000 hits a day since it was started up (sometime in 2007 I believe).

It’s kind of freaky to be honest, especially when I can see the top visitors to me site as well, it leads to some very interesting IP resolutions (at this point I’d like to say hello to Mr./Mrs. Government Minister .o/).

also 50% of all hits have been with Mozilla 4.0 or higher and 25% for MSIE6.0 and above.

also I’d like to say hi to the person who visited my site from Tuvalu, it’s a privilege to have a hit from the 4th smallest country in the world.

.o/

FYP Update

January 24th, 2009

Not much to update today, i haven’t touched my FYP.

i have sidetracked myself  - i seem to be excellent with doing that - with creating a website for myself to give myself a little bit of web presence, a while back DigiWeb gave all students a free .com domain and web space with x amount of gigabytes storage, x amount of mySQL/postgreSQL yadda yadda and bar for some file hosting i never used it. well i decided to start to use it.

i have a very rudimentary site up with links to my blog and flickr account which can be viewed here. since i have neither the time or the visual design skills neccessary to design my own site i am going to be using a open source template from http://www.oswd.org and if you are interested in seeing what design i am using here is the link to the template greeny_blu.

The web site should be up and fully running by the end of next week (friday 30th jan).

.o/