Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\power\user.c Create Date:2022-07-28 10:03:55
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:snapshot_ioctl

Proto:static long snapshot_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)

Type:long

Parameter:

TypeParameterName
struct file *filp
unsigned intcmd
unsigned longarg
204  error = 0
209  If _IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC Then Return -ENOTTY
211  If _IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR Then Return -ENOTTY
213  If Not Check operation authority Then Return -EPERM
216  If Not mutex_trylock - try to acquire the mutex, without waiting*@lock: the mutex to be acquired* Try to acquire the mutex atomically Then Return -EBUSY
219  lock_device_hotplug()
220  data = needed for tty driver, and maybe others
224  Case cmd == SNAPSHOT_FREEZE
225  If frozen Then Break
228  ksys_sync_helper()
230  error = ze_processes - Signal user space processes to enter the refrigerator.* The current thread will not be frozen. The same process that calls* freeze_processes must later call thaw_processes.* On success, returns 0
231  If error Then Break
234  error = reate_basic_memory_bitmaps - Create bitmaps to hold basic page information
235  If error Then thaw_processes()
237  Else frozen = true
240  Break
242  Case cmd == SNAPSHOT_UNFREEZE
243  If Not frozen || ready Then Break
245  pm_restore_gfp_mask()
246  _basic_memory_bitmaps - Free memory bitmaps holding basic information.* Free memory bitmaps allocated by create_basic_memory_bitmaps(). The* auxiliary pointers are necessary so that the bitmaps themselves are not* referred to while they are being freed.
247  free_bitmaps = false
248  thaw_processes()
249  frozen = false
250  Break
252  Case cmd == SNAPSHOT_CREATE_IMAGE
253  If mode != O_RDONLY || Not frozen || ready Then
254  error = -EPERM
255  Break
257  pm_restore_gfp_mask()
258  error = hibernation_snapshot - Quiesce devices and create a hibernation image.*@platform_mode: If set, use platform driver to prepare for the transition.* This routine must be called with system_transition_mutex held.
259  If Not error Then
261  ready = Not freezer_test_done && Not error
262  freezer_test_done = false
264  Break
266  Case cmd == SNAPSHOT_ATOMIC_RESTORE
267  snapshot_write_finalize - Complete the loading of a hibernation image.* Must be called after the last call to snapshot_write_next() in case the last* page in the image happens to be a highmem page and its contents should be* stored in highmem
268  If mode != O_WRONLY || Not frozen || Not snapshot_image_loaded( & handle) Then
270  error = -EPERM
271  Break
273  error = hibernation_restore - Quiesce devices and restore from a hibernation image
274  Break
276  Case cmd == SNAPSHOT_FREE
277  swsusp_free - Free pages allocated for hibernation image.* Image pages are alocated before snapshot creation, so they need to be* released after resume.
278  memset( & handle, 0, sizeof(structsnapshot_handle))
279  ready = false
288  thaw_kernel_threads()
289  Break
291  Case cmd == SNAPSHOT_PREF_IMAGE_SIZE
292  Preferred image size in bytes (tunable via /sys/power/image_size).* When it is set to N, swsusp will do its best to ensure the image* size will not exceed N bytes, but if that is impossible, it will* try to create the smallest image possible. = arg
293  Break
295  Case cmd == SNAPSHOT_GET_IMAGE_SIZE
296  If Not ready Then
297  error = -ENODATA
298  Break
300  size = snapshot_get_image_size()
301  size <<= PAGE_SHIFT determines the page size
302  error = Write a simple value into user space(size, (loff_t__user * )arg)
303  Break
305  Case cmd == SNAPSHOT_AVAIL_SWAP_SIZE
306  size = count_swap_pages(swap, 1)
307  size <<= PAGE_SHIFT determines the page size
308  error = Write a simple value into user space(size, (loff_t__user * )arg)
309  Break
311  Case cmd == SNAPSHOT_ALLOC_SWAP_PAGE
312  If swap < 0 || swap >= MAX_SWAPFILES Then
313  error = -ENODEV
314  Break
316  offset = alloc_swapdev_block - allocate a swap page and register that it has* been allocated, so that it can be freed in case of an error.
317  If offset Then
320  Else
321  error = -ENOSPC
323  Break
325  Case cmd == SNAPSHOT_FREE_SWAP_PAGES
326  If swap < 0 || swap >= MAX_SWAPFILES Then
327  error = -ENODEV
328  Break
330  _all_swap_pages - free swap pages allocated for saving image data.* It also frees the extents used to register which swap entries had been* allocated.
331  Break
333  Case cmd == SNAPSHOT_S2RAM
334  If Not frozen Then
335  error = -EPERM
336  Break
342  error = suspend_devices_and_enter - Suspend devices and enter system sleep state.*@state: System sleep state to enter.
343  ready = false
344  Break
346  Case cmd == SNAPSHOT_PLATFORM_SUPPORT
347  platform_support = Not Not arg
348  Break
350  Case cmd == SNAPSHOT_POWER_OFF
351  If platform_support Then error = hibernation_platform_enter - Power off the system using the platform driver.
353  Break
355  Case cmd == SNAPSHOT_SET_SWAP_AREA
356  If swsusp_swap_in_use() Then
357  error = -EPERM
358  Else
364  If error Then
365  error = -EFAULT
366  Break
374  If swdev Then
375  offset = offset
376  swap = swap_type_of(swdev, offset, NULL)
377  If swap < 0 Then error = -ENODEV
379  Else
380  swap = -1
381  error = -EINVAL
384  Break
386  Default
387  error = -ENOTTY
391  unlock_device_hotplug()
392  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
394  Return error
Caller
NameDescribe
snapshot_compat_ioctl