bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new tmpfs filesystem


From: Alexey Dejneka
Subject: Re: new tmpfs filesystem
Date: Sat, 30 Dec 2000 12:15:12 +0300

Here is a patch for your code, that makes it compilable:
--- cut here ---
diff -ur -x *CVS* /home/alexey/gnu/hurd/tmpfs/dir.c
/mnt/hurd/root/prog/hurd/tmpfs/dir.c
--- /home/alexey/gnu/hurd/tmpfs/dir.c   Wed Dec 27 03:57:36 2000
+++ /mnt/hurd/root/prog/hurd/tmpfs/dir.c        Sat Dec 30 15:00:47 2000
@@ -19,6 +19,8 @@
 
 #include "tmpfs.h"
 #include <stdlib.h>
+#include <stddef.h>
+#include <sys/mman.h>
 
 error_t
 diskfs_init_dir (struct node *dp, struct node *pdp, struct protid
*cred)
@@ -146,7 +148,7 @@
     }
   if (namelen == 2 && name[0] == '.' && name[1] == '.')
     {
-      struct disknode *ddnp = dp->dn->dir.dotdot;
+      struct disknode *ddnp = dp->dn->u.dir.dotdot;
       assert (np != 0);
       if (ddnp == 0)           /* root directory */
        return EAGAIN;
@@ -156,7 +158,7 @@
          diskfs_nput (dp);
        default:
          diskfs_nref (ddnp);
-         mutex_lock (&ddnp->lock);
+         mutex_lock (&dp->lock);
        case REMOVE|SPEC_DOTDOT:
        case RENAME|SPEC_DOTDOT:
          *np = ddnp;
diff -ur -x *CVS* /home/alexey/gnu/hurd/tmpfs/node.c
/mnt/hurd/root/prog/hurd/tmpfs/node.c
--- /home/alexey/gnu/hurd/tmpfs/node.c  Fri Dec 29 10:23:24 2000
+++ /mnt/hurd/root/prog/hurd/tmpfs/node.c       Sat Dec 30 14:58:15 2000
@@ -19,6 +19,7 @@
 
 #include "tmpfs.h"
 #include <stdlib.h>
+#include <stddef.h>
 
 unsigned int num_files;
 static unsigned int gen;
@@ -75,7 +76,7 @@
 
   spin_lock (&diskfs_node_refcnt_lock);
   --num_files;
-  tmpfs_space_used -= sizeof *dn;
+  tmpfs_space_used -= sizeof *np->dn;
   spin_unlock (&diskfs_node_refcnt_lock);
 }
 
@@ -106,7 +107,7 @@
          np->dn->u.reg.allocpages = np->allocsize / vm_page_size;
          break;
        case DT_CHR:
-       case DT_DEV:
+       case DT_BLK:
          np->dn->u.chr = np->dn_stat.st_rdev;
          break;
        }
@@ -124,7 +125,7 @@
 recompute_blocks (struct node *np)
 {
   struct disknode *const dn = np->dn;
-  struct stat *const st = np->dn_stat;
+  struct stat *const st = &np->dn_stat;
 
   st->st_blocks = sizeof *dn + dn->translen;
   switch (dn->type)
@@ -137,7 +138,7 @@
       st->st_blocks += st->st_size + 1;
       break;
     case DT_CHR:
-    case DT_DEV:
+    case DT_BLK:
       st->st_rdev = dn->u.chr;
       break;
     case DT_DIR:
@@ -164,6 +165,7 @@
     }
   else
     {
+       struct stat *st;
       /* Create the new node.  */
       np = diskfs_make_node (dn);
       np->cache_id = (ino_t) dn;
@@ -174,7 +176,7 @@
       all_nodes = np;
       spin_unlock (&diskfs_node_refcnt_lock);
 
-      st = &dn->dn_stat;
+      st = &np->dn_stat;
       memset (st, 0, sizeof *st);
       st->st_fstype = FSTYPE_MEMFS;
       st->st_fsid = getpid ();
@@ -320,8 +322,8 @@
   if (np->dn_stat.st_size > 0)
     {
       const size_t size = np->dn_stat.st_size + 1;
-      char *const new = malloc (np->dn->u.lnk, size);
-      if (new == 0)
+      np->dn->u.lnk = malloc (size);
+      if (np->dn->u.lnk == 0)
        return ENOSPC;
       memcpy (np->dn->u.lnk, target, size);
       adjust_used (size);
@@ -329,6 +331,8 @@
     }
   return 0;
 }
+
+static error_t read_symlink_hook (struct node *np, char *target);
 error_t (*diskfs_read_symlink_hook)(struct node *np, char *target)
      = read_symlink_hook;
 
diff -ur -x *CVS* /home/alexey/gnu/hurd/tmpfs/tmpfs.c
/mnt/hurd/root/prog/hurd/tmpfs/tmpfs.c
--- /home/alexey/gnu/hurd/tmpfs/tmpfs.c Wed Dec 27 03:57:36 2000
+++ /mnt/hurd/root/prog/hurd/tmpfs/tmpfs.c      Sat Dec 30 15:04:24 2000
@@ -20,6 +20,10 @@
 #include "tmpfs.h"
 #include <limits.h>
 #include <version.h>
+#include <argp.h>
+#include <argz.h>
+#include <inttypes.h>
+#include <error.h>
 
 char *diskfs_server_name = "tmpfs";
 char *diskfs_server_version = HURD_VERSION;
@@ -42,6 +46,10 @@
 
 struct node *diskfs_root_node;
 
+unsigned int num_files;
+off_t tmpfs_page_limit, tmpfs_space_used;
+
+mach_port_t default_pager;
 ^L
 error_t
 diskfs_set_statfs (struct statfs *st)
@@ -122,7 +130,7 @@
       else
        {
          char *end = NULL;
-         intmax_t size = strtoimax (state->argv[state->next], 0, &end);
+         intmax_t size = strtoimax (state->argv[state->next], &end, 0);
          if (end == NULL || end == arg)
            {
              argp_error (state, "argument must be a number");
@@ -229,8 +237,8 @@
     error (0, err, "Cannot get host privileged port");
   else
     {
-      err = vm_set_default_memory_manager (host, &default_pager);
-      mach_port_deallocate (mach_task_self (), host);
+      err = vm_set_default_memory_manager (host_priv, &default_pager);
+      mach_port_deallocate (mach_task_self (), host_priv);
       if (err)
        error (0, err, "Cannot get default pager port");
     }
diff -ur -x *CVS* /home/alexey/gnu/hurd/tmpfs/tmpfs.h
/mnt/hurd/root/prog/hurd/tmpfs/tmpfs.h
--- /home/alexey/gnu/hurd/tmpfs/tmpfs.h Wed Dec 27 03:57:36 2000
+++ /mnt/hurd/root/prog/hurd/tmpfs/tmpfs.h      Sat Dec 30 14:42:39 2000
@@ -51,11 +51,6 @@
     } reg;
     struct
     {
-      mach_port_t memobj;
-      unsigned int allocpages; /* largest size while memobj was live */
-    };
-    struct
-    {
       struct tmpfs_dirent *entries;
       struct disknode *dotdot;
     } dir;
--- cut here ---
But it is not linkable:
---
../libpager/libpager.so: undefined reference to `pager_report_extent'
../libdiskfs/libdiskfs.so: undefined reference to
`diskfs_S_file_get_storage_info'
../libpager/libpager.so: undefined reference to `pager_write_page'
../libdiskfs/libdiskfs.so: undefined reference to
`diskfs_readonly_changed'
../libpager/libpager.so: undefined reference to `pager_read_page'
../libpager/libpager.so: undefined reference to `pager_clear_user_data'
../libpager/libpager.so: undefined reference to `pager_unlock_page'
../libpager/libpager.so: undefined reference to `pager_dropweak'
../libdiskfs/libdiskfs.so: undefined reference to `diskfs_synchronous'
collect2: ld returned 1 exit status
make: *** [tmpfs] Error 1
---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]