Whamcloud - gitweb
Many files:
authorTheodore Ts'o <tytso@mit.edu>
Tue, 24 Mar 1998 16:17:51 +0000 (16:17 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 24 Mar 1998 16:17:51 +0000 (16:17 +0000)
  block.c (ext2fs_block_iterate3): Make the ref_offset field contain the
   offset into the inode.i_blocks array when ref_block is zero.  Since we
   haven't done a formal release of e2fsprogs since block_iterate2 was
   first introduced, I removed block_iterate2, and renamed block_iterate3
   to be block_iterate2.
  bb_inode.c, bmove.c, dblist_dir.c, dir_iterate.c, expanddir.c,
   ext2fs.h, ext2fsP.h, read_bb.c: Change use of block_iterate and
   block_iterate2 to block_iterate2 with the new prototype for the
   interator function.  (using blkcnt_t forr blockcount)
ChangeLog, debugfs.c, ls.c, lsdel.c:
  debugfs.c, ls.c, lsdel.c: Add support for large files.  (The high 32
   bits share space with the i_dir_acl field.)

15 files changed:
debugfs/ChangeLog
debugfs/debugfs.c
debugfs/ls.c
debugfs/lsdel.c
lib/ext2fs/ChangeLog
lib/ext2fs/bb_inode.c
lib/ext2fs/block.c
lib/ext2fs/bmove.c
lib/ext2fs/dblist_dir.c
lib/ext2fs/dir_iterate.c
lib/ext2fs/dll/jump.funcs
lib/ext2fs/expanddir.c
lib/ext2fs/ext2fs.h
lib/ext2fs/ext2fsP.h
lib/ext2fs/read_bb.c

index 2118556..834f8e1 100644 (file)
@@ -1,3 +1,8 @@
+1998-03-23  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * debugfs.c, ls.c, lsdel.c: Add support for large files.  (The
+               high 32 bits share space with the i_dir_acl field.)
+
 Sun Mar  8 22:53:04 1998  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * ls.c (list_dir_proc): Mask off high 8 bits from
index 85d14b0..232d0be 100644 (file)
@@ -306,16 +306,24 @@ static void dump_inode(ino_t inode_num, struct ext2_inode inode)
        fprintf(out, "Inode: %ld   Type: %s    ", inode_num, i_type);
        fprintf(out, "Mode:  %04o   Flags: 0x%x   Version: %d\n",
                inode.i_mode & 0777, inode.i_flags, inode.i_version);
-       fprintf(out, "User: %5d   Group: %5d   Size: %d\n",  
-               inode.i_uid, inode.i_gid, inode.i_size);
+       fprintf(out, "User: %5d   Group: %5d   Size: ",
+               inode.i_uid, inode.i_gid);
+       if (LINUX_S_ISDIR(inode.i_mode))
+               fprintf(out, "%d\n", inode.i_size);
+       else {
+               __u64 i_size = (inode.i_size |
+                               ((unsigned long long)inode.i_size_high << 32));
+               
+               fprintf(out, "%lld\n", i_size);
+       }
        if (current_fs->super->s_creator_os == EXT2_OS_HURD)
                fprintf(out,
                        "File ACL: %d    Directory ACL: %d Translator: %d\n",
-                       inode.i_file_acl, inode.i_dir_acl,
+                       inode.i_file_acl, LINUX_S_ISDIR(inode.i_mode) ? inode.i_dir_acl : 0,
                        inode.osd1.hurd1.h_i_translator);
        else
                fprintf(out, "File ACL: %d    Directory ACL: %d\n",
-                       inode.i_file_acl, inode.i_dir_acl);
+                       inode.i_file_acl, LINUX_S_ISDIR(inode.i_mode) ? inode.i_dir_acl : 0);
        fprintf(out, "Links: %d   Blockcount: %d\n", inode.i_links_count,
                inode.i_blocks);
        switch (os) {
@@ -681,7 +689,10 @@ void do_modify_inode(int argc, char *argv[])
        modify_u32(argv[0], "Reserved1", decimal_format, &inode.i_reserved1);
 #endif
        modify_u32(argv[0], "File acl", decimal_format, &inode.i_file_acl);
-       modify_u32(argv[0], "Directory acl", decimal_format, &inode.i_dir_acl);
+       if (LINUX_S_ISDIR(inode.i_mode))
+               modify_u32(argv[0], "Directory acl", decimal_format, &inode.i_dir_acl);
+       else
+               modify_u32(argv[0], "High 32bits of size", decimal_format, &inode.i_size_high);
 
        if (current_fs->super->s_creator_os == EXT2_OS_HURD)
                modify_u32(argv[0], "Translator Block",
index 2f5c83a..aadf75d 100644 (file)
@@ -51,8 +51,14 @@ static void ls_l_file(struct list_dir_struct *ls, char *name, ino_t ino)
        sprintf(datestr, "%2d-%s-%2d %02d:%02d",
                tm_p->tm_mday, monstr[tm_p->tm_mon], tm_p->tm_year,
                tm_p->tm_hour, tm_p->tm_min);
-       fprintf(ls->f, "%6ld %6o  %5d  %5d   %5d %s %s\n", ino, inode.i_mode,
-              inode.i_uid, inode.i_gid, inode.i_size, datestr, name);
+       fprintf(ls->f, "%6ld %6o  %5d  %5d   ", ino, inode.i_mode,
+              inode.i_uid, inode.i_gid);
+       if (LINUX_S_ISDIR(inode.i_mode))
+               fprintf(ls->f, "%5d", inode.i_size);
+       else
+               fprintf(ls->f, "%5lld", inode.i_size |
+                       ((__u64)inode.i_size_high << 32));
+       fprintf (ls->f, " %s %s\n", datestr, name);
 }
 
 static void ls_file(struct list_dir_struct *ls, char *name,
index a307d8b..f2e41dc 100644 (file)
@@ -23,7 +23,7 @@ struct deleted_info {
        ino_t   ino;
        unsigned short mode;
        unsigned short uid;
-       unsigned long size;
+       __u64   size;
        time_t  dtime;
        int     num_blocks;
        int     free_blocks;
@@ -148,6 +148,9 @@ void do_lsdel(int argc, char **argv)
                        delarray[num_delarray].mode = inode.i_mode;
                        delarray[num_delarray].uid = inode.i_uid;
                        delarray[num_delarray].size = inode.i_size;
+                       if (!LINUX_S_ISDIR(inode.i_mode))
+                               delarray[num_delarray].size |= 
+                                       ((__u64) inode.i_size_high << 32);
                        delarray[num_delarray].dtime = inode.i_dtime;
                        delarray[num_delarray].num_blocks = lsd.num_blocks;
                        delarray[num_delarray].free_blocks = lsd.free_blocks;
@@ -170,7 +173,7 @@ void do_lsdel(int argc, char **argv)
              deleted_info_compare);
        
        for (i = 0; i < num_delarray; i++) {
-               printf("%6lu %6d %6o %6lu %4d/%4d %s", delarray[i].ino,
+               printf("%6lu %6d %6o %6llu %4d/%4d %s", delarray[i].ino,
                       delarray[i].uid, delarray[i].mode, delarray[i].size,
                       delarray[i].free_blocks, delarray[i].num_blocks, 
                       time_to_string(delarray[i].dtime));
index 99285ee..3ddfaff 100644 (file)
@@ -1,3 +1,18 @@
+1998-03-23  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * block.c (ext2fs_block_iterate3): Make the ref_offset field
+               contain the offset into the inode.i_blocks array when
+               ref_block is zero.  Since we haven't done a formal
+               release of e2fsprogs since block_iterate2 was first
+               introduced, I removed block_iterate2, and renamed
+               block_iterate3 to be block_iterate2.
+
+       * bb_inode.c, bmove.c, dblist_dir.c, dir_iterate.c,
+               expanddir.c, ext2fs.h, ext2fsP.h, read_bb.c: Change
+               use of block_iterate and block_iterate2 to
+               block_iterate2 with the new prototype for the
+               interator function.  (using blkcnt_t forr blockcount)
+
 1998-03-21  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * ext2fs.h: Add new superblock fields (s_algorithm_usage_bitmap, 
index cc867cd..995e3ba 100644 (file)
@@ -46,10 +46,12 @@ struct set_badblock_record {
        errcode_t       err;
 };
 
-static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt,
+static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
+                             blkcnt_t blockcnt,
                              blk_t ref_block, int ref_offset,
                              void *priv_data);
-static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt,
+static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
+                               blkcnt_t blockcnt,
                                blk_t ref_block, int ref_offset,
                                void *priv_data);
        
@@ -163,7 +165,8 @@ cleanup:
 #ifdef __TURBOC__
 #pragma argsused
 #endif
-static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt,
+static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
+                               blkcnt_t blockcnt,
                                blk_t ref_block, int ref_offset,
                                void *priv_data)
 {
@@ -222,7 +225,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt,
 #pragma argsused
 #endif
 static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
-                             int blockcnt, blk_t ref_block, 
+                             blkcnt_t blockcnt, blk_t ref_block, 
                              int ref_offset, void *priv_data)
 {
        struct set_badblock_record *rec = (struct set_badblock_record *)
index 455307b..16a97c8 100644 (file)
@@ -301,7 +301,7 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block,
        return ret;
 }
        
-errcode_t ext2fs_block_iterate3(ext2_filsys fs,
+errcode_t ext2fs_block_iterate2(ext2_filsys fs,
                                ino_t   ino,
                                int     flags,
                                char *block_buf,
@@ -384,28 +384,28 @@ errcode_t ext2fs_block_iterate3(ext2_filsys fs,
        for (i = 0; i < EXT2_NDIR_BLOCKS ; i++, ctx.bcount++) {
                if (blocks[i] || (flags & BLOCK_FLAG_APPEND)) {
                        ret |= (*ctx.func)(fs, &blocks[i],
-                                           ctx.bcount, 0, 0, priv_data);
+                                           ctx.bcount, 0, i, priv_data);
                        if (ret & BLOCK_ABORT)
                                goto abort;
                }
        }
        if (*(blocks + EXT2_IND_BLOCK) || (flags & BLOCK_FLAG_APPEND)) {
                ret |= block_iterate_ind(blocks + EXT2_IND_BLOCK,
-                                        0, 0, &ctx);
+                                        0, EXT2_IND_BLOCK, &ctx);
                if (ret & BLOCK_ABORT)
                        goto abort;
        } else
                ctx.bcount += limit;
        if (*(blocks + EXT2_DIND_BLOCK) || (flags & BLOCK_FLAG_APPEND)) {
                ret |= block_iterate_dind(blocks + EXT2_DIND_BLOCK,
-                                         0, 0, &ctx);
+                                         0, EXT2_DIND_BLOCK, &ctx);
                if (ret & BLOCK_ABORT)
                        goto abort;
        } else
                ctx.bcount += limit * limit;
        if (*(blocks + EXT2_TIND_BLOCK) || (flags & BLOCK_FLAG_APPEND)) {
                ret |= block_iterate_tind(blocks + EXT2_TIND_BLOCK,
-                                         0, 0, &ctx);
+                                         0, EXT2_TIND_BLOCK, &ctx);
                if (ret & BLOCK_ABORT)
                        goto abort;
        }
@@ -468,54 +468,7 @@ errcode_t ext2fs_block_iterate(ext2_filsys fs,
        xl.real_private = priv_data;
        xl.func = func;
 
-       return ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_NO_LARGE | flags,
+       return ext2fs_block_iterate2(fs, ino, BLOCK_FLAG_NO_LARGE | flags,
                                     block_buf, xlate_func, &xl);
 }
 
-/*
- * Emulate the old ext2fs_block_iterate2 function!
- */
-
-struct xlate2 {
-       int (*func)(ext2_filsys fs,
-                   blk_t       *blocknr,
-                   int         blockcnt,
-                   blk_t       ref_blk,
-                   int         ref_offset,
-                   void        *priv_data);
-       void *real_private;
-};
-
-#ifdef __TURBOC__
-#pragma argsused
-#endif
-static int xlate_func2(ext2_filsys fs, blk_t *blocknr, blkcnt_t blockcnt,
-                     blk_t ref_block, int ref_offset, void *priv_data)
-{
-       struct xlate2 *xl = (struct xlate2 *) priv_data;
-
-       return (*xl->func)(fs, blocknr, (int) blockcnt, ref_block,
-                          ref_offset, xl->real_private);
-}
-
-errcode_t ext2fs_block_iterate2(ext2_filsys fs,
-                               ino_t   ino,
-                               int     flags,
-                               char *block_buf,
-                               int (*func)(ext2_filsys fs,
-                                           blk_t       *blocknr,
-                                           int blockcnt,
-                                           blk_t       ref_blk,
-                                           int         ref_offset,
-                                           void        *priv_data),
-                               void *priv_data)
-{
-       struct xlate2 xl;
-       
-       xl.real_private = priv_data;
-       xl.func = func;
-
-       return ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_NO_LARGE | flags,
-                                    block_buf, xlate_func2, &xl);
-}
-
index 0a06ff0..24368e9 100644 (file)
@@ -38,7 +38,7 @@ struct process_block_struct {
 };
 
 static int process_block(ext2_filsys fs, blk_t *block_nr,
-                        int blockcnt, blk_t ref_block,
+                        blkcnt_t blockcnt, blk_t ref_block,
                         int ref_offset, void *priv_data)
 {
        struct process_block_struct *pb;
@@ -78,12 +78,12 @@ static int process_block(ext2_filsys fs, blk_t      *block_nr,
                ext2fs_mark_block_bitmap(pb->alloc_map, block);
                ret = BLOCK_CHANGED;
                if (pb->flags & EXT2_BMOVE_DEBUG)
-                       printf("ino=%ld, blockcnt=%d, %d->%d\n", pb->ino,
+                       printf("ino=%ld, blockcnt=%ld, %d->%d\n", pb->ino,
                               blockcnt, orig, block);
        }
        if (pb->add_dir) {
                retval = ext2fs_add_dir_block(fs->dblist, pb->ino,
-                                             block, blockcnt);
+                                             block, (int) blockcnt);
                if (retval) {
                        pb->error = retval;
                        ret |= BLOCK_ABORT;
index 7ad159e..7fd14e0 100644 (file)
@@ -79,5 +79,5 @@ static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
        ctx->dir = db_info->ino;
        
        return ext2fs_process_dir_block(fs, &db_info->blk,
-                                       db_info->blockcnt, priv_data);
+                                       db_info->blockcnt, 0, 0, priv_data);
 }
index 2d254b7..869c13b 100644 (file)
@@ -59,8 +59,8 @@ errcode_t ext2fs_dir_iterate(ext2_filsys fs,
        ctx.func2 = 0;
        ctx.priv_data = priv_data;
        ctx.errcode = 0;
-       retval = ext2fs_block_iterate(fs, dir, 0, 0,
-                                     ext2fs_process_dir_block, &ctx);
+       retval = ext2fs_block_iterate2(fs, dir, 0, 0,
+                                      ext2fs_process_dir_block, &ctx);
        if (!block_buf)
                ext2fs_free_mem((void **) &ctx.buf);
        if (retval)
@@ -74,7 +74,9 @@ errcode_t ext2fs_dir_iterate(ext2_filsys fs,
  */
 extern int ext2fs_process_dir_block(ext2_filsys        fs,
                                    blk_t               *blocknr,
-                                   int         blockcnt,
+                                   blkcnt_t            blockcnt,
+                                   blk_t               ref_block,
+                                   int                 ref_offset,
                                    void                *priv_data)
 {
        struct dir_context *ctx = (struct dir_context *) priv_data;
@@ -88,12 +90,12 @@ extern int ext2fs_process_dir_block(ext2_filsys     fs,
        if (blockcnt < 0)
                return 0;
 
+       entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE;
+       
        ctx->errcode = ext2fs_read_dir_block(fs, *blocknr, ctx->buf);
        if (ctx->errcode)
                return BLOCK_ABORT;
 
-       entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE;
-       
        while (offset < fs->blocksize) {
                dirent = (struct ext2_dir_entry *) (ctx->buf + offset);
                if (!dirent->inode &&
index 63377ee..4995478 100644 (file)
 00000000 T _ext2fs_get_mem                     libext2fs       inline
 00000000 T _ext2fs_free_mem                    libext2fs       inline
 00000000 T _ext2fs_resize_mem                  libext2fs       inline
-00000000 T _ext2fs_block_iterate3              libext2fs       block
index 043e9c0..e2d8c35 100644 (file)
@@ -28,10 +28,12 @@ struct expand_dir_struct {
        errcode_t       err;
 };
 
-static int expand_dir_proc(ext2_filsys fs,
-                          blk_t        *blocknr,
-                          int  blockcnt,
-                          void *priv_data)
+static int expand_dir_proc(ext2_filsys         fs,
+                          blk_t                *blocknr,
+                          blkcnt_t             blockcnt,
+                          blk_t                ref_block,
+                          int                  ref_offset,
+                          void                 *priv_data)
 {
        struct expand_dir_struct *es = (struct expand_dir_struct *) priv_data;
        blk_t   new_blk;
@@ -105,8 +107,8 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ino_t dir)
        es.done = 0;
        es.err = 0;
        
-       retval = ext2fs_block_iterate(fs, dir, BLOCK_FLAG_APPEND,
-                                     0, expand_dir_proc, &es);
+       retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND,
+                                      0, expand_dir_proc, &es);
 
        if (es.err)
                return es.err;
index 0180a43..eec5520 100644 (file)
@@ -228,7 +228,7 @@ struct struct_ext2_filsys {
  * called for data blocks only.
  *
  * BLOCK_FLAG_NO_LARGE is for internal use only.  It informs
- * ext2fs_block_iterate3 that large files won't be accepted.
+ * ext2fs_block_iterate2 that large files won't be accepted.
  */
 #define BLOCK_FLAG_APPEND      1
 #define BLOCK_FLAG_HOLE                1
@@ -533,24 +533,12 @@ extern errcode_t ext2fs_block_iterate(ext2_filsys fs,
                                                  int   blockcnt,
                                                  void  *priv_data),
                                      void *priv_data);
-
 errcode_t ext2fs_block_iterate2(ext2_filsys fs,
                                ino_t   ino,
                                int     flags,
                                char *block_buf,
                                int (*func)(ext2_filsys fs,
                                            blk_t       *blocknr,
-                                           int blockcnt,
-                                           blk_t       ref_blk,
-                                           int         ref_offset,
-                                           void        *priv_data),
-                               void *priv_data);
-errcode_t ext2fs_block_iterate3(ext2_filsys fs,
-                               ino_t   ino,
-                               int     flags,
-                               char *block_buf,
-                               int (*func)(ext2_filsys fs,
-                                           blk_t       *blocknr,
                                            blkcnt_t    blockcnt,
                                            blk_t       ref_blk,
                                            int         ref_offset,
@@ -631,11 +619,6 @@ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
                                          char  *buf,
                                          void  *priv_data),
                              void *priv_data);
-       /* priv_data to library */
-extern int ext2fs_process_dir_block(ext2_filsys        fs,
-                                   blk_t               *blocknr,
-                                   int         blockcnt,
-                                   void                *priv_data);
 
 /* dupfs.c */
 extern errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest);
index f5bc1be..129cf90 100644 (file)
@@ -83,8 +83,11 @@ struct ext2_inode_cache_ent {
 
 /* Function prototypes */
 
-extern int ext2_process_dir_block(ext2_filsys fs,
-                                 blk_t *blocknr,
-                                 int   blockcnt,
-                                 void  *priv_data);
+extern int ext2fs_process_dir_block(ext2_filsys        fs,
+                                   blk_t               *blocknr,
+                                   blkcnt_t            blockcnt,
+                                   blk_t               ref_block,
+                                   int                 ref_offset,
+                                   void                *priv_data);
+
 
index d8c6463..c43f97c 100644 (file)
@@ -43,7 +43,8 @@ struct read_bb_record {
 #pragma argsused
 #endif
 static int mark_bad_block(ext2_filsys fs, blk_t *block_nr,
-                            int blockcnt, void *priv_data)
+                         blkcnt_t blockcnt, blk_t ref_block,
+                         int ref_offset, void *priv_data)
 {
        struct read_bb_record *rb = (struct read_bb_record *) priv_data;
        
@@ -80,7 +81,7 @@ errcode_t ext2fs_read_bb_inode(ext2_filsys fs, ext2_badblocks_list *bb_list)
 
        rb.bb_list = *bb_list;
        rb.err = 0;
-       retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0,
+       retval = ext2fs_block_iterate2(fs, EXT2_BAD_INO, 0, 0,
                                      mark_bad_block, &rb);
        if (retval)
                return retval;