alhafoudh / fdlink Goto Github PK
View Code? Open in Web Editor NEWFile Descriptor Link - recover deleted files that are still opened
Home Page: http://sourceforge.net/projects/fdlink
File Descriptor Link - recover deleted files that are still opened
Home Page: http://sourceforge.net/projects/fdlink
Have you ever found yourself in a situation where you removed a precious file which was still open by a program? This kernel module and application will allow you to link that file back into its file system. It could be useful in other situations too.
It doesn't work with new kernels (e.g. 3.2.0-2-amd64).
I think these changes fix it:
--- flink_dev.c.old 2012-03-09 22:47:45.000000000 +0100
+++ flink_dev.c.new 2012-03-09 22:47:33.000000000 +0100
@@ -41,7 +41,7 @@
old_dentry = f->f_dentry;
error = 0;
- error = path_lookup(to, LOOKUP_PARENT, &nd);
+ error = kern_path(to, LOOKUP_PARENT, &nd);
if (error)
goto release_f;
@@ -49,7 +49,8 @@
if (f->f_vfsmnt != nd.path.mnt)
goto release_nd;
- new_dentry = lookup_create(&nd, 0);
+ struct path unused;
+ new_dentry = kern_path_create(AT_FDCWD, to, &unused, 0);
error = PTR_ERR(new_dentry);
if (!IS_ERR(new_dentry)) {
error = vfs_link(old_dentry, nd.path.dentry->d_inode, new_dentry);
Quick patch:
diff --git a/flink/Makefile b/flink/Makefile
index b2ac1fc..8362f00 100644
--- a/flink/Makefile
+++ b/flink/Makefile
@@ -5,7 +5,7 @@ obj-m := flink_dev.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
-CFLAGS += -g
+EXTRA_CFLAGS += -g
LDFLAGS += -g
all: default flinkapp
diff --git a/flink/flink_dev.c b/flink/flink_dev.c
index d1fcde9..a8b7d6e 100644
--- a/flink/flink_dev.c
+++ b/flink/flink_dev.c
@@ -12,13 +12,13 @@
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/namei.h>
+#include <linux/proc_fs.h>
#include <asm/uaccess.h>
#include "flink.h"
-static int flink_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
+static long flink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct flink __user *p = (struct flink __user *)arg;
struct dentry *old_dentry;
@@ -68,7 +68,7 @@ exit:
static const struct file_operations flink_fops = {
.owner = THIS_MODULE,
.ioctl = flink_ioctl,
.unlocked_ioctl = flink_ioctl,
};
static struct miscdevice flink_dev = {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.