2697 lines · 62.9 KB · C
RawDownload
		if (arg3 || arg4 || arg5)			return -EINVAL;		error = SET_TAGGED_ADDR_CTRL(arg2);		break;	case PR_GET_TAGGED_ADDR_CTRL:		if (arg2 || arg3 || arg4 || arg5)			return -EINVAL;		error = GET_TAGGED_ADDR_CTRL();		break;	case PR_SET_IO_FLUSHER:		if (!capable(CAP_SYS_RESOURCE))			return -EPERM; 		if (arg3 || arg4 || arg5)			return -EINVAL; 		if (arg2 == 1)			current->flags |= PR_IO_FLUSHER;		else if (!arg2)			current->flags &= ~PR_IO_FLUSHER;		else			return -EINVAL;		break;	case PR_GET_IO_FLUSHER:		if (!capable(CAP_SYS_RESOURCE))			return -EPERM; 		if (arg2 || arg3 || arg4 || arg5)			return -EINVAL; 		error = (current->flags & PR_IO_FLUSHER) == PR_IO_FLUSHER;		break;	default:		error = -EINVAL;		break;	}	return error;} SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,		struct getcpu_cache __user *, unused){	int err = 0;	int cpu = raw_smp_processor_id(); 	if (cpup)		err |= put_user(cpu, cpup);	if (nodep)		err |= put_user(cpu_to_node(cpu), nodep);	return err ? -EFAULT : 0;} /** * do_sysinfo - fill in sysinfo struct * @info: pointer to buffer to fill */static int do_sysinfo(struct sysinfo *info){	unsigned long mem_total, sav_total;	unsigned int mem_unit, bitcount;	struct timespec64 tp; 	memset(info, 0, sizeof(struct sysinfo)); 	ktime_get_boottime_ts64(&tp);	timens_add_boottime(&tp);	info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0); 	get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT); 	info->procs = nr_threads; 	si_meminfo(info);	si_swapinfo(info); 	/*	 * If the sum of all the available memory (i.e. ram + swap)	 * is less than can be stored in a 32 bit unsigned long then	 * we can be binary compatible with 2.2.x kernels.  If not,	 * well, in that case 2.2.x was broken anyways...	 *	 *  -Erik Andersen <andersee@debian.org>	 */ 	mem_total = info->totalram + info->totalswap;	if (mem_total < info->totalram || mem_total < info->totalswap)		goto out;	bitcount = 0;	mem_unit = info->mem_unit;	while (mem_unit > 1) {		bitcount++;		mem_unit >>= 1;		sav_total = mem_total;		mem_total <<= 1;		if (mem_total < sav_total)			goto out;	} 	/*	 * If mem_total did not overflow, multiply all memory values by	 * info->mem_unit and set it to 1.  This leaves things compatible	 * with 2.2.x, and also retains compatibility with earlier 2.4.x	 * kernels...	 */ 	info->mem_unit = 1;	info->totalram <<= bitcount;	info->freeram <<= bitcount;	info->sharedram <<= bitcount;	info->bufferram <<= bitcount;	info->totalswap <<= bitcount;	info->freeswap <<= bitcount;	info->totalhigh <<= bitcount;	info->freehigh <<= bitcount; out:	return 0;} SYSCALL_DEFINE1(sysinfo, struct sysinfo __user *, info){	struct sysinfo val; 	do_sysinfo(&val); 	if (copy_to_user(info, &val, sizeof(struct sysinfo)))		return -EFAULT; 	return 0;} #ifdef CONFIG_COMPATstruct compat_sysinfo {	s32 uptime;	u32 loads[3];	u32 totalram;	u32 freeram;	u32 sharedram;	u32 bufferram;	u32 totalswap;	u32 freeswap;	u16 procs;	u16 pad;	u32 totalhigh;	u32 freehigh;	u32 mem_unit;	char _f[20-2*sizeof(u32)-sizeof(int)];}; COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info){	struct sysinfo s;	struct compat_sysinfo s_32; 	do_sysinfo(&s); 	/* Check to see if any memory value is too large for 32-bit and scale	 *  down if needed	 */	if (upper_32_bits(s.totalram) || upper_32_bits(s.totalswap)) {		int bitcount = 0; 		while (s.mem_unit < PAGE_SIZE) {			s.mem_unit <<= 1;			bitcount++;		} 		s.totalram >>= bitcount;		s.freeram >>= bitcount;		s.sharedram >>= bitcount;		s.bufferram >>= bitcount;		s.totalswap >>= bitcount;		s.freeswap >>= bitcount;		s.totalhigh >>= bitcount;		s.freehigh >>= bitcount;	} 	memset(&s_32, 0, sizeof(s_32));	s_32.uptime = s.uptime;	s_32.loads[0] = s.loads[0];	s_32.loads[1] = s.loads[1];	s_32.loads[2] = s.loads[2];	s_32.totalram = s.totalram;	s_32.freeram = s.freeram;	s_32.sharedram = s.sharedram;	s_32.bufferram = s.bufferram;	s_32.totalswap = s.totalswap;	s_32.freeswap = s.freeswap;	s_32.procs = s.procs;	s_32.totalhigh = s.totalhigh;	s_32.freehigh = s.freehigh;	s_32.mem_unit = s.mem_unit;	if (copy_to_user(info, &s_32, sizeof(s_32)))		return -EFAULT;	return 0;}#endif /* CONFIG_COMPAT */

Lines 2501–2697 of 2697. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t