@@ -329,12 +329,17 @@ typedef int __bitwise __kernel_rwf_t;
329
329
/* per-IO negation of O_APPEND */
330
330
#define RWF_NOAPPEND ((__force __kernel_rwf_t)0x00000020)
331
331
332
+ /* Atomic Write */
333
+ #define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040)
334
+
332
335
/* mask of flags supported by the kernel */
333
336
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
334
- RWF_APPEND | RWF_NOAPPEND)
337
+ RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC)
338
+
339
+ #define PROCFS_IOCTL_MAGIC 'f'
335
340
336
341
/* Pagemap ioctl */
337
- #define PAGEMAP_SCAN _IOWR('f' , 16, struct pm_scan_arg)
342
+ #define PAGEMAP_SCAN _IOWR(PROCFS_IOCTL_MAGIC , 16, struct pm_scan_arg)
338
343
339
344
/* Bitmasks provided in pm_scan_args masks and reported in page_region.categories. */
340
345
#define PAGE_IS_WPALLOWED (1 << 0)
@@ -393,4 +398,158 @@ struct pm_scan_arg {
393
398
__u64 return_mask ;
394
399
};
395
400
401
+ /* /proc/<pid>/maps ioctl */
402
+ #define PROCMAP_QUERY _IOWR(PROCFS_IOCTL_MAGIC, 17, struct procmap_query)
403
+
404
+ enum procmap_query_flags {
405
+ /*
406
+ * VMA permission flags.
407
+ *
408
+ * Can be used as part of procmap_query.query_flags field to look up
409
+ * only VMAs satisfying specified subset of permissions. E.g., specifying
410
+ * PROCMAP_QUERY_VMA_READABLE only will return both readable and read/write VMAs,
411
+ * while having PROCMAP_QUERY_VMA_READABLE | PROCMAP_QUERY_VMA_WRITABLE will only
412
+ * return read/write VMAs, though both executable/non-executable and
413
+ * private/shared will be ignored.
414
+ *
415
+ * PROCMAP_QUERY_VMA_* flags are also returned in procmap_query.vma_flags
416
+ * field to specify actual VMA permissions.
417
+ */
418
+ PROCMAP_QUERY_VMA_READABLE = 0x01 ,
419
+ PROCMAP_QUERY_VMA_WRITABLE = 0x02 ,
420
+ PROCMAP_QUERY_VMA_EXECUTABLE = 0x04 ,
421
+ PROCMAP_QUERY_VMA_SHARED = 0x08 ,
422
+ /*
423
+ * Query modifier flags.
424
+ *
425
+ * By default VMA that covers provided address is returned, or -ENOENT
426
+ * is returned. With PROCMAP_QUERY_COVERING_OR_NEXT_VMA flag set, closest
427
+ * VMA with vma_start > addr will be returned if no covering VMA is
428
+ * found.
429
+ *
430
+ * PROCMAP_QUERY_FILE_BACKED_VMA instructs query to consider only VMAs that
431
+ * have file backing. Can be combined with PROCMAP_QUERY_COVERING_OR_NEXT_VMA
432
+ * to iterate all VMAs with file backing.
433
+ */
434
+ PROCMAP_QUERY_COVERING_OR_NEXT_VMA = 0x10 ,
435
+ PROCMAP_QUERY_FILE_BACKED_VMA = 0x20 ,
436
+ };
437
+
438
+ /*
439
+ * Input/output argument structured passed into ioctl() call. It can be used
440
+ * to query a set of VMAs (Virtual Memory Areas) of a process.
441
+ *
442
+ * Each field can be one of three kinds, marked in a short comment to the
443
+ * right of the field:
444
+ * - "in", input argument, user has to provide this value, kernel doesn't modify it;
445
+ * - "out", output argument, kernel sets this field with VMA data;
446
+ * - "in/out", input and output argument; user provides initial value (used
447
+ * to specify maximum allowable buffer size), and kernel sets it to actual
448
+ * amount of data written (or zero, if there is no data).
449
+ *
450
+ * If matching VMA is found (according to criterias specified by
451
+ * query_addr/query_flags, all the out fields are filled out, and ioctl()
452
+ * returns 0. If there is no matching VMA, -ENOENT will be returned.
453
+ * In case of any other error, negative error code other than -ENOENT is
454
+ * returned.
455
+ *
456
+ * Most of the data is similar to the one returned as text in /proc/<pid>/maps
457
+ * file, but procmap_query provides more querying flexibility. There are no
458
+ * consistency guarantees between subsequent ioctl() calls, but data returned
459
+ * for matched VMA is self-consistent.
460
+ */
461
+ struct procmap_query {
462
+ /* Query struct size, for backwards/forward compatibility */
463
+ __u64 size ;
464
+ /*
465
+ * Query flags, a combination of enum procmap_query_flags values.
466
+ * Defines query filtering and behavior, see enum procmap_query_flags.
467
+ *
468
+ * Input argument, provided by user. Kernel doesn't modify it.
469
+ */
470
+ __u64 query_flags ; /* in */
471
+ /*
472
+ * Query address. By default, VMA that covers this address will
473
+ * be looked up. PROCMAP_QUERY_* flags above modify this default
474
+ * behavior further.
475
+ *
476
+ * Input argument, provided by user. Kernel doesn't modify it.
477
+ */
478
+ __u64 query_addr ; /* in */
479
+ /* VMA starting (inclusive) and ending (exclusive) address, if VMA is found. */
480
+ __u64 vma_start ; /* out */
481
+ __u64 vma_end ; /* out */
482
+ /* VMA permissions flags. A combination of PROCMAP_QUERY_VMA_* flags. */
483
+ __u64 vma_flags ; /* out */
484
+ /* VMA backing page size granularity. */
485
+ __u64 vma_page_size ; /* out */
486
+ /*
487
+ * VMA file offset. If VMA has file backing, this specifies offset
488
+ * within the file that VMA's start address corresponds to.
489
+ * Is set to zero if VMA has no backing file.
490
+ */
491
+ __u64 vma_offset ; /* out */
492
+ /* Backing file's inode number, or zero, if VMA has no backing file. */
493
+ __u64 inode ; /* out */
494
+ /* Backing file's device major/minor number, or zero, if VMA has no backing file. */
495
+ __u32 dev_major ; /* out */
496
+ __u32 dev_minor ; /* out */
497
+ /*
498
+ * If set to non-zero value, signals the request to return VMA name
499
+ * (i.e., VMA's backing file's absolute path, with " (deleted)" suffix
500
+ * appended, if file was unlinked from FS) for matched VMA. VMA name
501
+ * can also be some special name (e.g., "[heap]", "[stack]") or could
502
+ * be even user-supplied with prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME).
503
+ *
504
+ * Kernel will set this field to zero, if VMA has no associated name.
505
+ * Otherwise kernel will return actual amount of bytes filled in
506
+ * user-supplied buffer (see vma_name_addr field below), including the
507
+ * terminating zero.
508
+ *
509
+ * If VMA name is longer that user-supplied maximum buffer size,
510
+ * -E2BIG error is returned.
511
+ *
512
+ * If this field is set to non-zero value, vma_name_addr should point
513
+ * to valid user space memory buffer of at least vma_name_size bytes.
514
+ * If set to zero, vma_name_addr should be set to zero as well
515
+ */
516
+ __u32 vma_name_size ; /* in/out */
517
+ /*
518
+ * If set to non-zero value, signals the request to extract and return
519
+ * VMA's backing file's build ID, if the backing file is an ELF file
520
+ * and it contains embedded build ID.
521
+ *
522
+ * Kernel will set this field to zero, if VMA has no backing file,
523
+ * backing file is not an ELF file, or ELF file has no build ID
524
+ * embedded.
525
+ *
526
+ * Build ID is a binary value (not a string). Kernel will set
527
+ * build_id_size field to exact number of bytes used for build ID.
528
+ * If build ID is requested and present, but needs more bytes than
529
+ * user-supplied maximum buffer size (see build_id_addr field below),
530
+ * -E2BIG error will be returned.
531
+ *
532
+ * If this field is set to non-zero value, build_id_addr should point
533
+ * to valid user space memory buffer of at least build_id_size bytes.
534
+ * If set to zero, build_id_addr should be set to zero as well
535
+ */
536
+ __u32 build_id_size ; /* in/out */
537
+ /*
538
+ * User-supplied address of a buffer of at least vma_name_size bytes
539
+ * for kernel to fill with matched VMA's name (see vma_name_size field
540
+ * description above for details).
541
+ *
542
+ * Should be set to zero if VMA name should not be returned.
543
+ */
544
+ __u64 vma_name_addr ; /* in */
545
+ /*
546
+ * User-supplied address of a buffer of at least build_id_size bytes
547
+ * for kernel to fill with matched VMA's ELF build ID, if available
548
+ * (see build_id_size field description above for details).
549
+ *
550
+ * Should be set to zero if build ID should not be returned.
551
+ */
552
+ __u64 build_id_addr ; /* in */
553
+ };
554
+
396
555
#endif /* _UAPI_LINUX_FS_H */
0 commit comments