B Thibault 9 yıl önce
ebeveyn
işleme
5841019bf5
5 değiştirilmiş dosya ile 69 ekleme ve 31 silme
  1. 10 31
      .gitignore
  2. 10 0
      Makefile
  3. 24 0
      butterflyfs.c
  4. 9 0
      src/butterfly.h
  5. 16 0
      src/mount.c

+ 10 - 31
.gitignore

@@ -1,34 +1,13 @@
-# ---> C
-# Object files
-*.o
-*.ko
-*.obj
-*.elf
-
-# Precompiled Headers
-*.gch
-*.pch
-
-# Libraries
-*.lib
-*.a
-*.la
-*.lo
+/test
+/Module.symvers
+/.tmp_versions
+/modules.order
 
-# Shared objects (inc. Windows DLLs)
-*.dll
-*.so
-*.so.*
-*.dylib
-
-# Executables
-*.exe
-*.out
-*.app
-*.i*86
-*.x86_64
-*.hex
+*.ko
+*.mod.c
+*.mod.o
+.*.cmd
+*.o
 
-# Debug files
-*.dSYM/
+\.*.swp
 

+ 10 - 0
Makefile

@@ -0,0 +1,10 @@
+obj-m += butterflyfs.o
+
+butterflyfs-objs := ./src/mount.o
+
+all:
+	make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
+
+clean:
+	make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean
+

+ 24 - 0
butterflyfs.c

@@ -0,0 +1,24 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include "src/butterfly.h"
+
+static struct file_system_type butterfly_fs = {
+    .owner          = THIS_MODULE,
+    .name           = "butterflyfs",
+    .fs_flags       = FS_REQUIRES_DEV,
+
+    .mount          = butterfly_mount,
+    .kill_sb        = butterfly_unmount
+};
+
+int init_module()
+{
+    return register_filesystem(&butterfly_fs);
+}
+
+void cleanup_module()
+{
+    unregister_filesystem(&butterfly_fs);
+}
+

+ 9 - 0
src/butterfly.h

@@ -0,0 +1,9 @@
+#ifndef  __BUTTERFLY_H__
+# define __BUTTERFLY_H__
+
+#include <linux/fs.h>
+
+struct dentry   *butterfly_mount(struct file_system_type *fs, int flags, const char *devname, void *data);
+void            butterfly_unmount(struct super_block *sb);
+
+#endif /*__BUTTERFLY_H__*/

+ 16 - 0
src/mount.c

@@ -0,0 +1,16 @@
+#include "butterfly.h"
+
+struct dentry   *butterfly_mount(
+        struct file_system_type *fs,
+        int flags,
+        const char *devname,
+        void *data)
+{
+    return NULL;
+}
+
+void butterfly_unmount(struct super_block *sb)
+{
+    kill_block_super(sb);
+}
+