[Galaxy 3 Android Development] cdesai:
Difference in fs folder

diff -crB linux/fs g3/fs > fs.patch

diff -crB linux/fs/fat/dir.c g3/fs/fat/dir.c
*** linux/fs/fat/dir.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/fat/dir.c	2011-02-26 04:41:56.000000000 -0800
***************
*** 758,763 ****
--- 758,770 ----
return ret;
}

+ static int fat_ioctl_volume_id(struct inode *dir)
+ {
+	struct super_block *sb = dir->i_sb;
+	struct msdos_sb_info *sbi = MSDOS_SB(sb);
+	return sbi->vol_id;
+ }
+
static int fat_dir_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
***************
*** 773,778 ****
--- 780,787 ----
short_only = 0;
both = 1;
break;
+	case VFAT_IOCTL_GET_VOLUME_ID:
+	return fat_ioctl_volume_id(inode);
default:
return fat_generic_ioctl(inode, filp, cmd, arg);
}
diff -crB linux/fs/fat/fat.h g3/fs/fat/fat.h
*** linux/fs/fat/fat.h	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/fat/fat.h	2011-02-26 04:41:56.000000000 -0800
***************
*** 76,81 ****
--- 76,82 ----
const void *dir_ops;	/* Opaque; default directory operations */
int dir_per_block;	/* dir entries per block */
int dir_per_block_bits;	/* log2(dir_per_block) */
+	unsigned long vol_id; /* volume ID */

int fatent_shift;
struct fatent_operations *fatent_ops;
diff -crB linux/fs/fat/inode.c g3/fs/fat/inode.c
*** linux/fs/fat/inode.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/fat/inode.c	2011-02-26 04:41:56.000000000 -0800
***************
*** 1215,1220 ****
--- 1215,1221 ----
struct inode *root_inode = NULL, *fat_inode = NULL;
struct buffer_head *bh;
struct fat_boot_sector *b;
+	struct fat_boot_bsx *bsx;
struct msdos_sb_info *sbi;
u16 logical_sector_size;
u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors;
***************
*** 1357,1362 ****
--- 1358,1365 ----
goto out_fail;
}

+	bsx = (struct fat_boot_bsx *)(bh->b_data + FAT32_BSX_OFFSET);
+
fsinfo = (struct fat_boot_fsinfo *)fsinfo_bh->b_data;
if (!IS_FSINFO(fsinfo)) {
printk(KERN_WARNING "FAT: Invalid FSINFO signature: "
***************
*** 1372,1379 ****
--- 1375,1388 ----
}

brelse(fsinfo_bh);
+	} else {
+	bsx = (struct fat_boot_bsx *)(bh->b_data + FAT16_BSX_OFFSET);
}

+	/* interpret volume ID as a little endian 32 bit integer */
+	sbi->vol_id = (((u32)bsx->vol_id[0]) | ((u32)bsx->vol_id[1] << 8) |
+	((u32)bsx->vol_id[2] << 16) | ((u32)bsx->vol_id[3] << 24));
+
sbi->dir_per_block = sb->s_blocksize / sizeof(struct msdos_dir_entry);
sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1;

diff -crB linux/fs/fs-writeback.c g3/fs/fs-writeback.c
*** linux/fs/fs-writeback.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/fs-writeback.c	2011-02-26 04:41:56.000000000 -0800
***************
*** 1071,1077 ****
if ((inode->i_state & flags) == flags)
return;

!	if (unlikely(block_dump))
block_dump___mark_inode_dirty(inode);

spin_lock(&inode_lock);
--- 1071,1077 ----
if ((inode->i_state & flags) == flags)
return;

!	if (unlikely(block_dump > 1))
block_dump___mark_inode_dirty(inode);

spin_lock(&inode_lock);
diff -crB linux/fs/Kconfig g3/fs/Kconfig
*** linux/fs/Kconfig	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/Kconfig	2011-02-26 04:41:55.000000000 -0800
***************
*** 174,179 ****
--- 174,183 ----
source "fs/befs/Kconfig"
source "fs/bfs/Kconfig"
source "fs/efs/Kconfig"
+
+ # Patched by YAFFS
+ source "fs/yaffs2/Kconfig"
+
source "fs/jffs2/Kconfig"
# UBIFS File system configuration
source "fs/ubifs/Kconfig"
diff -crB linux/fs/Makefile g3/fs/Makefile
*** linux/fs/Makefile	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/Makefile	2011-02-26 04:41:55.000000000 -0800
***************
*** 124,126 ****
--- 124,129 ----
obj-$(CONFIG_BTRFS_FS)	+= btrfs/
obj-$(CONFIG_GFS2_FS) += gfs2/
obj-$(CONFIG_EXOFS_FS) += exofs/
+
+ # Patched by YAFFS
+ obj-$(CONFIG_YAFFS_FS)	+= yaffs2/
diff -crB linux/fs/partitions/check.c g3/fs/partitions/check.c
*** linux/fs/partitions/check.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/partitions/check.c	2011-02-26 04:41:57.000000000 -0800
***************
*** 327,336 ****
--- 327,345 ----
kfree(p);
}

+ static int part_uevent(struct device *dev, struct kobj_uevent_env *env)
+ {
+	struct hd_struct *part = dev_to_part(dev);
+
+	add_uevent_var(env, "PARTN=%u", part->partno);
+	return 0;
+ }
+
struct device_type part_type = {
.name	= "partition",
.groups	= part_attr_groups,
.release	= part_release,
+	.uevent	= part_uevent,
};

static void delete_partition_rcu_cb(struct rcu_head *head)
diff -crB linux/fs/proc/base.c g3/fs/proc/base.c
*** linux/fs/proc/base.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/proc/base.c	2011-02-26 04:41:57.000000000 -0800
***************
*** 128,133 ****
--- 128,139 ----
NULL, &proc_single_file_operations,	\
{ .proc_show = show } )

+ /* ANDROID is for special files in /proc. */
+ #define ANDROID(NAME, MODE, OTYPE)	\
+	NOD(NAME, (S_IFREG|(MODE)),	\
+	&proc_##OTYPE##_inode_operations,	\
+	&proc_##OTYPE##_operations, {})
+
/*
* Count the number of hardlinks for the pid_entry table, excluding the .
* and .. links.
***************
*** 241,247 ****

mm = get_task_mm(task);
if (mm && mm != current->mm &&
!	!ptrace_may_access(task, PTRACE_MODE_READ)) {
mmput(mm);
mm = NULL;
}
--- 247,254 ----

mm = get_task_mm(task);
if (mm && mm != current->mm &&
!	!ptrace_may_access(task, PTRACE_MODE_READ) &&
!	!capable(CAP_SYS_RESOURCE)) {
mmput(mm);
mm = NULL;
}
***************
*** 1061,1066 ****
--- 1068,1100 ----
return count;
}

+ static int oom_adjust_permission(struct inode *inode, int mask)
+ {
+	uid_t uid;
+	struct task_struct *p = get_proc_task(inode);
+	if(p) {
+	uid = task_uid(p);
+	put_task_struct(p);
+	}
+
+	/*
+	* System Server (uid == 1000) is granted access to oom_adj of all
+	* android applications (uid > 10000) as and services (uid >= 1000)
+	*/
+	if (p && (current_fsuid() == 1000) && (uid >= 1000)) {
+	if (inode->i_mode >> 6 & mask) {
+	return 0;
+	}
+	}
+
+	/* Fall back to default. */
+	return generic_permission(inode, mask, NULL);
+ }
+
+ static const struct inode_operations proc_oom_adjust_inode_operations = {
+	.permission	= oom_adjust_permission,
+ };
+
static const struct file_operations proc_oom_adjust_operations = {
.read	= oom_adjust_read,
.write	= oom_adjust_write,
***************
*** 2548,2554 ****
REG("cgroup", S_IRUGO, proc_cgroup_operations),
#endif
INF("oom_score", S_IRUGO, proc_oom_score),
!	REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
#ifdef CONFIG_AUDITSYSCALL
REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
REG("sessionid", S_IRUGO, proc_sessionid_operations),
--- 2582,2588 ----
REG("cgroup", S_IRUGO, proc_cgroup_operations),
#endif
INF("oom_score", S_IRUGO, proc_oom_score),
!	ANDROID("oom_adj",S_IRUGO|S_IWUSR, oom_adjust),
#ifdef CONFIG_AUDITSYSCALL
REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
REG("sessionid", S_IRUGO, proc_sessionid_operations),
diff -crB linux/fs/proc/task_mmu.c g3/fs/proc/task_mmu.c
*** linux/fs/proc/task_mmu.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/proc/task_mmu.c	2011-02-26 04:41:57.000000000 -0800
***************
*** 404,409 ****
--- 404,410 ----

memset(&mss, 0, sizeof mss);
mss.vma = vma;
+	/* mmap_sem is held in m_start */
if (vma->vm_mm && !is_vm_hugetlb_page(vma))
walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);

***************
*** 550,556 ****
};

struct pagemapread {
!	u64 __user *out, *end;
};

#define PM_ENTRY_BYTES sizeof(u64)
--- 551,558 ----
};

struct pagemapread {
!	int pos, len;
!	u64 *buffer;
};

#define PM_ENTRY_BYTES sizeof(u64)
***************
*** 573,582 ****
static int add_to_pagemap(unsigned long addr, u64 pfn,
struct pagemapread *pm)
{
!	if (put_user(pfn, pm->out))
!	return -EFAULT;
!	pm->out++;
!	if (pm->out >= pm->end)
return PM_END_OF_BUFFER;
return 0;
}
--- 575,582 ----
static int add_to_pagemap(unsigned long addr, u64 pfn,
struct pagemapread *pm)
{
!	pm->buffer[pm->pos++] = pfn;
!	if (pm->pos >= pm->len)
return PM_END_OF_BUFFER;
return 0;
}
***************
*** 674,694 ****
* determine which areas of memory are actually mapped and llseek to
* skip over unmapped regions.
*/
static ssize_t pagemap_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
-	struct page **pages, *page;
-	unsigned long uaddr, uend;
struct mm_struct *mm;
struct pagemapread pm;
-	int pagecount;
int ret = -ESRCH;
struct mm_walk pagemap_walk = {};
unsigned long src;
unsigned long svpfn;
unsigned long start_vaddr;
unsigned long end_vaddr;

if (!task)
goto out;
--- 674,693 ----
* determine which areas of memory are actually mapped and llseek to
* skip over unmapped regions.
*/
+ #define PAGEMAP_WALK_SIZE	(PMD_SIZE)
static ssize_t pagemap_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
struct mm_struct *mm;
struct pagemapread pm;
int ret = -ESRCH;
struct mm_walk pagemap_walk = {};
unsigned long src;
unsigned long svpfn;
unsigned long start_vaddr;
unsigned long end_vaddr;
+	int copied = 0;

if (!task)
goto out;
***************
*** 711,745 ****
if (!mm)
goto out_task;

!
!	uaddr = (unsigned long)buf & PAGE_MASK;
!	uend = (unsigned long)(buf + count);
!	pagecount = (PAGE_ALIGN(uend) - uaddr) / PAGE_SIZE;
!	ret = 0;
!	if (pagecount == 0)
!	goto out_mm;
!	pages = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL);
ret = -ENOMEM;
!	if (!pages)
goto out_mm;

-	down_read(&current->mm->mmap_sem);
-	ret = get_user_pages(current, current->mm, uaddr, pagecount,
-	1, 0, pages, NULL);
-	up_read(&current->mm->mmap_sem);
-
-	if (ret < 0)
-	goto out_free;
-
-	if (ret != pagecount) {
-	pagecount = ret;
-	ret = -EFAULT;
-	goto out_pages;
-	}
-
-	pm.out = (u64 __user *)buf;
-	pm.end = (u64 __user *)(buf + count);
-
pagemap_walk.pmd_entry = pagemap_pte_range;
pagemap_walk.pte_hole = pagemap_pte_hole;
pagemap_walk.mm = mm;
--- 710,721 ----
if (!mm)
goto out_task;

!	pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
!	pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
ret = -ENOMEM;
!	if (!pm.buffer)
goto out_mm;

pagemap_walk.pmd_entry = pagemap_pte_range;
pagemap_walk.pte_hole = pagemap_pte_hole;
pagemap_walk.mm = mm;
***************
*** 760,782 ****
* user buffer is tracked in "pm", and the walk
* will stop when we hit the end of the buffer.
*/
!	ret = walk_page_range(start_vaddr, end_vaddr, &pagemap_walk);
!	if (ret == PM_END_OF_BUFFER)
!	ret = 0;
!	/* don't need mmap_sem for these, but this looks cleaner */
!	*ppos += (char __user *)pm.out - buf;
!	if (!ret)
!	ret = (char __user *)pm.out - buf;
!
! out_pages:
!	for (; pagecount; pagecount--) {
!	page = pages[pagecount-1];
!	if (!PageReserved(page))
!	SetPageDirty(page);
!	page_cache_release(page);
}
out_free:
!	kfree(pages);
out_mm:
mmput(mm);
out_task:
--- 736,771 ----
* user buffer is tracked in "pm", and the walk
* will stop when we hit the end of the buffer.
*/
!	ret = 0;
!	while (count && (start_vaddr < end_vaddr)) {
!	int len;
!	unsigned long end;
!
!	pm.pos = 0;
!	end = start_vaddr + PAGEMAP_WALK_SIZE;
!	/* overflow ? */
!	if (end < start_vaddr || end > end_vaddr)
!	end = end_vaddr;
!	down_read(&mm->mmap_sem);
!	ret = walk_page_range(start_vaddr, end, &pagemap_walk);
!	up_read(&mm->mmap_sem);
!	start_vaddr = end;
!
!	len = min(count, PM_ENTRY_BYTES * pm.pos);
!	if (copy_to_user(buf, pm.buffer, len) < 0) {
!	ret = -EFAULT;
!	goto out_free;
!	}
!	copied += len;
!	buf += len;
!	count -= len;
}
+	*ppos += copied;
+	if (!ret || ret == PM_END_OF_BUFFER)
+	ret = copied;
+
out_free:
!	kfree(pm.buffer);
out_mm:
mmput(mm);
out_task:
diff -crB linux/fs/sysfs/dir.c g3/fs/sysfs/dir.c
*** linux/fs/sysfs/dir.c	2010-02-23 07:38:51.000000000 -0800
--- g3/fs/sysfs/dir.c	2011-02-26 04:41:57.000000000 -0800
***************
*** 636,644 ****
{
struct sysfs_dirent *sd;

!	for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling)
if (!strcmp(sd->s_name, name))
return sd;
return NULL;
}

--- 636,651 ----
{
struct sysfs_dirent *sd;

!	for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) {
!
!	if(!sd->s_name) {
!	printk("sysfs_find_dirent->s_name Error \n");
!	continue;
!	}
!
if (!strcmp(sd->s_name, name))
return sd;
+	}
return NULL;
}

Only in g3/fs: yaffs2