With BRD's TIAMAT kernel, I am able to mount just about any file system, except for something HFS+ formatted...
BRD, will there be some mac love in one of your new kernels??
This is the last piece to make this device optimal for me...and probably a lot of other people as well.
Any insight would be great!! Really dig your work as well!! Love my xoom!!
is hfs built into Linux tree? If not, post up the source and I'll add it in.
I found this a link but I cant post it due to site restrictions...
But it includes this
/*
* linux/fs/hfs/hfs.h
*
* Copyright (C) 1995-1997 Paul H. Hargrove
* (C) 2003 Ardis Technologies <[email protected]>
* This file may be distributed under the terms of the GNU General Public License.
*/
#ifndef _HFS_H
#define _HFS_H
/* offsets to various blocks */
#define HFS_DD_BLK 0 /* Driver Descriptor block */
#define HFS_PMAP_BLK 1 /* First block of partition map */
#define HFS_MDB_BLK 2 /* Block (w/i partition) of MDB */
/* magic numbers for various disk blocks */
#define HFS_DRVR_DESC_MAGIC 0x4552 /* "ER": driver descriptor map */
#define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */
#define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */
#define HFS_SUPER_MAGIC 0x4244 /* "BD": HFS MDB (super block) */
#define HFS_MFS_SUPER_MAGIC 0xD2D7 /* MFS MDB (super block) */
/* various FIXED size parameters */
#define HFS_SECTOR_SIZE 512 /* size of an HFS sector */
#define HFS_SECTOR_SIZE_BITS 9 /* log_2(HFS_SECTOR_SIZE) */
#define HFS_NAMELEN 31 /* maximum length of an HFS filename */
#define HFS_MAX_NAMELEN 128
#define HFS_MAX_VALENCE 32767U
/* Meanings of the drAtrb field of the MDB,
* Reference: _Inside Macintosh: Files_ p. 2-61
*/
#define HFS_SB_ATTRIB_HLOCK (1 << 7)
#define HFS_SB_ATTRIB_UNMNT (1 << 8)
#define HFS_SB_ATTRIB_SPARED (1 << 9)
#define HFS_SB_ATTRIB_INCNSTNT (1 << 11)
#define HFS_SB_ATTRIB_SLOCK (1 << 15)
/* Some special File ID numbers */
#define HFS_POR_CNID 1 /* Parent Of the Root */
#define HFS_ROOT_CNID 2 /* ROOT directory */
#define HFS_EXT_CNID 3 /* EXTents B-tree */
#define HFS_CAT_CNID 4 /* CATalog B-tree */
#define HFS_BAD_CNID 5 /* BAD blocks file */
#define HFS_ALLOC_CNID 6 /* ALLOCation file (HFS+) */
#define HFS_START_CNID 7 /* STARTup file (HFS+) */
#define HFS_ATTR_CNID 8 /* ATTRibutes file (HFS+) */
#define HFS_EXCH_CNID 15 /* ExchangeFiles temp id */
#define HFS_FIRSTUSER_CNID 16
/* values for hfs_cat_rec.cdrType */
#define HFS_CDR_DIR 0x01 /* folder (directory) */
#define HFS_CDR_FIL 0x02 /* file */
#define HFS_CDR_THD 0x03 /* folder (directory) thread */
#define HFS_CDR_FTH 0x04 /* file thread */
/* legal values for hfs_ext_key.FkType and hfs_file.fork */
#define HFS_FK_DATA 0x00
#define HFS_FK_RSRC 0xFF
/* bits in hfs_fil_entry.Flags */
#define HFS_FIL_LOCK 0x01 /* locked */
#define HFS_FIL_THD 0x02 /* file thread */
#define HFS_FIL_DOPEN 0x04 /* data fork open */
#define HFS_FIL_ROPEN 0x08 /* resource fork open */
#define HFS_FIL_DIR 0x10 /* directory (always clear) */
#define HFS_FIL_NOCOPY 0x40 /* copy-protected file */
#define HFS_FIL_USED 0x80 /* open */
/* bits in hfs_dir_entry.Flags. dirflags is 16 bits. */
#define HFS_DIR_LOCK 0x01 /* locked */
#define HFS_DIR_THD 0x02 /* directory thread */
#define HFS_DIR_INEXPFOLDER 0x04 /* in a shared area */
#define HFS_DIR_MOUNTED 0x08 /* mounted */
#define HFS_DIR_DIR 0x10 /* directory (always set) */
#define HFS_DIR_EXPFOLDER 0x20 /* share point */
/* bits hfs_finfo.fdFlags */
#define HFS_FLG_INITED 0x0100
#define HFS_FLG_LOCKED 0x1000
#define HFS_FLG_INVISIBLE 0x4000
/*======== HFS structures as they appear on the disk ========*/
/* Pascal-style string of up to 31 characters */
struct hfs_name {
u8 len;
u8 name[HFS_NAMELEN];
} __packed;
struct hfs_point {
__be16 v;
__be16 h;
} __packed;
struct hfs_rect {
__be16 top;
__be16 left;
__be16 bottom;
__be16 right;
} __packed;
struct hfs_finfo {
__be32 fdType;
__be32 fdCreator;
__be16 fdFlags;
struct hfs_point fdLocation;
__be16 fdFldr;
} __packed;
struct hfs_fxinfo {
__be16 fdIconID;
u8 fdUnused[8];
__be16 fdComment;
__be32 fdPutAway;
} __packed;
struct hfs_dinfo {
struct hfs_rect frRect;
__be16 frFlags;
struct hfs_point frLocation;
__be16 frView;
} __packed;
struct hfs_dxinfo {
struct hfs_point frScroll;
__be32 frOpenChain;
__be16 frUnused;
__be16 frComment;
__be32 frPutAway;
} __packed;
union hfs_finder_info {
struct {
struct hfs_finfo finfo;
struct hfs_fxinfo fxinfo;
} file;
struct {
struct hfs_dinfo dinfo;
struct hfs_dxinfo dxinfo;
} dir;
} __packed;
/* Cast to a pointer to a generic bkey */
#define HFS_BKEY(X) (((void)((X)->KeyLen)), ((struct hfs_bkey *)(X)))
/* The key used in the catalog b-tree: */
struct hfs_cat_key {
u8 key_len; /* number of bytes in the key */
u8 reserved; /* padding */
__be32 ParID; /* CNID of the parent dir */
struct hfs_name CName; /* The filename of the entry */
} __packed;
/* The key used in the extents b-tree: */
struct hfs_ext_key {
u8 key_len; /* number of bytes in the key */
u8 FkType; /* HFS_FK_{DATA,RSRC} */
__be32 FNum; /* The File ID of the file */
__be16 FABN; /* allocation blocks number*/
} __packed;
typedef union hfs_btree_key {
u8 key_len; /* number of bytes in the key */
struct hfs_cat_key cat;
struct hfs_ext_key ext;
} hfs_btree_key;
#define HFS_MAX_CAT_KEYLEN (sizeof(struct hfs_cat_key) - sizeof(u8))
#define HFS_MAX_EXT_KEYLEN (sizeof(struct hfs_ext_key) - sizeof(u8))
typedef union hfs_btree_key btree_key;
struct hfs_extent {
__be16 block;
__be16 count;
};
typedef struct hfs_extent hfs_extent_rec[3];
/* The catalog record for a file */
struct hfs_cat_file {
s8 type; /* The type of entry */
u8 reserved;
u8 Flags; /* Flags such as read-only */
s8 Typ; /* file version number = 0 */
struct hfs_finfo UsrWds; /* data used by the Finder */
__be32 FlNum; /* The CNID */
__be16 StBlk; /* obsolete */
__be32 LgLen; /* The logical EOF of the data fork*/
__be32 PyLen; /* The physical EOF of the data fork */
__be16 RStBlk; /* obsolete */
__be32 RLgLen; /* The logical EOF of the rsrc fork */
__be32 RPyLen; /* The physical EOF of the rsrc fork */
__be32 CrDat; /* The creation date */
__be32 MdDat; /* The modified date */
__be32 BkDat; /* The last backup date */
struct hfs_fxinfo FndrInfo; /* more data for the Finder */
__be16 ClpSize; /* number of bytes to allocate
when extending files */
hfs_extent_rec ExtRec; /* first extent record
for the data fork */
hfs_extent_rec RExtRec; /* first extent record
for the resource fork */
u32 Resrv; /* reserved by Apple */
} __packed;
/* the catalog record for a directory */
struct hfs_cat_dir {
s8 type; /* The type of entry */
u8 reserved;
__be16 Flags; /* flags */
__be16 Val; /* Valence: number of files and
dirs in the directory */
__be32 DirID; /* The CNID */
__be32 CrDat; /* The creation date */
__be32 MdDat; /* The modification date */
__be32 BkDat; /* The last backup date */
struct hfs_dinfo UsrInfo; /* data used by the Finder */
struct hfs_dxinfo FndrInfo; /* more data used by Finder */
u8 Resrv[16]; /* reserved by Apple */
} __packed;
/* the catalog record for a thread */
struct hfs_cat_thread {
s8 type; /* The type of entry */
u8 reserved[9]; /* reserved by Apple */
__be32 ParID; /* CNID of parent directory */
struct hfs_name CName; /* The name of this entry */
} __packed;
/* A catalog tree record */
typedef union hfs_cat_rec {
s8 type; /* The type of entry */
struct hfs_cat_file file;
struct hfs_cat_dir dir;
struct hfs_cat_thread thread;
} hfs_cat_rec;
struct hfs_mdb {
__be16 drSigWord; /* Signature word indicating fs type */
__be32 drCrDate; /* fs creation date/time */
__be32 drLsMod; /* fs modification date/time */
__be16 drAtrb; /* fs attributes */
__be16 drNmFls; /* number of files in root directory */
__be16 drVBMSt; /* location (in 512-byte blocks)
of the volume bitmap */
__be16 drAllocPtr; /* location (in allocation blocks)
to begin next allocation search */
__be16 drNmAlBlks; /* number of allocation blocks */
__be32 drAlBlkSiz; /* bytes in an allocation block */
__be32 drClpSiz; /* clumpsize, the number of bytes to
allocate when extending a file */
__be16 drAlBlSt; /* location (in 512-byte blocks)
of the first allocation block */
__be32 drNxtCNID; /* CNID to assign to the next
file or directory created */
__be16 drFreeBks; /* number of free allocation blocks */
u8 drVN[28]; /* the volume label */
__be32 drVolBkUp; /* fs backup date/time */
__be16 drVSeqNum; /* backup sequence number */
__be32 drWrCnt; /* fs write count */
__be32 drXTClpSiz; /* clumpsize for the extents B-tree */
__be32 drCTClpSiz; /* clumpsize for the catalog B-tree */
__be16 drNmRtDirs; /* number of directories in
the root directory */
__be32 drFilCnt; /* number of files in the fs */
__be32 drDirCnt; /* number of directories in the fs */
u8 drFndrInfo[32]; /* data used by the Finder */
__be16 drEmbedSigWord; /* embedded volume signature */
__be32 drEmbedExtent; /* starting block number (xdrStABN)
and number of allocation blocks
(xdrNumABlks) occupied by embedded
volume */
__be32 drXTFlSize; /* bytes in the extents B-tree */
hfs_extent_rec drXTExtRec; /* extents B-tree's first 3 extents */
__be32 drCTFlSize; /* bytes in the catalog B-tree */
hfs_extent_rec drCTExtRec; /* catalog B-tree's first 3 extents */
} __packed;
/*======== Data structures kept in memory ========*/
struct hfs_readdir_data {
struct list_head list;
struct file *file;
struct hfs_cat_key key;
};
#endif
Click to expand...
Click to collapse
and this...
/*
* linux/fs/hfs/hfs_fs.h
*
* Copyright (C) 1995-1997 Paul H. Hargrove
* (C) 2003 Ardis Technologies <[email protected]>
* This file may be distributed under the terms of the GNU General Public License.
*/
#ifndef _LINUX_HFS_FS_H
#define _LINUX_HFS_FS_H
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/buffer_head.h>
#include <linux/fs.h>
#include <asm/byteorder.h>
#include <asm/uaccess.h>
#include "hfs.h"
#define DBG_BNODE_REFS 0x00000001
#define DBG_BNODE_MOD 0x00000002
#define DBG_CAT_MOD 0x00000004
#define DBG_INODE 0x00000008
#define DBG_SUPER 0x00000010
#define DBG_EXTENT 0x00000020
#define DBG_BITMAP 0x00000040
//#define DBG_MASK (DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD|DBG_CAT_MOD|DBG_BITMAP)
//#define DBG_MASK (DBG_BNODE_MOD|DBG_CAT_MOD|DBG_INODE)
//#define DBG_MASK (DBG_CAT_MOD|DBG_BNODE_REFS|DBG_INODE|DBG_EXTENT)
#define DBG_MASK (0)
#define dprint(flg, fmt, args...) \
if (flg & DBG_MASK) printk(fmt , ## args)
/*
* struct hfs_inode_info
*
* The HFS-specific part of a Linux (struct inode)
*/
struct hfs_inode_info {
atomic_t opencnt;
unsigned int flags;
/* to deal with localtime ugliness */
int tz_secondswest;
struct hfs_cat_key cat_key;
struct list_head open_dir_list;
struct inode *rsrc_inode;
struct mutex extents_lock;
u16 alloc_blocks, clump_blocks;
sector_t fs_blocks;
/* Allocation extents from catlog record or volume header */
hfs_extent_rec first_extents;
u16 first_blocks;
hfs_extent_rec cached_extents;
u16 cached_start, cached_blocks;
loff_t phys_size;
struct inode vfs_inode;
};
#define HFS_FLG_RSRC 0x0001
#define HFS_FLG_EXT_DIRTY 0x0002
#define HFS_FLG_EXT_NEW 0x0004
#define HFS_IS_RSRC(inode) (HFS_I(inode)->flags & HFS_FLG_RSRC)
/*
* struct hfs_sb_info
*
* The HFS-specific part of a Linux (struct super_block)
*/
struct hfs_sb_info {
struct buffer_head *mdb_bh; /* The hfs_buffer
holding the real
superblock (aka VIB
or MDB) */
struct hfs_mdb *mdb;
struct buffer_head *alt_mdb_bh; /* The hfs_buffer holding
the alternate superblock */
struct hfs_mdb *alt_mdb;
__be32 *bitmap; /* The page holding the
allocation bitmap */
struct hfs_btree *ext_tree; /* Information about
the extents b-tree */
struct hfs_btree *cat_tree; /* Information about
the catalog b-tree */
u32 file_count; /* The number of
regular files in
the filesystem */
u32 folder_count; /* The number of
directories in the
filesystem */
u32 next_id; /* The next available
file id number */
u32 clumpablks; /* The number of allocation
blocks to try to add when
extending a file */
u32 fs_start; /* The first 512-byte
block represented
in the bitmap */
u32 part_start;
u16 root_files; /* The number of
regular
(non-directory)
files in the root
directory */
u16 root_dirs; /* The number of
directories in the
root directory */
u16 fs_ablocks; /* The number of
allocation blocks
in the filesystem */
u16 free_ablocks; /* the number of unused
allocation blocks
in the filesystem */
u32 alloc_blksz; /* The size of an
"allocation block" */
int s_quiet; /* Silent failure when
changing owner or mode? */
__be32 s_type; /* Type for new files */
__be32 s_creator; /* Creator for new files */
umode_t s_file_umask; /* The umask applied to the
permissions on all files */
umode_t s_dir_umask; /* The umask applied to the
permissions on all dirs */
uid_t s_uid; /* The uid of all files */
gid_t s_gid; /* The gid of all files */
int session, part;
struct nls_table *nls_io, *nls_disk;
struct mutex bitmap_lock;
unsigned long flags;
u16 blockoffset;
int fs_div;
};
#define HFS_FLG_BITMAP_DIRTY 0
#define HFS_FLG_MDB_DIRTY 1
#define HFS_FLG_ALT_MDB_DIRTY 2
/* bitmap.c */
extern u32 hfs_vbm_search_free(struct super_block *, u32, u32 *);
extern int hfs_clear_vbm_bits(struct super_block *, u16, u16);
/* catalog.c */
extern int hfs_cat_keycmp(const btree_key *, const btree_key *);
struct hfs_find_data;
extern int hfs_cat_find_brec(struct super_block *, u32, struct hfs_find_data *);
extern int hfs_cat_create(u32, struct inode *, struct qstr *, struct inode *);
extern int hfs_cat_delete(u32, struct inode *, struct qstr *);
extern int hfs_cat_move(u32, struct inode *, struct qstr *,
struct inode *, struct qstr *);
extern void hfs_cat_build_key(struct super_block *, btree_key *, u32, struct qstr *);
/* dir.c */
extern const struct file_operations hfs_dir_operations;
extern const struct inode_operations hfs_dir_inode_operations;
/* extent.c */
extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
extern int hfs_free_fork(struct super_block *, struct hfs_cat_file *, int);
extern void hfs_ext_write_extent(struct inode *);
extern int hfs_extend_file(struct inode *);
extern void hfs_file_truncate(struct inode *);
extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
/* inode.c */
extern const struct address_space_operations hfs_aops;
extern const struct address_space_operations hfs_btree_aops;
extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int);
extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
extern int hfs_write_inode(struct inode *, struct writeback_control *);
extern int hfs_inode_setattr(struct dentry *, struct iattr *);
extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
__be32 log_size, __be32 phys_size, u32 clump_size);
extern struct inode *hfs_iget(struct super_block *, struct hfs_cat_key *, hfs_cat_rec *);
extern void hfs_evict_inode(struct inode *);
extern void hfs_delete_inode(struct inode *);
/* attr.c */
extern int hfs_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
void *value, size_t size);
extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
/* mdb.c */
extern int hfs_mdb_get(struct super_block *);
extern void hfs_mdb_commit(struct super_block *);
extern void hfs_mdb_close(struct super_block *);
extern void hfs_mdb_put(struct super_block *);
/* part_tbl.c */
extern int hfs_part_find(struct super_block *, sector_t *, sector_t *);
/* string.c */
extern const struct dentry_operations hfs_dentry_operations;
extern int hfs_hash_dentry(const struct dentry *, const struct inode *,
struct qstr *);
extern int hfs_strcmp(const unsigned char *, unsigned int,
const unsigned char *, unsigned int);
extern int hfs_compare_dentry(const struct dentry *parent,
const struct inode *pinode,
const struct dentry *dentry, const struct inode *inode,
unsigned int len, const char *str, const struct qstr *name);
/* trans.c */
extern void hfs_asc2mac(struct super_block *, struct hfs_name *, struct qstr *);
extern int hfs_mac2asc(struct super_block *, char *, const struct hfs_name *);
extern struct timezone sys_tz;
/*
* There are two time systems. Both are based on seconds since
* a particular time/date.
* Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970
* mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904
*
*/
#define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60)
#define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60)
#define HFS_I(inode) (list_entry(inode, struct hfs_inode_info, vfs_inode))
#define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info)
#define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) }
#define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec)
#define hfs_mtime() __hfs_u_to_mtime(get_seconds())
static inline const char *hfs_mdb_name(struct super_block *sb)
{
return sb->s_id;
}
static inline void hfs_bitmap_dirty(struct super_block *sb)
{
set_bit(HFS_FLG_BITMAP_DIRTY, &HFS_SB(sb)->flags);
sb->s_dirt = 1;
}
#define sb_bread512(sb, sec, data) ({ \
struct buffer_head *__bh; \
sector_t __block; \
loff_t __start; \
int __offset; \
\
__start = (loff_t)(sec) << HFS_SECTOR_SIZE_BITS;\
__block = __start >> (sb)->s_blocksize_bits; \
__offset = __start & ((sb)->s_blocksize - 1); \
__bh = sb_bread((sb), __block); \
if (likely(__bh != NULL)) \
data = (void *)(__bh->b_data + __offset);\
else \
data = NULL; \
__bh; \
})
#endif
Click to expand...
Click to collapse
Not sure if thats what your looking for...I really appreciate the help!
BRD,
I know you're working on the new kernel...I was just wondering if you had any further thoughts on this?
I'm not sure if what I posted is even what you need to accomplish this ...
Thanks!
Sent from my Xoom using Tapatalk
mradlauer said:
BRD,
I know you're working on the new kernel...I was just wondering if you had any further thoughts on this?
I'm not sure if what I posted is even what you need to accomplish this ...
Thanks!
Sent from my Xoom using Tapatalk
Click to expand...
Click to collapse
OK. That should point me in the right direction. Ill see what I can whip up
Your awesome! Thanks a bunch and if you need a beta tester for it, let me know...
I'm sure this will be welcome to a lot of folks out there with a mac.
BRD,
I have loaded your new kernel and everything looks to be pretty smooth now.
A quick question about mounting HFS/HFSPlus...
I know you have to disable journaling on the disk to make it RW...I am curious as to how to mount hfs tho...When I plug in a drive, it shows up in USB_OTG with 200mb avail....
I'm thinking that we'll need an app similar to that of the NTFS mount tool...Which works perfecty...
Any thoughts? Or should I just app request something like the NTFS mount tool?
Thanks again! Your work is greatly appreciated!
Related
Big news for every hacker on Samsung devices! j4fs driver is now OpenSource Enjoy: http://bit.ly/jatK1c
Click to expand...
Click to collapse
http://romkitchen.org/sgs/?s=home
Someone care to explain the benefits, if any, of this? My understanding from what little i read is it will help with kernal development on a decent number of samsung devices.
Edit: as in should i be "super excited", "meh", or "cool beans".
second that question .. does this help us?
Would this driver be the one that controls download mode?
Sent from my GT-I9000 using XDA Premium App
Maybe this?
added: Should have checked supercurio's github
Samsung v1 GT-I9100 sources: [common] param.lfs/j4fs driver (communication with bootloader), now OpenSource, yay!
google :
j4fs...
its a filesystem.... FACT
So my GUESS...
a driver for a filesystem...
like ext4 and fat drivers for handling our other storage..
a new filesystem for us to tweak the crap out of and use..?
though ive been wrong before. that is only a logical conclusion not a factual statement
TRusselo said:
google :
j4fs...
its a filesystem.... FACT
So my GUESS...
a driver for a filesystem...
like ext4 and fat drivers for handling our other storage..
a new filesystem for us to tweak the crap out of and use..?
though ive been wrong before. that is only a logical conclusion not a factual statement
Click to expand...
Click to collapse
Sounds good to me.
Sent from my GT-I9000 using XDA Premium App
TRusselo said:
google :
j4fs...
its a filesystem.... FACT
So my GUESS...
a driver for a filesystem...
like ext4 and fat drivers for handling our other storage..
a new filesystem for us to tweak the crap out of and use..?
though ive been wrong before. that is only a logical conclusion not a factual statement
Click to expand...
Click to collapse
according to the post above you this may be the file system used for the bootloaders on the sgs2 so it would help those folks when hacking.
J4FS porting released
If someone is still interested I've just finished the porting of the J4FS on 3.1.x kernel adding support for normal "block device" (for loopback image mounting).
movitool.ntd.homelinux.org/trac/movitool/wiki/j4fs
Hope this can help...
Ceers
Nitro
And another tool (standalone) to extract j4fs/lfs images (eg. param.lfs).
Note: it only extracts - if you want to modify an image you'll have to use the kernel module from the post above (or a hexeditor and some cleverness).
https://github.com/ius/j4fs_extract
(for Googleability)
whiteguypl said:
http://romkitchen.org/sgs/?s=home
Someone care to explain the benefits, if any, of this? My understanding from what little i read is it will help with kernal development on a decent number of samsung devices.
Edit: as in should i be "super excited", "meh", or "cool beans".
Click to expand...
Click to collapse
dunno for what the driver/partition is used, had troubles (device freeze) with custom kernel an the original module from my GT-I9100 (ICS)
as note: device boots and working without the j4fs module in initramfs...
just for fun a little patch for kernel 3.0.15, just read operation tested.
Code:
Index: jv/llid_kernel.c
===================================================================
--- jv/llid_kernel.c (Revision 2075)
+++ jv/llid_kernel.c (Arbeitskopie)
@@ -95,7 +95,7 @@
set_fs(oldfs);
j4fs_filp->f_flags &= ~O_NONBLOCK;
if (ret < 0) {
- printk(1, "j4fs_filp->read() failed: %d\n", ret);
+ printk(KERN_WARNING "j4fs_filp->read() failed: %d\n", ret);
return J4FS_FAIL;
}
// J4FS for moviNAND merged from ROSSI
@@ -153,7 +153,7 @@
set_fs(oldfs);
j4fs_filp->f_flags &= ~O_NONBLOCK;
if (ret < 0) {
- printk(1, "j4fs_filp->write() failed: %d\n", ret);
+ printk(KERN_WARNING "j4fs_filp->write() failed: %d\n", ret);
return J4FS_FAIL;
}
// J4FS for moviNAND merged from ROSSI
Index: jv/j4fs_kernel.c
===================================================================
--- jv/j4fs_kernel.c (Revision 2075)
+++ jv/j4fs_kernel.c (Arbeitskopie)
@@ -10,7 +10,9 @@
* 2009.03 - Currently managed by SungHwan.yun <[email protected]> @[email protected]
*
*/
-#include <linux/smp_lock.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/smp.h>
#include <linux/time.h>
#include <linux/highuid.h>
#include <linux/pagemap.h>
@@ -53,6 +55,8 @@
#define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags)
+#define init_MUTEX(sema) sema_init(sema,1)
+
extern j4fs_device_info device_info;
extern unsigned int j4fs_traceMask;
extern unsigned int j4fs_rw_start;
@@ -234,7 +238,7 @@
T(J4FS_TRACE_FS, ("start j4fs_write_begin\n"));
if(to>PAGE_CACHE_SIZE) {
- T(J4FS_TRACE_ALWAYS,("%s %d: page size overflow(pos,index,offset,len,to)=(%d,%d,%d,%d,%d)\n",__FUNCTION__,__LINE__,pos,index,offset,len,to));
+ T(J4FS_TRACE_ALWAYS,("%s %d: page size overflow(pos,index,offset,len,to)=(%llu,%lu,%d,%d,%d)\n",__FUNCTION__,__LINE__,pos,index,offset,len,to));
j4fs_panic("page size overflow");
return -ENOSPC;
}
@@ -1221,7 +1225,7 @@
struct j4fs_sb_info * sbi;
struct j4fs_super_block * es;
struct inode *root;
- u32 tmp, len,ret;
+ u32 ret;
T(J4FS_TRACE_FS,("%s %d\n",__FUNCTION__,__LINE__));
@@ -1322,11 +1326,11 @@
}
-int j4fs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt)
+static struct dentry *j4fs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
{
T(J4FS_TRACE_FS,("%s %d\n",__FUNCTION__,__LINE__));
- return get_sb_bdev(fs_type, flags, dev_name, data, j4fs_fill_super, mnt);
+ return mount_bdev(fs_type, flags, dev_name, data, j4fs_fill_super);
}
struct kmem_cache * j4fs_inode_cachep;
@@ -1386,7 +1390,7 @@
struct file_system_type j4fs_fs_type = {
.owner = THIS_MODULE,
.name = "j4fs",
- .get_sb = j4fs_get_sb,
+ .mount = j4fs_mount,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};
@@ -1416,9 +1420,16 @@
return -EINVAL;
}
-int j4fs_fsync(struct file *file, struct dentry *dentry, int datasync)
+static int j4fs_fsync(struct file *file, int datasync)
{
- return 0;
+ int rc = 0;
+
+ rc = generic_file_fsync(file, datasync);
+ if (rc)
+ goto out;
+ rc = vfs_fsync(file, datasync);
+out:
+ return rc;
}
int __init init_j4fs_fs(void)
Index: jv/j4fs.h
===================================================================
--- jv/j4fs.h (Revision 2075)
+++ jv/j4fs.h (Arbeitskopie)
@@ -167,6 +167,7 @@
#define J4FS_RECLAIM_RESET_UNUSED_SPACE
#define J4FS_TRANSACTION_LOGGING
+#undef T
#define T(mask, p) do { if ((mask) & (j4fs_traceMask | J4FS_TRACE_ALWAYS)) TOUT(p); } while (0)
#define POR(mask, p, q) do { if (((mask) & (j4fs_PORMask))&&!(--j4fs_PORCount)) {TOUT(p); while(1); }} while (0)
Index: jv/Makefile
===================================================================
--- jv/Makefile (Revision 2075)
+++ jv/Makefile (Arbeitskopie)
@@ -1,31 +1,5 @@
-##############################################################################
-# COPYRIGHT(C) : Samsung Electronics Co.Ltd, 2006-2011 ALL RIGHTS RESERVED
-# 2009.02 - Currently managed by JongMinKim <[email protected]> , SungHwanYun <[email protected]>
-##############################################################################
-# VERSION&DATE : Version 1.00 2009/02
-##############################################################################
+EXTRA_CFLAGS += -Wframe-larger-than=2048 -Wno-error=declaration-after-statement
-MOD_NAME = j4fs
+obj-$(CONFIG_J4FS) += j4fs.o
-ifneq ($(KERNELRELEASE), )
-
-EXTRA_CFLAGS += -I$(PRJROOT)/modules/include -I$(KDIR)/drivers/tfsr/Inc -I$(KDIR)/include -I$(KDIR)/include/linux -I$(KDIR)/include/asm -D__KERNEL
-
-obj-m := $(MOD_NAME).o
-
-$(MOD_NAME)-y := j4fs_kernel.o llid_kernel.o fsd_common.o
-
-else
-
-all:
- @$(MAKE) -C $(KDIR) \
- SUBDIRS=$(CURDIR) modules
-
-clean:
- rm -f *.o *.ko *.mod.c *~ .*.cmd
-
-install:
- @$(MAKE) --no-print-directory -C $(KDIR) \
- SUBDIRS=$(CURDIR) modules_install
-
-endif
+j4fs-objs := j4fs_kernel.o llid_kernel.o fsd_common.o
Just wanted to share some knowledge here.
The main code responsable for the random MAC wifi adress with the newer BCMDHD wifi driver is mainly due to a small peace of code :
eeprom-wifi-mac.c in /tf101-kernel_whatever/arch/arm/mach-tegra.
code snippet:
Code:
#include <linux/i2c/at24.h>
#include <linux/sysfs.h>
#include <linux/device.h>
#include <linux/slab.h>
#define EEPROM_LEN 32
static char wifi_mac[] = "ff:ff:ff:ff:ff:ff";
static ssize_t show_addr_sysfs(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%s\n", wifi_mac);
}
DEVICE_ATTR(addr, 0444, show_addr_sysfs, NULL);
static struct attribute *wifi_mac_addr_attributes[] = {
&dev_attr_addr.attr,
NULL
};
static const struct attribute_group wifi_mac_addr_group = {
.attrs = wifi_mac_addr_attributes,
};
int create_sys_fs(void)
{
int ret = -1;
static struct kobject *reg_kobj;
reg_kobj = kobject_create_and_add("wifi_mac_addr", kernel_kobj);
if (!reg_kobj)
return -ENOMEM;
ret = sysfs_create_group(reg_kobj, &wifi_mac_addr_group);
if (ret < 0) {
kobject_put(reg_kobj);
return ret;
}
return ret;
}
void get_mac_addr(struct memory_accessor *mem_acc, void *context)
{
char *mac_addr;
int ret = 0;
off_t offset = (off_t)context;
mac_addr = kzalloc(sizeof(char)*EEPROM_LEN, GFP_ATOMIC);
if (!mac_addr) {
pr_err("no memory to allocate");
return;
}
/* Read MAC addr from EEPROM */
ret = mem_acc->read(mem_acc, mac_addr, offset, EEPROM_LEN);
if (ret == EEPROM_LEN) {
pr_err("Read MAC addr from EEPROM: %pM\n", (mac_addr+19));
sprintf(wifi_mac, "%02x:%02x:%02x:%02x:%02x:%02x",
*(mac_addr+19), *(mac_addr+20), *(mac_addr+21),
*(mac_addr+22), *(mac_addr+23), *(mac_addr+24));
} else
pr_err("Error reading MAC addr from EEPROM\n");
create_sys_fs();
}
Now we need a code monkey to do some dirty work and give us a new algorithm we can apply to the kernel for reading out / creating the MAC adress in another way. Maybe create a new sysfs interface to be able to change the MAC adress to whatever we like in userspace mode, e.g. per app.
Remember: This is a dev thread. Please do only post development-related stuff in here. Any help is appreciated. If you just want to say 'thanks', well, you know where the corresponding button is, don't ya ?
I don't understand what positive use a random MAC could be?
Sent from my Transformer TF101 using xda app-developers app
Probably the easiest way would be to strace wifimacwriter on ICS. It must call something in the kernel to get the MAC, or run some ioctls. Anyway, it's not self contained, so if we figure out how it works, we can write it ourselves, in kernel space.
I'm trying compile My own kernel but always show error
Code:
[email protected]:~/Desktop/kernel_jb/kernel$ export ARCH=arm
[email protected]:~/Desktop/kernel_jb/kernel$ export CROSS_COMPILE=/home/jbliz/Desktop/kernel_jb/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-
[email protected]:~/Desktop/kernel_jb/kernel$ make -j2
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
warning: (SCSI_SRP) selects SCSI_TGT which has unmet direct dependencies (SCSI && EXPERIMENTAL)
warning: (DRM && ION) selects DMA_SHARED_BUFFER which has unmet direct dependencies (EXPERIMENTAL)
warning: (USB_DWC3) selects USB_XHCI_PLATFORM which has unmet direct dependencies (USB_SUPPORT && USB_XHCI_HCD)
warning: (SCSI_SRP) selects SCSI_TGT which has unmet direct dependencies (SCSI && EXPERIMENTAL)
warning: (DRM && ION) selects DMA_SHARED_BUFFER which has unmet direct dependencies (EXPERIMENTAL)
warning: (USB_DWC3) selects USB_XHCI_PLATFORM which has unmet direct dependencies (USB_SUPPORT && USB_XHCI_HCD)
CHK include/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC scripts/genksyms/genksyms.o
HOSTCC scripts/genksyms/lex.lex.o
HOSTCC scripts/genksyms/parse.tab.o
HOSTLD scripts/genksyms/genksyms
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/selinux/genheaders/genheaders
HOSTCC scripts/selinux/mdp/mdp
HOSTCC scripts/mod/modpost.o
HOSTCC scripts/mod/sumversion.o
HOSTCC scripts/kallsyms
HOSTLD scripts/mod/modpost
make[1]: `include/generated/mach-types.h' is up to date.
HOSTCC scripts/conmakehash
CC kernel/bounds.s
GEN include/generated/bounds.h
CC arch/arm/kernel/asm-offsets.s
In file included from include/linux/spinlock.h:50:0,
from include/linux/seqlock.h:29,
from include/linux/time.h:8,
from include/linux/timex.h:56,
from include/linux/sched.h:57,
from arch/arm/kernel/asm-offsets.c:13:
include/linux/preempt.h:110:0: warning: "inc_preempt_count" redefined [enabled by default]
error, forbidden warning: preempt.h:110
make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2
[email protected]:~/Desktop/kernel_jb/kernel$
preempt.h
Code:
#ifndef __LINUX_PREEMPT_H
#define __LINUX_PREEMPT_H
/*
* include/linux/preempt.h - macros for accessing and manipulating
* preempt_count (used for kernel preemption, interrupt count, etc.)
*/
#include <linux/thread_info.h>
#include <linux/linkage.h>
#include <linux/list.h>
#if defined(CONFIG_DEBUG_PREEMPT) || defined(CONFIG_PREEMPT_TRACER)
extern void add_preempt_count(int val);
extern void sub_preempt_count(int val);
#else
# define add_preempt_count(val) do { preempt_count() += (val); } while (0)
# define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
#endif
#define inc_preempt_count() add_preempt_count(1)
#define dec_preempt_count() sub_preempt_count(1)
#define preempt_count() (current_thread_info()->preempt_count)
#ifdef CONFIG_PREEMPT
asmlinkage void preempt_schedule(void);
#define preempt_check_resched() \
do { \
if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
preempt_schedule(); \
} while (0)
#else /* !CONFIG_PREEMPT */
#define preempt_check_resched() do { } while (0)
#endif /* CONFIG_PREEMPT */
#ifdef CONFIG_PREEMPT_COUNT
#define preempt_disable() \
do { \
inc_preempt_count(); \
barrier(); \
} while (0)
#define sched_preempt_enable_no_resched() \
do { \
barrier(); \
dec_preempt_count(); \
} while (0)
#define preempt_enable_no_resched() sched_preempt_enable_no_resched()
#define preempt_enable() \
do { \
preempt_enable_no_resched(); \
barrier(); \
preempt_check_resched(); \
} while (0)
/* For debugging and tracer internals only! */
#define add_preempt_count_notrace(val) \
do { preempt_count() += (val); } while (0)
#define sub_preempt_count_notrace(val) \
do { preempt_count() -= (val); } while (0)
#define inc_preempt_count_notrace() add_preempt_count_notrace(1)
#define dec_preempt_count_notrace() sub_preempt_count_notrace(1)
#define preempt_disable_notrace() \
do { \
inc_preempt_count_notrace(); \
barrier(); \
} while (0)
#define preempt_enable_no_resched_notrace() \
do { \
barrier(); \
dec_preempt_count_notrace(); \
} while (0)
/* preempt_check_resched is OK to trace */
#define preempt_enable_notrace() \
do { \
preempt_enable_no_resched_notrace(); \
barrier(); \
preempt_check_resched(); \
} while (0)
#else /* !CONFIG_PREEMPT_COUNT */
#define preempt_disable() do { } while (0)
#define sched_preempt_enable_no_resched() do { } while (0)
#define preempt_enable_no_resched() do { } while (0)
#define preempt_enable() do { } while (0)
#define preempt_disable_notrace() do { } while (0)
#define preempt_enable_no_resched_notrace() do { } while (0)
#define preempt_enable_notrace() do { } while (0)
//20130122-JordanChen
#define add_preempt_count_notrace(val) do { } while (0)
#define sub_preempt_count_notrace(val) do { } while (0)
#define inc_preempt_count_notrace() do { } while (0)
#define dec_preempt_count_notrace() do { } while (0)
#define inc_preempt_count() do { } while (0)
#define dec_preempt_count() do { } while (0)
//20130122-JordanChen
#endif /* CONFIG_PREEMPT_COUNT */
#ifdef CONFIG_PREEMPT_NOTIFIERS
struct preempt_notifier;
/**
* preempt_ops - notifiers called when a task is preempted and rescheduled
* @sched_in: we're about to be rescheduled:
* notifier: struct preempt_notifier for the task being scheduled
* cpu: cpu we're scheduled on
* @sched_out: we've just been preempted
* notifier: struct preempt_notifier for the task being preempted
* next: the task that's kicking us out
*
* Please note that sched_in and out are called under different
* contexts. sched_out is called with rq lock held and irq disabled
* while sched_in is called without rq lock and irq enabled. This
* difference is intentional and depended upon by its users.
*/
struct preempt_ops {
void (*sched_in)(struct preempt_notifier *notifier, int cpu);
void (*sched_out)(struct preempt_notifier *notifier,
struct task_struct *next);
};
/**
* preempt_notifier - key for installing preemption notifiers
* @link: internal use
* @ops: defines the notifier functions to be called
*
* Usually used in conjunction with container_of().
*/
struct preempt_notifier {
struct hlist_node link;
struct preempt_ops *ops;
};
void preempt_notifier_register(struct preempt_notifier *notifier);
void preempt_notifier_unregister(struct preempt_notifier *notifier);
static inline void preempt_notifier_init(struct preempt_notifier *notifier,
struct preempt_ops *ops)
{
INIT_HLIST_NODE(¬ifier->link);
notifier->ops = ops;
}
#endif
#endif /* __LINUX_PREEMPT_H */
Toolchains by DooMLoRD
Code:
/home/jbliz/Desktop/kernel_jb/toolchains/arm-2009q3/
/home/jbliz/Desktop/kernel_jb/toolchains/arm-2010.09/
/home/jbliz/Desktop/kernel_jb/toolchains/arm-2011.03/
/home/jbliz/Desktop/kernel_jb/toolchains/arm-2011.09/
/home/jbliz/Desktop/kernel_jb/toolchains/arm-eabi-4.4.3/
/home/jbliz/Desktop/kernel_jb/toolchains/arm-eabi-linaro-4.6.2/
So, I decided I want to put Kali-Linux on my samsung s3 neo device, and I succeeded after hard work and a lots of research... Now I had another problem, that my built-in chipset does not support aircrack-ng, so i decided to work around it, and use a wireless usb adapter.
what i did is modifying the kernel, to be able to support some of the wireless devices... the point where i got stuck is at compiling the new-made kernel... basically i followed the following guide:
PHP:
http://forum.xda-developers.com/showthread.php?t=2338179
and i got stuck at the final section of the compiling segment...
So here is my error.
arch/arm/crypto/sha512_neon_glue.c: In function 'sha512_neon_update':
arch/arm/crypto/sha512_neon_glue.c:144:3: warning: implicit declaration of function 'crypto_sha512_update' [-Wimplicit-function-declaration]
error, forbidden warning: sha512_neon_glue.c:144
scripts/Makefile.build:307: recipe for target 'arch/arm/crypto/sha512_neon_glue.o' failed
make[1]: *** [arch/arm/crypto/sha512_neon_glue.o] Error 1
Makefile:950: recipe for target 'arch/arm/crypto' failed
make: *** [arch/arm/crypto] Error 2
Click to expand...
Click to collapse
so, first of all I have a question, where exactly do i put "KCONFIG_CFLAGS += -w" in the code of the Makefile, and if it would solve the error? according to the guide it should ignore errors that the compiler makes.
2nd question right under the code lines.
Makefile:
PHP:
https://github.com/CyanogenMod/android_kernel_samsung_s3ve3g/blob/cm-12.1/Makefile
Couldn't post it here, too long.
Second question, in case the first solution would not work, if i wanted to edit the problematic file, so it would see the declared functions, how do i do that?
NOTE: the error is in line 144
(will be marked with "------->")
Code:
*
* Glue code for the SHA512 Secure Hash Algorithm assembly implementation
* using NEON instructions.
*
* Copyright © 2014 Jussi Kivilinna <[email protected]>
*
* This file is based on sha512_ssse3_glue.c:
* Copyright (C) 2013 Intel Corporation
* Author: Tim Chen <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
#include <crypto/internal/hash.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/cryptohash.h>
#include <linux/types.h>
#include <linux/string.h>
#include <crypto/sha.h>
#include <asm/byteorder.h>
#include <asm/simd.h>
#include <asm/neon.h>
static const u64 sha512_k[] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
0xd807aa98a3030242ULL, 0x12835b0145706fbeULL,
0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL,
0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL,
0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL,
0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL,
0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL,
0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
0xd192e819d6ef5218ULL, 0xd69906245565a910ULL,
0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL,
0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL,
0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL,
0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL,
0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
0x28db77f523047d84ULL, 0x32caab7b40c72493ULL,
0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
};
asmlinkage void sha512_transform_neon(u64 *digest, const void *data,
const u64 k[], unsigned int num_blks);
static int sha512_neon_init(struct shash_desc *desc)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
sctx->state[0] = SHA512_H0;
sctx->state[1] = SHA512_H1;
sctx->state[2] = SHA512_H2;
sctx->state[3] = SHA512_H3;
sctx->state[4] = SHA512_H4;
sctx->state[5] = SHA512_H5;
sctx->state[6] = SHA512_H6;
sctx->state[7] = SHA512_H7;
sctx->count[0] = sctx->count[1] = 0;
return 0;
}
static int __sha512_neon_update(struct shash_desc *desc, const u8 *data,
unsigned int len, unsigned int partial)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
unsigned int done = 0;
sctx->count[0] += len;
if (sctx->count[0] < len)
sctx->count[1]++;
if (partial) {
done = SHA512_BLOCK_SIZE - partial;
memcpy(sctx->buf + partial, data, done);
sha512_transform_neon(sctx->state, sctx->buf, sha512_k, 1);
}
if (len - done >= SHA512_BLOCK_SIZE) {
const unsigned int rounds = (len - done) / SHA512_BLOCK_SIZE;
sha512_transform_neon(sctx->state, data + done, sha512_k,
rounds);
done += rounds * SHA512_BLOCK_SIZE;
}
memcpy(sctx->buf, data + done, len - done);
return 0;
}
static int sha512_neon_update(struct shash_desc *desc, const u8 *data,
unsigned int len)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
unsigned int partial = sctx->count[0] % SHA512_BLOCK_SIZE;
int res;
/* Handle the fast case right here */
if (partial + len < SHA512_BLOCK_SIZE) {
sctx->count[0] += len;
if (sctx->count[0] < len)
sctx->count[1]++;
memcpy(sctx->buf + partial, data, len);
return 0;
}
if (!may_use_simd()) {
------------> res = crypto_sha512_update(desc, data, len);
} else {
kernel_neon_begin();
res = __sha512_neon_update(desc, data, len, partial);
kernel_neon_end();
}
return res;
}
/* Add padding and return the message digest. */
static int sha512_neon_final(struct shash_desc *desc, u8 *out)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
unsigned int i, index, padlen;
__be64 *dst = (__be64 *)out;
__be64 bits[2];
static const u8 padding[SHA512_BLOCK_SIZE] = { 0x80, };
/* save number of bits */
bits[1] = cpu_to_be64(sctx->count[0] << 3);
bits[0] = cpu_to_be64(sctx->count[1] << 3 | sctx->count[0] >> 61);
/* Pad out to 112 mod 128 and append length */
index = sctx->count[0] & 0x7f;
padlen = (index < 112) ? (112 - index) : ((128+112) - index);
if (!may_use_simd()) {
crypto_sha512_update(desc, padding, padlen);
crypto_sha512_update(desc, (const u8 *)&bits, sizeof(bits));
} else {
kernel_neon_begin();
/* We need to fill a whole block for __sha512_neon_update() */
if (padlen <= 112) {
sctx->count[0] += padlen;
if (sctx->count[0] < padlen)
sctx->count[1]++;
memcpy(sctx->buf + index, padding, padlen);
} else {
__sha512_neon_update(desc, padding, padlen, index);
}
__sha512_neon_update(desc, (const u8 *)&bits,
sizeof(bits), 112);
kernel_neon_end();
}
/* Store state in digest */
for (i = 0; i < 8; i++)
dst[i] = cpu_to_be64(sctx->state[i]);
/* Wipe context */
memset(sctx, 0, sizeof(*sctx));
return 0;
}
static int sha512_neon_export(struct shash_desc *desc, void *out)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
memcpy(out, sctx, sizeof(*sctx));
return 0;
}
static int sha512_neon_import(struct shash_desc *desc, const void *in)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
memcpy(sctx, in, sizeof(*sctx));
return 0;
}
static int sha384_neon_init(struct shash_desc *desc)
{
struct sha512_state *sctx = shash_desc_ctx(desc);
sctx->state[0] = SHA384_H0;
sctx->state[1] = SHA384_H1;
sctx->state[2] = SHA384_H2;
sctx->state[3] = SHA384_H3;
sctx->state[4] = SHA384_H4;
sctx->state[5] = SHA384_H5;
sctx->state[6] = SHA384_H6;
sctx->state[7] = SHA384_H7;
sctx->count[0] = sctx->count[1] = 0;
return 0;
}
static int sha384_neon_final(struct shash_desc *desc, u8 *hash)
{
u8 D[SHA512_DIGEST_SIZE];
sha512_neon_final(desc, D);
memcpy(hash, D, SHA384_DIGEST_SIZE);
memset(D, 0, SHA512_DIGEST_SIZE);
return 0;
}
static struct shash_alg algs[] = { {
.digestsize = SHA512_DIGEST_SIZE,
.init = sha512_neon_init,
.update = sha512_neon_update,
.final = sha512_neon_final,
.export = sha512_neon_export,
.import = sha512_neon_import,
.descsize = sizeof(struct sha512_state),
.statesize = sizeof(struct sha512_state),
.base = {
.cra_name = "sha512",
.cra_driver_name = "sha512-neon",
.cra_priority = 250,
.cra_flags = CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize = SHA512_BLOCK_SIZE,
.cra_module = THIS_MODULE,
}
}, {
.digestsize = SHA384_DIGEST_SIZE,
.init = sha384_neon_init,
.update = sha512_neon_update,
.final = sha384_neon_final,
.export = sha512_neon_export,
.import = sha512_neon_import,
.descsize = sizeof(struct sha512_state),
.statesize = sizeof(struct sha512_state),
.base = {
.cra_name = "sha384",
.cra_driver_name = "sha384-neon",
.cra_priority = 250,
.cra_flags = CRYPTO_ALG_TYPE_SHASH,
.cra_blocksize = SHA384_BLOCK_SIZE,
.cra_module = THIS_MODULE,
}
} };
static int __init sha512_neon_mod_init(void)
{
if (!cpu_has_neon())
return -ENODEV;
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
static void __exit sha512_neon_mod_fini(void)
{
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
module_init(sha512_neon_mod_init);
module_exit(sha512_neon_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SHA512 Secure Hash Algorithm, NEON accelerated");
MODULE_ALIAS("sha512");
MODULE_ALIAS("sha384");
Please help me I will be very thankful.
(NOTE: I am not a developer, and I wish I was, or at least i'm ought to be so please explain carefully your solutions since I'm not familiar with any coding language, and for me, reaching this stage of the kernel compiling was time consuming and my only tools were my logic and the internet). thanks in advance for any help i can get i wish it will work so i can move on in learning kali better!
Hi guys,
I'm trying to compile fourkbomb's Oreo Kernel but I'm stuck on:
drivers/power/qpnp-bms.c:432:13: error: redefinition of 'disable_bms_irq_nosync'
drivers/power/qpnp-bms.c:421:13: note: previous definition of 'disable_bms_irq_nosync' was here
drivers/power/qpnp-bms.c:421:13: warning: 'disable_bms_irq_nosync' defined but not used [-Wunused-function]
error, forbidden warning: qpnp-bms.c:421
scripts/Makefile.build:307: recipe for target 'drivers/power/qpnp-bms.o' failed
make[2]: *** [drivers/power/qpnp-bms.o] Error 1
scripts/Makefile.build:443: recipe for target 'drivers/power' failed
make[1]: *** [drivers/power] Error 2
Makefile:954: recipe for target 'drivers' failed
make: *** [drivers] Error 2
The only things I added are the mac80211 injection patch( http://patches.aircrack-ng.org/mac80211.compat08082009.wl_frag+ack_v1.patch ) and the keyboard gadget patch ( https://github.com/pelya/android-ke...eric-kernel-version/generic_kernel_3.04.patch )
Does anyone know how to solve this?
nik012003 said:
Hi guys,
I'm trying to compile fourkbomb's Oreo Kernel but I'm stuck on:
drivers/power/qpnp-bms.c:432:13: error: redefinition of 'disable_bms_irq_nosync'
drivers/power/qpnp-bms.c:421:13: note: previous definition of 'disable_bms_irq_nosync' was here
drivers/power/qpnp-bms.c:421:13: warning: 'disable_bms_irq_nosync' defined but not used [-Wunused-function]
error, forbidden warning: qpnp-bms.c:421
scripts/Makefile.build:307: recipe for target 'drivers/power/qpnp-bms.o' failed
make[2]: *** [drivers/power/qpnp-bms.o] Error 1
scripts/Makefile.build:443: recipe for target 'drivers/power' failed
make[1]: *** [drivers/power] Error 2
Makefile:954: recipe for target 'drivers' failed
make: *** [drivers] Error 2
The only things I added are the mac80211 injection patch( http://patches.aircrack-ng.org/mac80211.compat08082009.wl_frag+ack_v1.patch ) and the keyboard gadget patch ( https://github.com/pelya/android-ke...eric-kernel-version/generic_kernel_3.04.patch )
Does anyone know how to solve this?
Click to expand...
Click to collapse
This should be the kernel you're trying to build, right?
Look at the compiler errors. The first one tells you that a function in drivers/power/qpnp-bms.c is defined twice. This should not happen. A quick look to the commit history of that file reveals that this commit added a second definition of that function that was not needed, since the other definition was already present. Compare the two definitions: they're similar but not equal. The other one has been improved with the addition of some code by previous commits. So revert this commit: b48e3d6c4c41822f21b0967b0663cbf6a521ec3b to remove the second, useless definition. The second error (unused function) should disappear too, after reverting that commit. Anyway, neither one nor the other error was caused by the patches you applied to the kernel source. fourkbomb probably made a little mistake when merging some commits, I guess.
Tomoms said:
This should be the kernel you're trying to build, right?
Look at the compiler errors. The first one tells you that a function in drivers/power/qpnp-bms.c is defined twice. This should not happen. A quick look to the commit history of that file reveals that this commit added a second definition of that function that was not needed, since the other definition was already present. Compare the two definitions: they're similar but not equal. The other one has been improved with the addition of some code by previous commits. So revert this commit: b48e3d6c4c41822f21b0967b0663cbf6a521ec3b to remove the second, useless definition. The second error (unused function) should disappear too, after reverting that commit. Anyway, neither one nor the other error was caused by the patches you applied to the kernel source. fourkbomb probably made a little mistake when merging some commits, I guess.
Click to expand...
Click to collapse
Looks like it worked!
Thank you so much!
Now I got another error:
CC drivers/staging/android/binder.o
drivers/staging/android/binder.c: In function 'binder_transaction_buffer_release':
drivers/staging/android/binder.c:1629:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
error, forbidden warning: binder.c:1629
scripts/Makefile.build:307: recipe for target 'drivers/staging/android/binder.o' failed
make[3]: *** [drivers/staging/android/binder.o] Error 1
scripts/Makefile.build:443: recipe for target 'drivers/staging/android' failed
make[2]: *** [drivers/staging/android] Error 2
scripts/Makefile.build:443: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:954: recipe for target 'drivers' failed
make: *** [drivers] Error 2
I'll try to figure out where the problem is
nik012003 said:
Looks like it worked!
Thank you so much!
Now I got another error:
CC drivers/staging/android/binder.o
drivers/staging/android/binder.c: In function 'binder_transaction_buffer_release':
drivers/staging/android/binder.c:1629:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
error, forbidden warning: binder.c:1629
scripts/Makefile.build:307: recipe for target 'drivers/staging/android/binder.o' failed
make[3]: *** [drivers/staging/android/binder.o] Error 1
scripts/Makefile.build:443: recipe for target 'drivers/staging/android' failed
make[2]: *** [drivers/staging/android] Error 2
scripts/Makefile.build:443: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:954: recipe for target 'drivers' failed
make: *** [drivers] Error 2
I'll try to figure out where the problem is
Click to expand...
Click to collapse
I've found the problem, but this one might be trickier for you to solve it. Should you need any advice or help, just ask me
Tomoms said:
I've found the problem, but this one might be trickier for you to solve it. Should you need any advice or help, just ask me
Click to expand...
Click to collapse
I'm so tempted to revert back this commit but I have a feeling that it's not going to work...
There is a problem with the function binder_transaction_buffer_release on line 1629 where I can see:
fd_array = (u32 *)(parent_buffer + fda->parent_offset);
I think "(u32 *)" that is wrong because the function isn't returning 32bit values but I have no idea how to fix that.
I have to nail down the bug further or find a LineageOs Oreo Kernel that compiles...
nik012003 said:
I'm so tempted to revert back this commit but I have a felling that it's not going to work...
There is a problem with the function binder_transaction_buffer_release on line 1629 where I can see:
fd_array = (u32 *)(parent_buffer + fda->parent_offset);
I think "(u32 *)" that is wrong because the function isn't returning 32bit values but I have no idea how to fix that.
I have to nail down the bug further or find a LineageOs Oreo Kernel that compiles...
Click to expand...
Click to collapse
No, that commit is not the cause of the issue. The issue is related to a new binder configuration option that is needed to ensure Oreo compatibility. Revert this commit: https://github.com/fourkbomb/android_kernel_oppo_msm8974/commit/b9bb71ce90bfb91740ac72d2a5584897cdee07a6 and set CONFIG_ANDROID_BINDER_IPC_32BIT=y in your defconfig.
Tomoms said:
No, that commit is not the cause of the issue. The issue is related to a new binder configuration option that is needed to ensure Oreo compatibility. Revert this commit: https://github.com/fourkbomb/android_kernel_oppo_msm8974/commit/b9bb71ce90bfb91740ac72d2a5584897cdee07a6 and set CONFIG_ANDROID_BINDER_IPC_32BIT=y in your defconfig.
Click to expand...
Click to collapse
I'll try that tomorrow and I'll let you know how it goes.
Thank you very much!
Ok, it worked!
Now I'm getting errors regarding the android usb gadget patch:
CC drivers/usb/gadget/android.o
In file included from drivers/usb/gadget/android.c:82:0:
drivers/usb/gadget/f_hid_android_keyboard.c:5:36: warning: 'ghid_device_android_keyboard' defined but not used [-Wunused-variable]
error, forbidden warning: f_hid_android_keyboard.c:5
scripts/Makefile.build:307: recipe for target 'drivers/usb/gadget/android.o' failed
make[3]: *** [drivers/usb/gadget/android.o] Error 1
scripts/Makefile.build:443: recipe for target 'drivers/usb/gadget' failed
make[2]: *** [drivers/usb/gadget] Error 2
scripts/Makefile.build:443: recipe for target 'drivers/usb' failed
make[1]: *** [drivers/usb] Error 2
Makefile:954: recipe for target 'drivers' failed
My f_hid_android_keyboard.c contains only a struct:
#include <linux/platform_device.h>
#include <linux/usb/g_hid.h>
/* hid descriptor for a keyboard */
static struct hidg_func_descriptor ghid_device_android_keyboard = {
.subclass = 1, /* Boot Interface Subclass */
.protocol = 1, /* Keyboard */
.report_length = 8,
.report_desc_length = 63,
.report_desc = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x06, /* USAGE (Keyboard) */
0xa1, 0x01, /* COLLECTION (Application) */
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */
0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x95, 0x08, /* REPORT_COUNT (8) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
0x95, 0x01, /* REPORT_COUNT (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x81, 0x03, /* INPUT (Cnst,Var,Abs) */
0x95, 0x05, /* REPORT_COUNT (5) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x05, 0x08, /* USAGE_PAGE (LEDs) */
0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */
0x29, 0x05, /* USAGE_MAXIMUM (Kana) */
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
0x95, 0x01, /* REPORT_COUNT (1) */
0x75, 0x03, /* REPORT_SIZE (3) */
0x91, 0x03, /* OUTPUT (Cnst,Var,Abs) */
0x95, 0x06, /* REPORT_COUNT (6) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x65, /* LOGICAL_MAXIMUM (101) */
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
0x19, 0x00, /* USAGE_MINIMUM (Reserved) */
0x29, 0x65, /* USAGE_MAXIMUM (Keyboard Application) */
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
0xc0 /* END_COLLECTION */
}
};
I can see that the patch wasn't applied correctly due to some missing code in my android.c file.( I can't see the function hid_function_bind_config, but It's there in the patch file)
Can I just manually apply the patches?
nik012003 said:
Ok, it worked!
Now I'm getting errors regarding the android usb gadget patch:
CC drivers/usb/gadget/android.o
In file included from drivers/usb/gadget/android.c:82:0:
drivers/usb/gadget/f_hid_android_keyboard.c:5:36: warning: 'ghid_device_android_keyboard' defined but not used [-Wunused-variable]
error, forbidden warning: f_hid_android_keyboard.c:5
scripts/Makefile.build:307: recipe for target 'drivers/usb/gadget/android.o' failed
make[3]: *** [drivers/usb/gadget/android.o] Error 1
scripts/Makefile.build:443: recipe for target 'drivers/usb/gadget' failed
make[2]: *** [drivers/usb/gadget] Error 2
scripts/Makefile.build:443: recipe for target 'drivers/usb' failed
make[1]: *** [drivers/usb] Error 2
Makefile:954: recipe for target 'drivers' failed
My f_hid_android_keyboard.c contains only a struct:
#include <linux/platform_device.h>
#include <linux/usb/g_hid.h>
/* hid descriptor for a keyboard */
static struct hidg_func_descriptor ghid_device_android_keyboard = {
.subclass = 1, /* Boot Interface Subclass */
.protocol = 1, /* Keyboard */
.report_length = 8,
.report_desc_length = 63,
.report_desc = {
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x06, /* USAGE (Keyboard) */
0xa1, 0x01, /* COLLECTION (Application) */
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */
0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x95, 0x08, /* REPORT_COUNT (8) */
0x81, 0x02, /* INPUT (Data,Var,Abs) */
0x95, 0x01, /* REPORT_COUNT (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x81, 0x03, /* INPUT (Cnst,Var,Abs) */
0x95, 0x05, /* REPORT_COUNT (5) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x05, 0x08, /* USAGE_PAGE (LEDs) */
0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */
0x29, 0x05, /* USAGE_MAXIMUM (Kana) */
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
0x95, 0x01, /* REPORT_COUNT (1) */
0x75, 0x03, /* REPORT_SIZE (3) */
0x91, 0x03, /* OUTPUT (Cnst,Var,Abs) */
0x95, 0x06, /* REPORT_COUNT (6) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x65, /* LOGICAL_MAXIMUM (101) */
0x05, 0x07, /* USAGE_PAGE (Keyboard) */
0x19, 0x00, /* USAGE_MINIMUM (Reserved) */
0x29, 0x65, /* USAGE_MAXIMUM (Keyboard Application) */
0x81, 0x00, /* INPUT (Data,Ary,Abs) */
0xc0 /* END_COLLECTION */
}
};
I can see that the patch wasn't applied correctly due to some missing code in my android.c file.( I can't see the function hid_function_bind_config, but It's there in the patch file)
Can I just manually apply the patches?
Click to expand...
Click to collapse
Revert the patch you applied, and add this one: https://github.com/Tomoms/neon_kernel/commit/7707cc859fe788af5af9a9cba5ab2c21c66470be
It's working properly for me.