Skip to content
Snippets Groups Projects
Commit 1513f4b5 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

do some debugging

parent b654b627
No related branches found
No related tags found
No related merge requests found
obj-m := hellofs.o
hellofs-objs := khellofs.o super.o inode.o dir.o file.o
ccflags-y := -std=gnu99 -Wno-declaration-after-statement
CFLAGS_khellofs.o := -DDEBUG
CFLAGS_super.o := -DDEBUG
CFLAGS_inode.o := -DDEBUG
......
......@@ -12,6 +12,7 @@ int hellofs_iterate(struct file *filp, struct dir_context *ctx) {
struct hellofs_inode *hellofs_inode;
struct hellofs_dir_record *dir_record;
uint64_t i;
RLIB_KTRACE_FUNC(iterate);
pos = ctx->pos;
inode = filp->f_path.dentry->d_inode;
......
......@@ -8,6 +8,8 @@
#define HELLOFS_DEFAULT_DATA_BLOCK_TABLE_SIZE 1024
#define HELLOFS_FILENAME_MAXLEN 255
#include "rlib/macro.hpp"
/* Define filesystem structures */
extern struct mutex hellofs_sb_lock;
......@@ -70,4 +72,8 @@ static inline uint64_t HELLOFS_DATA_BLOCK_TABLE_START_BLOCK_NO_HSB(
+ 1;
}
/* Debug function */
#define RLIB_KTRACE_FUNC(name) \
printk(KERN_ALERT "Recolic ktrace: [" RLIB_MACRO_TO_CSTR(name) "] called.\n")
#endif /*__HELLOFS_H__*/
\ No newline at end of file
#include "khellofs.h"
#include <linux/timekeeping.h>
void hellofs_destroy_inode(struct inode *inode) {
struct hellofs_inode *hellofs_inode = HELLOFS_INODE(inode);
......@@ -65,6 +64,9 @@ int hellofs_alloc_hellofs_inode(struct super_block *sb, uint64_t *out_inode_no)
break;
}
}
// Booms if inode buffer is full.
// locking critical section is too large, but Im too lazy
// to have it optimized.
mark_buffer_dirty(bh);
sync_dirty_buffer(bh);
......@@ -249,11 +251,13 @@ int hellofs_create_inode(struct inode *dir, struct dentry *dentry,
int hellofs_create(struct inode *dir, struct dentry *dentry,
umode_t mode, bool excl) {
RLIB_KTRACE_FUNC(hellofs_create);
return hellofs_create_inode(dir, dentry, mode);
}
int hellofs_mkdir(struct inode *dir, struct dentry *dentry,
umode_t mode) {
RLIB_KTRACE_FUNC(hellofs_mkdir);
/* @Sankar: The mkdir callback does not have S_IFDIR set.
Even ext2 sets it explicitly. Perhaps this is a bug */
mode |= S_IFDIR;
......@@ -270,6 +274,7 @@ struct dentry *hellofs_lookup(struct inode *dir,
struct hellofs_inode *hellofs_child_inode;
struct inode *child_inode;
uint64_t i;
RLIB_KTRACE_FUNC(hellofs_lookup);
bh = sb_bread(sb, parent_hellofs_inode->data_block_no);
BUG_ON(!bh);
......
......@@ -6,6 +6,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "hellofs.h"
......@@ -75,6 +76,7 @@ int main(int argc, char *argv[]) {
ret = 0;
do {
assert(sizeof(hellofs_sb) <= hellofs_sb.blocksize);
// write super block
if (sizeof(hellofs_sb)
!= write(fd, &hellofs_sb, sizeof(hellofs_sb))) {
......@@ -118,6 +120,9 @@ int main(int argc, char *argv[]) {
break;
}
printf("block size = %d, debug sizes=(sb)%d,(in_bitm)%d,(db_bitm)%d,(in_size)%d\n", hellofs_sb.blocksize, sizeof(hellofs_sb), sizeof(inode_bitmap), sizeof(data_block_bitmap), sizeof(root_hellofs_inode));
printf("Writing root inode data block at pos 0x%x\n", HELLOFS_DATA_BLOCK_TABLE_START_BLOCK_NO_HSB(&hellofs_sb) * hellofs_sb.blocksize);
printf("welcome file data block starts at pos 0x%x\n", (HELLOFS_DATA_BLOCK_TABLE_START_BLOCK_NO_HSB(&hellofs_sb)+1) * hellofs_sb.blocksize);
// write root inode data block
if ((off_t)-1
== lseek(
......
#ifndef R_MACRO_HPP
#define R_MACRO_HPP
#ifdef RLIB_EMPTY_MACRO
#undef RLIB_EMPTY_MACRO
#endif
#define RLIB_EMPTY_MACRO
#ifndef RLIB_MACRO_DECAY
#define RLIB_MACRO_DECAY(m) (m)
#endif
#ifndef _RLIB_MACRO_ENSTRING
#define _RLIB_MACRO_ENSTRING(_s) #_s
#endif
#ifndef RLIB_MACRO_TO_CSTR
#define RLIB_MACRO_TO_CSTR(m) _RLIB_MACRO_ENSTRING(m)
#endif
//#ifndef RLIB_MACRO_EQL
//#define RLIB_MACRO_EQL(a, b) (RLIB_MACRO_TO_CSTR(a) == RLIB_MACRO_TO_CSTR(b))
//#endif
#ifndef RLIB_MACRO_CAT
#define RLIB_MACRO_CAT(a, b) _RLIB_MACRO_CAT_I(a, b)
#define _RLIB_MACRO_CAT_I(a, b) _RLIB_MACRO_CAT_II(~, a ## b)
#define _RLIB_MACRO_CAT_II(p, res) res
#endif
#ifndef RLIB_MAKE_UNIQUE_NAME
#define RLIB_MAKE_UNIQUE_NAME(base) RLIB_MACRO_CAT(base, __COUNTER__)
#endif
#endif
#!/usr/bin/fish
#test_dir="test-dir"
#test_mount_point="test-mount-point"
function hellofs_create_test_image
dd bs=4096 count=6000 if=/dev/zero of=$argv[1]
../mkfs-hellofs $argv[1]
end
function hellofs_mount_fs_image
mkdir $argv[2]
sudo insmod ../hellofs.ko
sudo mount -o loop,owner,group,users -t hellofs $argv[1] $argv[2]
end
function hellofs_unmount_fs
sudo umount $argv[1]
sudo rmmod ../hellofs.ko
end
#cleanup
#trap cleanup SIGINT EXIT
#mkdir "$test_dir" "$test_mount_point"
#create_test_image "$test_dir/image"
#
## run 1
#mount_fs_image "$test_dir/image" "$test_mount_point"
#do_some_operations "$test_mount_point"
#cd "$root_pwd"
#unmount_fs "$test_mount_point"
#
## run 2
#mount_fs_image "$test_dir/image" "$test_mount_point"
#do_read_operations "$test_mount_point"
#cd "$root_pwd"
#ls -lR "$test_mount_point"
#unmount_fs "$test_mount_point"
#
#echo "Test finished successfully!"
#cleanup
#
#make clean
#rm -rf "$test_dir/image" "$test_mount_point"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment