Whamcloud - gitweb
mostly read, 2.2.1 -> 2.2.9 updates
authorpschwan <pschwan>
Thu, 10 Jun 1999 00:17:26 +0000 (00:17 +0000)
committerpschwan <pschwan>
Thu, 10 Jun 1999 00:17:26 +0000 (00:17 +0000)
lustre/include/linux/sym_obd.h
lustre/obdclass/obdcontrol

index 87c86b2..8bdfcbb 100755 (executable)
@@ -19,8 +19,8 @@ extern int obd_print_entry;
 #define D_UNUSED2     4
 #define D_UNUSED3     8
 #define D_UNUSED4    16
-#define D_UNUSED5    32
-#define D_UNUSED6    64
+#define D_WARNING    32 /* misc warnings */
+#define D_EXT2       64 /* anything from ext2_debug */
 #define D_MALLOC    128 /* print malloc, free information */
 #define D_CACHE     256 /* cache-related items */
 #define D_INFO      512 /* general information, especially from interface.c */
@@ -33,7 +33,7 @@ extern int obd_print_entry;
        if (obd_debug_level & mask) {                                   \
                printk("(%s,l. %d): ",  __FUNCTION__, __LINE__);        \
                printk(format, ## a); }                                 \
-       } while (0);
+       } while (0)
 
 #define ENTRY                                                                \
         if (obd_print_entry)                                                 \
@@ -45,7 +45,7 @@ extern int obd_print_entry;
 
 #else /* SYM_OBD_DEBUG */
 
-#       define CDEBUG(mask, format, a...) ;
+#       define CDEBUG ;
 #       define ENTRY ;
 #       define EXIT ;
 
@@ -101,18 +101,19 @@ struct ioc_prealloc {
 #define OBD_IOC_DESTROY                _IOW('f', 6, long)
 
 #define OBD_IOC_DEC_USE_COUNT          _IO('f', 8)
-
+#define OBD_IOC_SETATTR                _IOR('f', 9, long)
+#define OBD_IOC_READ                   _IOWR('f', 10, long)
 
 /* balloc.c */
-int obd_new_block (const struct inode * inode, unsigned long goal,
+int ext2_new_block (const struct inode * inode, unsigned long goal,
                    u32 * prealloc_count, u32 * prealloc_block, int * err);
-void obd_free_blocks (const struct inode * inode, unsigned long block,
+void ext2_free_blocks (const struct inode * inode, unsigned long block,
                       unsigned long count);
-unsigned long obd_count_free_blocks (struct super_block * sb);
+unsigned long ext2_count_free_blocks (struct super_block * sb);
 int ext2_group_sparse(int group);
 struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
-                                            unsigned int block_group,
-                                            struct buffer_head ** bh);
+                                            unsigned int block_group,
+                                            struct buffer_head ** bh);
 
 
 /* bitmap.c */
@@ -145,17 +146,36 @@ extern int obd_create (struct super_block * sb, int inode_hint, int * err);
 extern void obd_unlink (struct inode * inode);
 
 /* ioctl.c */
+struct oic_setattr_s {
+       unsigned long inode;
+       struct iattr iattr;
+};
+struct oic_read_s {
+       unsigned long inode;
+       char * buf;
+       unsigned long count;
+       loff_t offset;
+};
 int obd_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
               unsigned long arg);
 
 /* super.c */
+#define ext2_warning obd_warning
+#define ext2_error obd_warning
+#define ext2_panic obd_warning
+
+#ifdef EXT2FS_DEBUG
+#  undef ext2_debug
+#  define ext2_debug(format, a...) CDEBUG(D_EXT2, format, ## a)
+#endif
+
 #define obd_error obd_warning
 #define obd_panic obd_warning
-extern void obd_warning (struct super_block *, const char *, const char *, ...)
-       __attribute__ ((format (printf, 3, 4)));
+#define obd_warning(sb, func, format, a...) CDEBUG(D_WARNING, format, ## a)
+
 int obd_remount (struct super_block * sb, int * flags, char * data);
-struct super_block * obd_read_super (struct super_block * sb, void * data,
-                                    int silent);
+struct super_block * ext2_read_super (struct super_block * sb, void * data,
+                                     int silent);
 
 /* sysctl.c */
 extern void obd_sysctl_init (void);
@@ -166,9 +186,10 @@ void obd_truncate (struct inode * inode);
 
 /* operations */
 /* dir.c */
-extern struct inode_operations obd_dir_inode_operations;
+extern struct inode_operations ext2_dir_inode_operations;
 
 /* file.c */
-extern struct inode_operations obd_file_inode_operations;
+extern struct file_operations ext2_file_operations;
+extern struct inode_operations ext2_file_inode_operations;
 
 #endif /* __LINUX_SYM_OBD_H */
index 6967bdc..63a760f 100755 (executable)
@@ -15,6 +15,8 @@ eval 'sub OBD_IOC_DESTROY () { &_IOC(1, ord(\'f\'), 6, 4);}' unless
   defined(&OBD_IOC_DESTROY);
 eval 'sub OBD_IOC_DEC_USE_COUNT () { &_IOC(0, ord(\'f\'), 8, 0);}' unless
   defined(&OBD_IOC_DEC_USE_COUNT);
+eval 'sub OBD_IOC_READ () { &_IOC(3, ord(\'f\'), 10, 4);}' unless
+  defined(&OBD_IOC_READ);
 
 use Getopt::Long;
 use File::stat;
@@ -47,7 +49,8 @@ my %commands =
      'setup' => {func => "Setup", doc => "setup: initializes the environment"},
      'sync' => {func => "Sync", doc => "sync: flushes buffers to disk"},
      'destroy' => {func => "Destroy", doc => "setup: destroys an inode"},
-     'dec_use_count' => {func => "Decusecount", doc => "decreases the module use count so that it can be unmounted following an oops"},
+     'dec_use_count' => {func => "Decusecount", doc => "decreases the module use count so that the module can be removed following an oops"},
+     'read' => {func => "Read", doc => "read <inode> <count> [offset]"},
      'help' => {func => \&Help,  doc => "help: this message"},
      'quit' => {func => \&Quit,  doc => "see \"exit\""},
      'exit' => {func => \&Quit,  doc => "see \"quit\""}
@@ -209,6 +212,49 @@ sub Destroy {
     }
 }
 
+sub Read {
+    my $inode = shift;
+    my $count = shift;
+    my $offset = shift;
+
+    if (!defined($inode) || scalar($inode) < 1 || !defined($count) ||
+       $count < 1 || (defined($offset) && $offset < 0)) {
+       print "invalid arguments; type \"help read\" for a synopsis\n";
+       return;
+    }
+
+    if (!defined($offset)) {
+       $offset = 0;
+    }
+
+    print("Reading $count bytes starting at byte $offset from object " .
+         "$inode...\n");
+
+    # "allocate" a large enough buffer
+    my $buf = sprintf("%${count}s", " ");
+    die "suck" if (length($buf) != $count);
+
+    my $packed = pack("LpLLL", $inode, $buf, $count, 0, $offset);
+    my $rc = ioctl(DEV_OBD, &OBD_IOC_READ, $packed);
+
+    $retval = unpack("x4x4L", $packed);
+
+    if (!defined $rc) {
+       print STDERR "ioctl failed: $!\n";
+    } elsif ($rc eq "0 but true") {
+       if ($retval >= 0) {
+               print substr($buf, 0, $retval);
+               print "\nRead $retval of an attempted $count bytes.\n";
+               print "Finished (success)\n";
+       } else {
+               print "Finished (error $retval)\n";
+       }
+    } else {
+       print "ioctl returned error code $rc.\n";
+    }
+}
+
+# Unused for now
 sub Preallocate {
     my $arg = shift;
 
@@ -238,7 +284,7 @@ sub Preallocate {
 }
 
 sub Decusecount {
-    my $rc = ioctl(DEV_OBD, &OBD_IOC_DEC_USE_COUNT, NULL);
+    my $rc = ioctl(DEV_OBD, &OBD_IOC_DEC_USE_COUNT, 0);
 
     if (!defined $rc) {
        print STDERR "ioctl failed: $!\n";