]> git.hungrycats.org Git - linux/commitdiff
[PATCH] more use fat_get_short_entry()
authorHirofumi Ogawa <hirofumi@mail.parknet.co.jp>
Sat, 2 Aug 2003 11:09:20 +0000 (04:09 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Sat, 2 Aug 2003 11:09:20 +0000 (04:09 -0700)
This uses fat_get_short_entry() in fat_dir_empty(). Moves fat_scan() and
fat_subdirs() to dir.c.

fs/fat/dir.c
fs/fat/misc.c
include/linux/msdos_fs.h

index 44474ae18fd6c5b5e34bc19dd97238f5dfb884c7..c1fa8e4820208a8b5a095f2ccdfd228bba2ae552 100644 (file)
@@ -688,32 +688,6 @@ int fat_dir_ioctl(struct inode * inode, struct file * filp,
        return ret;
 }
 
-/***** See if directory is empty */
-int fat_dir_empty(struct inode *dir)
-{
-       loff_t pos, i_pos;
-       struct buffer_head *bh;
-       struct msdos_dir_entry *de;
-       int result = 0;
-
-       pos = 0;
-       bh = NULL;
-       while (fat_get_entry(dir,&pos,&bh,&de,&i_pos) > -1) {
-               /* Ignore vfat longname entries */
-               if (de->attr == ATTR_EXT)
-                       continue;
-               if (!IS_FREE(de->name) && 
-                   strncmp(de->name,MSDOS_DOT   , MSDOS_NAME) &&
-                   strncmp(de->name,MSDOS_DOTDOT, MSDOS_NAME)) {
-                       result = -ENOTEMPTY;
-                       break;
-               }
-       }
-
-       brelse(bh);
-       return result;
-}
-
 /* This assumes that size of cluster is above the 32*slots */
 
 int fat_add_entries(struct inode *dir,int slots, struct buffer_head **bh,
@@ -790,19 +764,75 @@ int fat_new_dir(struct inode *dir, struct inode *parent, int is_vfat)
        return 0;
 }
 
+static int fat_get_short_entry(struct inode *dir, loff_t *pos,
+                              struct buffer_head **bh,
+                              struct msdos_dir_entry **de, loff_t *i_pos)
+{
+       while (fat_get_entry(dir, pos, bh, de, i_pos) >= 0) {
+               /* free entry or long name entry or volume label */
+               if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME))
+                       return 0;
+       }
+       return -ENOENT;
+}
+
+/* See if directory is empty */
+int fat_dir_empty(struct inode *dir)
+{
+       struct buffer_head *bh;
+       struct msdos_dir_entry *de;
+       loff_t cpos, i_pos;
+       int result = 0;
+
+       bh = NULL;
+       cpos = 0;
+       while (fat_get_short_entry(dir, &cpos, &bh, &de, &i_pos) >= 0) {
+               if (strncmp(de->name, MSDOS_DOT   , MSDOS_NAME) &&
+                   strncmp(de->name, MSDOS_DOTDOT, MSDOS_NAME)) {
+                       result = -ENOTEMPTY;
+                       break;
+               }
+       }
+       brelse(bh);
+       return result;
+}
+
+/*
+ * fat_subdirs counts the number of sub-directories of dir. It can be run
+ * on directories being created.
+ */
+int fat_subdirs(struct inode *dir)
+{
+       struct buffer_head *bh;
+       struct msdos_dir_entry *de;
+       loff_t cpos, i_pos;
+       int count = 0;
+
+       bh = NULL;
+       cpos = 0;
+       while (fat_get_short_entry(dir, &cpos, &bh, &de, &i_pos) >= 0) {
+               if (de->attr & ATTR_DIR)
+                       count++;
+       }
+       brelse(bh);
+       return count;
+}
+
 /*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-indent-level: 8
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -8
- * c-argdecl-indent: 8
- * c-label-offset: -8
- * c-continued-statement-offset: 8
- * c-continued-brace-offset: 0
- * End:
+ * Scans a directory for a given file (name points to its formatted name).
+ * Returns an error code or zero.
  */
+int fat_scan(struct inode *dir, const unsigned char *name,
+            struct buffer_head **bh, struct msdos_dir_entry **de,
+            loff_t *i_pos)
+{
+       loff_t cpos;
+
+       *bh = NULL;
+       cpos = 0;
+       while (fat_get_short_entry(dir, &cpos, bh, de, i_pos) >= 0) {
+               if (!strncmp((*de)->name, name, MSDOS_NAME))
+                       return 0;
+       }
+       return -ENOENT;
+}
index 6406f202bbb7282f736572c56fe156e8c53101d2..b50f423466eb9129c8c2868ba717b30d5127ff2f 100644 (file)
@@ -308,55 +308,3 @@ next:
 
        return 0;
 }
-
-static int fat_get_short_entry(struct inode *dir, loff_t *pos,
-                              struct buffer_head **bh,
-                              struct msdos_dir_entry **de, loff_t *i_pos)
-{
-       while (fat_get_entry(dir, pos, bh, de, i_pos) >= 0) {
-               /* free entry or long name entry or volume label */
-               if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME))
-                       return 0;
-       }
-       return -ENOENT;
-}
-
-/*
- * fat_subdirs counts the number of sub-directories of dir. It can be run
- * on directories being created.
- */
-int fat_subdirs(struct inode *dir)
-{
-       struct buffer_head *bh;
-       struct msdos_dir_entry *de;
-       loff_t cpos, i_pos;
-       int count = 0;
-
-       bh = NULL;
-       cpos = 0;
-       while (fat_get_short_entry(dir, &cpos, &bh, &de, &i_pos) >= 0) {
-               if (de->attr & ATTR_DIR)
-                       count++;
-       }
-       brelse(bh);
-       return count;
-}
-
-/*
- * Scans a directory for a given file (name points to its formatted name).
- * Returns an error code or zero.
- */
-int fat_scan(struct inode *dir, const unsigned char *name,
-            struct buffer_head **bh, struct msdos_dir_entry **de,
-            loff_t *i_pos)
-{
-       loff_t cpos;
-
-       *bh = NULL;
-       cpos = 0;
-       while (fat_get_short_entry(dir, &cpos, bh, de, i_pos) >= 0) {
-               if (!strncmp((*de)->name, name, MSDOS_NAME))
-                       return 0;
-       }
-       return -ENOENT;
-}
index 060549a8785195254bfb689f540ca94f57fe91ac..b1fb57c910866b9103ffbfe8b287116b2759a3c0 100644 (file)
@@ -249,10 +249,14 @@ extern int fat_search_long(struct inode *inode, const unsigned char *name,
 extern int fat_readdir(struct file *filp, void *dirent, filldir_t filldir);
 extern int fat_dir_ioctl(struct inode * inode, struct file * filp,
                         unsigned int cmd, unsigned long arg);
-extern int fat_dir_empty(struct inode *dir);
 extern int fat_add_entries(struct inode *dir, int slots, struct buffer_head **bh,
                        struct msdos_dir_entry **de, loff_t *i_pos);
 extern int fat_new_dir(struct inode *dir, struct inode *parent, int is_vfat);
+extern int fat_dir_empty(struct inode *dir);
+extern int fat_subdirs(struct inode *dir);
+extern int fat_scan(struct inode *dir, const unsigned char *name,
+                   struct buffer_head **res_bh,
+                   struct msdos_dir_entry **res_de, loff_t *i_pos);
 
 /* fat/file.c */
 extern struct file_operations fat_file_operations;
@@ -304,10 +308,6 @@ static __inline__ int fat_get_entry(struct inode *dir, loff_t *pos,
        }
        return fat__get_entry(dir, pos, bh, de, i_pos);
 }
-extern int fat_subdirs(struct inode *dir);
-extern int fat_scan(struct inode *dir, const unsigned char *name,
-                   struct buffer_head **res_bh,
-                   struct msdos_dir_entry **res_de, loff_t *i_pos);
 
 /* msdos/namei.c  - these are for Umsdos */
 extern struct dentry *msdos_lookup(struct inode *dir, struct dentry *, struct nameidata *);