+ return yaffs_do_listxattr(path, data, size, 1);
+}
+
+int yaffs_llistxattr(const YCHAR *path, char *data, int size)
+{
+ return yaffs_do_listxattr(path, data, size, 0);
+}
+
+int yaffs_flistxattr(int fd, char *data, int size)
+{
+ struct yaffs_obj *obj;
+
+ int retVal = -1;
+
+ yaffsfs_Lock();
+ obj = yaffsfs_GetHandleObject(fd);
+
+ if(obj) {
+ retVal = yaffs_list_xattrib(obj,data,size);
+ if(retVal< 0){
+ yaffsfs_SetError(retVal);
+ retVal = -1;
+ }
+ } else
+ /* bad handle */
+ yaffsfs_SetError(-EBADF);
+
+ yaffsfs_Unlock();
+
+ return retVal;
+}
+
+static int yaffs_do_removexattr(const YCHAR *path, const char *name, int follow)
+{
+ struct yaffs_obj *obj=NULL;
+ struct yaffs_obj *dir=NULL;
+
+ int retVal = -1;
+
+ yaffsfs_Lock();
+
+ obj = yaffsfs_FindObject(NULL,path,0,1, &dir);
+
+ if(follow)
+ obj = yaffsfs_FollowLink(obj,0);
+
+ if(!dir)
+ yaffsfs_SetError(-ENOTDIR);
+ else if(!obj)
+ yaffsfs_SetError(-ENOENT);
+ else {
+ retVal = yaffs_remove_xattrib(obj,name);
+ if(retVal< 0){
+ yaffsfs_SetError(retVal);
+ retVal = -1;
+ }
+ }
+
+ yaffsfs_Unlock();
+
+ return retVal;
+
+}
+
+int yaffs_removexattr(const YCHAR *path, const char *name)
+{
+ return yaffs_do_removexattr(path, name, 1);
+}
+
+int yaffs_lremovexattr(const YCHAR *path, const char *name)
+{
+ return yaffs_do_removexattr(path, name, 0);
+}
+
+int yaffs_fremovexattr(int fd, const char *name)
+{
+ struct yaffs_obj *obj;
+
+ int retVal = -1;
+
+ yaffsfs_Lock();
+ obj = yaffsfs_GetHandleObject(fd);
+
+ if(obj){
+ retVal = yaffs_remove_xattrib(obj,name);
+ if(retVal< 0){
+ yaffsfs_SetError(retVal);
+ retVal = -1;
+ }
+ }else
+ /* bad handle */
+ yaffsfs_SetError(-EBADF);
+
+ yaffsfs_Unlock();
+
+ return retVal;
+}
+#endif
+
+#ifdef CONFIG_YAFFS_WINCE
+int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime)
+{
+ struct yaffs_obj *obj;
+
+ int retVal = -1;
+
+ yaffsfs_Lock();
+ obj = yaffsfs_GetHandleObject(fd);
+
+ if(obj){
+
+ if(wctime){
+ wctime[0] = obj->win_ctime[0];
+ wctime[1] = obj->win_ctime[1];
+ }
+ if(watime){
+ watime[0] = obj->win_atime[0];
+ watime[1] = obj->win_atime[1];
+ }
+ if(wmtime){
+ wmtime[0] = obj->win_mtime[0];
+ wmtime[1] = obj->win_mtime[1];
+ }
+
+
+ retVal = 0;
+ } else
+ /* bad handle */
+ yaffsfs_SetError(-EBADF);
+
+ yaffsfs_Unlock();
+
+ return retVal;
+}
+
+
+int yaffs_set_wince_times(int fd,
+ const unsigned *wctime,
+ const unsigned *watime,
+ const unsigned *wmtime)
+{
+ struct yaffs_obj *obj;
+ int result;
+ int retVal = -1;
+
+ yaffsfs_Lock();
+ obj = yaffsfs_GetHandleObject(fd);
+
+ if(obj){
+
+ if(wctime){
+ obj->win_ctime[0] = wctime[0];
+ obj->win_ctime[1] = wctime[1];
+ }
+ if(watime){
+ obj->win_atime[0] = watime[0];
+ obj->win_atime[1] = watime[1];
+ }
+ if(wmtime){
+ obj->win_mtime[0] = wmtime[0];
+ obj->win_mtime[1] = wmtime[1];
+ }
+
+ obj->dirty = 1;
+ result = yaffs_flush_file(obj,0,0);
+ retVal = 0;
+ } else
+ /* bad handle */
+ yaffsfs_SetError(-EBADF);
+
+ yaffsfs_Unlock();
+
+ return retVal;
+}
+
+#endif
+
+
+static int yaffsfs_DoChMod(struct yaffs_obj *obj,mode_t mode)
+{
+ int result = -1;
+
+ if(obj)
+ obj = yaffs_get_equivalent_obj(obj);
+
+ if(obj) {
+ obj->yst_mode = mode;
+ obj->dirty = 1;
+ result = yaffs_flush_file(obj,0,0);
+ }
+
+ return result == YAFFS_OK ? 0 : -1;
+}
+
+
+int yaffs_access(const YCHAR *path, int amode)
+{
+ struct yaffs_obj *obj=NULL;
+ struct yaffs_obj *dir=NULL;
+
+ int retval = -1;
+
+ if(amode & ~(R_OK | W_OK | X_OK)){
+ yaffsfs_SetError(-EINVAL);
+ return -1;
+ }
+
+ yaffsfs_Lock();
+
+ obj = yaffsfs_FindObject(NULL,path,0,1, &dir);
+
+ if(!dir)
+ yaffsfs_SetError(-ENOTDIR);
+ else if(!obj)
+ yaffsfs_SetError(-ENOENT);
+ else {
+ int access_ok = 1;
+
+ if((amode & R_OK) && !(obj->yst_mode & S_IREAD))
+ access_ok = 0;
+ if((amode & W_OK) && !(obj->yst_mode & S_IWRITE))
+ access_ok = 0;
+ if((amode & X_OK) && !(obj->yst_mode & S_IEXEC))
+ access_ok = 0;
+
+ if(!access_ok)
+ yaffsfs_SetError(-EACCES);
+ else
+ retval = 0;
+ }
+
+ yaffsfs_Unlock();
+
+ return retval;
+
+}
+
+
+int yaffs_chmod(const YCHAR *path, mode_t mode)
+{
+ struct yaffs_obj *obj=NULL;
+ struct yaffs_obj *dir=NULL;
+ int retVal = -1;
+
+ if(mode & ~(0777)){
+ yaffsfs_SetError(-EINVAL);
+ return -1;