/*
 *  linux/fs/proc/fslog.c
 *
 */

#include <linux/types.h>
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/proc_fs.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/interrupt.h>
#include <asm/uaccess.h>
#include <linux/fs.h>
#include <linux/seq_file.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/sched/clock.h>

/* For compatibility */
#include <linux/fslog.h>

#define FSLOG_ACTION_CLOSE          	0
#define FSLOG_ACTION_OPEN           	1
#define FSLOG_ACTION_READ		2
#define FSLOG_ACTION_READ_ALL		3
#define FSLOG_ACTION_WRITE    		4
#define FSLOG_ACTION_SIZE_BUFFER   	5

#define S_PREFIX_MAX			32
#define FSLOG_BUF_LINE_MAX		(1024 - S_PREFIX_MAX)

#define FSLOG_BUF_ALIGN			__alignof__(struct fslog_metadata)

#ifdef CONFIG_PROC_FSLOG_LOWMEM
#define FSLOG_BUFLEN_STLOG		(32 * 1024)
#define FSLOG_BUFLEN_DLOG_EFS		(16 * 1024)
#define FSLOG_BUFLEN_DLOG_RMDIR		(16 * 1024)
#define FSLOG_BUFLEN_DLOG_ETC		(64 * 1024)
#define FSLOG_BUFLEN_DLOG_MM		(128 * 1024)
#else /* device has DRAM of high capacity */
#define FSLOG_BUFLEN_STLOG		(32 * 1024)
#define FSLOG_BUFLEN_DLOG_EFS		(16 * 1024)
#define FSLOG_BUFLEN_DLOG_RMDIR		(16 * 1024)
#define FSLOG_BUFLEN_DLOG_ETC		(192 * 1024)
#define FSLOG_BUFLEN_DLOG_MM		(256 * 1024)
#endif

#define FSLOG_FILE_MODE_VERSION		(S_IRUSR | S_IRGRP | S_IROTH)
#define FSLOG_FILE_MODE_DIR \
	(S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
#define FSLOG_FILE_MODE_STLOG \
	(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH)
#define FSLOG_FILE_MODE_DLOG		(S_IRUSR | S_IRGRP)

struct fslog_sequence {
	u64 fslog_seq;
	u32 fslog_idx;
	u64 fslog_first_seq;
	u32 fslog_first_idx;
	u64 fslog_next_seq;
	u32 fslog_next_idx;
	u64 fslog_clear_seq;
	u32 fslog_clear_idx;
	u64 fslog_end_seq;
};

struct fslog_metadata {
	u64 ts_nsec;
	u16 len;
	u16 text_len;
	pid_t pid;
	pid_t tgid;
	char comm[TASK_COMM_LEN];
	char tgid_comm[TASK_COMM_LEN];
};

struct fslog_data {
	struct fslog_sequence fslog_seq;
	struct fslog_metadata fslog_meta;
	spinlock_t fslog_spinlock;
	wait_queue_head_t fslog_wait_queue;
	u32 fslog_buf_len;
	char *fslog_cbuf;
};

static struct proc_dir_entry *fslog_dir;

static int do_fslog(int type, struct fslog_data *fl_data, char __user *buf, int count);
static int do_fslog_write(struct fslog_data *fl_data, const char __user *buf, int len);
static int vfslog(struct fslog_data *fl_data, const char *fmt, va_list args);

#define DEFINE_FSLOG_VARIABLE(_name, size) \
static char fslog_cbuf_##_name[size]; \
\
static struct fslog_data fslog_data_##_name = { \
	.fslog_seq = { \
		.fslog_seq = 0, \
		.fslog_idx = 0, \
		.fslog_first_seq = 0, \
		.fslog_first_idx = 0, \
		.fslog_next_seq = 0, \
		.fslog_next_idx = 0, \
		.fslog_clear_seq = 0, \
		.fslog_clear_idx = 0, \
		.fslog_end_seq = -1 \
	}, \
	.fslog_meta = { \
		.ts_nsec = 0, \
		.len = 0, \
		.text_len = 0, \
		.pid = 0, \
		.tgid = 0, \
		.comm = {0, }, \
		.tgid_comm = {0, } \
	}, \
	.fslog_spinlock = __SPIN_LOCK_INITIALIZER(fslog_data_##_name.fslog_spinlock), \
	.fslog_wait_queue = __WAIT_QUEUE_HEAD_INITIALIZER(fslog_data_##_name.fslog_wait_queue), \
	.fslog_buf_len = size, \
	.fslog_cbuf = fslog_cbuf_##_name, \
}

static int fslog_release(struct inode *inode, struct file *file)
{
	struct fslog_data *fl_data = (struct fslog_data *)(file->private_data);
	return do_fslog(FSLOG_ACTION_CLOSE, fl_data, NULL, 0);
}

static ssize_t fslog_read(struct file *file, char __user *buf,
		                         size_t count, loff_t *ppos)
{
	struct fslog_data *fl_data = (struct fslog_data *)(file->private_data);
	return do_fslog(FSLOG_ACTION_READ_ALL, fl_data, buf, count);
}

static ssize_t fslog_write(struct file *file, const char __user *buf,
		                         size_t count, loff_t *ppos)
{
	struct fslog_data *fl_data = (struct fslog_data *)(file->private_data);
	return do_fslog(FSLOG_ACTION_WRITE, fl_data, (char __user *)buf, count);
}

loff_t fslog_llseek(struct file *file, loff_t offset, int whence)
{
	struct fslog_data *fl_data = (struct fslog_data *)(file->private_data);
	return (loff_t)do_fslog(FSLOG_ACTION_SIZE_BUFFER, fl_data, 0, 0);
}

#define DEFINE_FSLOG_OPERATION(_name) \
static int fslog_open_##_name(struct inode *inode, struct file *file) \
{ \
	file->f_flags |= O_NONBLOCK; \
	file->private_data = &fslog_data_##_name; \
	return do_fslog(FSLOG_ACTION_OPEN, &fslog_data_##_name, NULL, 0); \
} \
\
static const struct file_operations fslog_##_name##_operations = { \
	.read           = fslog_read, \
	.write          = fslog_write, \
	.open           = fslog_open_##_name, \
	.release        = fslog_release, \
	.llseek         = fslog_llseek, \
};

DEFINE_FSLOG_VARIABLE(dlog_mm, FSLOG_BUFLEN_DLOG_MM);
DEFINE_FSLOG_VARIABLE(dlog_efs, FSLOG_BUFLEN_DLOG_EFS);
DEFINE_FSLOG_VARIABLE(dlog_etc, FSLOG_BUFLEN_DLOG_ETC);
DEFINE_FSLOG_VARIABLE(dlog_rmdir, FSLOG_BUFLEN_DLOG_RMDIR);
DEFINE_FSLOG_VARIABLE(stlog, FSLOG_BUFLEN_STLOG);

DEFINE_FSLOG_OPERATION(dlog_mm);
DEFINE_FSLOG_OPERATION(dlog_efs);
DEFINE_FSLOG_OPERATION(dlog_etc);
DEFINE_FSLOG_OPERATION(dlog_rmdir);
DEFINE_FSLOG_OPERATION(stlog);

static const char FSLOG_VERSION_STR[] = "1.1.0\n";

static int fslog_version_show(struct seq_file *m, void *v)
{
	seq_printf(m, "%s", FSLOG_VERSION_STR);
	return 0;
}

static int fslog_version_open(struct inode *inode, struct file *file)
{
	return single_open(file, fslog_version_show, NULL);
}

static const struct file_operations fslog_ver_operations = {
	.open           = fslog_version_open,
	.read           = seq_read,
	.llseek         = seq_lseek,
	.release        = single_release,
};

#define DEFINE_FSLOG_CREATE(_name, log_name, file_mode) \
static void fslog_create_##_name(struct proc_dir_entry *fslog_dir) \
{ \
	proc_create(#log_name, file_mode, \
			fslog_dir, &fslog_##_name##_operations); \
}

DEFINE_FSLOG_CREATE(dlog_mm, dlog_mm, FSLOG_FILE_MODE_DLOG);
DEFINE_FSLOG_CREATE(dlog_efs, dlog_efs, FSLOG_FILE_MODE_DLOG);
DEFINE_FSLOG_CREATE(dlog_etc, dlog_etc, FSLOG_FILE_MODE_DLOG);
DEFINE_FSLOG_CREATE(dlog_rmdir, dlog_rmdir, FSLOG_FILE_MODE_DLOG);
DEFINE_FSLOG_CREATE(stlog, stlog, FSLOG_FILE_MODE_STLOG);

static int __init fslog_init(void)
{
	fslog_dir = proc_mkdir_mode("fslog", FSLOG_FILE_MODE_DIR, NULL);

	proc_create("version", FSLOG_FILE_MODE_VERSION, fslog_dir, &fslog_ver_operations);

	fslog_create_dlog_mm(fslog_dir);
	fslog_create_dlog_efs(fslog_dir);
	fslog_create_dlog_etc(fslog_dir);
	fslog_create_dlog_rmdir(fslog_dir);
	fslog_create_stlog(fslog_dir);

	/* To ensure sub-compatibility in versions below O OS */
	proc_symlink("stlog", NULL, "/proc/fslog/stlog");
	proc_symlink("stlog_version", NULL, "/proc/fslog/version");

	return 0;
}
module_init(fslog_init);

/* human readable text of the record */
static char *fslog_text(const struct fslog_metadata *msg)
{
	return (char *)msg + sizeof(struct fslog_metadata);
}

static struct fslog_metadata *fslog_buf_from_idx(char *fslog_cbuf, u32 idx)
{
	struct fslog_metadata *msg = (struct fslog_metadata *)(fslog_cbuf + idx);

	if (!msg->len)
		return (struct fslog_metadata *)fslog_cbuf;
	return msg;
}

static u32 fslog_next(char *fslog_cbuf, u32 idx)
{
	struct fslog_metadata *msg = (struct fslog_metadata *)(fslog_cbuf + idx);

	if (!msg->len) {
		msg = (struct fslog_metadata *)fslog_cbuf;
		return msg->len;
	}
	return idx + msg->len;
}

static inline void fslog_find_task_by_vpid(struct fslog_metadata *msg,
						struct task_struct *owner)
{
	struct task_struct *p;

	rcu_read_lock();
	p = find_task_by_vpid(owner->tgid);
	if (p) {
		msg->tgid = owner->tgid;
		memcpy(msg->tgid_comm, p->comm, TASK_COMM_LEN);
		rcu_read_unlock();
		return;
	}
	rcu_read_unlock();

	msg->tgid = 0;
	msg->tgid_comm[0] = 0;
}

static void fslog_buf_store(const char *text, u16 text_len,
					struct fslog_data *fl_data,
					struct task_struct *owner)
{
	struct fslog_metadata *msg;
	struct fslog_sequence *fslog_seq = &(fl_data->fslog_seq);
	wait_queue_head_t *fslog_wait_queue = &(fl_data->fslog_wait_queue);
	char *fslog_cbuf = fl_data->fslog_cbuf;
	u32 size, pad_len, fslog_buf_len = fl_data->fslog_buf_len;

	/* number of '\0' padding bytes to next message */
	size = sizeof(struct fslog_metadata) + text_len;
	pad_len = (-size) & (FSLOG_BUF_ALIGN - 1);
	size += pad_len;

	while (fslog_seq->fslog_first_seq < fslog_seq->fslog_next_seq) {
		u32 free;

		if (fslog_seq->fslog_next_idx > fslog_seq->fslog_first_idx)
			free = max(fslog_buf_len - fslog_seq->fslog_next_idx,
							fslog_seq->fslog_first_idx);
		else
			free = fslog_seq->fslog_first_idx - fslog_seq->fslog_next_idx;

		if (free > size + sizeof(struct fslog_metadata))
			break;

		/* drop old messages until we have enough space */
		fslog_seq->fslog_first_idx = fslog_next(fslog_cbuf, fslog_seq->fslog_first_idx);
		fslog_seq->fslog_first_seq++;
	}

	if (fslog_seq->fslog_next_idx + size + sizeof(struct fslog_metadata) >= fslog_buf_len) {
		memset(fslog_cbuf + fslog_seq->fslog_next_idx, 0, sizeof(struct fslog_metadata));
		fslog_seq->fslog_next_idx = 0;
	}

	/* fill message */
	msg = (struct fslog_metadata *)(fslog_cbuf + fslog_seq->fslog_next_idx);
	memcpy(fslog_text(msg), text, text_len);
	msg->text_len = text_len;
	msg->pid = owner->pid;
	memcpy(msg->comm, owner->comm, TASK_COMM_LEN);
	fslog_find_task_by_vpid(msg, owner);
	msg->ts_nsec = local_clock();
	msg->len = sizeof(struct fslog_metadata) + text_len + pad_len;

	/* insert message */
	fslog_seq->fslog_next_idx += msg->len;
	fslog_seq->fslog_next_seq++;
	wake_up_interruptible(fslog_wait_queue);

}

static size_t fslog_print_time(u64 ts, char *buf)
{
	unsigned long rem_nsec;

	rem_nsec = do_div(ts, 1000000000);

	if (!buf)
		return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);

	return sprintf(buf, "[%5lu.%06lu] ",
			(unsigned long)ts, rem_nsec / 1000);
}

static size_t fslog_print_pid(const struct fslog_metadata *msg, char *buf)
{
	if (!buf) {
		if (msg->pid == msg->tgid)
			return snprintf(NULL, 0, "[%15s, %5d] ",
					msg->comm, msg->pid);

		return snprintf(NULL, 0, "[%s(%d)|%s(%d)] ",
				msg->comm, msg->pid, msg->tgid_comm, msg->tgid);

	}

	if (msg->pid == msg->tgid)
		return sprintf(buf, "[%15s, %5d] ", msg->comm, msg->pid);

	return sprintf(buf, "[%s(%d)|%s(%d)] ",
			msg->comm, msg->pid, msg->tgid_comm, msg->tgid);
}

static size_t fslog_print_prefix(const struct fslog_metadata *msg, char *buf)
{
	size_t len = 0;

	len += fslog_print_time(msg->ts_nsec, buf ? buf + len : NULL);
	len += fslog_print_pid(msg, buf ? buf + len : NULL);
	return len;
}

static size_t fslog_print_text(const struct fslog_metadata *msg, char *buf, size_t size)
{
	const char *text = fslog_text(msg);
	size_t text_size = msg->text_len;
	bool prefix = true;
	bool newline = true;
	size_t len = 0;

	do {
		const char *next = memchr(text, '\n', text_size);
		size_t text_len;

		if (next) {
			text_len = next - text;
			next++;
			text_size -= next - text;
		} else {
			text_len = text_size;
		}

		if (buf) {
			if (fslog_print_prefix(msg, NULL) + text_len + 1 >= size - len)
				break;

			if (prefix)
				len += fslog_print_prefix(msg, buf + len);
			memcpy(buf + len, text, text_len);
			len += text_len;
			if (next || newline)
				buf[len++] = '\n';
		} else {
			/*  buffer size only calculation */
			if (prefix)
				len += fslog_print_prefix(msg, NULL);
			len += text_len;
			if (next || newline)
				len++;
		}

		prefix = true;
		text = next;
	} while (text);

	return len;
}

static int fslog_print_all(struct fslog_data *fl_data, char __user *buf, int size)
{
	char *text;
	int len = 0;
	struct fslog_sequence *fslog_seq = &(fl_data->fslog_seq);
	spinlock_t *fslog_spinlock = &(fl_data->fslog_spinlock);
	char *fslog_cbuf = fl_data->fslog_cbuf;
	u64 seq = fslog_seq->fslog_next_seq;
	u32 idx = fslog_seq->fslog_next_idx;

	text = kmalloc(FSLOG_BUF_LINE_MAX + S_PREFIX_MAX, GFP_KERNEL);
	if (!text)
		return -ENOMEM;
	spin_lock_irq(fslog_spinlock);

	if (fslog_seq->fslog_end_seq == -1)
		fslog_seq->fslog_end_seq = fslog_seq->fslog_next_seq;

	if (buf) {

		if (fslog_seq->fslog_clear_seq < fslog_seq->fslog_first_seq) {
			/* messages are gone, move to first available one */
			fslog_seq->fslog_clear_seq = fslog_seq->fslog_first_seq;
			fslog_seq->fslog_clear_idx = fslog_seq->fslog_first_idx;
		}

		seq = fslog_seq->fslog_clear_seq;
		idx = fslog_seq->fslog_clear_idx;

		while (seq < fslog_seq->fslog_end_seq) {
			struct fslog_metadata *msg =
					fslog_buf_from_idx(fslog_cbuf, idx);
			int textlen;

			textlen = fslog_print_text(msg, text,
						 FSLOG_BUF_LINE_MAX + S_PREFIX_MAX);
			if (textlen < 0) {
				len = textlen;
				break;
			} else if(len + textlen > size) {
				break;
			}
			idx = fslog_next(fslog_cbuf, idx);
			seq++;

			spin_unlock_irq(fslog_spinlock);
			if (copy_to_user(buf + len, text, textlen))
				len = -EFAULT;
			else
				len += textlen;
			spin_lock_irq(fslog_spinlock);

			if (seq < fslog_seq->fslog_first_seq) {
				/* messages are gone, move to next one */
				seq = fslog_seq->fslog_first_seq;
				idx = fslog_seq->fslog_first_idx;
			}
		}
	}

	fslog_seq->fslog_clear_seq = seq;
	fslog_seq->fslog_clear_idx = idx;

	spin_unlock_irq(fslog_spinlock);

	kfree(text);
	return len;
}

static int do_fslog(int type, struct fslog_data *fl_data, char __user *buf, int len)
{
	int error = 0;
	u32 fslog_buf_len = fl_data->fslog_buf_len;
	struct fslog_sequence *fslog_seq = &(fl_data->fslog_seq);

	switch (type) {
	case FSLOG_ACTION_CLOSE:	/* Close log */
		break;
	case FSLOG_ACTION_OPEN:	/* Open log */
		break;
	case FSLOG_ACTION_READ_ALL: /* cat /proc/fslog */ /* dumpstate */
		error = -EINVAL;
		if (!buf || len < 0)
			goto out;
		error = 0;
		if (!len)
			goto out;
		if (!access_ok(VERIFY_WRITE, buf, len)) {
			error = -EFAULT;
			goto out;
		}

		error = fslog_print_all(fl_data, buf, len);
		if (error == 0) {
			fslog_seq->fslog_clear_seq = fslog_seq->fslog_first_seq;
			fslog_seq->fslog_clear_idx = fslog_seq->fslog_first_idx;
			fslog_seq->fslog_end_seq = -1;
		}

		break;
	/* Size of the log buffer */
	case FSLOG_ACTION_WRITE:
		error = do_fslog_write(fl_data, (const char __user *)buf, len);
		break;
	case FSLOG_ACTION_SIZE_BUFFER:
		error = fslog_buf_len;
		break;
	default:
		error = -EINVAL;
		break;
	}
out:
	return error;
}

static int fslog(struct fslog_data *fl_data, const char *fmt, ...)
{
	va_list args;
	int r;

	va_start(args, fmt);
	r = vfslog(fl_data, fmt, args);

	va_end(args);

	return r;
}

static int do_fslog_write(struct fslog_data *fl_data, const char __user *buf, int len)
{
	int error = 0;
	char *kern_buf = 0;
	char *line = 0;

	if (!buf || len < 0)
		goto out;
	if (!len)
		goto out;
	if (len > FSLOG_BUF_LINE_MAX)
		return -EINVAL;

	kern_buf = kmalloc(len+1, GFP_KERNEL);
	if (kern_buf == NULL)
		return -ENOMEM;

	line = kern_buf;
	if (copy_from_user(line, buf, len)) {
		error = -EFAULT;
		goto out;
	}

	line[len] = '\0';
	error = fslog(fl_data, "%s", line);
	if ((line[len-1] == '\n') && (error == (len-1)))
		error++;
out:
	kfree(kern_buf);
	return error;

}

static int vfslog(struct fslog_data *fl_data, const char *fmt, va_list args)
{
	static char textbuf[FSLOG_BUF_LINE_MAX];
	char *text = textbuf;
	size_t text_len;
	unsigned long flags;
	int printed_len = 0;
	bool stored = false;
	spinlock_t *fslog_spinlock = &(fl_data->fslog_spinlock);

	local_irq_save(flags);

	spin_lock(fslog_spinlock);

	text_len = vscnprintf(text, sizeof(textbuf), fmt, args);

	/* mark and strip a trailing newline */
	if (text_len && text[text_len-1] == '\n')
		text_len--;

	if (!stored)
		fslog_buf_store(text, text_len, fl_data, current);

	printed_len += text_len;

	spin_unlock(fslog_spinlock);
	local_irq_restore(flags);

	return printed_len;
}

/*
 * fslog - print a deleted entry message
 * @fmt: format string
 */
#define DEFINE_FSLOG_FUNC(_name)\
int fslog_##_name(const char *fmt, ...)\
{\
	va_list args;\
	int r;\
\
	va_start(args, fmt);\
	r = vfslog(&fslog_data_##_name, fmt, args); \
\
	va_end(args);\
\
	return r;\
}

DEFINE_FSLOG_FUNC(dlog_mm);
DEFINE_FSLOG_FUNC(dlog_efs);
DEFINE_FSLOG_FUNC(dlog_etc);
DEFINE_FSLOG_FUNC(dlog_rmdir);
DEFINE_FSLOG_FUNC(stlog);
