GithubHelp home page GithubHelp logo

alhafoudh / fdlink Goto Github PK

View Code? Open in Web Editor NEW
23.0 3.0 9.0 283 KB

File Descriptor Link - recover deleted files that are still opened

Home Page: http://sourceforge.net/projects/fdlink

C 81.06% Perl 18.94%

fdlink's Introduction

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.

fdlink's People

Contributors

alhafoudh avatar benibela avatar oysteinkrog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fdlink's Issues

Does not work with new kernels

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);

Fails to compile with newer kernels

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 = {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.