Some yaffsfs cleanups for WinCE
authorCharles Manning <cdhmanning@gmail.com>
Tue, 5 Aug 2014 21:26:59 +0000 (09:26 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 5 Aug 2014 21:26:59 +0000 (09:26 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/yaffs_attribs.c
direct/yaffsfs.c
direct/yaffsfs.h
direct/yportenv.h
yaffs_guts.c

index 767af96..de80fe4 100644 (file)
 
 void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
 {
+#ifdef CONFIG_YAFFS_WINCE
+       obj->win_atime[0] = oh->win_atime[0];
+       obj->win_ctime[0] = oh->win_ctime[0];
+       obj->win_mtime[0] = oh->win_mtime[0];
+       obj->win_atime[1] = oh->win_atime[1];
+       obj->win_ctime[1] = oh->win_ctime[1];
+       obj->win_mtime[1] = oh->win_mtime[1];
+#else
        obj->yst_uid = oh->yst_uid;
        obj->yst_gid = oh->yst_gid;
        obj->yst_atime = oh->yst_atime;
        obj->yst_mtime = oh->yst_mtime;
        obj->yst_ctime = oh->yst_ctime;
        obj->yst_rdev = oh->yst_rdev;
+#endif
 }
 
 
 void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
 {
 #ifdef CONFIG_YAFFS_WINCE
-               oh->win_atime[0] = obj->win_atime[0];
-               oh->win_ctime[0] = obj->win_ctime[0];
-               oh->win_mtime[0] = obj->win_mtime[0];
-               oh->win_atime[1] = obj->win_atime[1];
-               oh->win_ctime[1] = obj->win_ctime[1];
-               oh->win_mtime[1] = obj->win_mtime[1];
+       oh->win_atime[0] = obj->win_atime[0];
+       oh->win_ctime[0] = obj->win_ctime[0];
+       oh->win_mtime[0] = obj->win_mtime[0];
+       oh->win_atime[1] = obj->win_atime[1];
+       oh->win_ctime[1] = obj->win_ctime[1];
+       oh->win_mtime[1] = obj->win_mtime[1];
 #else
-               oh->yst_uid = obj->yst_uid;
-               oh->yst_gid = obj->yst_gid;
-               oh->yst_atime = obj->yst_atime;
-               oh->yst_mtime = obj->yst_mtime;
-               oh->yst_ctime = obj->yst_ctime;
-               oh->yst_rdev = obj->yst_rdev;
+       oh->yst_uid = obj->yst_uid;
+       oh->yst_gid = obj->yst_gid;
+       oh->yst_atime = obj->yst_atime;
+       oh->yst_mtime = obj->yst_mtime;
+       oh->yst_ctime = obj->yst_ctime;
+       oh->yst_rdev = obj->yst_rdev;
 #endif
-
 }
 
 void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev)
 {
 
 #ifdef CONFIG_YAFFS_WINCE
-               yfsd_win_file_time_now(obj->win_atime);
-               obj->win_ctime[0] = obj->win_mtime[0] = obj->win_atime[0];
-               obj->win_ctime[1] = obj->win_mtime[1] = obj->win_atime[1];
+       yfsd_win_file_time_now(obj->win_atime);
+       obj->win_ctime[0] = obj->win_mtime[0] = obj->win_atime[0];
+       obj->win_ctime[1] = obj->win_mtime[1] = obj->win_atime[1];
 
 #else
        yaffs_load_current_time(obj, 1, 1);
@@ -64,11 +72,11 @@ void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev)
 void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
 {
 #ifdef CONFIG_YAFFS_WINCE
-               yfsd_win_file_time_now(the_obj->win_atime);
-               the_obj->win_ctime[0] = the_obj->win_mtime[0] =
-                   the_obj->win_atime[0];
-               the_obj->win_ctime[1] = the_obj->win_mtime[1] =
-                   the_obj->win_atime[1];
+       yfsd_win_file_time_now(obj->win_atime);
+       obj->win_ctime[0] = obj->win_mtime[0] =
+           obj->win_atime[0];
+       obj->win_ctime[1] = obj->win_mtime[1] =
+           obj->win_atime[1];
 
 #else
 
@@ -98,56 +106,3 @@ static Y_LOFF_T yaffs_get_file_size(struct yaffs_obj *obj)
        }
 }
 
-int yaffs_set_attribs(struct yaffs_obj *obj, struct iattr *attr)
-{
-       unsigned int valid = attr->ia_valid;
-
-       if (valid & ATTR_MODE)
-               obj->yst_mode = attr->ia_mode;
-       if (valid & ATTR_UID)
-               obj->yst_uid = attr->ia_uid;
-       if (valid & ATTR_GID)
-               obj->yst_gid = attr->ia_gid;
-
-       if (valid & ATTR_ATIME)
-               obj->yst_atime = Y_TIME_CONVERT(attr->ia_atime);
-       if (valid & ATTR_CTIME)
-               obj->yst_ctime = Y_TIME_CONVERT(attr->ia_ctime);
-       if (valid & ATTR_MTIME)
-               obj->yst_mtime = Y_TIME_CONVERT(attr->ia_mtime);
-
-       if (valid & ATTR_SIZE)
-               yaffs_resize_file(obj, attr->ia_size);
-
-       yaffs_update_oh(obj, NULL, 1, 0, 0, NULL);
-
-       return YAFFS_OK;
-
-}
-
-int yaffs_get_attribs(struct yaffs_obj *obj, struct iattr *attr)
-{
-       unsigned int valid = 0;
-
-       attr->ia_mode = obj->yst_mode;
-       valid |= ATTR_MODE;
-       attr->ia_uid = obj->yst_uid;
-       valid |= ATTR_UID;
-       attr->ia_gid = obj->yst_gid;
-       valid |= ATTR_GID;
-
-       Y_TIME_CONVERT(attr->ia_atime) = obj->yst_atime;
-       valid |= ATTR_ATIME;
-       Y_TIME_CONVERT(attr->ia_ctime) = obj->yst_ctime;
-       valid |= ATTR_CTIME;
-       Y_TIME_CONVERT(attr->ia_mtime) = obj->yst_mtime;
-       valid |= ATTR_MTIME;
-
-       attr->ia_size = yaffs_get_file_size(obj);
-       valid |= ATTR_SIZE;
-
-       attr->ia_valid = valid;
-
-       return YAFFS_OK;
-}
-
index 9db29b9..eab6c49 100644 (file)
@@ -398,7 +398,7 @@ static void yaffsfs_BreakDeviceHandles(struct yaffs_dev *dev)
  *  Stuff to handle names.
  */
 #ifdef CONFIG_YAFFS_CASE_INSENSITIVE
-
+#ifndef CONFIG_YAFFS_WINCE
 static int yaffs_toupper(YCHAR a)
 {
        if (a >= 'a' && a <= 'z')
@@ -406,6 +406,7 @@ static int yaffs_toupper(YCHAR a)
        else
                return a;
 }
+#endif
 
 static int yaffsfs_Match(YCHAR a, YCHAR b)
 {
@@ -432,7 +433,7 @@ static int yaffsfs_IsPathDivider(YCHAR ch)
        return 0;
 }
 
-static int yaffsfs_CheckNameLength(const char *name)
+static int yaffsfs_CheckNameLength(const YCHAR *name)
 {
        int retVal = 0;
 
@@ -1077,7 +1078,7 @@ static int yaffs_Dofsync(int handle, int datasync)
        else if (obj->my_dev->read_only)
                yaffsfs_SetError(-EROFS);
        else {
-               yaffs_flush_file(obj, 1, datasync);
+               yaffs_flush_file(obj, 1, datasync, 0);
                retVal = 0;
        }
 
@@ -1119,7 +1120,7 @@ int yaffs_close(int handle)
        else {
                /* clean up */
                if(!f->isDir)
-                       yaffs_flush_file(obj, 1, 0);
+                       yaffs_flush_file(obj, 1, 0, 1);
                yaffsfs_PutHandle(handle);
                retVal = 0;
        }
@@ -1854,8 +1855,6 @@ static int yaffsfs_DoUtime(struct yaffs_obj *obj,
                           const struct yaffs_utimbuf *buf)
 {
        int retVal = -1;
-       int result;
-
        struct yaffs_utimbuf local;
 
        obj = yaffs_get_equivalent_obj(obj);
@@ -1865,6 +1864,7 @@ static int yaffsfs_DoUtime(struct yaffs_obj *obj,
                return -1;
        }
 
+#if !CONFIG_YAFFS_WINCE
        if (!buf) {
                local.actime = Y_CURRENT_TIME;
                local.modtime = local.actime;
@@ -1872,12 +1872,15 @@ static int yaffsfs_DoUtime(struct yaffs_obj *obj,
        }
 
        if (obj) {
+               int result;
+
                obj->yst_atime = buf->actime;
                obj->yst_mtime = buf->modtime;
                obj->dirty = 1;
-               result = yaffs_flush_file(obj, 0, 0);
+               result = yaffs_flush_file(obj, 0, 0, 0);
                retVal = result == YAFFS_OK ? 0 : -1;
        }
+#endif
 
        return retVal;
 }
@@ -2460,7 +2463,7 @@ int yaffs_set_wince_times(int fd,
                }
 
                obj->dirty = 1;
-               result = yaffs_flush_file(obj, 0, 0);
+               result = yaffs_flush_file(obj, 0, 0, 0);
                retVal = 0;
        } else
                /* bad handle */
@@ -2483,7 +2486,7 @@ static int yaffsfs_DoChMod(struct yaffs_obj *obj, mode_t mode)
        if (obj) {
                obj->yst_mode = mode;
                obj->dirty = 1;
-               result = yaffs_flush_file(obj, 0, 0);
+               result = yaffs_flush_file(obj, 0, 0, 0);
        }
 
        return result == YAFFS_OK ? 0 : -1;
@@ -2866,7 +2869,7 @@ int yaffs_sync_common(struct yaffs_dev *dev, const YCHAR *path)
                        yaffsfs_SetError(-EROFS);
                else {
 
-                       yaffs_flush_whole_cache(dev);
+                       yaffs_flush_whole_cache(dev, 0);
                        yaffs_checkpoint_save(dev);
                        retVal = 0;
 
@@ -2973,7 +2976,7 @@ int yaffs_remount_common(struct yaffs_dev *dev, const YCHAR *path,
 
        if (dev) {
                if (dev->is_mounted) {
-                       yaffs_flush_whole_cache(dev);
+                       yaffs_flush_whole_cache(dev, 0);
 
                        if (force || !yaffsfs_IsDevBusy(dev)) {
                                if (read_only)
@@ -3024,7 +3027,7 @@ int yaffs_unmount2_common(struct yaffs_dev *dev, const YCHAR *path, int force)
        if (dev) {
                if (dev->is_mounted) {
                        int inUse;
-                       yaffs_flush_whole_cache(dev);
+                       yaffs_flush_whole_cache(dev, 0);
                        yaffs_checkpoint_save(dev);
                        inUse = yaffsfs_IsDevBusy(dev);
                        if (!inUse || force) {
@@ -3097,7 +3100,7 @@ int yaffs_format_common(struct yaffs_dev *dev,
 
                if (dev->is_mounted && unmount_flag) {
                        int inUse;
-                       yaffs_flush_whole_cache(dev);
+                       yaffs_flush_whole_cache(dev, 0);
                        yaffs_checkpoint_save(dev);
                        inUse = yaffsfs_IsDevBusy(dev);
                        if (!inUse || force_unmount_flag) {
index 6ae5bc5..e10fe84 100644 (file)
@@ -255,6 +255,8 @@ int yaffs_link_reldev(struct yaffs_dev *dev,
                        const YCHAR *oldpath, const YCHAR *linkpath);
 int yaffs_mknod_reldev(struct yaffs_dev *dev, const YCHAR *pathname,
                     mode_t mode, dev_t dev_val);
+Y_LOFF_T yaffs_freespace_reldev(struct yaffs_dev *dev);
+Y_LOFF_T yaffs_totalspace_reldev(struct yaffs_dev *dev);
 
 /* Some non-standard functions to use fds to access directories */
 struct yaffs_dirent *yaffs_readdir_fd(int fd);
index d6e073d..526b38d 100644 (file)
@@ -249,13 +249,28 @@ struct iattr {
 #define S_IFREG                0100000
 #endif
 
+#ifndef S_ISSOCK
 #define S_ISSOCK(m)    (((m) & S_IFMT) == S_IFSOCK)
+#endif
+#ifndef S_ISLNK
 #define S_ISLNK(m)     (((m) & S_IFMT) == S_IFLNK)
+#endif
+#ifndef S_ISDIR
 #define S_ISDIR(m)     (((m) & S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
 #define S_ISREG(m)     (((m) & S_IFMT) == S_IFREG)
+#endif
+#ifndef S_ISBLK
 #define S_ISBLK(m)     (((m) & S_IFMT) == S_IFBLK)
+#endif
+#ifndef S_ISCHR
 #define S_ISCHR(m)     (((m) & S_IFMT) == S_IFCHR)
+#endif
+#ifndef S_ISFIFO
 #define S_ISFIFO(m)    (((m) & S_IFMT) == S_IFIFO)
+#endif
+
 
 
 #ifndef S_IREAD
index 6a12aba..1c0ae71 100644 (file)
@@ -631,6 +631,78 @@ static void yaffs_retire_block(struct yaffs_dev *dev, int flash_block)
 
 /*---------------- Name handling functions ------------*/
 
+static void yaffs_load_name_from_oh(struct yaffs_dev *dev, YCHAR *name,
+                                   const YCHAR *oh_name, int buff_size)
+{
+#ifdef CONFIG_YAFFS_AUTO_UNICODE
+       if (dev->param.auto_unicode) {
+               if (*oh_name) {
+                       /* It is an ASCII name, do an ASCII to
+                        * unicode conversion */
+                       const char *ascii_oh_name = (const char *)oh_name;
+                       int n = buff_size - 1;
+                       while (n > 0 && *ascii_oh_name) {
+                               *name = *ascii_oh_name;
+                               name++;
+                               ascii_oh_name++;
+                               n--;
+                       }
+               } else {
+                       strncpy(name, oh_name + 1, buff_size - 1);
+               }
+       } else {
+#else
+       (void) dev;
+       {
+#endif
+               strncpy(name, oh_name, buff_size - 1);
+       }
+}
+
+static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR *oh_name,
+                                   const YCHAR *name)
+{
+#ifdef CONFIG_YAFFS_AUTO_UNICODE
+
+       int is_ascii;
+       const YCHAR *w;
+
+       if (dev->param.auto_unicode) {
+
+               is_ascii = 1;
+               w = name;
+
+               /* Figure out if the name will fit in ascii character set */
+               while (is_ascii && *w) {
+                       if ((*w) & 0xff00)
+                               is_ascii = 0;
+                       w++;
+               }
+
+               if (is_ascii) {
+                       /* It is an ASCII name, so convert unicode to ascii */
+                       char *ascii_oh_name = (char *)oh_name;
+                       int n = YAFFS_MAX_NAME_LENGTH - 1;
+                       while (n > 0 && *name) {
+                               *ascii_oh_name = *name;
+                               name++;
+                               ascii_oh_name++;
+                               n--;
+                       }
+               } else {
+                       /* Unicode name, so save starting at the second YCHAR */
+                       *oh_name = 0;
+                       strncpy(oh_name + 1, name, YAFFS_MAX_NAME_LENGTH - 2);
+               }
+       } else {
+#else
+       dev = dev;
+       {
+#endif
+               strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
+       }
+}
+
 static u16 yaffs_calc_name_sum(const YCHAR *name)
 {
        u16 sum = 0;
@@ -3176,78 +3248,6 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in)
        yaffs_release_temp_buffer(dev, buf);
 }
 
-static void yaffs_load_name_from_oh(struct yaffs_dev *dev, YCHAR *name,
-                                   const YCHAR *oh_name, int buff_size)
-{
-#ifdef CONFIG_YAFFS_AUTO_UNICODE
-       if (dev->param.auto_unicode) {
-               if (*oh_name) {
-                       /* It is an ASCII name, do an ASCII to
-                        * unicode conversion */
-                       const char *ascii_oh_name = (const char *)oh_name;
-                       int n = buff_size - 1;
-                       while (n > 0 && *ascii_oh_name) {
-                               *name = *ascii_oh_name;
-                               name++;
-                               ascii_oh_name++;
-                               n--;
-                       }
-               } else {
-                       strncpy(name, oh_name + 1, buff_size - 1);
-               }
-       } else {
-#else
-       (void) dev;
-       {
-#endif
-               strncpy(name, oh_name, buff_size - 1);
-       }
-}
-
-static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR *oh_name,
-                                   const YCHAR *name)
-{
-#ifdef CONFIG_YAFFS_AUTO_UNICODE
-
-       int is_ascii;
-       YCHAR *w;
-
-       if (dev->param.auto_unicode) {
-
-               is_ascii = 1;
-               w = name;
-
-               /* Figure out if the name will fit in ascii character set */
-               while (is_ascii && *w) {
-                       if ((*w) & 0xff00)
-                               is_ascii = 0;
-                       w++;
-               }
-
-               if (is_ascii) {
-                       /* It is an ASCII name, so convert unicode to ascii */
-                       char *ascii_oh_name = (char *)oh_name;
-                       int n = YAFFS_MAX_NAME_LENGTH - 1;
-                       while (n > 0 && *name) {
-                               *ascii_oh_name = *name;
-                               name++;
-                               ascii_oh_name++;
-                               n--;
-                       }
-               } else {
-                       /* Unicode name, so save starting at the second YCHAR */
-                       *oh_name = 0;
-                       strncpy(oh_name + 1, name, YAFFS_MAX_NAME_LENGTH - 2);
-               }
-       } else {
-#else
-       dev = dev;
-       {
-#endif
-               strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
-       }
-}
-
 /* UpdateObjectHeader updates the header on NAND for an object.
  * If name is not NULL, then that new name is used.
  */