static ssize_t ntfs_read(struct file * filp, char *buf, size_t count, loff_t *off) { int error; ntfs_io io; ntfs_inode *ino=NTFS_LINO2NINO(filp->f_dentry->d_inode); /* inode is not properly initialized */ if(!ino)return -EINVAL; ntfs_debug(DEBUG_OTHER, "ntfs_read %x,%x,%x ->", (unsigned)ino->i_number,(unsigned)*off,(unsigned)count); /* inode has no unnamed data attribute */ if(!ntfs_find_attr(ino,ino->vol->at_data,NULL)) return -EINVAL; /* read the data */ io.fn_put=ntfs_putuser; io.fn_get=0; io.param=buf; io.size=count; error=ntfs_read_attr(ino,ino->vol->at_data,NULL,*off,&io); if(error && !io.size)return -error; *off+=io.size; return io.size; }
/* loff_t is 64 bit signed, so is cool. */ static ssize_t ntfs_read(struct file *filp, char *buf, size_t count,loff_t *off) { int error; ntfs_io io; ntfs_attribute *attr; ntfs_inode *ino = NTFS_LINO2NINO(filp->f_dentry->d_inode); /* Inode is not properly initialized. */ if (!ino) return -EINVAL; ntfs_debug(DEBUG_OTHER, "ntfs_read %x, %Lx, %x ->", (unsigned)ino->i_number, (unsigned long long)*off, (unsigned)count); attr = ntfs_find_attr(ino, ino->vol->at_data, NULL); /* Inode has no unnamed data attribute. */ if (!attr) { ntfs_debug(DEBUG_OTHER, "ntfs_read: $DATA not found!\n"); return -EINVAL; } if (attr->flags & ATTR_IS_ENCRYPTED) return -EACCES; /* Read the data. */ io.fn_put = ntfs_putuser; io.fn_get = 0; io.param = buf; io.size = count; error = ntfs_read_attr(ino, ino->vol->at_data, NULL, *off, &io); if (error && !io.size) { ntfs_debug(DEBUG_OTHER, "ntfs_read: read_attr failed with " "error %i, io size %u.\n", error, io.size); return error; } *off += io.size; ntfs_debug(DEBUG_OTHER, "ntfs_read: finished. read %u bytes.\n", io.size); return io.size; }