Bug

[В начало]

Ошибка # 144

Показать/спрятать трассу ошибок
Error trace
Function bodies
Blocks
  • Others...
    Function bodies without model function calls
    Initialization function calls
    Initialization function bodies
    Entry point
    Entry point body
    Function calls
    Skipped function calls
    Formal parameter names
    Declarations
    Assumes
    Assume conditions
    Returns
    Return values
    DEG initialization
    DEG function calls
    Model function calls
    Model function bodies
    Model asserts
    Model state changes
    Model function function calls
    Model function function bodies
    Model returns
    Model others
    Identation
    Line numbers
    Expand signs
-__CPAchecker_initialize()
{
20 typedef unsigned char __u8;
23 typedef unsigned short __u16;
25 typedef int __s32;
26 typedef unsigned int __u32;
30 typedef unsigned long long __u64;
15 typedef signed char s8;
16 typedef unsigned char u8;
19 typedef unsigned short u16;
21 typedef int s32;
22 typedef unsigned int u32;
24 typedef long long s64;
25 typedef unsigned long long u64;
14 typedef long __kernel_long_t;
15 typedef unsigned long __kernel_ulong_t;
27 typedef int __kernel_pid_t;
44 typedef int __kernel_daddr_t;
48 typedef unsigned int __kernel_uid32_t;
49 typedef unsigned int __kernel_gid32_t;
71 typedef __kernel_ulong_t __kernel_size_t;
72 typedef __kernel_long_t __kernel_ssize_t;
87 typedef long long __kernel_loff_t;
88 typedef __kernel_long_t __kernel_time_t;
89 typedef __kernel_long_t __kernel_clock_t;
90 typedef int __kernel_timer_t;
91 typedef int __kernel_clockid_t;
32 typedef __u16 __le16;
33 typedef __u16 __be16;
34 typedef __u32 __le32;
35 typedef __u32 __be32;
36 typedef __u64 __le64;
259 struct kernel_symbol { unsigned long value; const char *name; } ;
33 struct module ;
12 typedef __u32 __kernel_dev_t;
15 typedef __kernel_dev_t dev_t;
18 typedef unsigned short umode_t;
21 typedef __kernel_pid_t pid_t;
26 typedef __kernel_clockid_t clockid_t;
29 typedef _Bool bool;
31 typedef __kernel_uid32_t uid_t;
32 typedef __kernel_gid32_t gid_t;
45 typedef __kernel_loff_t loff_t;
54 typedef __kernel_size_t size_t;
59 typedef __kernel_ssize_t ssize_t;
69 typedef __kernel_time_t time_t;
102 typedef __s32 int32_t;
108 typedef __u32 uint32_t;
133 typedef unsigned long sector_t;
134 typedef unsigned long blkcnt_t;
152 typedef u64 dma_addr_t;
157 typedef unsigned int gfp_t;
158 typedef unsigned int fmode_t;
161 typedef u64 phys_addr_t;
166 typedef phys_addr_t resource_size_t;
176 struct __anonstruct_atomic_t_6 { int counter; } ;
176 typedef struct __anonstruct_atomic_t_6 atomic_t;
181 struct __anonstruct_atomic64_t_7 { long counter; } ;
181 typedef struct __anonstruct_atomic64_t_7 atomic64_t;
182 struct list_head { struct list_head *next; struct list_head *prev; } ;
187 struct hlist_node ;
187 struct hlist_head { struct hlist_node *first; } ;
191 struct hlist_node { struct hlist_node *next; struct hlist_node **pprev; } ;
202 struct callback_head { struct callback_head *next; void (*func)(struct callback_head *); } ;
131 typedef void (*ctor_fn_t)();
48 struct device ;
432 struct file_operations ;
444 struct completion ;
445 struct pt_regs ;
555 struct bug_entry { int bug_addr_disp; int file_disp; unsigned short line; unsigned short flags; } ;
111 struct timespec ;
112 struct compat_timespec ;
113 struct __anonstruct_futex_25 { u32 *uaddr; u32 val; u32 flags; u32 bitset; u64 time; u32 *uaddr2; } ;
113 struct __anonstruct_nanosleep_26 { clockid_t clockid; struct timespec *rmtp; struct compat_timespec *compat_rmtp; u64 expires; } ;
113 struct pollfd ;
113 struct __anonstruct_poll_27 { struct pollfd *ufds; int nfds; int has_timeout; unsigned long tv_sec; unsigned long tv_nsec; } ;
113 union __anonunion____missing_field_name_24 { struct __anonstruct_futex_25 futex; struct __anonstruct_nanosleep_26 nanosleep; struct __anonstruct_poll_27 poll; } ;
113 struct restart_block { long int (*fn)(struct restart_block *); union __anonunion____missing_field_name_24 __annonCompField4; } ;
39 struct page ;
14 struct __anonstruct_pfn_t_28 { u64 val; } ;
14 typedef struct __anonstruct_pfn_t_28 pfn_t;
26 struct task_struct ;
27 struct mm_struct ;
288 struct pt_regs { unsigned long r15; unsigned long r14; unsigned long r13; unsigned long r12; unsigned long bp; unsigned long bx; unsigned long r11; unsigned long r10; unsigned long r9; unsigned long r8; unsigned long ax; unsigned long cx; unsigned long dx; unsigned long si; unsigned long di; unsigned long orig_ax; unsigned long ip; unsigned long cs; unsigned long flags; unsigned long sp; unsigned long ss; } ;
66 struct __anonstruct____missing_field_name_30 { unsigned int a; unsigned int b; } ;
66 struct __anonstruct____missing_field_name_31 { u16 limit0; u16 base0; unsigned char base1; unsigned char type; unsigned char s; unsigned char dpl; unsigned char p; unsigned char limit; unsigned char avl; unsigned char l; unsigned char d; unsigned char g; unsigned char base2; } ;
66 union __anonunion____missing_field_name_29 { struct __anonstruct____missing_field_name_30 __annonCompField5; struct __anonstruct____missing_field_name_31 __annonCompField6; } ;
66 struct desc_struct { union __anonunion____missing_field_name_29 __annonCompField7; } ;
12 typedef unsigned long pteval_t;
13 typedef unsigned long pmdval_t;
15 typedef unsigned long pgdval_t;
16 typedef unsigned long pgprotval_t;
18 struct __anonstruct_pte_t_32 { pteval_t pte; } ;
18 typedef struct __anonstruct_pte_t_32 pte_t;
20 struct pgprot { pgprotval_t pgprot; } ;
250 typedef struct pgprot pgprot_t;
252 struct __anonstruct_pgd_t_33 { pgdval_t pgd; } ;
252 typedef struct __anonstruct_pgd_t_33 pgd_t;
291 struct __anonstruct_pmd_t_35 { pmdval_t pmd; } ;
291 typedef struct __anonstruct_pmd_t_35 pmd_t;
417 typedef struct page *pgtable_t;
428 struct file ;
441 struct seq_file ;
479 struct thread_struct ;
481 struct cpumask ;
20 struct qspinlock { atomic_t val; } ;
33 typedef struct qspinlock arch_spinlock_t;
34 struct qrwlock { atomic_t cnts; arch_spinlock_t wait_lock; } ;
14 typedef struct qrwlock arch_rwlock_t;
253 struct math_emu_info { long ___orig_eip; struct pt_regs *regs; } ;
338 struct cpumask { unsigned long bits[128U]; } ;
15 typedef struct cpumask cpumask_t;
654 typedef struct cpumask *cpumask_var_t;
23 typedef atomic64_t atomic_long_t;
82 struct static_key { atomic_t enabled; } ;
22 struct tracepoint_func { void *func; void *data; int prio; } ;
28 struct tracepoint { const char *name; struct static_key key; void (*regfunc)(); void (*unregfunc)(); struct tracepoint_func *funcs; } ;
298 struct fregs_state { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u32 status; } ;
26 struct __anonstruct____missing_field_name_59 { u64 rip; u64 rdp; } ;
26 struct __anonstruct____missing_field_name_60 { u32 fip; u32 fcs; u32 foo; u32 fos; } ;
26 union __anonunion____missing_field_name_58 { struct __anonstruct____missing_field_name_59 __annonCompField13; struct __anonstruct____missing_field_name_60 __annonCompField14; } ;
26 union __anonunion____missing_field_name_61 { u32 padding1[12U]; u32 sw_reserved[12U]; } ;
26 struct fxregs_state { u16 cwd; u16 swd; u16 twd; u16 fop; union __anonunion____missing_field_name_58 __annonCompField15; u32 mxcsr; u32 mxcsr_mask; u32 st_space[32U]; u32 xmm_space[64U]; u32 padding[12U]; union __anonunion____missing_field_name_61 __annonCompField16; } ;
66 struct swregs_state { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u8 ftop; u8 changed; u8 lookahead; u8 no_update; u8 rm; u8 alimit; struct math_emu_info *info; u32 entry_eip; } ;
226 struct xstate_header { u64 xfeatures; u64 xcomp_bv; u64 reserved[6U]; } ;
232 struct xregs_state { struct fxregs_state i387; struct xstate_header header; u8 extended_state_area[0U]; } ;
247 union fpregs_state { struct fregs_state fsave; struct fxregs_state fxsave; struct swregs_state soft; struct xregs_state xsave; u8 __padding[4096U]; } ;
264 struct fpu { unsigned int last_cpu; unsigned char fpstate_active; unsigned char fpregs_active; unsigned char counter; union fpregs_state state; } ;
169 struct seq_operations ;
371 struct perf_event ;
372 struct thread_struct { struct desc_struct tls_array[3U]; unsigned long sp0; unsigned long sp; unsigned short es; unsigned short ds; unsigned short fsindex; unsigned short gsindex; unsigned long fsbase; unsigned long gsbase; struct perf_event *ptrace_bps[4U]; unsigned long debugreg6; unsigned long ptrace_dr7; unsigned long cr2; unsigned long trap_nr; unsigned long error_code; unsigned long *io_bitmap_ptr; unsigned long iopl; unsigned int io_bitmap_max; struct fpu fpu; } ;
33 struct lockdep_map ;
55 struct stack_trace { unsigned int nr_entries; unsigned int max_entries; unsigned long *entries; int skip; } ;
28 struct lockdep_subclass_key { char __one_byte; } ;
53 struct lock_class_key { struct lockdep_subclass_key subkeys[8U]; } ;
59 struct lock_class { struct hlist_node hash_entry; struct list_head lock_entry; struct lockdep_subclass_key *key; unsigned int subclass; unsigned int dep_gen_id; unsigned long usage_mask; struct stack_trace usage_traces[13U]; struct list_head locks_after; struct list_head locks_before; unsigned int version; unsigned long ops; const char *name; int name_version; unsigned long contention_point[4U]; unsigned long contending_point[4U]; } ;
144 struct lockdep_map { struct lock_class_key *key; struct lock_class *class_cache[2U]; const char *name; int cpu; unsigned long ip; } ;
207 struct held_lock { u64 prev_chain_key; unsigned long acquire_ip; struct lockdep_map *instance; struct lockdep_map *nest_lock; u64 waittime_stamp; u64 holdtime_stamp; unsigned short class_idx; unsigned char irq_context; unsigned char trylock; unsigned char read; unsigned char check; unsigned char hardirqs_off; unsigned short references; unsigned int pin_count; } ;
572 struct raw_spinlock { arch_spinlock_t raw_lock; unsigned int magic; unsigned int owner_cpu; void *owner; struct lockdep_map dep_map; } ;
32 typedef struct raw_spinlock raw_spinlock_t;
33 struct __anonstruct____missing_field_name_75 { u8 __padding[24U]; struct lockdep_map dep_map; } ;
33 union __anonunion____missing_field_name_74 { struct raw_spinlock rlock; struct __anonstruct____missing_field_name_75 __annonCompField19; } ;
33 struct spinlock { union __anonunion____missing_field_name_74 __annonCompField20; } ;
76 typedef struct spinlock spinlock_t;
23 struct __anonstruct_rwlock_t_76 { arch_rwlock_t raw_lock; unsigned int magic; unsigned int owner_cpu; void *owner; struct lockdep_map dep_map; } ;
23 typedef struct __anonstruct_rwlock_t_76 rwlock_t;
416 struct seqcount { unsigned int sequence; struct lockdep_map dep_map; } ;
52 typedef struct seqcount seqcount_t;
404 struct __anonstruct_seqlock_t_89 { struct seqcount seqcount; spinlock_t lock; } ;
404 typedef struct __anonstruct_seqlock_t_89 seqlock_t;
598 struct timespec { __kernel_time_t tv_sec; long tv_nsec; } ;
83 struct user_namespace ;
22 struct __anonstruct_kuid_t_90 { uid_t val; } ;
22 typedef struct __anonstruct_kuid_t_90 kuid_t;
27 struct __anonstruct_kgid_t_91 { gid_t val; } ;
27 typedef struct __anonstruct_kgid_t_91 kgid_t;
139 struct kstat { u64 ino; dev_t dev; umode_t mode; unsigned int nlink; kuid_t uid; kgid_t gid; dev_t rdev; loff_t size; struct timespec atime; struct timespec mtime; struct timespec ctime; unsigned long blksize; unsigned long long blocks; } ;
36 struct vm_area_struct ;
38 struct __wait_queue_head { spinlock_t lock; struct list_head task_list; } ;
43 typedef struct __wait_queue_head wait_queue_head_t;
97 struct __anonstruct_nodemask_t_92 { unsigned long bits[16U]; } ;
97 typedef struct __anonstruct_nodemask_t_92 nodemask_t;
13 struct optimistic_spin_queue { atomic_t tail; } ;
39 struct mutex { atomic_t count; spinlock_t wait_lock; struct list_head wait_list; struct task_struct *owner; void *magic; struct lockdep_map dep_map; } ;
67 struct mutex_waiter { struct list_head list; struct task_struct *task; void *magic; } ;
177 struct rw_semaphore ;
178 struct rw_semaphore { long count; struct list_head wait_list; raw_spinlock_t wait_lock; struct optimistic_spin_queue osq; struct task_struct *owner; struct lockdep_map dep_map; } ;
176 struct completion { unsigned int done; wait_queue_head_t wait; } ;
446 union ktime { s64 tv64; } ;
41 typedef union ktime ktime_t;
1129 struct timer_list { struct hlist_node entry; unsigned long expires; void (*function)(unsigned long); unsigned long data; u32 flags; int slack; int start_pid; void *start_site; char start_comm[16U]; struct lockdep_map lockdep_map; } ;
240 struct hrtimer ;
241 enum hrtimer_restart ;
242 struct rb_node { unsigned long __rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } ;
41 struct rb_root { struct rb_node *rb_node; } ;
838 struct nsproxy ;
261 struct workqueue_struct ;
262 struct work_struct ;
54 struct work_struct { atomic_long_t data; struct list_head entry; void (*func)(struct work_struct *); struct lockdep_map lockdep_map; } ;
107 struct delayed_work { struct work_struct work; struct timer_list timer; struct workqueue_struct *wq; int cpu; } ;
217 struct resource ;
64 struct resource { resource_size_t start; resource_size_t end; const char *name; unsigned long flags; unsigned long desc; struct resource *parent; struct resource *sibling; struct resource *child; } ;
217 struct pci_dev ;
58 struct pm_message { int event; } ;
64 typedef struct pm_message pm_message_t;
65 struct dev_pm_ops { int (*prepare)(struct device *); void (*complete)(struct device *); int (*suspend)(struct device *); int (*resume)(struct device *); int (*freeze)(struct device *); int (*thaw)(struct device *); int (*poweroff)(struct device *); int (*restore)(struct device *); int (*suspend_late)(struct device *); int (*resume_early)(struct device *); int (*freeze_late)(struct device *); int (*thaw_early)(struct device *); int (*poweroff_late)(struct device *); int (*restore_early)(struct device *); int (*suspend_noirq)(struct device *); int (*resume_noirq)(struct device *); int (*freeze_noirq)(struct device *); int (*thaw_noirq)(struct device *); int (*poweroff_noirq)(struct device *); int (*restore_noirq)(struct device *); int (*runtime_suspend)(struct device *); int (*runtime_resume)(struct device *); int (*runtime_idle)(struct device *); } ;
320 enum rpm_status { RPM_ACTIVE = 0, RPM_RESUMING = 1, RPM_SUSPENDED = 2, RPM_SUSPENDING = 3 } ;
327 enum rpm_request { RPM_REQ_NONE = 0, RPM_REQ_IDLE = 1, RPM_REQ_SUSPEND = 2, RPM_REQ_AUTOSUSPEND = 3, RPM_REQ_RESUME = 4 } ;
335 struct wakeup_source ;
336 struct wake_irq ;
337 struct pm_domain_data ;
338 struct pm_subsys_data { spinlock_t lock; unsigned int refcount; struct list_head clock_list; struct pm_domain_data *domain_data; } ;
556 struct dev_pm_qos ;
556 struct dev_pm_info { pm_message_t power_state; unsigned char can_wakeup; unsigned char async_suspend; bool is_prepared; bool is_suspended; bool is_noirq_suspended; bool is_late_suspended; bool early_init; bool direct_complete; spinlock_t lock; struct list_head entry; struct completion completion; struct wakeup_source *wakeup; bool wakeup_path; bool syscore; bool no_pm_callbacks; struct timer_list suspend_timer; unsigned long timer_expires; struct work_struct work; wait_queue_head_t wait_queue; struct wake_irq *wakeirq; atomic_t usage_count; atomic_t child_count; unsigned char disable_depth; unsigned char idle_notification; unsigned char request_pending; unsigned char deferred_resume; unsigned char run_wake; unsigned char runtime_auto; bool ignore_children; unsigned char no_callbacks; unsigned char irq_safe; unsigned char use_autosuspend; unsigned char timer_autosuspends; unsigned char memalloc_noio; enum rpm_request request; enum rpm_status runtime_status; int runtime_error; int autosuspend_delay; unsigned long last_busy; unsigned long active_jiffies; unsigned long suspended_jiffies; unsigned long accounting_timestamp; struct pm_subsys_data *subsys_data; void (*set_latency_tolerance)(struct device *, s32 ); struct dev_pm_qos *qos; } ;
616 struct dev_pm_domain { struct dev_pm_ops ops; void (*detach)(struct device *, bool ); int (*activate)(struct device *); void (*sync)(struct device *); void (*dismiss)(struct device *); } ;
144 struct pci_bus ;
26 struct ldt_struct ;
26 struct vdso_image ;
26 struct __anonstruct_mm_context_t_161 { struct ldt_struct *ldt; unsigned short ia32_compat; struct mutex lock; void *vdso; const struct vdso_image *vdso_image; atomic_t perf_rdpmc_allowed; } ;
26 typedef struct __anonstruct_mm_context_t_161 mm_context_t;
22 struct bio_vec ;
1238 struct llist_node ;
64 struct llist_node { struct llist_node *next; } ;
17 struct call_single_data { struct llist_node llist; void (*func)(void *); void *info; unsigned int flags; } ;
37 struct cred ;
19 struct inode ;
58 struct arch_uprobe_task { unsigned long saved_scratch_register; unsigned int saved_trap_nr; unsigned int saved_tf; } ;
66 enum uprobe_task_state { UTASK_RUNNING = 0, UTASK_SSTEP = 1, UTASK_SSTEP_ACK = 2, UTASK_SSTEP_TRAPPED = 3 } ;
73 struct __anonstruct____missing_field_name_197 { struct arch_uprobe_task autask; unsigned long vaddr; } ;
73 struct __anonstruct____missing_field_name_198 { struct callback_head dup_xol_work; unsigned long dup_xol_addr; } ;
73 union __anonunion____missing_field_name_196 { struct __anonstruct____missing_field_name_197 __annonCompField35; struct __anonstruct____missing_field_name_198 __annonCompField36; } ;
73 struct uprobe ;
73 struct return_instance ;
73 struct uprobe_task { enum uprobe_task_state state; union __anonunion____missing_field_name_196 __annonCompField37; struct uprobe *active_uprobe; unsigned long xol_vaddr; struct return_instance *return_instances; unsigned int depth; } ;
94 struct return_instance { struct uprobe *uprobe; unsigned long func; unsigned long stack; unsigned long orig_ret_vaddr; bool chained; struct return_instance *next; } ;
110 struct xol_area ;
111 struct uprobes_state { struct xol_area *xol_area; } ;
150 struct address_space ;
151 struct mem_cgroup ;
152 union __anonunion____missing_field_name_199 { struct address_space *mapping; void *s_mem; atomic_t compound_mapcount; } ;
152 union __anonunion____missing_field_name_201 { unsigned long index; void *freelist; } ;
152 struct __anonstruct____missing_field_name_205 { unsigned short inuse; unsigned short objects; unsigned char frozen; } ;
152 union __anonunion____missing_field_name_204 { atomic_t _mapcount; struct __anonstruct____missing_field_name_205 __annonCompField40; int units; } ;
152 struct __anonstruct____missing_field_name_203 { union __anonunion____missing_field_name_204 __annonCompField41; atomic_t _refcount; } ;
152 union __anonunion____missing_field_name_202 { unsigned long counters; struct __anonstruct____missing_field_name_203 __annonCompField42; unsigned int active; } ;
152 struct __anonstruct____missing_field_name_200 { union __anonunion____missing_field_name_201 __annonCompField39; union __anonunion____missing_field_name_202 __annonCompField43; } ;
152 struct dev_pagemap ;
152 struct __anonstruct____missing_field_name_207 { struct page *next; int pages; int pobjects; } ;
152 struct __anonstruct____missing_field_name_208 { unsigned long compound_head; unsigned int compound_dtor; unsigned int compound_order; } ;
152 struct __anonstruct____missing_field_name_209 { unsigned long __pad; pgtable_t pmd_huge_pte; } ;
152 union __anonunion____missing_field_name_206 { struct list_head lru; struct dev_pagemap *pgmap; struct __anonstruct____missing_field_name_207 __annonCompField45; struct callback_head callback_head; struct __anonstruct____missing_field_name_208 __annonCompField46; struct __anonstruct____missing_field_name_209 __annonCompField47; } ;
152 struct kmem_cache ;
152 union __anonunion____missing_field_name_210 { unsigned long private; spinlock_t *ptl; struct kmem_cache *slab_cache; } ;
152 struct page { unsigned long flags; union __anonunion____missing_field_name_199 __annonCompField38; struct __anonstruct____missing_field_name_200 __annonCompField44; union __anonunion____missing_field_name_206 __annonCompField48; union __anonunion____missing_field_name_210 __annonCompField49; struct mem_cgroup *mem_cgroup; } ;
196 struct page_frag { struct page *page; __u32 offset; __u32 size; } ;
281 struct userfaultfd_ctx ;
281 struct vm_userfaultfd_ctx { struct userfaultfd_ctx *ctx; } ;
288 struct __anonstruct_shared_211 { struct rb_node rb; unsigned long rb_subtree_last; } ;
288 struct anon_vma ;
288 struct vm_operations_struct ;
288 struct mempolicy ;
288 struct vm_area_struct { unsigned long vm_start; unsigned long vm_end; struct vm_area_struct *vm_next; struct vm_area_struct *vm_prev; struct rb_node vm_rb; unsigned long rb_subtree_gap; struct mm_struct *vm_mm; pgprot_t vm_page_prot; unsigned long vm_flags; struct __anonstruct_shared_211 shared; struct list_head anon_vma_chain; struct anon_vma *anon_vma; const struct vm_operations_struct *vm_ops; unsigned long vm_pgoff; struct file *vm_file; void *vm_private_data; struct mempolicy *vm_policy; struct vm_userfaultfd_ctx vm_userfaultfd_ctx; } ;
361 struct core_thread { struct task_struct *task; struct core_thread *next; } ;
366 struct core_state { atomic_t nr_threads; struct core_thread dumper; struct completion startup; } ;
380 struct task_rss_stat { int events; int count[4U]; } ;
388 struct mm_rss_stat { atomic_long_t count[4U]; } ;
393 struct kioctx_table ;
394 struct linux_binfmt ;
394 struct mmu_notifier_mm ;
394 struct mm_struct { struct vm_area_struct *mmap; struct rb_root mm_rb; u32 vmacache_seqnum; unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); unsigned long mmap_base; unsigned long mmap_legacy_base; unsigned long task_size; unsigned long highest_vm_end; pgd_t *pgd; atomic_t mm_users; atomic_t mm_count; atomic_long_t nr_ptes; atomic_long_t nr_pmds; int map_count; spinlock_t page_table_lock; struct rw_semaphore mmap_sem; struct list_head mmlist; unsigned long hiwater_rss; unsigned long hiwater_vm; unsigned long total_vm; unsigned long locked_vm; unsigned long pinned_vm; unsigned long data_vm; unsigned long exec_vm; unsigned long stack_vm; unsigned long def_flags; unsigned long start_code; unsigned long end_code; unsigned long start_data; unsigned long end_data; unsigned long start_brk; unsigned long brk; unsigned long start_stack; unsigned long arg_start; unsigned long arg_end; unsigned long env_start; unsigned long env_end; unsigned long saved_auxv[46U]; struct mm_rss_stat rss_stat; struct linux_binfmt *binfmt; cpumask_var_t cpu_vm_mask_var; mm_context_t context; unsigned long flags; struct core_state *core_state; spinlock_t ioctx_lock; struct kioctx_table *ioctx_table; struct task_struct *owner; struct file *exe_file; struct mmu_notifier_mm *mmu_notifier_mm; struct cpumask cpumask_allocation; unsigned long numa_next_scan; unsigned long numa_scan_offset; int numa_scan_seq; bool tlb_flush_pending; struct uprobes_state uprobes_state; void *bd_addr; atomic_long_t hugetlb_usage; struct work_struct async_put_work; } ;
564 struct vm_fault ;
615 struct vdso_image { void *data; unsigned long size; unsigned long alt; unsigned long alt_len; long sym_vvar_start; long sym_vvar_page; long sym_hpet_page; long sym_pvclock_page; long sym_VDSO32_NOTE_MASK; long sym___kernel_sigreturn; long sym___kernel_rt_sigreturn; long sym___kernel_vsyscall; long sym_int80_landing_pad; } ;
15 typedef __u64 Elf64_Addr;
16 typedef __u16 Elf64_Half;
18 typedef __u64 Elf64_Off;
20 typedef __u32 Elf64_Word;
21 typedef __u64 Elf64_Xword;
190 struct elf64_sym { Elf64_Word st_name; unsigned char st_info; unsigned char st_other; Elf64_Half st_shndx; Elf64_Addr st_value; Elf64_Xword st_size; } ;
198 typedef struct elf64_sym Elf64_Sym;
219 struct elf64_hdr { unsigned char e_ident[16U]; Elf64_Half e_type; Elf64_Half e_machine; Elf64_Word e_version; Elf64_Addr e_entry; Elf64_Off e_phoff; Elf64_Off e_shoff; Elf64_Word e_flags; Elf64_Half e_ehsize; Elf64_Half e_phentsize; Elf64_Half e_phnum; Elf64_Half e_shentsize; Elf64_Half e_shnum; Elf64_Half e_shstrndx; } ;
235 typedef struct elf64_hdr Elf64_Ehdr;
313 struct elf64_shdr { Elf64_Word sh_name; Elf64_Word sh_type; Elf64_Xword sh_flags; Elf64_Addr sh_addr; Elf64_Off sh_offset; Elf64_Xword sh_size; Elf64_Word sh_link; Elf64_Word sh_info; Elf64_Xword sh_addralign; Elf64_Xword sh_entsize; } ;
325 typedef struct elf64_shdr Elf64_Shdr;
53 union __anonunion____missing_field_name_216 { unsigned long bitmap[4U]; struct callback_head callback_head; } ;
53 struct idr_layer { int prefix; int layer; struct idr_layer *ary[256U]; int count; union __anonunion____missing_field_name_216 __annonCompField50; } ;
41 struct idr { struct idr_layer *hint; struct idr_layer *top; int layers; int cur; spinlock_t lock; int id_free_cnt; struct idr_layer *id_free; } ;
124 struct ida_bitmap { long nr_busy; unsigned long bitmap[15U]; } ;
167 struct ida { struct idr idr; struct ida_bitmap *free_bitmap; } ;
199 struct dentry ;
200 struct iattr ;
201 struct super_block ;
202 struct file_system_type ;
203 struct kernfs_open_node ;
204 struct kernfs_iattrs ;
227 struct kernfs_root ;
227 struct kernfs_elem_dir { unsigned long subdirs; struct rb_root children; struct kernfs_root *root; } ;
85 struct kernfs_node ;
85 struct kernfs_elem_symlink { struct kernfs_node *target_kn; } ;
89 struct kernfs_ops ;
89 struct kernfs_elem_attr { const struct kernfs_ops *ops; struct kernfs_open_node *open; loff_t size; struct kernfs_node *notify_next; } ;
96 union __anonunion____missing_field_name_221 { struct kernfs_elem_dir dir; struct kernfs_elem_symlink symlink; struct kernfs_elem_attr attr; } ;
96 struct kernfs_node { atomic_t count; atomic_t active; struct lockdep_map dep_map; struct kernfs_node *parent; const char *name; struct rb_node rb; const void *ns; unsigned int hash; union __anonunion____missing_field_name_221 __annonCompField51; void *priv; unsigned short flags; umode_t mode; unsigned int ino; struct kernfs_iattrs *iattr; } ;
138 struct kernfs_syscall_ops { int (*remount_fs)(struct kernfs_root *, int *, char *); int (*show_options)(struct seq_file *, struct kernfs_root *); int (*mkdir)(struct kernfs_node *, const char *, umode_t ); int (*rmdir)(struct kernfs_node *); int (*rename)(struct kernfs_node *, struct kernfs_node *, const char *); int (*show_path)(struct seq_file *, struct kernfs_node *, struct kernfs_root *); } ;
157 struct kernfs_root { struct kernfs_node *kn; unsigned int flags; struct ida ino_ida; struct kernfs_syscall_ops *syscall_ops; struct list_head supers; wait_queue_head_t deactivate_waitq; } ;
173 struct kernfs_open_file { struct kernfs_node *kn; struct file *file; void *priv; struct mutex mutex; struct mutex prealloc_mutex; int event; struct list_head list; char *prealloc_buf; size_t atomic_write_len; bool mmapped; const struct vm_operations_struct *vm_ops; } ;
191 struct kernfs_ops { int (*seq_show)(struct seq_file *, void *); void * (*seq_start)(struct seq_file *, loff_t *); void * (*seq_next)(struct seq_file *, void *, loff_t *); void (*seq_stop)(struct seq_file *, void *); ssize_t (*read)(struct kernfs_open_file *, char *, size_t , loff_t ); size_t atomic_write_len; bool prealloc; ssize_t (*write)(struct kernfs_open_file *, char *, size_t , loff_t ); int (*mmap)(struct kernfs_open_file *, struct vm_area_struct *); struct lock_class_key lockdep_key; } ;
499 struct sock ;
500 struct kobject ;
501 enum kobj_ns_type { KOBJ_NS_TYPE_NONE = 0, KOBJ_NS_TYPE_NET = 1, KOBJ_NS_TYPES = 2 } ;
507 struct kobj_ns_type_operations { enum kobj_ns_type type; bool (*current_may_mount)(); void * (*grab_current_ns)(); const void * (*netlink_ns)(struct sock *); const void * (*initial_ns)(); void (*drop_ns)(void *); } ;
59 struct bin_attribute ;
60 struct attribute { const char *name; umode_t mode; bool ignore_lockdep; struct lock_class_key *key; struct lock_class_key skey; } ;
37 struct attribute_group { const char *name; umode_t (*is_visible)(struct kobject *, struct attribute *, int); umode_t (*is_bin_visible)(struct kobject *, struct bin_attribute *, int); struct attribute **attrs; struct bin_attribute **bin_attrs; } ;
92 struct bin_attribute { struct attribute attr; size_t size; void *private; ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t ); ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t ); int (*mmap)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *); } ;
165 struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *, char *); ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t ); } ;
530 struct kref { atomic_t refcount; } ;
52 struct kset ;
52 struct kobj_type ;
52 struct kobject { const char *name; struct list_head entry; struct kobject *parent; struct kset *kset; struct kobj_type *ktype; struct kernfs_node *sd; struct kref kref; struct delayed_work release; unsigned char state_initialized; unsigned char state_in_sysfs; unsigned char state_add_uevent_sent; unsigned char state_remove_uevent_sent; unsigned char uevent_suppress; } ;
115 struct kobj_type { void (*release)(struct kobject *); const struct sysfs_ops *sysfs_ops; struct attribute **default_attrs; const struct kobj_ns_type_operations * (*child_ns_type)(struct kobject *); const void * (*namespace)(struct kobject *); } ;
123 struct kobj_uevent_env { char *argv[3U]; char *envp[32U]; int envp_idx; char buf[2048U]; int buflen; } ;
131 struct kset_uevent_ops { const int (*filter)(struct kset *, struct kobject *); const const char * (*name)(struct kset *, struct kobject *); const int (*uevent)(struct kset *, struct kobject *, struct kobj_uevent_env *); } ;
148 struct kset { struct list_head list; spinlock_t list_lock; struct kobject kobj; const struct kset_uevent_ops *uevent_ops; } ;
223 struct kernel_param ;
228 struct kernel_param_ops { unsigned int flags; int (*set)(const char *, const struct kernel_param *); int (*get)(char *, const struct kernel_param *); void (*free)(void *); } ;
62 struct kparam_string ;
62 struct kparam_array ;
62 union __anonunion____missing_field_name_224 { void *arg; const struct kparam_string *str; const struct kparam_array *arr; } ;
62 struct kernel_param { const char *name; struct module *mod; const struct kernel_param_ops *ops; const u16 perm; s8 level; u8 flags; union __anonunion____missing_field_name_224 __annonCompField52; } ;
83 struct kparam_string { unsigned int maxlen; char *string; } ;
89 struct kparam_array { unsigned int max; unsigned int elemsize; unsigned int *num; const struct kernel_param_ops *ops; void *elem; } ;
470 struct latch_tree_node { struct rb_node node[2U]; } ;
211 struct mod_arch_specific { } ;
38 struct module_param_attrs ;
38 struct module_kobject { struct kobject kobj; struct module *mod; struct kobject *drivers_dir; struct module_param_attrs *mp; struct completion *kobj_completion; } ;
48 struct module_attribute { struct attribute attr; ssize_t (*show)(struct module_attribute *, struct module_kobject *, char *); ssize_t (*store)(struct module_attribute *, struct module_kobject *, const char *, size_t ); void (*setup)(struct module *, const char *); int (*test)(struct module *); void (*free)(struct module *); } ;
74 struct exception_table_entry ;
290 enum module_state { MODULE_STATE_LIVE = 0, MODULE_STATE_COMING = 1, MODULE_STATE_GOING = 2, MODULE_STATE_UNFORMED = 3 } ;
297 struct mod_tree_node { struct module *mod; struct latch_tree_node node; } ;
304 struct module_layout { void *base; unsigned int size; unsigned int text_size; unsigned int ro_size; struct mod_tree_node mtn; } ;
318 struct mod_kallsyms { Elf64_Sym *symtab; unsigned int num_symtab; char *strtab; } ;
332 struct klp_modinfo { Elf64_Ehdr hdr; Elf64_Shdr *sechdrs; char *secstrings; unsigned int symndx; } ;
340 struct module_sect_attrs ;
340 struct module_notes_attrs ;
340 struct trace_event_call ;
340 struct trace_enum_map ;
340 struct module { enum module_state state; struct list_head list; char name[56U]; struct module_kobject mkobj; struct module_attribute *modinfo_attrs; const char *version; const char *srcversion; struct kobject *holders_dir; const struct kernel_symbol *syms; const unsigned long *crcs; unsigned int num_syms; struct mutex param_lock; struct kernel_param *kp; unsigned int num_kp; unsigned int num_gpl_syms; const struct kernel_symbol *gpl_syms; const unsigned long *gpl_crcs; const struct kernel_symbol *unused_syms; const unsigned long *unused_crcs; unsigned int num_unused_syms; unsigned int num_unused_gpl_syms; const struct kernel_symbol *unused_gpl_syms; const unsigned long *unused_gpl_crcs; bool sig_ok; bool async_probe_requested; const struct kernel_symbol *gpl_future_syms; const unsigned long *gpl_future_crcs; unsigned int num_gpl_future_syms; unsigned int num_exentries; struct exception_table_entry *extable; int (*init)(); struct module_layout core_layout; struct module_layout init_layout; struct mod_arch_specific arch; unsigned int taints; unsigned int num_bugs; struct list_head bug_list; struct bug_entry *bug_table; struct mod_kallsyms *kallsyms; struct mod_kallsyms core_kallsyms; struct module_sect_attrs *sect_attrs; struct module_notes_attrs *notes_attrs; char *args; void *percpu; unsigned int percpu_size; unsigned int num_tracepoints; const struct tracepoint **tracepoints_ptrs; unsigned int num_trace_bprintk_fmt; const char **trace_bprintk_fmt_start; struct trace_event_call **trace_events; unsigned int num_trace_events; struct trace_enum_map **trace_enums; unsigned int num_trace_enums; bool klp; bool klp_alive; struct klp_modinfo *klp_info; struct list_head source_list; struct list_head target_list; void (*exit)(); atomic_t refcnt; ctor_fn_t (**ctors)(); unsigned int num_ctors; } ;
54 struct percpu_ref ;
55 typedef void percpu_ref_func_t(struct percpu_ref *);
68 struct percpu_ref { atomic_long_t count; unsigned long percpu_count_ptr; percpu_ref_func_t *release; percpu_ref_func_t *confirm_switch; bool force_atomic; struct callback_head rcu; } ;
93 struct shrink_control { gfp_t gfp_mask; unsigned long nr_to_scan; int nid; struct mem_cgroup *memcg; } ;
27 struct shrinker { unsigned long int (*count_objects)(struct shrinker *, struct shrink_control *); unsigned long int (*scan_objects)(struct shrinker *, struct shrink_control *); int seeks; long batch; unsigned long flags; struct list_head list; atomic_long_t *nr_deferred; } ;
41 struct rlimit { __kernel_ulong_t rlim_cur; __kernel_ulong_t rlim_max; } ;
173 struct file_ra_state ;
174 struct user_struct ;
175 struct writeback_control ;
176 struct bdi_writeback ;
273 struct vm_fault { unsigned int flags; gfp_t gfp_mask; unsigned long pgoff; void *virtual_address; struct page *cow_page; struct page *page; void *entry; unsigned long max_pgoff; pte_t *pte; } ;
317 struct vm_operations_struct { void (*open)(struct vm_area_struct *); void (*close)(struct vm_area_struct *); int (*mremap)(struct vm_area_struct *); int (*fault)(struct vm_area_struct *, struct vm_fault *); int (*pmd_fault)(struct vm_area_struct *, unsigned long, pmd_t *, unsigned int); void (*map_pages)(struct vm_area_struct *, struct vm_fault *); int (*page_mkwrite)(struct vm_area_struct *, struct vm_fault *); int (*pfn_mkwrite)(struct vm_area_struct *, struct vm_fault *); int (*access)(struct vm_area_struct *, unsigned long, void *, int, int); const char * (*name)(struct vm_area_struct *); int (*set_policy)(struct vm_area_struct *, struct mempolicy *); struct mempolicy * (*get_policy)(struct vm_area_struct *, unsigned long); struct page * (*find_special_page)(struct vm_area_struct *, unsigned long); } ;
2409 enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED = 1, IRQ_WAKE_THREAD = 2 } ;
16 typedef enum irqreturn irqreturn_t;
64 struct irq_domain ;
414 struct proc_dir_entry ;
63 struct exception_table_entry { int insn; int fixup; int handler; } ;
61 struct timerqueue_node { struct rb_node node; ktime_t expires; } ;
12 struct timerqueue_head { struct rb_root head; struct timerqueue_node *next; } ;
50 struct hrtimer_clock_base ;
51 struct hrtimer_cpu_base ;
60 enum hrtimer_restart { HRTIMER_NORESTART = 0, HRTIMER_RESTART = 1 } ;
65 struct hrtimer { struct timerqueue_node node; ktime_t _softexpires; enum hrtimer_restart (*function)(struct hrtimer *); struct hrtimer_clock_base *base; u8 state; u8 is_rel; int start_pid; void *start_site; char start_comm[16U]; } ;
125 struct hrtimer_clock_base { struct hrtimer_cpu_base *cpu_base; int index; clockid_t clockid; struct timerqueue_head active; ktime_t (*get_time)(); ktime_t offset; } ;
158 struct hrtimer_cpu_base { raw_spinlock_t lock; seqcount_t seq; struct hrtimer *running; unsigned int cpu; unsigned int active_bases; unsigned int clock_was_set_seq; bool migration_enabled; bool nohz_active; unsigned char in_hrtirq; unsigned char hres_active; unsigned char hang_detected; ktime_t expires_next; struct hrtimer *next_timer; unsigned int nr_events; unsigned int nr_retries; unsigned int nr_hangs; unsigned int max_hang_time; struct hrtimer_clock_base clock_base[4U]; } ;
22 struct kernel_cap_struct { __u32 cap[2U]; } ;
25 typedef struct kernel_cap_struct kernel_cap_t;
84 struct plist_node { int prio; struct list_head prio_list; struct list_head node_list; } ;
4 typedef unsigned long cputime_t;
25 struct sem_undo_list ;
25 struct sysv_sem { struct sem_undo_list *undo_list; } ;
26 struct sysv_shm { struct list_head shm_clist; } ;
24 struct __anonstruct_sigset_t_251 { unsigned long sig[1U]; } ;
24 typedef struct __anonstruct_sigset_t_251 sigset_t;
25 struct siginfo ;
17 typedef void __signalfn_t(int);
18 typedef __signalfn_t *__sighandler_t;
20 typedef void __restorefn_t();
21 typedef __restorefn_t *__sigrestore_t;
34 union sigval { int sival_int; void *sival_ptr; } ;
10 typedef union sigval sigval_t;
11 struct __anonstruct__kill_253 { __kernel_pid_t _pid; __kernel_uid32_t _uid; } ;
11 struct __anonstruct__timer_254 { __kernel_timer_t _tid; int _overrun; char _pad[0U]; sigval_t _sigval; int _sys_private; } ;
11 struct __anonstruct__rt_255 { __kernel_pid_t _pid; __kernel_uid32_t _uid; sigval_t _sigval; } ;
11 struct __anonstruct__sigchld_256 { __kernel_pid_t _pid; __kernel_uid32_t _uid; int _status; __kernel_clock_t _utime; __kernel_clock_t _stime; } ;
11 struct __anonstruct__addr_bnd_259 { void *_lower; void *_upper; } ;
11 union __anonunion____missing_field_name_258 { struct __anonstruct__addr_bnd_259 _addr_bnd; __u32 _pkey; } ;
11 struct __anonstruct__sigfault_257 { void *_addr; short _addr_lsb; union __anonunion____missing_field_name_258 __annonCompField61; } ;
11 struct __anonstruct__sigpoll_260 { long _band; int _fd; } ;
11 struct __anonstruct__sigsys_261 { void *_call_addr; int _syscall; unsigned int _arch; } ;
11 union __anonunion__sifields_252 { int _pad[28U]; struct __anonstruct__kill_253 _kill; struct __anonstruct__timer_254 _timer; struct __anonstruct__rt_255 _rt; struct __anonstruct__sigchld_256 _sigchld; struct __anonstruct__sigfault_257 _sigfault; struct __anonstruct__sigpoll_260 _sigpoll; struct __anonstruct__sigsys_261 _sigsys; } ;
11 struct siginfo { int si_signo; int si_errno; int si_code; union __anonunion__sifields_252 _sifields; } ;
118 typedef struct siginfo siginfo_t;
22 struct sigpending { struct list_head list; sigset_t signal; } ;
257 struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; __sigrestore_t sa_restorer; sigset_t sa_mask; } ;
271 struct k_sigaction { struct sigaction sa; } ;
457 enum pid_type { PIDTYPE_PID = 0, PIDTYPE_PGID = 1, PIDTYPE_SID = 2, PIDTYPE_MAX = 3 } ;
464 struct pid_namespace ;
464 struct upid { int nr; struct pid_namespace *ns; struct hlist_node pid_chain; } ;
56 struct pid { atomic_t count; unsigned int level; struct hlist_head tasks[3U]; struct callback_head rcu; struct upid numbers[1U]; } ;
68 struct pid_link { struct hlist_node node; struct pid *pid; } ;
43 struct seccomp_filter ;
44 struct seccomp { int mode; struct seccomp_filter *filter; } ;
40 struct rt_mutex_waiter ;
12 enum kcov_mode { KCOV_MODE_DISABLED = 0, KCOV_MODE_TRACE = 1 } ;
17 struct task_io_accounting { u64 rchar; u64 wchar; u64 syscr; u64 syscw; u64 read_bytes; u64 write_bytes; u64 cancelled_write_bytes; } ;
45 struct latency_record { unsigned long backtrace[12U]; unsigned int count; unsigned long time; unsigned long max; } ;
41 struct assoc_array_ptr ;
41 struct assoc_array { struct assoc_array_ptr *root; unsigned long nr_leaves_on_tree; } ;
31 typedef int32_t key_serial_t;
34 typedef uint32_t key_perm_t;
35 struct key ;
36 struct signal_struct ;
37 struct key_type ;
41 struct keyring_index_key { struct key_type *type; const char *description; size_t desc_len; } ;
91 union key_payload { void *rcu_data0; void *data[4U]; } ;
128 union __anonunion____missing_field_name_282 { struct list_head graveyard_link; struct rb_node serial_node; } ;
128 struct key_user ;
128 union __anonunion____missing_field_name_283 { time_t expiry; time_t revoked_at; } ;
128 struct __anonstruct____missing_field_name_285 { struct key_type *type; char *description; } ;
128 union __anonunion____missing_field_name_284 { struct keyring_index_key index_key; struct __anonstruct____missing_field_name_285 __annonCompField64; } ;
128 struct __anonstruct____missing_field_name_287 { struct list_head name_link; struct assoc_array keys; } ;
128 union __anonunion____missing_field_name_286 { union key_payload payload; struct __anonstruct____missing_field_name_287 __annonCompField66; int reject_error; } ;
128 struct key { atomic_t usage; key_serial_t serial; union __anonunion____missing_field_name_282 __annonCompField62; struct rw_semaphore sem; struct key_user *user; void *security; union __anonunion____missing_field_name_283 __annonCompField63; time_t last_used_at; kuid_t uid; kgid_t gid; key_perm_t perm; unsigned short quotalen; unsigned short datalen; unsigned long flags; union __anonunion____missing_field_name_284 __annonCompField65; union __anonunion____missing_field_name_286 __annonCompField67; int (*restrict_link)(struct key *, const struct key_type *, const union key_payload *); } ;
377 struct audit_context ;
27 struct group_info { atomic_t usage; int ngroups; int nblocks; kgid_t small_block[32U]; kgid_t *blocks[0U]; } ;
90 struct cred { atomic_t usage; atomic_t subscribers; void *put_addr; unsigned int magic; kuid_t uid; kgid_t gid; kuid_t suid; kgid_t sgid; kuid_t euid; kgid_t egid; kuid_t fsuid; kgid_t fsgid; unsigned int securebits; kernel_cap_t cap_inheritable; kernel_cap_t cap_permitted; kernel_cap_t cap_effective; kernel_cap_t cap_bset; kernel_cap_t cap_ambient; unsigned char jit_keyring; struct key *session_keyring; struct key *process_keyring; struct key *thread_keyring; struct key *request_key_auth; void *security; struct user_struct *user; struct user_namespace *user_ns; struct group_info *group_info; struct callback_head rcu; } ;
377 enum rcu_sync_type { RCU_SYNC = 0, RCU_SCHED_SYNC = 1, RCU_BH_SYNC = 2 } ;
383 struct rcu_sync { int gp_state; int gp_count; wait_queue_head_t gp_wait; int cb_state; struct callback_head cb_head; enum rcu_sync_type gp_type; } ;
65 struct percpu_rw_semaphore { struct rcu_sync rss; unsigned int *fast_read_ctr; struct rw_semaphore rw_sem; atomic_t slow_read_ctr; wait_queue_head_t write_waitq; } ;
54 struct cgroup ;
55 struct cgroup_root ;
56 struct cgroup_subsys ;
57 struct cgroup_taskset ;
101 struct cgroup_file { struct kernfs_node *kn; } ;
90 struct cgroup_subsys_state { struct cgroup *cgroup; struct cgroup_subsys *ss; struct percpu_ref refcnt; struct cgroup_subsys_state *parent; struct list_head sibling; struct list_head children; int id; unsigned int flags; u64 serial_nr; atomic_t online_cnt; struct callback_head callback_head; struct work_struct destroy_work; } ;
141 struct css_set { atomic_t refcount; struct hlist_node hlist; struct list_head tasks; struct list_head mg_tasks; struct list_head cgrp_links; struct cgroup *dfl_cgrp; struct cgroup_subsys_state *subsys[13U]; struct list_head mg_preload_node; struct list_head mg_node; struct cgroup *mg_src_cgrp; struct cgroup *mg_dst_cgrp; struct css_set *mg_dst_cset; struct list_head e_cset_node[13U]; struct list_head task_iters; bool dead; struct callback_head callback_head; } ;
221 struct cgroup { struct cgroup_subsys_state self; unsigned long flags; int id; int level; int populated_cnt; struct kernfs_node *kn; struct cgroup_file procs_file; struct cgroup_file events_file; u16 subtree_control; u16 subtree_ss_mask; u16 old_subtree_control; u16 old_subtree_ss_mask; struct cgroup_subsys_state *subsys[13U]; struct cgroup_root *root; struct list_head cset_links; struct list_head e_csets[13U]; struct list_head pidlists; struct mutex pidlist_mutex; wait_queue_head_t offline_waitq; struct work_struct release_agent_work; int ancestor_ids[]; } ;
306 struct cgroup_root { struct kernfs_root *kf_root; unsigned int subsys_mask; int hierarchy_id; struct cgroup cgrp; int cgrp_ancestor_id_storage; atomic_t nr_cgrps; struct list_head root_list; unsigned int flags; struct idr cgroup_idr; char release_agent_path[4096U]; char name[64U]; } ;
345 struct cftype { char name[64U]; unsigned long private; size_t max_write_len; unsigned int flags; unsigned int file_offset; struct cgroup_subsys *ss; struct list_head node; struct kernfs_ops *kf_ops; u64 (*read_u64)(struct cgroup_subsys_state *, struct cftype *); s64 (*read_s64)(struct cgroup_subsys_state *, struct cftype *); int (*seq_show)(struct seq_file *, void *); void * (*seq_start)(struct seq_file *, loff_t *); void * (*seq_next)(struct seq_file *, void *, loff_t *); void (*seq_stop)(struct seq_file *, void *); int (*write_u64)(struct cgroup_subsys_state *, struct cftype *, u64 ); int (*write_s64)(struct cgroup_subsys_state *, struct cftype *, s64 ); ssize_t (*write)(struct kernfs_open_file *, char *, size_t , loff_t ); struct lock_class_key lockdep_key; } ;
430 struct cgroup_subsys { struct cgroup_subsys_state * (*css_alloc)(struct cgroup_subsys_state *); int (*css_online)(struct cgroup_subsys_state *); void (*css_offline)(struct cgroup_subsys_state *); void (*css_released)(struct cgroup_subsys_state *); void (*css_free)(struct cgroup_subsys_state *); void (*css_reset)(struct cgroup_subsys_state *); int (*can_attach)(struct cgroup_taskset *); void (*cancel_attach)(struct cgroup_taskset *); void (*attach)(struct cgroup_taskset *); void (*post_attach)(); int (*can_fork)(struct task_struct *); void (*cancel_fork)(struct task_struct *); void (*fork)(struct task_struct *); void (*exit)(struct task_struct *); void (*free)(struct task_struct *); void (*bind)(struct cgroup_subsys_state *); bool early_init; bool implicit_on_dfl; bool broken_hierarchy; bool warned_broken_hierarchy; int id; const char *name; const char *legacy_name; struct cgroup_root *root; struct idr css_idr; struct list_head cfts; struct cftype *dfl_cftypes; struct cftype *legacy_cftypes; unsigned int depends_on; } ;
128 struct futex_pi_state ;
129 struct robust_list_head ;
130 struct bio_list ;
131 struct fs_struct ;
132 struct perf_event_context ;
133 struct blk_plug ;
135 struct nameidata ;
188 struct cfs_rq ;
189 struct task_group ;
492 struct sighand_struct { atomic_t count; struct k_sigaction action[64U]; spinlock_t siglock; wait_queue_head_t signalfd_wqh; } ;
534 struct pacct_struct { int ac_flag; long ac_exitcode; unsigned long ac_mem; cputime_t ac_utime; cputime_t ac_stime; unsigned long ac_minflt; unsigned long ac_majflt; } ;
542 struct cpu_itimer { cputime_t expires; cputime_t incr; u32 error; u32 incr_error; } ;
549 struct prev_cputime { cputime_t utime; cputime_t stime; raw_spinlock_t lock; } ;
574 struct task_cputime { cputime_t utime; cputime_t stime; unsigned long long sum_exec_runtime; } ;
590 struct task_cputime_atomic { atomic64_t utime; atomic64_t stime; atomic64_t sum_exec_runtime; } ;
612 struct thread_group_cputimer { struct task_cputime_atomic cputime_atomic; bool running; bool checking_timer; } ;
657 struct autogroup ;
658 struct tty_struct ;
658 struct taskstats ;
658 struct tty_audit_buf ;
658 struct signal_struct { atomic_t sigcnt; atomic_t live; int nr_threads; atomic_t oom_victims; struct list_head thread_head; wait_queue_head_t wait_chldexit; struct task_struct *curr_target; struct sigpending shared_pending; int group_exit_code; int notify_count; struct task_struct *group_exit_task; int group_stop_count; unsigned int flags; unsigned char is_child_subreaper; unsigned char has_child_subreaper; int posix_timer_id; struct list_head posix_timers; struct hrtimer real_timer; struct pid *leader_pid; ktime_t it_real_incr; struct cpu_itimer it[2U]; struct thread_group_cputimer cputimer; struct task_cputime cputime_expires; struct list_head cpu_timers[3U]; struct pid *tty_old_pgrp; int leader; struct tty_struct *tty; struct autogroup *autogroup; seqlock_t stats_lock; cputime_t utime; cputime_t stime; cputime_t cutime; cputime_t cstime; cputime_t gtime; cputime_t cgtime; struct prev_cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; unsigned long cnvcsw; unsigned long cnivcsw; unsigned long min_flt; unsigned long maj_flt; unsigned long cmin_flt; unsigned long cmaj_flt; unsigned long inblock; unsigned long oublock; unsigned long cinblock; unsigned long coublock; unsigned long maxrss; unsigned long cmaxrss; struct task_io_accounting ioac; unsigned long long sum_sched_runtime; struct rlimit rlim[16U]; struct pacct_struct pacct; struct taskstats *stats; unsigned int audit_tty; struct tty_audit_buf *tty_audit_buf; bool oom_flag_origin; short oom_score_adj; short oom_score_adj_min; struct mutex cred_guard_mutex; } ;
833 struct user_struct { atomic_t __count; atomic_t processes; atomic_t sigpending; atomic_t inotify_watches; atomic_t inotify_devs; atomic_t fanotify_listeners; atomic_long_t epoll_watches; unsigned long mq_bytes; unsigned long locked_shm; unsigned long unix_inflight; atomic_long_t pipe_bufs; struct key *uid_keyring; struct key *session_keyring; struct hlist_node uidhash_node; kuid_t uid; atomic_long_t locked_vm; } ;
878 struct backing_dev_info ;
879 struct reclaim_state ;
880 struct sched_info { unsigned long pcount; unsigned long long run_delay; unsigned long long last_arrival; unsigned long long last_queued; } ;
894 struct task_delay_info { spinlock_t lock; unsigned int flags; u64 blkio_start; u64 blkio_delay; u64 swapin_delay; u32 blkio_count; u32 swapin_count; u64 freepages_start; u64 freepages_delay; u32 freepages_count; } ;
951 struct wake_q_node { struct wake_q_node *next; } ;
1183 struct io_context ;
1217 struct pipe_inode_info ;
1219 struct load_weight { unsigned long weight; u32 inv_weight; } ;
1226 struct sched_avg { u64 last_update_time; u64 load_sum; u32 util_sum; u32 period_contrib; unsigned long load_avg; unsigned long util_avg; } ;
1284 struct sched_statistics { u64 wait_start; u64 wait_max; u64 wait_count; u64 wait_sum; u64 iowait_count; u64 iowait_sum; u64 sleep_start; u64 sleep_max; s64 sum_sleep_runtime; u64 block_start; u64 block_max; u64 exec_max; u64 slice_max; u64 nr_migrations_cold; u64 nr_failed_migrations_affine; u64 nr_failed_migrations_running; u64 nr_failed_migrations_hot; u64 nr_forced_migrations; u64 nr_wakeups; u64 nr_wakeups_sync; u64 nr_wakeups_migrate; u64 nr_wakeups_local; u64 nr_wakeups_remote; u64 nr_wakeups_affine; u64 nr_wakeups_affine_attempts; u64 nr_wakeups_passive; u64 nr_wakeups_idle; } ;
1319 struct sched_entity { struct load_weight load; struct rb_node run_node; struct list_head group_node; unsigned int on_rq; u64 exec_start; u64 sum_exec_runtime; u64 vruntime; u64 prev_sum_exec_runtime; u64 nr_migrations; struct sched_statistics statistics; int depth; struct sched_entity *parent; struct cfs_rq *cfs_rq; struct cfs_rq *my_q; struct sched_avg avg; } ;
1356 struct rt_rq ;
1356 struct sched_rt_entity { struct list_head run_list; unsigned long timeout; unsigned long watchdog_stamp; unsigned int time_slice; unsigned short on_rq; unsigned short on_list; struct sched_rt_entity *back; struct sched_rt_entity *parent; struct rt_rq *rt_rq; struct rt_rq *my_q; } ;
1374 struct sched_dl_entity { struct rb_node rb_node; u64 dl_runtime; u64 dl_deadline; u64 dl_period; u64 dl_bw; s64 runtime; u64 deadline; unsigned int flags; int dl_throttled; int dl_boosted; int dl_yielded; struct hrtimer dl_timer; } ;
1438 struct tlbflush_unmap_batch { struct cpumask cpumask; bool flush_required; bool writable; } ;
1457 struct sched_class ;
1457 struct files_struct ;
1457 struct compat_robust_list_head ;
1457 struct numa_group ;
1457 struct kcov ;
1457 struct task_struct { volatile long state; void *stack; atomic_t usage; unsigned int flags; unsigned int ptrace; struct llist_node wake_entry; int on_cpu; unsigned int wakee_flips; unsigned long wakee_flip_decay_ts; struct task_struct *last_wakee; int wake_cpu; int on_rq; int prio; int static_prio; int normal_prio; unsigned int rt_priority; const struct sched_class *sched_class; struct sched_entity se; struct sched_rt_entity rt; struct task_group *sched_task_group; struct sched_dl_entity dl; struct hlist_head preempt_notifiers; unsigned int policy; int nr_cpus_allowed; cpumask_t cpus_allowed; unsigned long rcu_tasks_nvcsw; bool rcu_tasks_holdout; struct list_head rcu_tasks_holdout_list; int rcu_tasks_idle_cpu; struct sched_info sched_info; struct list_head tasks; struct plist_node pushable_tasks; struct rb_node pushable_dl_tasks; struct mm_struct *mm; struct mm_struct *active_mm; u32 vmacache_seqnum; struct vm_area_struct *vmacache[4U]; struct task_rss_stat rss_stat; int exit_state; int exit_code; int exit_signal; int pdeath_signal; unsigned long jobctl; unsigned int personality; unsigned char sched_reset_on_fork; unsigned char sched_contributes_to_load; unsigned char sched_migrated; unsigned char sched_remote_wakeup; unsigned char; unsigned char in_execve; unsigned char in_iowait; unsigned char memcg_may_oom; unsigned char memcg_kmem_skip_account; unsigned char brk_randomized; unsigned long atomic_flags; struct restart_block restart_block; pid_t pid; pid_t tgid; struct task_struct *real_parent; struct task_struct *parent; struct list_head children; struct list_head sibling; struct task_struct *group_leader; struct list_head ptraced; struct list_head ptrace_entry; struct pid_link pids[3U]; struct list_head thread_group; struct list_head thread_node; struct completion *vfork_done; int *set_child_tid; int *clear_child_tid; cputime_t utime; cputime_t stime; cputime_t utimescaled; cputime_t stimescaled; cputime_t gtime; struct prev_cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; u64 start_time; u64 real_start_time; unsigned long min_flt; unsigned long maj_flt; struct task_cputime cputime_expires; struct list_head cpu_timers[3U]; const struct cred *real_cred; const struct cred *cred; char comm[16U]; struct nameidata *nameidata; struct sysv_sem sysvsem; struct sysv_shm sysvshm; unsigned long last_switch_count; struct fs_struct *fs; struct files_struct *files; struct nsproxy *nsproxy; struct signal_struct *signal; struct sighand_struct *sighand; sigset_t blocked; sigset_t real_blocked; sigset_t saved_sigmask; struct sigpending pending; unsigned long sas_ss_sp; size_t sas_ss_size; unsigned int sas_ss_flags; struct callback_head *task_works; struct audit_context *audit_context; kuid_t loginuid; unsigned int sessionid; struct seccomp seccomp; u32 parent_exec_id; u32 self_exec_id; spinlock_t alloc_lock; raw_spinlock_t pi_lock; struct wake_q_node wake_q; struct rb_root pi_waiters; struct rb_node *pi_waiters_leftmost; struct rt_mutex_waiter *pi_blocked_on; struct mutex_waiter *blocked_on; unsigned int irq_events; unsigned long hardirq_enable_ip; unsigned long hardirq_disable_ip; unsigned int hardirq_enable_event; unsigned int hardirq_disable_event; int hardirqs_enabled; int hardirq_context; unsigned long softirq_disable_ip; unsigned long softirq_enable_ip; unsigned int softirq_disable_event; unsigned int softirq_enable_event; int softirqs_enabled; int softirq_context; u64 curr_chain_key; int lockdep_depth; unsigned int lockdep_recursion; struct held_lock held_locks[48U]; gfp_t lockdep_reclaim_gfp; unsigned int in_ubsan; void *journal_info; struct bio_list *bio_list; struct blk_plug *plug; struct reclaim_state *reclaim_state; struct backing_dev_info *backing_dev_info; struct io_context *io_context; unsigned long ptrace_message; siginfo_t *last_siginfo; struct task_io_accounting ioac; u64 acct_rss_mem1; u64 acct_vm_mem1; cputime_t acct_timexpd; nodemask_t mems_allowed; seqcount_t mems_allowed_seq; int cpuset_mem_spread_rotor; int cpuset_slab_spread_rotor; struct css_set *cgroups; struct list_head cg_list; struct robust_list_head *robust_list; struct compat_robust_list_head *compat_robust_list; struct list_head pi_state_list; struct futex_pi_state *pi_state_cache; struct perf_event_context *perf_event_ctxp[2U]; struct mutex perf_event_mutex; struct list_head perf_event_list; struct mempolicy *mempolicy; short il_next; short pref_node_fork; int numa_scan_seq; unsigned int numa_scan_period; unsigned int numa_scan_period_max; int numa_preferred_nid; unsigned long numa_migrate_retry; u64 node_stamp; u64 last_task_numa_placement; u64 last_sum_exec_runtime; struct callback_head numa_work; struct list_head numa_entry; struct numa_group *numa_group; unsigned long *numa_faults; unsigned long total_numa_faults; unsigned long numa_faults_locality[3U]; unsigned long numa_pages_migrated; struct tlbflush_unmap_batch tlb_ubc; struct callback_head rcu; struct pipe_inode_info *splice_pipe; struct page_frag task_frag; struct task_delay_info *delays; int make_it_fail; int nr_dirtied; int nr_dirtied_pause; unsigned long dirty_paused_when; int latency_record_count; struct latency_record latency_record[32U]; u64 timer_slack_ns; u64 default_timer_slack_ns; unsigned int kasan_depth; unsigned long trace; unsigned long trace_recursion; enum kcov_mode kcov_mode; unsigned int kcov_size; void *kcov_area; struct kcov *kcov; struct mem_cgroup *memcg_in_oom; gfp_t memcg_oom_gfp_mask; int memcg_oom_order; unsigned int memcg_nr_pages_over_high; struct uprobe_task *utask; unsigned int sequential_io; unsigned int sequential_io_avg; unsigned long task_state_change; int pagefault_disabled; struct task_struct *oom_reaper_list; struct thread_struct thread; } ;
26 struct device_type ;
28 struct class ;
52 struct klist_node ;
37 struct klist_node { void *n_klist; struct list_head n_node; struct kref n_ref; } ;
68 struct hlist_bl_node ;
68 struct hlist_bl_head { struct hlist_bl_node *first; } ;
36 struct hlist_bl_node { struct hlist_bl_node *next; struct hlist_bl_node **pprev; } ;
114 struct __anonstruct____missing_field_name_321 { spinlock_t lock; int count; } ;
114 union __anonunion____missing_field_name_320 { struct __anonstruct____missing_field_name_321 __annonCompField73; } ;
114 struct lockref { union __anonunion____missing_field_name_320 __annonCompField74; } ;
75 struct path ;
76 struct vfsmount ;
77 struct __anonstruct____missing_field_name_323 { u32 hash; u32 len; } ;
77 union __anonunion____missing_field_name_322 { struct __anonstruct____missing_field_name_323 __annonCompField75; u64 hash_len; } ;
77 struct qstr { union __anonunion____missing_field_name_322 __annonCompField76; const unsigned char *name; } ;
65 struct dentry_operations ;
65 union __anonunion____missing_field_name_324 { struct list_head d_lru; wait_queue_head_t *d_wait; } ;
65 union __anonunion_d_u_325 { struct hlist_node d_alias; struct hlist_bl_node d_in_lookup_hash; struct callback_head d_rcu; } ;
65 struct dentry { unsigned int d_flags; seqcount_t d_seq; struct hlist_bl_node d_hash; struct dentry *d_parent; struct qstr d_name; struct inode *d_inode; unsigned char d_iname[32U]; struct lockref d_lockref; const struct dentry_operations *d_op; struct super_block *d_sb; unsigned long d_time; void *d_fsdata; union __anonunion____missing_field_name_324 __annonCompField77; struct list_head d_child; struct list_head d_subdirs; union __anonunion_d_u_325 d_u; } ;
121 struct dentry_operations { int (*d_revalidate)(struct dentry *, unsigned int); int (*d_weak_revalidate)(struct dentry *, unsigned int); int (*d_hash)(const struct dentry *, struct qstr *); int (*d_compare)(const struct dentry *, const struct dentry *, unsigned int, const char *, const struct qstr *); int (*d_delete)(const struct dentry *); void (*d_release)(struct dentry *); void (*d_prune)(struct dentry *); void (*d_iput)(struct dentry *, struct inode *); char * (*d_dname)(struct dentry *, char *, int); struct vfsmount * (*d_automount)(struct path *); int (*d_manage)(struct dentry *, bool ); struct inode * (*d_select_inode)(struct dentry *, unsigned int); struct dentry * (*d_real)(struct dentry *, struct inode *); } ;
577 struct path { struct vfsmount *mnt; struct dentry *dentry; } ;
27 struct list_lru_one { struct list_head list; long nr_items; } ;
32 struct list_lru_memcg { struct list_lru_one *lru[0U]; } ;
37 struct list_lru_node { spinlock_t lock; struct list_lru_one lru; struct list_lru_memcg *memcg_lrus; } ;
47 struct list_lru { struct list_lru_node *node; struct list_head list; } ;
63 struct __anonstruct____missing_field_name_327 { struct radix_tree_node *parent; void *private_data; } ;
63 union __anonunion____missing_field_name_326 { struct __anonstruct____missing_field_name_327 __annonCompField78; struct callback_head callback_head; } ;
63 struct radix_tree_node { unsigned char shift; unsigned char offset; unsigned int count; union __anonunion____missing_field_name_326 __annonCompField79; struct list_head private_list; void *slots[64U]; unsigned long tags[3U][1U]; } ;
106 struct radix_tree_root { gfp_t gfp_mask; struct radix_tree_node *rnode; } ;
45 struct fiemap_extent { __u64 fe_logical; __u64 fe_physical; __u64 fe_length; __u64 fe_reserved64[2U]; __u32 fe_flags; __u32 fe_reserved[3U]; } ;
38 enum migrate_mode { MIGRATE_ASYNC = 0, MIGRATE_SYNC_LIGHT = 1, MIGRATE_SYNC = 2 } ;
44 struct bio_set ;
45 struct bio ;
46 struct bio_integrity_payload ;
47 struct block_device ;
17 typedef void bio_end_io_t(struct bio *);
19 struct bio_vec { struct page *bv_page; unsigned int bv_len; unsigned int bv_offset; } ;
28 struct bvec_iter { sector_t bi_sector; unsigned int bi_size; unsigned int bi_idx; unsigned int bi_bvec_done; } ;
40 union __anonunion____missing_field_name_332 { struct bio_integrity_payload *bi_integrity; } ;
40 struct bio { struct bio *bi_next; struct block_device *bi_bdev; unsigned int bi_flags; int bi_error; unsigned long bi_rw; struct bvec_iter bi_iter; unsigned int bi_phys_segments; unsigned int bi_seg_front_size; unsigned int bi_seg_back_size; atomic_t __bi_remaining; bio_end_io_t *bi_end_io; void *bi_private; struct io_context *bi_ioc; struct cgroup_subsys_state *bi_css; union __anonunion____missing_field_name_332 __annonCompField80; unsigned short bi_vcnt; unsigned short bi_max_vecs; atomic_t __bi_cnt; struct bio_vec *bi_io_vec; struct bio_set *bi_pool; struct bio_vec bi_inline_vecs[0U]; } ;
245 typedef unsigned int blk_qc_t;
268 struct delayed_call { void (*fn)(void *); void *arg; } ;
261 struct export_operations ;
262 struct hd_geometry ;
264 struct kiocb ;
265 struct poll_table_struct ;
266 struct kstatfs ;
267 struct swap_info_struct ;
268 struct iov_iter ;
269 struct fscrypt_info ;
270 struct fscrypt_operations ;
76 struct iattr { unsigned int ia_valid; umode_t ia_mode; kuid_t ia_uid; kgid_t ia_gid; loff_t ia_size; struct timespec ia_atime; struct timespec ia_mtime; struct timespec ia_ctime; struct file *ia_file; } ;
265 struct percpu_counter { raw_spinlock_t lock; s64 count; struct list_head list; s32 *counters; } ;
213 struct dquot ;
214 struct kqid ;
19 typedef __kernel_uid32_t projid_t;
23 struct __anonstruct_kprojid_t_333 { projid_t val; } ;
23 typedef struct __anonstruct_kprojid_t_333 kprojid_t;
181 enum quota_type { USRQUOTA = 0, GRPQUOTA = 1, PRJQUOTA = 2 } ;
66 typedef long long qsize_t;
67 union __anonunion____missing_field_name_334 { kuid_t uid; kgid_t gid; kprojid_t projid; } ;
67 struct kqid { union __anonunion____missing_field_name_334 __annonCompField81; enum quota_type type; } ;
184 struct mem_dqblk { qsize_t dqb_bhardlimit; qsize_t dqb_bsoftlimit; qsize_t dqb_curspace; qsize_t dqb_rsvspace; qsize_t dqb_ihardlimit; qsize_t dqb_isoftlimit; qsize_t dqb_curinodes; time_t dqb_btime; time_t dqb_itime; } ;
206 struct quota_format_type ;
207 struct mem_dqinfo { struct quota_format_type *dqi_format; int dqi_fmt_id; struct list_head dqi_dirty_list; unsigned long dqi_flags; unsigned int dqi_bgrace; unsigned int dqi_igrace; qsize_t dqi_max_spc_limit; qsize_t dqi_max_ino_limit; void *dqi_priv; } ;
272 struct dquot { struct hlist_node dq_hash; struct list_head dq_inuse; struct list_head dq_free; struct list_head dq_dirty; struct mutex dq_lock; atomic_t dq_count; wait_queue_head_t dq_wait_unused; struct super_block *dq_sb; struct kqid dq_id; loff_t dq_off; unsigned long dq_flags; struct mem_dqblk dq_dqb; } ;
299 struct quota_format_ops { int (*check_quota_file)(struct super_block *, int); int (*read_file_info)(struct super_block *, int); int (*write_file_info)(struct super_block *, int); int (*free_file_info)(struct super_block *, int); int (*read_dqblk)(struct dquot *); int (*commit_dqblk)(struct dquot *); int (*release_dqblk)(struct dquot *); int (*get_next_id)(struct super_block *, struct kqid *); } ;
311 struct dquot_operations { int (*write_dquot)(struct dquot *); struct dquot * (*alloc_dquot)(struct super_block *, int); void (*destroy_dquot)(struct dquot *); int (*acquire_dquot)(struct dquot *); int (*release_dquot)(struct dquot *); int (*mark_dirty)(struct dquot *); int (*write_info)(struct super_block *, int); qsize_t * (*get_reserved_space)(struct inode *); int (*get_projid)(struct inode *, kprojid_t *); int (*get_next_id)(struct super_block *, struct kqid *); } ;
328 struct qc_dqblk { int d_fieldmask; u64 d_spc_hardlimit; u64 d_spc_softlimit; u64 d_ino_hardlimit; u64 d_ino_softlimit; u64 d_space; u64 d_ino_count; s64 d_ino_timer; s64 d_spc_timer; int d_ino_warns; int d_spc_warns; u64 d_rt_spc_hardlimit; u64 d_rt_spc_softlimit; u64 d_rt_space; s64 d_rt_spc_timer; int d_rt_spc_warns; } ;
351 struct qc_type_state { unsigned int flags; unsigned int spc_timelimit; unsigned int ino_timelimit; unsigned int rt_spc_timelimit; unsigned int spc_warnlimit; unsigned int ino_warnlimit; unsigned int rt_spc_warnlimit; unsigned long long ino; blkcnt_t blocks; blkcnt_t nextents; } ;
397 struct qc_state { unsigned int s_incoredqs; struct qc_type_state s_state[3U]; } ;
408 struct qc_info { int i_fieldmask; unsigned int i_flags; unsigned int i_spc_timelimit; unsigned int i_ino_timelimit; unsigned int i_rt_spc_timelimit; unsigned int i_spc_warnlimit; unsigned int i_ino_warnlimit; unsigned int i_rt_spc_warnlimit; } ;
421 struct quotactl_ops { int (*quota_on)(struct super_block *, int, int, struct path *); int (*quota_off)(struct super_block *, int); int (*quota_enable)(struct super_block *, unsigned int); int (*quota_disable)(struct super_block *, unsigned int); int (*quota_sync)(struct super_block *, int); int (*set_info)(struct super_block *, int, struct qc_info *); int (*get_dqblk)(struct super_block *, struct kqid , struct qc_dqblk *); int (*get_nextdqblk)(struct super_block *, struct kqid *, struct qc_dqblk *); int (*set_dqblk)(struct super_block *, struct kqid , struct qc_dqblk *); int (*get_state)(struct super_block *, struct qc_state *); int (*rm_xquota)(struct super_block *, unsigned int); } ;
437 struct quota_format_type { int qf_fmt_id; const struct quota_format_ops *qf_ops; struct module *qf_owner; struct quota_format_type *qf_next; } ;
501 struct quota_info { unsigned int flags; struct mutex dqio_mutex; struct mutex dqonoff_mutex; struct inode *files[3U]; struct mem_dqinfo info[3U]; const struct quota_format_ops *ops[3U]; } ;
531 struct kiocb { struct file *ki_filp; loff_t ki_pos; void (*ki_complete)(struct kiocb *, long, long); void *private; int ki_flags; } ;
371 struct address_space_operations { int (*writepage)(struct page *, struct writeback_control *); int (*readpage)(struct file *, struct page *); int (*writepages)(struct address_space *, struct writeback_control *); int (*set_page_dirty)(struct page *); int (*readpages)(struct file *, struct address_space *, struct list_head *, unsigned int); int (*write_begin)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page **, void **); int (*write_end)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page *, void *); sector_t (*bmap)(struct address_space *, sector_t ); void (*invalidatepage)(struct page *, unsigned int, unsigned int); int (*releasepage)(struct page *, gfp_t ); void (*freepage)(struct page *); ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *); int (*migratepage)(struct address_space *, struct page *, struct page *, enum migrate_mode ); int (*launder_page)(struct page *); int (*is_partially_uptodate)(struct page *, unsigned long, unsigned long); void (*is_dirty_writeback)(struct page *, bool *, bool *); int (*error_remove_page)(struct address_space *, struct page *); int (*swap_activate)(struct swap_info_struct *, struct file *, sector_t *); void (*swap_deactivate)(struct file *); } ;
428 struct address_space { struct inode *host; struct radix_tree_root page_tree; spinlock_t tree_lock; atomic_t i_mmap_writable; struct rb_root i_mmap; struct rw_semaphore i_mmap_rwsem; unsigned long nrpages; unsigned long nrexceptional; unsigned long writeback_index; const struct address_space_operations *a_ops; unsigned long flags; spinlock_t private_lock; struct list_head private_list; void *private_data; } ;
449 struct request_queue ;
450 struct hd_struct ;
450 struct gendisk ;
450 struct block_device { dev_t bd_dev; int bd_openers; struct inode *bd_inode; struct super_block *bd_super; struct mutex bd_mutex; struct list_head bd_inodes; void *bd_claiming; void *bd_holder; int bd_holders; bool bd_write_holder; struct list_head bd_holder_disks; struct block_device *bd_contains; unsigned int bd_block_size; struct hd_struct *bd_part; unsigned int bd_part_count; int bd_invalidated; struct gendisk *bd_disk; struct request_queue *bd_queue; struct list_head bd_list; unsigned long bd_private; int bd_fsfreeze_count; struct mutex bd_fsfreeze_mutex; } ;
566 struct posix_acl ;
592 struct inode_operations ;
592 union __anonunion____missing_field_name_339 { const unsigned int i_nlink; unsigned int __i_nlink; } ;
592 union __anonunion____missing_field_name_340 { struct hlist_head i_dentry; struct callback_head i_rcu; } ;
592 struct file_lock_context ;
592 struct cdev ;
592 union __anonunion____missing_field_name_341 { struct pipe_inode_info *i_pipe; struct block_device *i_bdev; struct cdev *i_cdev; char *i_link; unsigned int i_dir_seq; } ;
592 struct inode { umode_t i_mode; unsigned short i_opflags; kuid_t i_uid; kgid_t i_gid; unsigned int i_flags; struct posix_acl *i_acl; struct posix_acl *i_default_acl; const struct inode_operations *i_op; struct super_block *i_sb; struct address_space *i_mapping; void *i_security; unsigned long i_ino; union __anonunion____missing_field_name_339 __annonCompField82; dev_t i_rdev; loff_t i_size; struct timespec i_atime; struct timespec i_mtime; struct timespec i_ctime; spinlock_t i_lock; unsigned short i_bytes; unsigned int i_blkbits; blkcnt_t i_blocks; unsigned long i_state; struct rw_semaphore i_rwsem; unsigned long dirtied_when; unsigned long dirtied_time_when; struct hlist_node i_hash; struct list_head i_io_list; struct bdi_writeback *i_wb; int i_wb_frn_winner; u16 i_wb_frn_avg_time; u16 i_wb_frn_history; struct list_head i_lru; struct list_head i_sb_list; union __anonunion____missing_field_name_340 __annonCompField83; u64 i_version; atomic_t i_count; atomic_t i_dio_count; atomic_t i_writecount; atomic_t i_readcount; const struct file_operations *i_fop; struct file_lock_context *i_flctx; struct address_space i_data; struct list_head i_devices; union __anonunion____missing_field_name_341 __annonCompField84; __u32 i_generation; __u32 i_fsnotify_mask; struct hlist_head i_fsnotify_marks; struct fscrypt_info *i_crypt_info; void *i_private; } ;
870 struct fown_struct { rwlock_t lock; struct pid *pid; enum pid_type pid_type; kuid_t uid; kuid_t euid; int signum; } ;
878 struct file_ra_state { unsigned long start; unsigned int size; unsigned int async_size; unsigned int ra_pages; unsigned int mmap_miss; loff_t prev_pos; } ;
901 union __anonunion_f_u_342 { struct llist_node fu_llist; struct callback_head fu_rcuhead; } ;
901 struct file { union __anonunion_f_u_342 f_u; struct path f_path; struct inode *f_inode; const struct file_operations *f_op; spinlock_t f_lock; atomic_long_t f_count; unsigned int f_flags; fmode_t f_mode; struct mutex f_pos_lock; loff_t f_pos; struct fown_struct f_owner; const struct cred *f_cred; struct file_ra_state f_ra; u64 f_version; void *f_security; void *private_data; struct list_head f_ep_links; struct list_head f_tfile_llink; struct address_space *f_mapping; } ;
986 typedef void *fl_owner_t;
987 struct file_lock ;
988 struct file_lock_operations { void (*fl_copy_lock)(struct file_lock *, struct file_lock *); void (*fl_release_private)(struct file_lock *); } ;
994 struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long int (*lm_owner_key)(struct file_lock *); fl_owner_t (*lm_get_owner)(fl_owner_t ); void (*lm_put_owner)(fl_owner_t ); void (*lm_notify)(struct file_lock *); int (*lm_grant)(struct file_lock *, int); bool (*lm_break)(struct file_lock *); int (*lm_change)(struct file_lock *, int, struct list_head *); void (*lm_setup)(struct file_lock *, void **); } ;
1021 struct nlm_lockowner ;
1022 struct nfs_lock_info { u32 state; struct nlm_lockowner *owner; struct list_head list; } ;
14 struct nfs4_lock_state ;
15 struct nfs4_lock_info { struct nfs4_lock_state *owner; } ;
19 struct fasync_struct ;
19 struct __anonstruct_afs_344 { struct list_head link; int state; } ;
19 union __anonunion_fl_u_343 { struct nfs_lock_info nfs_fl; struct nfs4_lock_info nfs4_fl; struct __anonstruct_afs_344 afs; } ;
19 struct file_lock { struct file_lock *fl_next; struct list_head fl_list; struct hlist_node fl_link; struct list_head fl_block; fl_owner_t fl_owner; unsigned int fl_flags; unsigned char fl_type; unsigned int fl_pid; int fl_link_cpu; struct pid *fl_nspid; wait_queue_head_t fl_wait; struct file *fl_file; loff_t fl_start; loff_t fl_end; struct fasync_struct *fl_fasync; unsigned long fl_break_time; unsigned long fl_downgrade_time; const struct file_lock_operations *fl_ops; const struct lock_manager_operations *fl_lmops; union __anonunion_fl_u_343 fl_u; } ;
1074 struct file_lock_context { spinlock_t flc_lock; struct list_head flc_flock; struct list_head flc_posix; struct list_head flc_lease; } ;
1287 struct fasync_struct { spinlock_t fa_lock; int magic; int fa_fd; struct fasync_struct *fa_next; struct file *fa_file; struct callback_head fa_rcu; } ;
1322 struct sb_writers { int frozen; wait_queue_head_t wait_unfrozen; struct percpu_rw_semaphore rw_sem[3U]; } ;
1348 struct super_operations ;
1348 struct xattr_handler ;
1348 struct mtd_info ;
1348 struct super_block { struct list_head s_list; dev_t s_dev; unsigned char s_blocksize_bits; unsigned long s_blocksize; loff_t s_maxbytes; struct file_system_type *s_type; const struct super_operations *s_op; const struct dquot_operations *dq_op; const struct quotactl_ops *s_qcop; const struct export_operations *s_export_op; unsigned long s_flags; unsigned long s_iflags; unsigned long s_magic; struct dentry *s_root; struct rw_semaphore s_umount; int s_count; atomic_t s_active; void *s_security; const struct xattr_handler **s_xattr; const struct fscrypt_operations *s_cop; struct hlist_bl_head s_anon; struct list_head s_mounts; struct block_device *s_bdev; struct backing_dev_info *s_bdi; struct mtd_info *s_mtd; struct hlist_node s_instances; unsigned int s_quota_types; struct quota_info s_dquot; struct sb_writers s_writers; char s_id[32U]; u8 s_uuid[16U]; void *s_fs_info; unsigned int s_max_links; fmode_t s_mode; u32 s_time_gran; struct mutex s_vfs_rename_mutex; char *s_subtype; char *s_options; const struct dentry_operations *s_d_op; int cleancache_poolid; struct shrinker s_shrink; atomic_long_t s_remove_count; int s_readonly_remount; struct workqueue_struct *s_dio_done_wq; struct hlist_head s_pins; struct list_lru s_dentry_lru; struct list_lru s_inode_lru; struct callback_head rcu; struct work_struct destroy_work; struct mutex s_sync_lock; int s_stack_depth; spinlock_t s_inode_list_lock; struct list_head s_inodes; } ;
1594 struct fiemap_extent_info { unsigned int fi_flags; unsigned int fi_extents_mapped; unsigned int fi_extents_max; struct fiemap_extent *fi_extents_start; } ;
1608 struct dir_context ;
1633 struct dir_context { int (*actor)(struct dir_context *, const char *, int, loff_t , u64 , unsigned int); loff_t pos; } ;
1639 struct block_device_operations ;
1640 struct file_operations { struct module *owner; loff_t (*llseek)(struct file *, loff_t , int); ssize_t (*read)(struct file *, char *, size_t , loff_t *); ssize_t (*write)(struct file *, const char *, size_t , loff_t *); ssize_t (*read_iter)(struct kiocb *, struct iov_iter *); ssize_t (*write_iter)(struct kiocb *, struct iov_iter *); int (*iterate)(struct file *, struct dir_context *); int (*iterate_shared)(struct file *, struct dir_context *); unsigned int (*poll)(struct file *, struct poll_table_struct *); long int (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); long int (*compat_ioctl)(struct file *, unsigned int, unsigned long); int (*mmap)(struct file *, struct vm_area_struct *); int (*open)(struct inode *, struct file *); int (*flush)(struct file *, fl_owner_t ); int (*release)(struct inode *, struct file *); int (*fsync)(struct file *, loff_t , loff_t , int); int (*aio_fsync)(struct kiocb *, int); int (*fasync)(int, struct file *, int); int (*lock)(struct file *, int, struct file_lock *); ssize_t (*sendpage)(struct file *, struct page *, int, size_t , loff_t *, int); unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); int (*check_flags)(int); int (*flock)(struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t , unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t , unsigned int); int (*setlease)(struct file *, long, struct file_lock **, void **); long int (*fallocate)(struct file *, int, loff_t , loff_t ); void (*show_fdinfo)(struct seq_file *, struct file *); ssize_t (*copy_file_range)(struct file *, loff_t , struct file *, loff_t , size_t , unsigned int); int (*clone_file_range)(struct file *, loff_t , struct file *, loff_t , u64 ); ssize_t (*dedupe_file_range)(struct file *, u64 , u64 , struct file *, u64 ); } ;
1709 struct inode_operations { struct dentry * (*lookup)(struct inode *, struct dentry *, unsigned int); const char * (*get_link)(struct dentry *, struct inode *, struct delayed_call *); int (*permission)(struct inode *, int); struct posix_acl * (*get_acl)(struct inode *, int); int (*readlink)(struct dentry *, char *, int); int (*create)(struct inode *, struct dentry *, umode_t , bool ); int (*link)(struct dentry *, struct inode *, struct dentry *); int (*unlink)(struct inode *, struct dentry *); int (*symlink)(struct inode *, struct dentry *, const char *); int (*mkdir)(struct inode *, struct dentry *, umode_t ); int (*rmdir)(struct inode *, struct dentry *); int (*mknod)(struct inode *, struct dentry *, umode_t , dev_t ); int (*rename)(struct inode *, struct dentry *, struct inode *, struct dentry *); int (*rename2)(struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int); int (*setattr)(struct dentry *, struct iattr *); int (*getattr)(struct vfsmount *, struct dentry *, struct kstat *); int (*setxattr)(struct dentry *, struct inode *, const char *, const void *, size_t , int); ssize_t (*getxattr)(struct dentry *, struct inode *, const char *, void *, size_t ); ssize_t (*listxattr)(struct dentry *, char *, size_t ); int (*removexattr)(struct dentry *, const char *); int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 , u64 ); int (*update_time)(struct inode *, struct timespec *, int); int (*atomic_open)(struct inode *, struct dentry *, struct file *, unsigned int, umode_t , int *); int (*tmpfile)(struct inode *, struct dentry *, umode_t ); int (*set_acl)(struct inode *, struct posix_acl *, int); } ;
1766 struct super_operations { struct inode * (*alloc_inode)(struct super_block *); void (*destroy_inode)(struct inode *); void (*dirty_inode)(struct inode *, int); int (*write_inode)(struct inode *, struct writeback_control *); int (*drop_inode)(struct inode *); void (*evict_inode)(struct inode *); void (*put_super)(struct super_block *); int (*sync_fs)(struct super_block *, int); int (*freeze_super)(struct super_block *); int (*freeze_fs)(struct super_block *); int (*thaw_super)(struct super_block *); int (*unfreeze_fs)(struct super_block *); int (*statfs)(struct dentry *, struct kstatfs *); int (*remount_fs)(struct super_block *, int *, char *); void (*umount_begin)(struct super_block *); int (*show_options)(struct seq_file *, struct dentry *); int (*show_devname)(struct seq_file *, struct dentry *); int (*show_path)(struct seq_file *, struct dentry *); int (*show_stats)(struct seq_file *, struct dentry *); ssize_t (*quota_read)(struct super_block *, int, char *, size_t , loff_t ); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t , loff_t ); struct dquot ** (*get_dquots)(struct inode *); int (*bdev_try_to_free_page)(struct super_block *, struct page *, gfp_t ); long int (*nr_cached_objects)(struct super_block *, struct shrink_control *); long int (*free_cached_objects)(struct super_block *, struct shrink_control *); } ;
2005 struct file_system_type { const char *name; int fs_flags; struct dentry * (*mount)(struct file_system_type *, int, const char *, void *); void (*kill_sb)(struct super_block *); struct module *owner; struct file_system_type *next; struct hlist_head fs_supers; struct lock_class_key s_lock_key; struct lock_class_key s_umount_key; struct lock_class_key s_vfs_rename_key; struct lock_class_key s_writers_key[3U]; struct lock_class_key i_lock_key; struct lock_class_key i_mutex_key; struct lock_class_key i_mutex_dir_key; } ;
3176 struct seq_file { char *buf; size_t size; size_t from; size_t count; size_t pad_until; loff_t index; loff_t read_pos; u64 version; struct mutex lock; const struct seq_operations *op; int poll_event; const struct file *file; void *private; } ;
30 struct seq_operations { void * (*start)(struct seq_file *, loff_t *); void (*stop)(struct seq_file *, void *); void * (*next)(struct seq_file *, void *, loff_t *); int (*show)(struct seq_file *, void *); } ;
222 struct pinctrl ;
223 struct pinctrl_state ;
194 struct dev_pin_info { struct pinctrl *p; struct pinctrl_state *default_state; struct pinctrl_state *init_state; struct pinctrl_state *sleep_state; struct pinctrl_state *idle_state; } ;
48 struct dma_map_ops ;
48 struct dev_archdata { struct dma_map_ops *dma_ops; void *iommu; } ;
24 struct device_private ;
25 struct device_driver ;
26 struct driver_private ;
27 struct subsys_private ;
28 struct bus_type ;
29 struct device_node ;
30 struct fwnode_handle ;
31 struct iommu_ops ;
32 struct iommu_group ;
61 struct device_attribute ;
61 struct bus_type { const char *name; const char *dev_name; struct device *dev_root; struct device_attribute *dev_attrs; const struct attribute_group **bus_groups; const struct attribute_group **dev_groups; const struct attribute_group **drv_groups; int (*match)(struct device *, struct device_driver *); int (*uevent)(struct device *, struct kobj_uevent_env *); int (*probe)(struct device *); int (*remove)(struct device *); void (*shutdown)(struct device *); int (*online)(struct device *); int (*offline)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct dev_pm_ops *pm; const struct iommu_ops *iommu_ops; struct subsys_private *p; struct lock_class_key lock_key; } ;
201 enum probe_type { PROBE_DEFAULT_STRATEGY = 0, PROBE_PREFER_ASYNCHRONOUS = 1, PROBE_FORCE_SYNCHRONOUS = 2 } ;
207 struct of_device_id ;
207 struct acpi_device_id ;
207 struct device_driver { const char *name; struct bus_type *bus; struct module *owner; const char *mod_name; bool suppress_bind_attrs; enum probe_type probe_type; const struct of_device_id *of_match_table; const struct acpi_device_id *acpi_match_table; int (*probe)(struct device *); int (*remove)(struct device *); void (*shutdown)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct attribute_group **groups; const struct dev_pm_ops *pm; struct driver_private *p; } ;
357 struct class_attribute ;
357 struct class { const char *name; struct module *owner; struct class_attribute *class_attrs; const struct attribute_group **dev_groups; struct kobject *dev_kobj; int (*dev_uevent)(struct device *, struct kobj_uevent_env *); char * (*devnode)(struct device *, umode_t *); void (*class_release)(struct class *); void (*dev_release)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct kobj_ns_type_operations *ns_type; const void * (*namespace)(struct device *); const struct dev_pm_ops *pm; struct subsys_private *p; } ;
450 struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *, struct class_attribute *, char *); ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t ); } ;
525 struct device_type { const char *name; const struct attribute_group **groups; int (*uevent)(struct device *, struct kobj_uevent_env *); char * (*devnode)(struct device *, umode_t *, kuid_t *, kgid_t *); void (*release)(struct device *); const struct dev_pm_ops *pm; } ;
546 struct device_attribute { struct attribute attr; ssize_t (*show)(struct device *, struct device_attribute *, char *); ssize_t (*store)(struct device *, struct device_attribute *, const char *, size_t ); } ;
699 struct device_dma_parameters { unsigned int max_segment_size; unsigned long segment_boundary_mask; } ;
708 struct dma_coherent_mem ;
708 struct cma ;
708 struct device { struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; const struct device_type *type; struct mutex mutex; struct bus_type *bus; struct device_driver *driver; void *platform_data; void *driver_data; struct dev_pm_info power; struct dev_pm_domain *pm_domain; struct irq_domain *msi_domain; struct dev_pin_info *pins; struct list_head msi_list; int numa_node; u64 *dma_mask; u64 coherent_dma_mask; unsigned long dma_pfn_offset; struct device_dma_parameters *dma_parms; struct list_head dma_pools; struct dma_coherent_mem *dma_mem; struct cma *cma_area; struct dev_archdata archdata; struct device_node *of_node; struct fwnode_handle *fwnode; dev_t devt; u32 id; spinlock_t devres_lock; struct list_head devres_head; struct klist_node knode_class; struct class *class; const struct attribute_group **groups; void (*release)(struct device *); struct iommu_group *iommu_group; bool offline_disabled; bool offline; } ;
862 struct wakeup_source { const char *name; struct list_head entry; spinlock_t lock; struct wake_irq *wakeirq; struct timer_list timer; unsigned long timer_expires; ktime_t total_time; ktime_t max_time; ktime_t last_time; ktime_t start_prevent_time; ktime_t prevent_sleep_time; unsigned long event_count; unsigned long active_count; unsigned long relax_count; unsigned long expire_count; unsigned long wakeup_count; bool active; bool autosleep_enabled; } ;
82 struct disk_stats { unsigned long sectors[2U]; unsigned long ios[2U]; unsigned long merges[2U]; unsigned long ticks[2U]; unsigned long io_ticks; unsigned long time_in_queue; } ;
91 struct partition_meta_info { char uuid[37U]; u8 volname[64U]; } ;
103 struct hd_struct { sector_t start_sect; sector_t nr_sects; seqcount_t nr_sects_seq; sector_t alignment_offset; unsigned int discard_alignment; struct device __dev; struct kobject *holder_dir; int policy; int partno; struct partition_meta_info *info; int make_it_fail; unsigned long stamp; atomic_t in_flight[2U]; struct disk_stats *dkstats; struct percpu_ref ref; struct callback_head callback_head; } ;
157 struct disk_part_tbl { struct callback_head callback_head; int len; struct hd_struct *last_lookup; struct hd_struct *part[]; } ;
164 struct disk_events ;
165 struct badblocks ;
166 struct blk_integrity_profile ;
166 struct blk_integrity { struct blk_integrity_profile *profile; unsigned char flags; unsigned char tuple_size; unsigned char interval_exp; unsigned char tag_size; } ;
177 struct timer_rand_state ;
177 struct gendisk { int major; int first_minor; int minors; char disk_name[32U]; char * (*devnode)(struct gendisk *, umode_t *); unsigned int events; unsigned int async_events; struct disk_part_tbl *part_tbl; struct hd_struct part0; const struct block_device_operations *fops; struct request_queue *queue; void *private_data; int flags; struct device *driverfs_dev; struct kobject *slave_dir; struct timer_rand_state *random; atomic_t sync_io; struct disk_events *ev; struct kobject integrity_kobj; int node_id; struct badblocks *bb; } ;
13 typedef unsigned long kernel_ulong_t;
14 struct pci_device_id { __u32 vendor; __u32 device; __u32 subvendor; __u32 subdevice; __u32 class; __u32 class_mask; kernel_ulong_t driver_data; } ;
186 struct acpi_device_id { __u8 id[9U]; kernel_ulong_t driver_data; __u32 cls; __u32 cls_msk; } ;
229 struct of_device_id { char name[32U]; char type[32U]; char compatible[128U]; const void *data; } ;
70 struct hotplug_slot ;
70 struct pci_slot { struct pci_bus *bus; struct list_head list; struct hotplug_slot *hotplug; unsigned char number; struct kobject kobj; } ;
104 typedef int pci_power_t;
131 typedef unsigned int pci_channel_state_t;
132 enum pci_channel_state { pci_channel_io_normal = 1, pci_channel_io_frozen = 2, pci_channel_io_perm_failure = 3 } ;
157 typedef unsigned short pci_dev_flags_t;
184 typedef unsigned short pci_bus_flags_t;
241 struct pcie_link_state ;
242 struct pci_vpd ;
243 struct pci_sriov ;
245 struct pci_driver ;
245 union __anonunion____missing_field_name_346 { struct pci_sriov *sriov; struct pci_dev *physfn; } ;
245 struct pci_dev { struct list_head bus_list; struct pci_bus *bus; struct pci_bus *subordinate; void *sysdata; struct proc_dir_entry *procent; struct pci_slot *slot; unsigned int devfn; unsigned short vendor; unsigned short device; unsigned short subsystem_vendor; unsigned short subsystem_device; unsigned int class; u8 revision; u8 hdr_type; u8 pcie_cap; u8 msi_cap; u8 msix_cap; unsigned char pcie_mpss; u8 rom_base_reg; u8 pin; u16 pcie_flags_reg; unsigned long *dma_alias_mask; struct pci_driver *driver; u64 dma_mask; struct device_dma_parameters dma_parms; pci_power_t current_state; u8 pm_cap; unsigned char pme_support; unsigned char pme_interrupt; unsigned char pme_poll; unsigned char d1_support; unsigned char d2_support; unsigned char no_d1d2; unsigned char no_d3cold; unsigned char d3cold_allowed; unsigned char mmio_always_on; unsigned char wakeup_prepared; unsigned char runtime_d3cold; unsigned char ignore_hotplug; unsigned int d3_delay; unsigned int d3cold_delay; struct pcie_link_state *link_state; pci_channel_state_t error_state; struct device dev; int cfg_size; unsigned int irq; struct resource resource[17U]; bool match_driver; unsigned char transparent; unsigned char multifunction; unsigned char is_added; unsigned char is_busmaster; unsigned char no_msi; unsigned char no_64bit_msi; unsigned char block_cfg_access; unsigned char broken_parity_status; unsigned char irq_reroute_variant; unsigned char msi_enabled; unsigned char msix_enabled; unsigned char ari_enabled; unsigned char ats_enabled; unsigned char is_managed; unsigned char needs_freset; unsigned char state_saved; unsigned char is_physfn; unsigned char is_virtfn; unsigned char reset_fn; unsigned char is_hotplug_bridge; unsigned char __aer_firmware_first_valid; unsigned char __aer_firmware_first; unsigned char broken_intx_masking; unsigned char io_window_1k; unsigned char irq_managed; unsigned char has_secondary_link; unsigned char non_compliant_bars; pci_dev_flags_t dev_flags; atomic_t enable_cnt; u32 saved_config_space[16U]; struct hlist_head saved_cap_space; struct bin_attribute *rom_attr; int rom_attr_enabled; struct bin_attribute *res_attr[17U]; struct bin_attribute *res_attr_wc[17U]; const struct attribute_group **msi_irq_groups; struct pci_vpd *vpd; union __anonunion____missing_field_name_346 __annonCompField85; u16 ats_cap; u8 ats_stu; atomic_t ats_ref_cnt; phys_addr_t rom; size_t romlen; char *driver_override; } ;
446 struct pci_ops ;
446 struct msi_controller ;
446 struct pci_bus { struct list_head node; struct pci_bus *parent; struct list_head children; struct list_head devices; struct pci_dev *self; struct list_head slots; struct resource *resource[4U]; struct list_head resources; struct resource busn_res; struct pci_ops *ops; struct msi_controller *msi; void *sysdata; struct proc_dir_entry *procdir; unsigned char number; unsigned char primary; unsigned char max_bus_speed; unsigned char cur_bus_speed; char name[48U]; unsigned short bridge_ctl; pci_bus_flags_t bus_flags; struct device *bridge; struct device dev; struct bin_attribute *legacy_io; struct bin_attribute *legacy_mem; unsigned char is_added; } ;
570 struct pci_ops { int (*add_bus)(struct pci_bus *); void (*remove_bus)(struct pci_bus *); void * (*map_bus)(struct pci_bus *, unsigned int, int); int (*read)(struct pci_bus *, unsigned int, int, int, u32 *); int (*write)(struct pci_bus *, unsigned int, int, int, u32 ); } ;
600 struct pci_dynids { spinlock_t lock; struct list_head list; } ;
614 typedef unsigned int pci_ers_result_t;
624 struct pci_error_handlers { pci_ers_result_t (*error_detected)(struct pci_dev *, enum pci_channel_state ); pci_ers_result_t (*mmio_enabled)(struct pci_dev *); pci_ers_result_t (*link_reset)(struct pci_dev *); pci_ers_result_t (*slot_reset)(struct pci_dev *); void (*reset_notify)(struct pci_dev *, bool ); void (*resume)(struct pci_dev *); } ;
657 struct pci_driver { struct list_head node; const char *name; const struct pci_device_id *id_table; int (*probe)(struct pci_dev *, const struct pci_device_id *); void (*remove)(struct pci_dev *); int (*suspend)(struct pci_dev *, pm_message_t ); int (*suspend_late)(struct pci_dev *, pm_message_t ); int (*resume_early)(struct pci_dev *); int (*resume)(struct pci_dev *); void (*shutdown)(struct pci_dev *); int (*sriov_configure)(struct pci_dev *, int); const struct pci_error_handlers *err_handler; struct device_driver driver; struct pci_dynids dynids; } ;
1238 struct scatterlist { unsigned long sg_magic; unsigned long page_link; unsigned int offset; unsigned int length; dma_addr_t dma_address; unsigned int dma_length; } ;
21 struct sg_table { struct scatterlist *sgl; unsigned int nents; unsigned int orig_nents; } ;
2040 struct dma_attrs { unsigned long flags[1U]; } ;
89 enum dma_data_direction { DMA_BIDIRECTIONAL = 0, DMA_TO_DEVICE = 1, DMA_FROM_DEVICE = 2, DMA_NONE = 3 } ;
158 struct dma_map_ops { void * (*alloc)(struct device *, size_t , dma_addr_t *, gfp_t , struct dma_attrs *); void (*free)(struct device *, size_t , void *, dma_addr_t , struct dma_attrs *); int (*mmap)(struct device *, struct vm_area_struct *, void *, dma_addr_t , size_t , struct dma_attrs *); int (*get_sgtable)(struct device *, struct sg_table *, void *, dma_addr_t , size_t , struct dma_attrs *); dma_addr_t (*map_page)(struct device *, struct page *, unsigned long, size_t , enum dma_data_direction , struct dma_attrs *); void (*unmap_page)(struct device *, dma_addr_t , size_t , enum dma_data_direction , struct dma_attrs *); int (*map_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , struct dma_attrs *); void (*unmap_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , struct dma_attrs *); void (*sync_single_for_cpu)(struct device *, dma_addr_t , size_t , enum dma_data_direction ); void (*sync_single_for_device)(struct device *, dma_addr_t , size_t , enum dma_data_direction ); void (*sync_sg_for_cpu)(struct device *, struct scatterlist *, int, enum dma_data_direction ); void (*sync_sg_for_device)(struct device *, struct scatterlist *, int, enum dma_data_direction ); int (*mapping_error)(struct device *, dma_addr_t ); int (*dma_supported)(struct device *, u64 ); int (*set_dma_mask)(struct device *, u64 ); int is_phys; } ;
72 struct fprop_local_percpu { struct percpu_counter events; unsigned int period; raw_spinlock_t lock; } ;
32 typedef int congested_fn(void *, int);
41 struct bdi_writeback_congested { unsigned long state; atomic_t refcnt; struct backing_dev_info *bdi; int blkcg_id; struct rb_node rb_node; } ;
60 union __anonunion____missing_field_name_347 { struct work_struct release_work; struct callback_head rcu; } ;
60 struct bdi_writeback { struct backing_dev_info *bdi; unsigned long state; unsigned long last_old_flush; struct list_head b_dirty; struct list_head b_io; struct list_head b_more_io; struct list_head b_dirty_time; spinlock_t list_lock; struct percpu_counter stat[4U]; struct bdi_writeback_congested *congested; unsigned long bw_time_stamp; unsigned long dirtied_stamp; unsigned long written_stamp; unsigned long write_bandwidth; unsigned long avg_write_bandwidth; unsigned long dirty_ratelimit; unsigned long balanced_dirty_ratelimit; struct fprop_local_percpu completions; int dirty_exceeded; spinlock_t work_lock; struct list_head work_list; struct delayed_work dwork; struct list_head bdi_node; struct percpu_ref refcnt; struct fprop_local_percpu memcg_completions; struct cgroup_subsys_state *memcg_css; struct cgroup_subsys_state *blkcg_css; struct list_head memcg_node; struct list_head blkcg_node; union __anonunion____missing_field_name_347 __annonCompField86; } ;
134 struct backing_dev_info { struct list_head bdi_list; unsigned long ra_pages; unsigned int capabilities; congested_fn *congested_fn; void *congested_data; char *name; unsigned int min_ratio; unsigned int max_ratio; unsigned int max_prop_frac; atomic_long_t tot_write_bandwidth; struct bdi_writeback wb; struct list_head wb_list; struct radix_tree_root cgwb_tree; struct rb_root cgwb_congested_tree; atomic_t usage_cnt; wait_queue_head_t wb_waitq; struct device *dev; struct timer_list laptop_mode_wb_timer; struct dentry *debug_dir; struct dentry *debug_stats; } ;
12 typedef void * mempool_alloc_t(gfp_t , void *);
13 typedef void mempool_free_t(void *, void *);
14 struct mempool_s { spinlock_t lock; int min_nr; int curr_nr; void **elements; void *pool_data; mempool_alloc_t *alloc; mempool_free_t *free; wait_queue_head_t wait; } ;
25 typedef struct mempool_s mempool_t;
79 union __anonunion____missing_field_name_348 { struct list_head q_node; struct kmem_cache *__rcu_icq_cache; } ;
79 union __anonunion____missing_field_name_349 { struct hlist_node ioc_node; struct callback_head __rcu_head; } ;
79 struct io_cq { struct request_queue *q; struct io_context *ioc; union __anonunion____missing_field_name_348 __annonCompField87; union __anonunion____missing_field_name_349 __annonCompField88; unsigned int flags; } ;
92 struct io_context { atomic_long_t refcount; atomic_t active_ref; atomic_t nr_tasks; spinlock_t lock; unsigned short ioprio; int nr_batch_requests; unsigned long last_waited; struct radix_tree_root icq_tree; struct io_cq *icq_hint; struct hlist_head icq_list; struct work_struct release_work; } ;
352 struct bio_integrity_payload { struct bio *bip_bio; struct bvec_iter bip_iter; bio_end_io_t *bip_end_io; unsigned short bip_slab; unsigned short bip_vcnt; unsigned short bip_max_vcnt; unsigned short bip_flags; struct work_struct bip_work; struct bio_vec *bip_vec; struct bio_vec bip_inline_vecs[0U]; } ;
583 struct bio_list { struct bio *head; struct bio *tail; } ;
715 struct bio_set { struct kmem_cache *bio_slab; unsigned int front_pad; mempool_t *bio_pool; mempool_t *bvec_pool; mempool_t *bio_integrity_pool; mempool_t *bvec_integrity_pool; spinlock_t rescue_lock; struct bio_list rescue_list; struct work_struct rescue_work; struct workqueue_struct *rescue_workqueue; } ;
64 struct bsg_class_device { struct device *class_dev; struct device *parent; int minor; struct request_queue *queue; struct kref ref; void (*release)(struct device *); } ;
22 struct elevator_queue ;
24 struct request ;
26 struct bsg_job ;
27 struct blkcg_gq ;
28 struct blk_flush_queue ;
29 struct pr_ops ;
51 typedef void rq_end_io_fn(struct request *, int);
52 struct request_list { struct request_queue *q; struct blkcg_gq *blkg; int count[2U]; int starved[2U]; mempool_t *rq_pool; wait_queue_head_t wait[2U]; unsigned int flags; } ;
77 union __anonunion____missing_field_name_350 { struct call_single_data csd; unsigned long fifo_time; } ;
77 struct blk_mq_ctx ;
77 union __anonunion____missing_field_name_351 { struct hlist_node hash; struct list_head ipi_list; } ;
77 union __anonunion____missing_field_name_352 { struct rb_node rb_node; void *completion_data; } ;
77 struct __anonstruct_elv_354 { struct io_cq *icq; void *priv[2U]; } ;
77 struct __anonstruct_flush_355 { unsigned int seq; struct list_head list; rq_end_io_fn *saved_end_io; } ;
77 union __anonunion____missing_field_name_353 { struct __anonstruct_elv_354 elv; struct __anonstruct_flush_355 flush; } ;
77 struct request { struct list_head queuelist; union __anonunion____missing_field_name_350 __annonCompField89; struct request_queue *q; struct blk_mq_ctx *mq_ctx; u64 cmd_flags; unsigned int cmd_type; unsigned long atomic_flags; int cpu; unsigned int __data_len; sector_t __sector; struct bio *bio; struct bio *biotail; union __anonunion____missing_field_name_351 __annonCompField90; union __anonunion____missing_field_name_352 __annonCompField91; union __anonunion____missing_field_name_353 __annonCompField92; struct gendisk *rq_disk; struct hd_struct *part; unsigned long start_time; struct request_list *rl; unsigned long long start_time_ns; unsigned long long io_start_time_ns; unsigned short nr_phys_segments; unsigned short nr_integrity_segments; unsigned short ioprio; void *special; int tag; int errors; unsigned char __cmd[16U]; unsigned char *cmd; unsigned short cmd_len; unsigned int extra_len; unsigned int sense_len; unsigned int resid_len; void *sense; unsigned long deadline; struct list_head timeout_list; unsigned int timeout; int retries; rq_end_io_fn *end_io; void *end_io_data; struct request *next_rq; } ;
117 struct elevator_type ;
12 typedef int elevator_merge_fn(struct request_queue *, struct request **, struct bio *);
15 typedef void elevator_merge_req_fn(struct request_queue *, struct request *, struct request *);
17 typedef void elevator_merged_fn(struct request_queue *, struct request *, int);
19 typedef int elevator_allow_merge_fn(struct request_queue *, struct request *, struct bio *);
21 typedef void elevator_bio_merged_fn(struct request_queue *, struct request *, struct bio *);
24 typedef int elevator_dispatch_fn(struct request_queue *, int);
26 typedef void elevator_add_req_fn(struct request_queue *, struct request *);
27 typedef struct request * elevator_request_list_fn(struct request_queue *, struct request *);
28 typedef void elevator_completed_req_fn(struct request_queue *, struct request *);
29 typedef int elevator_may_queue_fn(struct request_queue *, int);
31 typedef void elevator_init_icq_fn(struct io_cq *);
32 typedef void elevator_exit_icq_fn(struct io_cq *);
33 typedef int elevator_set_req_fn(struct request_queue *, struct request *, struct bio *, gfp_t );
35 typedef void elevator_put_req_fn(struct request *);
36 typedef void elevator_activate_req_fn(struct request_queue *, struct request *);
37 typedef void elevator_deactivate_req_fn(struct request_queue *, struct request *);
39 typedef int elevator_init_fn(struct request_queue *, struct elevator_type *);
41 typedef void elevator_exit_fn(struct elevator_queue *);
42 typedef void elevator_registered_fn(struct request_queue *);
43 struct elevator_ops { elevator_merge_fn *elevator_merge_fn; elevator_merged_fn *elevator_merged_fn; elevator_merge_req_fn *elevator_merge_req_fn; elevator_allow_merge_fn *elevator_allow_merge_fn; elevator_bio_merged_fn *elevator_bio_merged_fn; elevator_dispatch_fn *elevator_dispatch_fn; elevator_add_req_fn *elevator_add_req_fn; elevator_activate_req_fn *elevator_activate_req_fn; elevator_deactivate_req_fn *elevator_deactivate_req_fn; elevator_completed_req_fn *elevator_completed_req_fn; elevator_request_list_fn *elevator_former_req_fn; elevator_request_list_fn *elevator_latter_req_fn; elevator_init_icq_fn *elevator_init_icq_fn; elevator_exit_icq_fn *elevator_exit_icq_fn; elevator_set_req_fn *elevator_set_req_fn; elevator_put_req_fn *elevator_put_req_fn; elevator_may_queue_fn *elevator_may_queue_fn; elevator_init_fn *elevator_init_fn; elevator_exit_fn *elevator_exit_fn; elevator_registered_fn *elevator_registered_fn; } ;
74 struct elv_fs_entry { struct attribute attr; ssize_t (*show)(struct elevator_queue *, char *); ssize_t (*store)(struct elevator_queue *, const char *, size_t ); } ;
82 struct elevator_type { struct kmem_cache *icq_cache; struct elevator_ops ops; size_t icq_size; size_t icq_align; struct elv_fs_entry *elevator_attrs; char elevator_name[16U]; struct module *elevator_owner; char icq_cache_name[21U]; struct list_head list; } ;
103 struct elevator_queue { struct elevator_type *type; void *elevator_data; struct kobject kobj; struct mutex sysfs_lock; unsigned char registered; struct hlist_head hash[64U]; } ;
212 typedef void request_fn_proc(struct request_queue *);
213 typedef blk_qc_t make_request_fn(struct request_queue *, struct bio *);
214 typedef int prep_rq_fn(struct request_queue *, struct request *);
215 typedef void unprep_rq_fn(struct request_queue *, struct request *);
218 typedef void softirq_done_fn(struct request *);
219 typedef int dma_drain_needed_fn(struct request *);
220 typedef int lld_busy_fn(struct request_queue *);
221 typedef int bsg_job_fn(struct bsg_job *);
222 enum blk_eh_timer_return { BLK_EH_NOT_HANDLED = 0, BLK_EH_HANDLED = 1, BLK_EH_RESET_TIMER = 2 } ;
229 typedef enum blk_eh_timer_return rq_timed_out_fn(struct request *);
235 struct blk_queue_tag { struct request **tag_index; unsigned long *tag_map; int busy; int max_depth; int real_max_depth; atomic_t refcnt; int alloc_policy; int next_tag; } ;
246 struct queue_limits { unsigned long bounce_pfn; unsigned long seg_boundary_mask; unsigned long virt_boundary_mask; unsigned int max_hw_sectors; unsigned int max_dev_sectors; unsigned int chunk_sectors; unsigned int max_sectors; unsigned int max_segment_size; unsigned int physical_block_size; unsigned int alignment_offset; unsigned int io_min; unsigned int io_opt; unsigned int max_discard_sectors; unsigned int max_hw_discard_sectors; unsigned int max_write_same_sectors; unsigned int discard_granularity; unsigned int discard_alignment; unsigned short logical_block_size; unsigned short max_segments; unsigned short max_integrity_segments; unsigned char misaligned; unsigned char discard_misaligned; unsigned char cluster; unsigned char discard_zeroes_data; unsigned char raid_partial_stripes_expensive; } ;
282 struct blk_mq_ops ;
282 struct blk_mq_hw_ctx ;
282 struct throtl_data ;
282 struct blk_mq_tag_set ;
282 struct request_queue { struct list_head queue_head; struct request *last_merge; struct elevator_queue *elevator; int nr_rqs[2U]; int nr_rqs_elvpriv; struct request_list root_rl; request_fn_proc *request_fn; make_request_fn *make_request_fn; prep_rq_fn *prep_rq_fn; unprep_rq_fn *unprep_rq_fn; softirq_done_fn *softirq_done_fn; rq_timed_out_fn *rq_timed_out_fn; dma_drain_needed_fn *dma_drain_needed; lld_busy_fn *lld_busy_fn; struct blk_mq_ops *mq_ops; unsigned int *mq_map; struct blk_mq_ctx *queue_ctx; unsigned int nr_queues; struct blk_mq_hw_ctx **queue_hw_ctx; unsigned int nr_hw_queues; sector_t end_sector; struct request *boundary_rq; struct delayed_work delay_work; struct backing_dev_info backing_dev_info; void *queuedata; unsigned long queue_flags; int id; gfp_t bounce_gfp; spinlock_t __queue_lock; spinlock_t *queue_lock; struct kobject kobj; struct kobject mq_kobj; struct blk_integrity integrity; struct device *dev; int rpm_status; unsigned int nr_pending; unsigned long nr_requests; unsigned int nr_congestion_on; unsigned int nr_congestion_off; unsigned int nr_batching; unsigned int dma_drain_size; void *dma_drain_buffer; unsigned int dma_pad_mask; unsigned int dma_alignment; struct blk_queue_tag *queue_tags; struct list_head tag_busy_list; unsigned int nr_sorted; unsigned int in_flight[2U]; unsigned int request_fn_active; unsigned int rq_timeout; struct timer_list timeout; struct work_struct timeout_work; struct list_head timeout_list; struct list_head icq_list; unsigned long blkcg_pols[1U]; struct blkcg_gq *root_blkg; struct list_head blkg_list; struct queue_limits limits; unsigned int sg_timeout; unsigned int sg_reserved_size; int node; struct blk_flush_queue *fq; struct list_head requeue_list; spinlock_t requeue_lock; struct work_struct requeue_work; struct mutex sysfs_lock; int bypass_depth; atomic_t mq_freeze_depth; bsg_job_fn *bsg_job_fn; int bsg_job_size; struct bsg_class_device bsg_dev; struct throtl_data *td; struct callback_head callback_head; wait_queue_head_t mq_freeze_wq; struct percpu_ref q_usage_counter; struct list_head all_q_node; struct blk_mq_tag_set *tag_set; struct list_head tag_set_list; struct bio_set *bio_split; bool mq_sysfs_init_done; } ;
1046 struct blk_plug { struct list_head list; struct list_head mq_list; struct list_head cb_list; } ;
1477 struct blk_integrity_iter { void *prot_buf; void *data_buf; sector_t seed; unsigned int data_size; unsigned short interval; const char *disk_name; } ;
1506 typedef int integrity_processing_fn(struct blk_integrity_iter *);
1507 struct blk_integrity_profile { integrity_processing_fn *generate_fn; integrity_processing_fn *verify_fn; const char *name; } ;
1666 struct block_device_operations { int (*open)(struct block_device *, fmode_t ); void (*release)(struct gendisk *, fmode_t ); int (*rw_page)(struct block_device *, sector_t , struct page *, int); int (*ioctl)(struct block_device *, fmode_t , unsigned int, unsigned long); int (*compat_ioctl)(struct block_device *, fmode_t , unsigned int, unsigned long); long int (*direct_access)(struct block_device *, sector_t , void **, pfn_t *, long); unsigned int (*check_events)(struct gendisk *, unsigned int); int (*media_changed)(struct gendisk *); void (*unlock_native_capacity)(struct gendisk *); int (*revalidate_disk)(struct gendisk *); int (*getgeo)(struct block_device *, struct hd_geometry *); void (*swap_slot_free_notify)(struct block_device *, unsigned long); struct module *owner; const struct pr_ops *pr_ops; } ;
272 struct request_sense ;
696 struct request_sense { unsigned char error_code; unsigned char valid; __u8 segment_number; unsigned char sense_key; unsigned char reserved2; unsigned char ili; unsigned char reserved1; __u8 information[4U]; __u8 add_sense_len; __u8 command_info[4U]; __u8 asc; __u8 ascq; __u8 fruc; __u8 sks[3U]; __u8 asb[46U]; } ;
328 union __anonunion____missing_field_name_364 { unsigned long error_addr; unsigned long feature_addr; } ;
328 union __anonunion____missing_field_name_365 { unsigned long status_addr; unsigned long command_addr; } ;
328 struct ide_io_ports { unsigned long data_addr; union __anonunion____missing_field_name_364 __annonCompField93; unsigned long nsect_addr; unsigned long lbal_addr; unsigned long lbam_addr; unsigned long lbah_addr; unsigned long device_addr; union __anonunion____missing_field_name_365 __annonCompField94; unsigned long ctl_addr; unsigned long irq_addr; } ;
179 typedef u8 hwif_chipset_t;
212 enum ldv_29544 { ide_stopped = 0, ide_started = 1 } ;
235 typedef enum ldv_29544 ide_startstop_t;
270 union __anonunion____missing_field_name_367 { u8 error; u8 feature; } ;
270 union __anonunion____missing_field_name_368 { u8 status; u8 command; } ;
270 struct ide_taskfile { u8 data; union __anonunion____missing_field_name_367 __annonCompField96; u8 nsect; u8 lbal; u8 lbam; u8 lbah; u8 device; union __anonunion____missing_field_name_368 __annonCompField97; } ;
296 struct __anonstruct_out_370 { u8 tf; u8 hob; } ;
296 struct __anonstruct_in_371 { u8 tf; u8 hob; } ;
296 struct __anonstruct_valid_369 { struct __anonstruct_out_370 out; struct __anonstruct_in_371 in; } ;
296 struct ide_cmd { struct ide_taskfile tf; struct ide_taskfile hob; struct __anonstruct_valid_369 valid; u16 tf_flags; u8 ftf_flags; int protocol; int sg_nents; int orig_sg_nents; int sg_dma_direction; unsigned int nbytes; unsigned int nleft; unsigned int last_xfer_len; struct scatterlist *cursg; unsigned int cursg_ofs; struct request *rq; } ;
334 struct ide_atapi_pc { u8 c[12U]; int retries; int error; int req_xfer; struct request *rq; unsigned long flags; unsigned long timeout; } ;
360 struct ide_devset ;
361 struct ide_driver ;
362 struct ide_acpi_drive_link ;
363 struct ide_acpi_hwif_link ;
364 struct ide_drive_s ;
365 struct ide_disk_ops { int (*check)(struct ide_drive_s *, const char *); int (*get_capacity)(struct ide_drive_s *); void (*unlock_native_capacity)(struct ide_drive_s *); void (*setup)(struct ide_drive_s *); void (*flush)(struct ide_drive_s *); int (*init_media)(struct ide_drive_s *, struct gendisk *); int (*set_doorlock)(struct ide_drive_s *, struct gendisk *, int); ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *, sector_t ); int (*ioctl)(struct ide_drive_s *, struct block_device *, fmode_t , unsigned int, unsigned long); } ;
446 struct ide_proc_devset ;
446 struct hwif_s ;
446 struct ide_drive_s { char name[4U]; char driver_req[10U]; struct request_queue *queue; struct request *rq; void *driver_data; u16 *id; struct proc_dir_entry *proc; const struct ide_proc_devset *settings; struct hwif_s *hwif; const struct ide_disk_ops *disk_ops; unsigned long dev_flags; unsigned long sleep; unsigned long timeout; u8 special_flags; u8 select; u8 retry_pio; u8 waiting_for_dma; u8 dma; u8 init_speed; u8 current_speed; u8 desired_speed; u8 pio_mode; u8 dma_mode; u8 dn; u8 acoustic; u8 media; u8 ready_stat; u8 mult_count; u8 mult_req; u8 io_32bit; u8 bad_wstat; u8 head; u8 sect; u8 bios_head; u8 bios_sect; u8 pc_delay; unsigned int bios_cyl; unsigned int cyl; void *drive_data; unsigned int failures; unsigned int max_failures; u64 probed_capacity; u64 capacity64; int lun; int crc_count; unsigned long debug_mask; struct ide_acpi_drive_link *acpidata; struct list_head list; struct device gendev; struct completion gendev_rel_comp; struct ide_atapi_pc *pc; struct ide_atapi_pc *failed_pc; int (*pc_callback)(struct ide_drive_s *, int); ide_startstop_t (*irq_handler)(struct ide_drive_s *); unsigned long atapi_flags; struct ide_atapi_pc request_sense_pc; bool sense_rq_armed; struct request sense_rq; struct request_sense sense_data; } ;
586 typedef struct ide_drive_s ide_drive_t;
588 struct ide_tp_ops { void (*exec_command)(struct hwif_s *, u8 ); u8 (*read_status)(struct hwif_s *); u8 (*read_altstatus)(struct hwif_s *); void (*write_devctl)(struct hwif_s *, u8 ); void (*dev_select)(ide_drive_t *); void (*tf_load)(ide_drive_t *, struct ide_taskfile *, u8 ); void (*tf_read)(ide_drive_t *, struct ide_taskfile *, u8 ); void (*input_data)(ide_drive_t *, struct ide_cmd *, void *, unsigned int); void (*output_data)(ide_drive_t *, struct ide_cmd *, void *, unsigned int); } ;
615 struct ide_port_ops { void (*init_dev)(ide_drive_t *); void (*set_pio_mode)(struct hwif_s *, ide_drive_t *); void (*set_dma_mode)(struct hwif_s *, ide_drive_t *); int (*reset_poll)(ide_drive_t *); void (*pre_reset)(ide_drive_t *); void (*resetproc)(ide_drive_t *); void (*maskproc)(ide_drive_t *, int); void (*quirkproc)(ide_drive_t *); void (*clear_irq)(ide_drive_t *); int (*test_irq)(struct hwif_s *); u8 (*mdma_filter)(ide_drive_t *); u8 (*udma_filter)(ide_drive_t *); u8 (*cable_detect)(struct hwif_s *); } ;
651 struct ide_dma_ops { void (*dma_host_set)(struct ide_drive_s *, int); int (*dma_setup)(struct ide_drive_s *, struct ide_cmd *); void (*dma_start)(struct ide_drive_s *); int (*dma_end)(struct ide_drive_s *); int (*dma_test_irq)(struct ide_drive_s *); void (*dma_lost_irq)(struct ide_drive_s *); int (*dma_check)(struct ide_drive_s *, struct ide_cmd *); int (*dma_timer_expiry)(struct ide_drive_s *); void (*dma_clear)(struct ide_drive_s *); u8 (*dma_sff_read_status)(struct hwif_s *); } ;
673 struct ide_host ;
674 struct hwif_s { struct hwif_s *mate; struct proc_dir_entry *proc; struct ide_host *host; char name[6U]; struct ide_io_ports io_ports; unsigned long sata_scr[3U]; ide_drive_t *devices[3U]; unsigned long port_flags; u8 major; u8 index; u8 channel; u32 host_flags; u8 pio_mask; u8 ultra_mask; u8 mwdma_mask; u8 swdma_mask; u8 cbl; hwif_chipset_t chipset; struct device *dev; void (*rw_disk)(ide_drive_t *, struct request *); const struct ide_tp_ops *tp_ops; const struct ide_port_ops *port_ops; const struct ide_dma_ops *dma_ops; unsigned int *dmatable_cpu; dma_addr_t dmatable_dma; int prd_max_nents; int prd_ent_size; struct scatterlist *sg_table; int sg_max_nents; struct ide_cmd cmd; int rqsize; int irq; unsigned long dma_base; unsigned long config_data; unsigned long select_data; unsigned long extra_base; unsigned int extra_ports; unsigned char present; unsigned char busy; struct device gendev; struct device *portdev; struct completion gendev_rel_comp; void *hwif_data; struct ide_acpi_hwif_link *acpidata; ide_startstop_t (*handler)(ide_drive_t *); unsigned char polling; ide_drive_t *cur_dev; struct request *rq; struct timer_list timer; unsigned long poll_timeout; int (*expiry)(ide_drive_t *); int req_gen; int req_gen_timer; spinlock_t lock; } ;
780 typedef struct hwif_s ide_hwif_t;
781 struct ide_host { ide_hwif_t *ports[5U]; unsigned int n_ports; struct device *dev[2U]; int (*init_chipset)(struct pci_dev *); void (*get_lock)(irqreturn_t (*)(int, void *), void *); void (*release_lock)(); irqreturn_t (*irq_handler)(int, void *); unsigned long host_flags; int irq_flags; void *host_priv; ide_hwif_t *cur_port; volatile unsigned long host_busy; } ;
819 struct ide_devset { int (*get)(ide_drive_t *); int (*set)(ide_drive_t *, int); unsigned int flags; } ;
894 struct ide_proc_devset { const char *name; const struct ide_devset *setting; int min; int max; int (*mulf)(ide_drive_t *); int (*divf)(ide_drive_t *); } ;
934 struct __anonstruct_ide_proc_entry_t_372 { const char *name; umode_t mode; const struct file_operations *proc_fops; } ;
934 typedef struct __anonstruct_ide_proc_entry_t_372 ide_proc_entry_t;
1019 struct ide_driver { const char *version; ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t ); struct device_driver gen_driver; int (*probe)(ide_drive_t *); void (*remove)(ide_drive_t *); void (*resume)(ide_drive_t *); void (*shutdown)(ide_drive_t *); ide_proc_entry_t * (*proc_entries)(ide_drive_t *); const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *); } ;
9 struct mtop { short mt_op; int mt_count; } ;
23 struct mtget { long mt_type; long mt_resid; long mt_dsreg; long mt_gstat; long mt_erreg; __kernel_daddr_t mt_fileno; __kernel_daddr_t mt_blkno; } ;
85 struct mtpos { long mt_blkno; } ;
131 struct ide_tape_obj { ide_drive_t *drive; struct ide_driver *driver; struct gendisk *disk; struct device dev; struct ide_atapi_pc queued_pc; bool postponed_rq; unsigned long dsc_polling_start; struct timer_list dsc_timer; unsigned long best_dsc_rw_freq; unsigned long dsc_poll_freq; unsigned long dsc_timeout; u8 partition; unsigned int first_frame; u8 sense_key; u8 asc; u8 ascq; unsigned int minor; char name[4U]; u8 chrdev_dir; unsigned short blk_size; int user_bs_factor; u8 caps[20U]; int buffer_size; void *buf; void *cur; size_t valid; unsigned long avg_time; int avg_size; int avg_speed; int door_locked; char drv_write_prot; char write_prot; } ;
219 typedef struct ide_tape_obj idetape_tape_t;
1034 struct idetape_config { int dsc_rw_frequency; int dsc_media_access_frequency; int nr_stages; } ;
48 typedef int ldv_func_ret_type;
1 unsigned long int __builtin_object_size(void *, int);
1 long int __builtin_expect(long, long);
33 extern struct module __this_module;
72 void set_bit(long nr, volatile unsigned long *addr);
110 void clear_bit(long nr, volatile unsigned long *addr);
204 int test_and_set_bit(long nr, volatile unsigned long *addr);
250 int test_and_clear_bit(long nr, volatile unsigned long *addr);
308 int constant_test_bit(long nr, const volatile unsigned long *addr);
7 __u32 __arch_swab32(__u32 val);
46 __u16 __fswab16(__u16 val);
55 __u32 __fswab32(__u32 val);
160 __u16 __swab16p(const __u16 *p);
173 __u32 __swab32p(const __u32 *p);
79 __u32 __be32_to_cpup(const __be32 *p);
87 __u16 __be16_to_cpup(const __be16 *p);
154 int printk(const char *, ...);
255 void __might_fault(const char *, int);
3 bool ldv_is_err(const void *ptr);
11 void * ldv_create_class();
13 void ldv_unregister_class();
15 int ldv_register_chrdev(int major);
17 void ldv_unregister_chrdev_region();
31 void * __memcpy(void *, const void *, size_t );
56 void * __memset(void *, int, size_t );
75 char * strstr(const char *, const char *);
41 bool IS_ERR(const void *ptr);
138 void mutex_lock_nested(struct mutex *, unsigned int);
174 void mutex_unlock(struct mutex *);
78 extern volatile unsigned long jiffies;
284 unsigned int jiffies_to_msecs(const unsigned long);
87 const char * kobject_name(const struct kobject *kobj);
46 void msleep(unsigned int);
964 void * lowmem_page_address(const struct page *page);
5 void kasan_check_read(const void *, unsigned int);
6 void kasan_check_write(const void *, unsigned int);
676 unsigned long int _copy_from_user(void *, const void *, unsigned int);
678 unsigned long int _copy_to_user(void *, const void *, unsigned int);
698 void __copy_from_user_overflow();
703 void __copy_to_user_overflow();
719 unsigned long int copy_from_user(void *to, const void *from, unsigned long n);
756 unsigned long int copy_to_user(void *to, const void *from, unsigned long n);
154 void kfree(const void *);
318 void * __kmalloc(size_t , gfp_t );
466 void * kmalloc(size_t size, gfp_t flags);
620 void * kzalloc(size_t size, gfp_t flags);
859 unsigned int iminor(const struct inode *inode);
2426 int __register_chrdev(unsigned int, unsigned int, unsigned int, const char *, const struct file_operations *);
2429 void __unregister_chrdev(unsigned int, unsigned int, unsigned int, const char *);
2434 int ldv_register_chrdev_5(unsigned int major, const char *name, const struct file_operations *fops);
2434 int register_chrdev(unsigned int major, const char *name, const struct file_operations *fops);
2444 void ldv_unregister_chrdev_6(unsigned int major, const char *name);
2444 void unregister_chrdev(unsigned int major, const char *name);
2791 loff_t noop_llseek(struct file *, loff_t , int);
109 ssize_t seq_read(struct file *, char *, size_t , loff_t *);
110 loff_t seq_lseek(struct file *, loff_t , int);
117 void seq_printf(struct seq_file *, const char *, ...);
135 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
137 int single_release(struct inode *, struct file *);
289 int driver_register(struct device_driver *);
290 void driver_unregister(struct device_driver *);
517 void class_destroy(struct class *);
520 void ldv_class_destroy_7(struct class *ldv_func_arg1);
524 void ldv_class_destroy_8(struct class *ldv_func_arg1);
865 const char * dev_name(const struct device *dev);
875 int dev_set_name(struct device *, const char *, ...);
1003 int device_register(struct device *);
1007 void device_del(struct device *);
1072 struct device * device_create(struct class *, struct device *, dev_t , void *, const char *, ...);
1080 void device_destroy(struct class *, dev_t );
1097 struct device * get_device(struct device *);
1098 void put_device(struct device *);
617 struct gendisk * alloc_disk(int);
619 void put_disk(struct gendisk *);
105 bool bio_has_data(struct bio *bio);
142 void * bio_data(struct bio *bio);
786 void blk_put_request(struct request *);
788 struct request * blk_get_request(struct request_queue *, int, gfp_t );
830 int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t );
834 int blk_execute_rq(struct request_queue *, struct gendisk *, struct request *, int);
859 unsigned int blk_rq_bytes(const struct request *rq);
871 unsigned int blk_rq_sectors(const struct request *rq);
39 void * PDE_DATA(const struct inode *);
942 void ide_proc_register_driver(ide_drive_t *, struct ide_driver *);
943 void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *);
945 extern const struct file_operations ide_capacity_proc_fops;
1042 int ide_device_get(ide_drive_t *);
1043 void ide_device_put(ide_drive_t *);
1054 int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned int, unsigned long);
1074 void ide_fixstring(u8 *, const int, const int);
1084 ide_startstop_t ide_do_reset(ide_drive_t *);
1090 int ide_complete_rq(ide_drive_t *, int, unsigned int);
1114 int ide_check_atapi_device(ide_drive_t *, const char *);
1116 void ide_init_pc(struct ide_atapi_pc *);
1138 int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *, void *, unsigned int);
1141 int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
1142 int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1143 int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1145 void ide_retry_pc(ide_drive_t *);
1147 void ide_prep_sense(ide_drive_t *, struct request *);
1154 ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_cmd *);
1176 void ide_stall_queue(ide_drive_t *, unsigned long);
1183 void ide_init_disk(struct gendisk *, ide_drive_t *);
1356 void ide_map_sg(ide_drive_t *, struct ide_cmd *);
1357 void ide_init_sg_cmd(struct ide_cmd *, unsigned int);
1449 void ide_register_region(struct gendisk *);
1450 void ide_unregister_region(struct gendisk *);
1540 extern struct bus_type ide_bus_type;
27 u32 get_unaligned_be32(const void *p);
37 void put_unaligned_le16(u16 val, void *p);
42 void put_unaligned_le32(u32 val, void *p);
47 void put_unaligned_le64(u64 val, void *p);
8 void __bad_unaligned_access_size();
221 struct mutex ide_tape_mutex = { { 1 }, { { { { { 0 } }, 3735899821U, 4294967295U, (void *)-1, { 0, { 0, 0 }, "ide_tape_mutex.wait_lock", 0, 0UL } } } }, { &(ide_tape_mutex.wait_list), &(ide_tape_mutex.wait_list) }, 0, (void *)(&ide_tape_mutex), { 0, { 0, 0 }, "ide_tape_mutex", 0, 0UL } };
222 struct mutex idetape_ref_mutex = { { 1 }, { { { { { 0 } }, 3735899821U, 4294967295U, (void *)-1, { 0, { 0, 0 }, "idetape_ref_mutex.wait_lock", 0, 0UL } } } }, { &(idetape_ref_mutex.wait_list), &(idetape_ref_mutex.wait_list) }, 0, (void *)(&idetape_ref_mutex), { 0, { 0, 0 }, "idetape_ref_mutex", 0, 0UL } };
224 struct mutex idetape_chrdev_mutex = { { 1 }, { { { { { 0 } }, 3735899821U, 4294967295U, (void *)-1, { 0, { 0, 0 }, "idetape_chrdev_mutex.wait_lock", 0, 0UL } } } }, { &(idetape_chrdev_mutex.wait_list), &(idetape_chrdev_mutex.wait_list) }, 0, (void *)(&idetape_chrdev_mutex), { 0, { 0, 0 }, "idetape_chrdev_mutex", 0, 0UL } };
226 struct class *idetape_sysfs_class = 0;
228 void ide_tape_release(struct device *dev);
230 struct ide_tape_obj *idetape_devs[20U] = { };
232 struct ide_tape_obj * ide_tape_get(struct gendisk *disk, bool cdev, unsigned int i);
255 void ide_tape_put(struct ide_tape_obj *tape);
269 void idetape_analyze_error(ide_drive_t *drive);
325 void ide_tape_handle_dsc(ide_drive_t *drive);
327 int ide_tape_callback(ide_drive_t *drive, int dsc);
379 void ide_tape_stall_queue(ide_drive_t *drive);
440 ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd, struct ide_atapi_pc *pc);
490 void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code);
516 ide_startstop_t idetape_media_access_finished(ide_drive_t *drive);
544 void ide_tape_create_rw_cmd(idetape_tape_t *tape, struct ide_atapi_pc *pc, struct request *rq, u8 opcode);
567 ide_startstop_t idetape_do_request(ide_drive_t *drive, struct request *rq, sector_t block);
673 void idetape_create_write_filemark_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc, int write_filemark);
682 int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout);
710 int idetape_flush_tape_buffers(ide_drive_t *drive);
724 int ide_tape_read_position(ide_drive_t *drive);
766 void idetape_create_locate_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc, unsigned int block, u8 partition, int skip);
778 void __ide_tape_discard_merge_buffer(ide_drive_t *drive);
801 int idetape_position_tape(ide_drive_t *drive, unsigned int block, u8 partition, int skip);
823 void ide_tape_discard_merge_buffer(ide_drive_t *drive, int restore_position);
845 int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size);
887 void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc);
895 void idetape_create_rewind_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc);
903 void idetape_create_erase_cmd(struct ide_atapi_pc *pc);
911 void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd);
920 void ide_tape_flush_merge_buffer(ide_drive_t *drive);
940 int idetape_init_rw(ide_drive_t *drive, int dir);
990 void idetape_pad_zeros(ide_drive_t *drive, int bcount);
1008 int idetape_rewind_tape(ide_drive_t *drive);
1029 int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg);
1062 int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, int mt_count);
1128 ssize_t idetape_chrdev_read(struct file *file, char *buf, size_t count, loff_t *ppos);
1183 ssize_t idetape_chrdev_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
1226 int idetape_write_filemark(ide_drive_t *drive);
1253 int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count);
1369 long int do_idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1424 long int idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1438 void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive);
1463 int idetape_chrdev_open(struct inode *inode, struct file *filp);
1548 void idetape_write_release(ide_drive_t *drive, unsigned int minor);
1565 int idetape_chrdev_release(struct inode *inode, struct file *filp);
1602 void idetape_get_inquiry_results(ide_drive_t *drive);
1631 void idetape_get_mode_sense_results(ide_drive_t *drive);
1707 int mulf_tdsc(ide_drive_t *drive);
1708 int divf_tdsc(ide_drive_t *drive);
1709 int divf_buffer(ide_drive_t *drive);
1710 int divf_buffer_size(ide_drive_t *drive);
1712 int get_dsc_overlap(ide_drive_t *drive);
1712 int set_dsc_overlap(ide_drive_t *drive, int arg);
1712 const struct ide_devset ide_devset_dsc_overlap = { &get_dsc_overlap, &set_dsc_overlap, 1U };
1714 int get_tdsc(ide_drive_t *drive);
1714 int set_tdsc(ide_drive_t *drive, int arg);
1714 const struct ide_devset ide_devset_tdsc = { &get_tdsc, &set_tdsc, 1U };
1716 int get_avg_speed(ide_drive_t *drive);
1716 const struct ide_devset ide_devset_avg_speed = { &get_avg_speed, (int (*)(ide_drive_t *, int))0, 0U };
1717 int get_speed(ide_drive_t *drive);
1717 const struct ide_devset ide_devset_speed = { &get_speed, (int (*)(ide_drive_t *, int))0, 0U };
1718 int get_buffer(ide_drive_t *drive);
1718 const struct ide_devset ide_devset_buffer = { &get_buffer, (int (*)(ide_drive_t *, int))0, 0U };
1719 int get_buffer_size(ide_drive_t *drive);
1719 const struct ide_devset ide_devset_buffer_size = { &get_buffer_size, (int (*)(ide_drive_t *, int))0, 0U };
1721 const struct ide_proc_devset idetape_settings[7U] = { { "avg_speed", &ide_devset_avg_speed, 0, 65535, (int (*)(ide_drive_t *))0, (int (*)(ide_drive_t *))0 }, { "buffer", &ide_devset_buffer, 0, 65535, (int (*)(ide_drive_t *))0, &divf_buffer }, { "buffer_size", &ide_devset_buffer_size, 0, 65535, (int (*)(ide_drive_t *))0, &divf_buffer_size }, { "dsc_overlap", &ide_devset_dsc_overlap, 0, 1, (int (*)(ide_drive_t *))0, (int (*)(ide_drive_t *))0 }, { "speed", &ide_devset_speed, 0, 65535, (int (*)(ide_drive_t *))0, (int (*)(ide_drive_t *))0 }, { "tdsc", &ide_devset_tdsc, 12, 100, &mulf_tdsc, &divf_tdsc }, { (const char *)0, 0, 0, 0, 0, 0 } };
1744 void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor);
1807 void ide_tape_remove(ide_drive_t *drive);
1840 int idetape_name_proc_show(struct seq_file *m, void *v);
1849 int idetape_name_proc_open(struct inode *inode, struct file *file);
1854 const struct file_operations idetape_name_proc_fops = { &__this_module, &seq_lseek, &seq_read, 0, 0, 0, 0, 0, 0, 0, 0, 0, &idetape_name_proc_open, 0, &single_release, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
1862 ide_proc_entry_t idetape_proc[3U] = { { "capacity", 33060U, &ide_capacity_proc_fops }, { "name", 33060U, &idetape_name_proc_fops } };
1868 ide_proc_entry_t * ide_tape_proc_entries(ide_drive_t *drive);
1873 const struct ide_proc_devset * ide_tape_proc_devsets(ide_drive_t *drive);
1879 int ide_tape_probe(ide_drive_t *drive);
1881 struct ide_driver idetape_driver = { "1.20", &idetape_do_request, { "ide-tape", &ide_bus_type, &__this_module, 0, (_Bool)0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, &ide_tape_probe, &ide_tape_remove, 0, 0, &ide_tape_proc_entries, &ide_tape_proc_devsets };
1898 const struct file_operations idetape_fops = { &__this_module, &noop_llseek, &idetape_chrdev_read, &idetape_chrdev_write, 0, 0, 0, 0, 0, &idetape_chrdev_ioctl, 0, 0, &idetape_chrdev_open, 0, &idetape_chrdev_release, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
1908 int idetape_open(struct block_device *bdev, fmode_t mode);
1922 void idetape_release(struct gendisk *disk, fmode_t mode);
1931 int idetape_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg);
1947 const struct block_device_operations idetape_block_ops = { &idetape_open, &idetape_release, 0, &idetape_ioctl, 0, 0, 0, 0, 0, 0, 0, 0, &__this_module, 0 };
2029 void idetape_exit();
2036 int idetape_init();
2091 void ldv_check_final_state();
2094 void ldv_check_return_value(int);
2097 void ldv_check_return_value_probe(int);
2100 void ldv_initialize();
2103 void ldv_handler_precall();
2106 int nondet_int();
2109 int LDV_IN_INTERRUPT = 0;
2112 void ldv_main0_sequence_infinite_withcheck_stateful();
10 void ldv_error();
20 void ldv_stop();
25 int ldv_undef_int();
26 void * ldv_undef_ptr();
39 int ldv_undef_int_nonpositive();
14 void * ldv_err_ptr(long error);
21 long int ldv_ptr_err(const void *ptr);
28 bool ldv_is_err_or_null(const void *ptr);
28 int ldv_usb_gadget_class = 0;
31 int ldv_usb_gadget_chrdev = 0;
34 int ldv_usb_gadget = 0;
61 int ldv_register_class();
124 int ldv_register_chrdev_region();
158 int ldv_register_usb_gadget();
179 void ldv_unregister_usb_gadget();
return ;
}
-entry_point
{
2114 struct inode *var_group1;
2115 struct file *var_group2;
2116 int res_idetape_name_proc_open_50;
2117 ide_drive_t *var_ide_tape_probe_56_p0;
2118 int res_ide_tape_probe_56;
2119 ide_drive_t *var_ide_tape_remove_47_p0;
2120 ide_drive_t *var_idetape_do_request_10_p0;
2121 struct request *var_group3;
2122 unsigned long var_idetape_do_request_10_p2;
2123 ide_drive_t *var_ide_tape_proc_entries_51_p0;
2124 ide_drive_t *var_ide_tape_proc_devsets_52_p0;
2125 char *var_idetape_chrdev_read_30_p1;
2126 unsigned long var_idetape_chrdev_read_30_p2;
2127 loff_t *var_idetape_chrdev_read_30_p3;
2128 long res_idetape_chrdev_read_30;
2129 const char *var_idetape_chrdev_write_31_p1;
2130 unsigned long var_idetape_chrdev_write_31_p2;
2131 loff_t *var_idetape_chrdev_write_31_p3;
2132 long res_idetape_chrdev_write_31;
2133 unsigned int var_idetape_chrdev_ioctl_35_p1;
2134 unsigned long var_idetape_chrdev_ioctl_35_p2;
2135 int res_idetape_chrdev_open_37;
2136 struct block_device *var_group4;
2137 unsigned int var_idetape_open_53_p1;
2138 int res_idetape_open_53;
2139 struct gendisk *var_group5;
2140 unsigned int var_idetape_release_54_p1;
2141 unsigned int var_idetape_ioctl_55_p1;
2142 unsigned int var_idetape_ioctl_55_p2;
2143 unsigned long var_idetape_ioctl_55_p3;
2144 int ldv_s_idetape_name_proc_fops_file_operations;
2145 int ldv_s_idetape_driver_ide_driver;
2146 int ldv_s_idetape_fops_file_operations;
2147 int ldv_s_idetape_block_ops_block_device_operations;
2148 int tmp;
2149 int tmp___0;
2150 int tmp___1;
3068 ldv_s_idetape_name_proc_fops_file_operations = 0;
3070 ldv_s_idetape_driver_ide_driver = 0;
3073 ldv_s_idetape_fops_file_operations = 0;
3076 ldv_s_idetape_block_ops_block_device_operations = 0;
2996 LDV_IN_INTERRUPT = 1;
3005 ldv_initialize() { /* Function call is skipped due to function is undefined */}
3065 ldv_handler_precall() { /* Function call is skipped due to function is undefined */}
3066 -idetape_init()
{
2038 int error;
2039 void *tmp;
2040 _Bool tmp___0;
2041 int tmp___1;
2038 error = 1;
2039 -ldv_create_class()
{
40 void *is_got;
43 is_got = ldv_undef_ptr() { /* Function call is skipped due to function is undefined */}
46 assume(((unsigned long)is_got) <= ((unsigned long)((void *)2012)));
49 assume(!(ldv_usb_gadget != 0));
51 assume(!(ldv_usb_gadget_class != 0));
53 ldv_usb_gadget_class = 1;
57 return is_got;;
}
2039 idetape_sysfs_class = (struct class *)tmp;
2040 -IS_ERR((const void *)idetape_sysfs_class)
{
36 _Bool tmp;
37 -ldv_is_err(ptr)
{
10 return ((unsigned long)ptr) > 2012UL;;
}
37 return tmp;;
}
2040 assume(((int)tmp___0) == 0);
2047 -register_chrdev(37U, "ht", &idetape_fops)
{
48 int ldv_func_res;
49 int tmp;
50 int tmp___0;
50 -ldv_register_chrdev_5(major, name, fops)
{
2437 int tmp;
2437 tmp = __register_chrdev(major, 0U, 256U, name, fops) { /* Function call is skipped due to function is undefined */}
2437 return tmp;;
}
50 ldv_func_res = tmp;
52 -ldv_register_chrdev((int)major)
{
97 int is_reg;
100 -ldv_undef_int_nonpositive()
{
41 int ret;
42 int tmp;
41 tmp = ldv_undef_int() { /* Function call is skipped due to function is undefined */}
41 ret = tmp;
43 assume(!(ret > 0));
45 return ret;;
}
103 assume(is_reg == 0);
106 assume(!(ldv_usb_gadget != 0));
108 assume(!(ldv_usb_gadget_chrdev != 0));
110 ldv_usb_gadget_chrdev = 1;
111 assume(!(major == 0));
120 return is_reg;;
}
52 return tmp___0;;
}
2047 assume(!(tmp___1 != 0));
2054 error = driver_register(&(idetape_driver.gen_driver)) { /* Function call is skipped due to function is undefined */}
2055 assume(error != 0);
2056 goto out_free_driver;
2059 out_free_driver:;
2061 driver_unregister(&(idetape_driver.gen_driver)) { /* Function call is skipped due to function is undefined */}
2062 out_free_class:;
2063 -ldv_class_destroy_8(idetape_sysfs_class)
{
76 class_destroy(ldv_func_arg1) { /* Function call is skipped due to function is undefined */}
78 -ldv_unregister_class()
{
87 assume(!(ldv_usb_gadget != 0));
89 assume(!(ldv_usb_gadget_class != 1));
91 ldv_usb_gadget_class = 0;
92 return ;;
}
79 return ;;
}
2064 out:;
2065 return error;;
}
3066 assume(tmp != 0);
3067 goto ldv_final;
4191 -ldv_check_final_state()
{
191 assume(!(ldv_usb_gadget_class != 0));
193 assume(ldv_usb_gadget_chrdev != 0);
193 -ldv_error()
{
15 LDV_ERROR:;
}
}
}
Source code
1 2 /* 3 * IDE ATAPI streaming tape driver. 4 * 5 * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> 6 * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz 7 * 8 * This driver was constructed as a student project in the software laboratory 9 * of the faculty of electrical engineering in the Technion - Israel's 10 * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. 11 * 12 * It is hereby placed under the terms of the GNU general public license. 13 * (See linux/COPYING). 14 * 15 * For a historical changelog see 16 * Documentation/ide/ChangeLog.ide-tape.1995-2002 17 */ 18 19 #define DRV_NAME "ide-tape" 20 21 #define IDETAPE_VERSION "1.20" 22 23 #include <linux/module.h> 24 #include <linux/types.h> 25 #include <linux/string.h> 26 #include <linux/kernel.h> 27 #include <linux/delay.h> 28 #include <linux/timer.h> 29 #include <linux/mm.h> 30 #include <linux/interrupt.h> 31 #include <linux/jiffies.h> 32 #include <linux/major.h> 33 #include <linux/errno.h> 34 #include <linux/genhd.h> 35 #include <linux/seq_file.h> 36 #include <linux/slab.h> 37 #include <linux/pci.h> 38 #include <linux/ide.h> 39 #include <linux/completion.h> 40 #include <linux/bitops.h> 41 #include <linux/mutex.h> 42 #include <scsi/scsi.h> 43 44 #include <asm/byteorder.h> 45 #include <linux/uaccess.h> 46 #include <linux/io.h> 47 #include <asm/unaligned.h> 48 #include <linux/mtio.h> 49 50 /* define to see debug info */ 51 #undef IDETAPE_DEBUG_LOG 52 53 #ifdef IDETAPE_DEBUG_LOG 54 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 55 #else 56 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 57 #endif 58 59 /**************************** Tunable parameters *****************************/ 60 /* 61 * After each failed packet command we issue a request sense command and retry 62 * the packet command IDETAPE_MAX_PC_RETRIES times. 63 * 64 * Setting IDETAPE_MAX_PC_RETRIES to 0 will disable retries. 65 */ 66 #define IDETAPE_MAX_PC_RETRIES 3 67 68 /* 69 * The following parameter is used to select the point in the internal tape fifo 70 * in which we will start to refill the buffer. Decreasing the following 71 * parameter will improve the system's latency and interactive response, while 72 * using a high value might improve system throughput. 73 */ 74 #define IDETAPE_FIFO_THRESHOLD 2 75 76 /* 77 * DSC polling parameters. 78 * 79 * Polling for DSC (a single bit in the status register) is a very important 80 * function in ide-tape. There are two cases in which we poll for DSC: 81 * 82 * 1. Before a read/write packet command, to ensure that we can transfer data 83 * from/to the tape's data buffers, without causing an actual media access. 84 * In case the tape is not ready yet, we take out our request from the device 85 * request queue, so that ide.c could service requests from the other device 86 * on the same interface in the meantime. 87 * 88 * 2. After the successful initialization of a "media access packet command", 89 * which is a command that can take a long time to complete (the interval can 90 * range from several seconds to even an hour). Again, we postpone our request 91 * in the middle to free the bus for the other device. The polling frequency 92 * here should be lower than the read/write frequency since those media access 93 * commands are slow. We start from a "fast" frequency - IDETAPE_DSC_MA_FAST 94 * (1 second), and if we don't receive DSC after IDETAPE_DSC_MA_THRESHOLD 95 * (5 min), we switch it to a lower frequency - IDETAPE_DSC_MA_SLOW (1 min). 96 * 97 * We also set a timeout for the timer, in case something goes wrong. The 98 * timeout should be longer then the maximum execution time of a tape operation. 99 */ 100 101 /* DSC timings. */ 102 #define IDETAPE_DSC_RW_MIN 5*HZ/100 /* 50 msec */ 103 #define IDETAPE_DSC_RW_MAX 40*HZ/100 /* 400 msec */ 104 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ /* 2 minutes */ 105 #define IDETAPE_DSC_MA_FAST 2*HZ /* 2 seconds */ 106 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ /* 5 minutes */ 107 #define IDETAPE_DSC_MA_SLOW 30*HZ /* 30 seconds */ 108 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ /* 2 hours */ 109 110 /*************************** End of tunable parameters ***********************/ 111 112 /* tape directions */ 113 enum { 114 IDETAPE_DIR_NONE = (1 << 0), 115 IDETAPE_DIR_READ = (1 << 1), 116 IDETAPE_DIR_WRITE = (1 << 2), 117 }; 118 119 /* Tape door status */ 120 #define DOOR_UNLOCKED 0 121 #define DOOR_LOCKED 1 122 #define DOOR_EXPLICITLY_LOCKED 2 123 124 /* Some defines for the SPACE command */ 125 #define IDETAPE_SPACE_OVER_FILEMARK 1 126 #define IDETAPE_SPACE_TO_EOD 3 127 128 /* Some defines for the LOAD UNLOAD command */ 129 #define IDETAPE_LU_LOAD_MASK 1 130 #define IDETAPE_LU_RETENSION_MASK 2 131 #define IDETAPE_LU_EOT_MASK 4 132 133 /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ 134 #define IDETAPE_BLOCK_DESCRIPTOR 0 135 #define IDETAPE_CAPABILITIES_PAGE 0x2a 136 137 /* 138 * Most of our global data which we need to save even as we leave the driver due 139 * to an interrupt or a timer event is stored in the struct defined below. 140 */ 141 typedef struct ide_tape_obj { 142 ide_drive_t *drive; 143 struct ide_driver *driver; 144 struct gendisk *disk; 145 struct device dev; 146 147 /* used by REQ_IDETAPE_{READ,WRITE} requests */ 148 struct ide_atapi_pc queued_pc; 149 150 /* 151 * DSC polling variables. 152 * 153 * While polling for DSC we use postponed_rq to postpone the current 154 * request so that ide.c will be able to service pending requests on the 155 * other device. Note that at most we will have only one DSC (usually 156 * data transfer) request in the device request queue. 157 */ 158 bool postponed_rq; 159 160 /* The time in which we started polling for DSC */ 161 unsigned long dsc_polling_start; 162 /* Timer used to poll for dsc */ 163 struct timer_list dsc_timer; 164 /* Read/Write dsc polling frequency */ 165 unsigned long best_dsc_rw_freq; 166 unsigned long dsc_poll_freq; 167 unsigned long dsc_timeout; 168 169 /* Read position information */ 170 u8 partition; 171 /* Current block */ 172 unsigned int first_frame; 173 174 /* Last error information */ 175 u8 sense_key, asc, ascq; 176 177 /* Character device operation */ 178 unsigned int minor; 179 /* device name */ 180 char name[4]; 181 /* Current character device data transfer direction */ 182 u8 chrdev_dir; 183 184 /* tape block size, usually 512 or 1024 bytes */ 185 unsigned short blk_size; 186 int user_bs_factor; 187 188 /* Copy of the tape's Capabilities and Mechanical Page */ 189 u8 caps[20]; 190 191 /* 192 * Active data transfer request parameters. 193 * 194 * At most, there is only one ide-tape originated data transfer request 195 * in the device request queue. This allows ide.c to easily service 196 * requests from the other device when we postpone our active request. 197 */ 198 199 /* Data buffer size chosen based on the tape's recommendation */ 200 int buffer_size; 201 /* Staging buffer of buffer_size bytes */ 202 void *buf; 203 /* The read/write cursor */ 204 void *cur; 205 /* The number of valid bytes in buf */ 206 size_t valid; 207 208 /* Measures average tape speed */ 209 unsigned long avg_time; 210 int avg_size; 211 int avg_speed; 212 213 /* the door is currently locked */ 214 int door_locked; 215 /* the tape hardware is write protected */ 216 char drv_write_prot; 217 /* the tape is write protected (hardware or opened as read-only) */ 218 char write_prot; 219 } idetape_tape_t; 220 221 static DEFINE_MUTEX(ide_tape_mutex); 222 static DEFINE_MUTEX(idetape_ref_mutex); 223 224 static DEFINE_MUTEX(idetape_chrdev_mutex); 225 226 static struct class *idetape_sysfs_class; 227 228 static void ide_tape_release(struct device *); 229 230 static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; 231 232 static struct ide_tape_obj *ide_tape_get(struct gendisk *disk, bool cdev, 233 unsigned int i) 234 { 235 struct ide_tape_obj *tape = NULL; 236 237 mutex_lock(&idetape_ref_mutex); 238 239 if (cdev) 240 tape = idetape_devs[i]; 241 else 242 tape = ide_drv_g(disk, ide_tape_obj); 243 244 if (tape) { 245 if (ide_device_get(tape->drive)) 246 tape = NULL; 247 else 248 get_device(&tape->dev); 249 } 250 251 mutex_unlock(&idetape_ref_mutex); 252 return tape; 253 } 254 255 static void ide_tape_put(struct ide_tape_obj *tape) 256 { 257 ide_drive_t *drive = tape->drive; 258 259 mutex_lock(&idetape_ref_mutex); 260 put_device(&tape->dev); 261 ide_device_put(drive); 262 mutex_unlock(&idetape_ref_mutex); 263 } 264 265 /* 266 * called on each failed packet command retry to analyze the request sense. We 267 * currently do not utilize this information. 268 */ 269 static void idetape_analyze_error(ide_drive_t *drive) 270 { 271 idetape_tape_t *tape = drive->driver_data; 272 struct ide_atapi_pc *pc = drive->failed_pc; 273 struct request *rq = drive->hwif->rq; 274 u8 *sense = bio_data(rq->bio); 275 276 tape->sense_key = sense[2] & 0xF; 277 tape->asc = sense[12]; 278 tape->ascq = sense[13]; 279 280 ide_debug_log(IDE_DBG_FUNC, 281 "cmd: 0x%x, sense key = %x, asc = %x, ascq = %x", 282 rq->cmd[0], tape->sense_key, tape->asc, tape->ascq); 283 284 /* correct remaining bytes to transfer */ 285 if (pc->flags & PC_FLAG_DMA_ERROR) 286 rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); 287 288 /* 289 * If error was the result of a zero-length read or write command, 290 * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives 291 * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. 292 */ 293 if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6) 294 /* length == 0 */ 295 && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { 296 if (tape->sense_key == 5) { 297 /* don't report an error, everything's ok */ 298 pc->error = 0; 299 /* don't retry read/write */ 300 pc->flags |= PC_FLAG_ABORT; 301 } 302 } 303 if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { 304 pc->error = IDE_DRV_ERROR_FILEMARK; 305 pc->flags |= PC_FLAG_ABORT; 306 } 307 if (pc->c[0] == WRITE_6) { 308 if ((sense[2] & 0x40) || (tape->sense_key == 0xd 309 && tape->asc == 0x0 && tape->ascq == 0x2)) { 310 pc->error = IDE_DRV_ERROR_EOD; 311 pc->flags |= PC_FLAG_ABORT; 312 } 313 } 314 if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { 315 if (tape->sense_key == 8) { 316 pc->error = IDE_DRV_ERROR_EOD; 317 pc->flags |= PC_FLAG_ABORT; 318 } 319 if (!(pc->flags & PC_FLAG_ABORT) && 320 (blk_rq_bytes(rq) - rq->resid_len)) 321 pc->retries = IDETAPE_MAX_PC_RETRIES + 1; 322 } 323 } 324 325 static void ide_tape_handle_dsc(ide_drive_t *); 326 327 static int ide_tape_callback(ide_drive_t *drive, int dsc) 328 { 329 idetape_tape_t *tape = drive->driver_data; 330 struct ide_atapi_pc *pc = drive->pc; 331 struct request *rq = drive->hwif->rq; 332 int uptodate = pc->error ? 0 : 1; 333 int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; 334 335 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc: %d, err: %d", rq->cmd[0], 336 dsc, err); 337 338 if (dsc) 339 ide_tape_handle_dsc(drive); 340 341 if (drive->failed_pc == pc) 342 drive->failed_pc = NULL; 343 344 if (pc->c[0] == REQUEST_SENSE) { 345 if (uptodate) 346 idetape_analyze_error(drive); 347 else 348 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " 349 "itself - Aborting request!\n"); 350 } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { 351 unsigned int blocks = 352 (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; 353 354 tape->avg_size += blocks * tape->blk_size; 355 356 if (time_after_eq(jiffies, tape->avg_time + HZ)) { 357 tape->avg_speed = tape->avg_size * HZ / 358 (jiffies - tape->avg_time) / 1024; 359 tape->avg_size = 0; 360 tape->avg_time = jiffies; 361 } 362 363 tape->first_frame += blocks; 364 365 if (pc->error) { 366 uptodate = 0; 367 err = pc->error; 368 } 369 } 370 rq->errors = err; 371 372 return uptodate; 373 } 374 375 /* 376 * Postpone the current request so that ide.c will be able to service requests 377 * from another device on the same port while we are polling for DSC. 378 */ 379 static void ide_tape_stall_queue(ide_drive_t *drive) 380 { 381 idetape_tape_t *tape = drive->driver_data; 382 383 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu", 384 drive->hwif->rq->cmd[0], tape->dsc_poll_freq); 385 386 tape->postponed_rq = true; 387 388 ide_stall_queue(drive, tape->dsc_poll_freq); 389 } 390 391 static void ide_tape_handle_dsc(ide_drive_t *drive) 392 { 393 idetape_tape_t *tape = drive->driver_data; 394 395 /* Media access command */ 396 tape->dsc_polling_start = jiffies; 397 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; 398 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; 399 /* Allow ide.c to handle other requests */ 400 ide_tape_stall_queue(drive); 401 } 402 403 /* 404 * Packet Command Interface 405 * 406 * The current Packet Command is available in drive->pc, and will not change 407 * until we finish handling it. Each packet command is associated with a 408 * callback function that will be called when the command is finished. 409 * 410 * The handling will be done in three stages: 411 * 412 * 1. ide_tape_issue_pc will send the packet command to the drive, and will set 413 * the interrupt handler to ide_pc_intr. 414 * 415 * 2. On each interrupt, ide_pc_intr will be called. This step will be 416 * repeated until the device signals us that no more interrupts will be issued. 417 * 418 * 3. ATAPI Tape media access commands have immediate status with a delayed 419 * process. In case of a successful initiation of a media access packet command, 420 * the DSC bit will be set when the actual execution of the command is finished. 421 * Since the tape drive will not issue an interrupt, we have to poll for this 422 * event. In this case, we define the request as "low priority request" by 423 * setting rq_status to IDETAPE_RQ_POSTPONED, set a timer to poll for DSC and 424 * exit the driver. 425 * 426 * ide.c will then give higher priority to requests which originate from the 427 * other device, until will change rq_status to RQ_ACTIVE. 428 * 429 * 4. When the packet command is finished, it will be checked for errors. 430 * 431 * 5. In case an error was found, we queue a request sense packet command in 432 * front of the request queue and retry the operation up to 433 * IDETAPE_MAX_PC_RETRIES times. 434 * 435 * 6. In case no error was found, or we decided to give up and not to retry 436 * again, the callback function will be called and then we will handle the next 437 * request. 438 */ 439 440 static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, 441 struct ide_cmd *cmd, 442 struct ide_atapi_pc *pc) 443 { 444 idetape_tape_t *tape = drive->driver_data; 445 struct request *rq = drive->hwif->rq; 446 447 if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) 448 drive->failed_pc = pc; 449 450 /* Set the current packet command */ 451 drive->pc = pc; 452 453 if (pc->retries > IDETAPE_MAX_PC_RETRIES || 454 (pc->flags & PC_FLAG_ABORT)) { 455 456 /* 457 * We will "abort" retrying a packet command in case legitimate 458 * error code was received (crossing a filemark, or end of the 459 * media, for example). 460 */ 461 if (!(pc->flags & PC_FLAG_ABORT)) { 462 if (!(pc->c[0] == TEST_UNIT_READY && 463 tape->sense_key == 2 && tape->asc == 4 && 464 (tape->ascq == 1 || tape->ascq == 8))) { 465 printk(KERN_ERR "ide-tape: %s: I/O error, " 466 "pc = %2x, key = %2x, " 467 "asc = %2x, ascq = %2x\n", 468 tape->name, pc->c[0], 469 tape->sense_key, tape->asc, 470 tape->ascq); 471 } 472 /* Giving up */ 473 pc->error = IDE_DRV_ERROR_GENERAL; 474 } 475 476 drive->failed_pc = NULL; 477 drive->pc_callback(drive, 0); 478 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); 479 return ide_stopped; 480 } 481 ide_debug_log(IDE_DBG_SENSE, "retry #%d, cmd: 0x%02x", pc->retries, 482 pc->c[0]); 483 484 pc->retries++; 485 486 return ide_issue_pc(drive, cmd); 487 } 488 489 /* A mode sense command is used to "sense" tape parameters. */ 490 static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) 491 { 492 ide_init_pc(pc); 493 pc->c[0] = MODE_SENSE; 494 if (page_code != IDETAPE_BLOCK_DESCRIPTOR) 495 /* DBD = 1 - Don't return block descriptors */ 496 pc->c[1] = 8; 497 pc->c[2] = page_code; 498 /* 499 * Changed pc->c[3] to 0 (255 will at best return unused info). 500 * 501 * For SCSI this byte is defined as subpage instead of high byte 502 * of length and some IDE drives seem to interpret it this way 503 * and return an error when 255 is used. 504 */ 505 pc->c[3] = 0; 506 /* We will just discard data in that case */ 507 pc->c[4] = 255; 508 if (page_code == IDETAPE_BLOCK_DESCRIPTOR) 509 pc->req_xfer = 12; 510 else if (page_code == IDETAPE_CAPABILITIES_PAGE) 511 pc->req_xfer = 24; 512 else 513 pc->req_xfer = 50; 514 } 515 516 static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) 517 { 518 ide_hwif_t *hwif = drive->hwif; 519 idetape_tape_t *tape = drive->driver_data; 520 struct ide_atapi_pc *pc = drive->pc; 521 u8 stat; 522 523 stat = hwif->tp_ops->read_status(hwif); 524 525 if (stat & ATA_DSC) { 526 if (stat & ATA_ERR) { 527 /* Error detected */ 528 if (pc->c[0] != TEST_UNIT_READY) 529 printk(KERN_ERR "ide-tape: %s: I/O error, ", 530 tape->name); 531 /* Retry operation */ 532 ide_retry_pc(drive); 533 return ide_stopped; 534 } 535 pc->error = 0; 536 } else { 537 pc->error = IDE_DRV_ERROR_GENERAL; 538 drive->failed_pc = NULL; 539 } 540 drive->pc_callback(drive, 0); 541 return ide_stopped; 542 } 543 544 static void ide_tape_create_rw_cmd(idetape_tape_t *tape, 545 struct ide_atapi_pc *pc, struct request *rq, 546 u8 opcode) 547 { 548 unsigned int length = blk_rq_sectors(rq) / (tape->blk_size >> 9); 549 550 ide_init_pc(pc); 551 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); 552 pc->c[1] = 1; 553 554 if (blk_rq_bytes(rq) == tape->buffer_size) 555 pc->flags |= PC_FLAG_DMA_OK; 556 557 if (opcode == READ_6) 558 pc->c[0] = READ_6; 559 else if (opcode == WRITE_6) { 560 pc->c[0] = WRITE_6; 561 pc->flags |= PC_FLAG_WRITING; 562 } 563 564 memcpy(rq->cmd, pc->c, 12); 565 } 566 567 static ide_startstop_t idetape_do_request(ide_drive_t *drive, 568 struct request *rq, sector_t block) 569 { 570 ide_hwif_t *hwif = drive->hwif; 571 idetape_tape_t *tape = drive->driver_data; 572 struct ide_atapi_pc *pc = NULL; 573 struct ide_cmd cmd; 574 u8 stat; 575 576 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u", 577 rq->cmd[0], (unsigned long long)blk_rq_pos(rq), 578 blk_rq_sectors(rq)); 579 580 BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV || 581 rq->cmd_type == REQ_TYPE_ATA_SENSE)); 582 583 /* Retry a failed packet command */ 584 if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { 585 pc = drive->failed_pc; 586 goto out; 587 } 588 589 /* 590 * If the tape is still busy, postpone our request and service 591 * the other device meanwhile. 592 */ 593 stat = hwif->tp_ops->read_status(hwif); 594 595 if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && 596 (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) 597 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; 598 599 if (drive->dev_flags & IDE_DFLAG_POST_RESET) { 600 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; 601 drive->dev_flags &= ~IDE_DFLAG_POST_RESET; 602 } 603 604 if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && 605 !(stat & ATA_DSC)) { 606 if (!tape->postponed_rq) { 607 tape->dsc_polling_start = jiffies; 608 tape->dsc_poll_freq = tape->best_dsc_rw_freq; 609 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; 610 } else if (time_after(jiffies, tape->dsc_timeout)) { 611 printk(KERN_ERR "ide-tape: %s: DSC timeout\n", 612 tape->name); 613 if (rq->cmd[13] & REQ_IDETAPE_PC2) { 614 idetape_media_access_finished(drive); 615 return ide_stopped; 616 } else { 617 return ide_do_reset(drive); 618 } 619 } else if (time_after(jiffies, 620 tape->dsc_polling_start + 621 IDETAPE_DSC_MA_THRESHOLD)) 622 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; 623 ide_tape_stall_queue(drive); 624 return ide_stopped; 625 } else { 626 drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; 627 tape->postponed_rq = false; 628 } 629 630 if (rq->cmd[13] & REQ_IDETAPE_READ) { 631 pc = &tape->queued_pc; 632 ide_tape_create_rw_cmd(tape, pc, rq, READ_6); 633 goto out; 634 } 635 if (rq->cmd[13] & REQ_IDETAPE_WRITE) { 636 pc = &tape->queued_pc; 637 ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); 638 goto out; 639 } 640 if (rq->cmd[13] & REQ_IDETAPE_PC1) { 641 pc = (struct ide_atapi_pc *)rq->special; 642 rq->cmd[13] &= ~(REQ_IDETAPE_PC1); 643 rq->cmd[13] |= REQ_IDETAPE_PC2; 644 goto out; 645 } 646 if (rq->cmd[13] & REQ_IDETAPE_PC2) { 647 idetape_media_access_finished(drive); 648 return ide_stopped; 649 } 650 BUG(); 651 652 out: 653 /* prepare sense request for this command */ 654 ide_prep_sense(drive, rq); 655 656 memset(&cmd, 0, sizeof(cmd)); 657 658 if (rq_data_dir(rq)) 659 cmd.tf_flags |= IDE_TFLAG_WRITE; 660 661 cmd.rq = rq; 662 663 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); 664 ide_map_sg(drive, &cmd); 665 666 return ide_tape_issue_pc(drive, &cmd, pc); 667 } 668 669 /* 670 * Write a filemark if write_filemark=1. Flush the device buffers without 671 * writing a filemark otherwise. 672 */ 673 static void idetape_create_write_filemark_cmd(ide_drive_t *drive, 674 struct ide_atapi_pc *pc, int write_filemark) 675 { 676 ide_init_pc(pc); 677 pc->c[0] = WRITE_FILEMARKS; 678 pc->c[4] = write_filemark; 679 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 680 } 681 682 static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) 683 { 684 idetape_tape_t *tape = drive->driver_data; 685 struct gendisk *disk = tape->disk; 686 int load_attempted = 0; 687 688 /* Wait for the tape to become ready */ 689 set_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), &drive->atapi_flags); 690 timeout += jiffies; 691 while (time_before(jiffies, timeout)) { 692 if (ide_do_test_unit_ready(drive, disk) == 0) 693 return 0; 694 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) 695 || (tape->asc == 0x3A)) { 696 /* no media */ 697 if (load_attempted) 698 return -ENOMEDIUM; 699 ide_do_start_stop(drive, disk, IDETAPE_LU_LOAD_MASK); 700 load_attempted = 1; 701 /* not about to be ready */ 702 } else if (!(tape->sense_key == 2 && tape->asc == 4 && 703 (tape->ascq == 1 || tape->ascq == 8))) 704 return -EIO; 705 msleep(100); 706 } 707 return -EIO; 708 } 709 710 static int idetape_flush_tape_buffers(ide_drive_t *drive) 711 { 712 struct ide_tape_obj *tape = drive->driver_data; 713 struct ide_atapi_pc pc; 714 int rc; 715 716 idetape_create_write_filemark_cmd(drive, &pc, 0); 717 rc = ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0); 718 if (rc) 719 return rc; 720 idetape_wait_ready(drive, 60 * 5 * HZ); 721 return 0; 722 } 723 724 static int ide_tape_read_position(ide_drive_t *drive) 725 { 726 idetape_tape_t *tape = drive->driver_data; 727 struct ide_atapi_pc pc; 728 u8 buf[20]; 729 730 ide_debug_log(IDE_DBG_FUNC, "enter"); 731 732 /* prep cmd */ 733 ide_init_pc(&pc); 734 pc.c[0] = READ_POSITION; 735 pc.req_xfer = 20; 736 737 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) 738 return -1; 739 740 if (!pc.error) { 741 ide_debug_log(IDE_DBG_FUNC, "BOP - %s", 742 (buf[0] & 0x80) ? "Yes" : "No"); 743 ide_debug_log(IDE_DBG_FUNC, "EOP - %s", 744 (buf[0] & 0x40) ? "Yes" : "No"); 745 746 if (buf[0] & 0x4) { 747 printk(KERN_INFO "ide-tape: Block location is unknown" 748 "to the tape\n"); 749 clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), 750 &drive->atapi_flags); 751 return -1; 752 } else { 753 ide_debug_log(IDE_DBG_FUNC, "Block Location: %u", 754 be32_to_cpup((__be32 *)&buf[4])); 755 756 tape->partition = buf[1]; 757 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); 758 set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), 759 &drive->atapi_flags); 760 } 761 } 762 763 return tape->first_frame; 764 } 765 766 static void idetape_create_locate_cmd(ide_drive_t *drive, 767 struct ide_atapi_pc *pc, 768 unsigned int block, u8 partition, int skip) 769 { 770 ide_init_pc(pc); 771 pc->c[0] = POSITION_TO_ELEMENT; 772 pc->c[1] = 2; 773 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); 774 pc->c[8] = partition; 775 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 776 } 777 778 static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) 779 { 780 idetape_tape_t *tape = drive->driver_data; 781 782 if (tape->chrdev_dir != IDETAPE_DIR_READ) 783 return; 784 785 clear_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags); 786 tape->valid = 0; 787 if (tape->buf != NULL) { 788 kfree(tape->buf); 789 tape->buf = NULL; 790 } 791 792 tape->chrdev_dir = IDETAPE_DIR_NONE; 793 } 794 795 /* 796 * Position the tape to the requested block using the LOCATE packet command. 797 * A READ POSITION command is then issued to check where we are positioned. Like 798 * all higher level operations, we queue the commands at the tail of the request 799 * queue and wait for their completion. 800 */ 801 static int idetape_position_tape(ide_drive_t *drive, unsigned int block, 802 u8 partition, int skip) 803 { 804 idetape_tape_t *tape = drive->driver_data; 805 struct gendisk *disk = tape->disk; 806 int ret; 807 struct ide_atapi_pc pc; 808 809 if (tape->chrdev_dir == IDETAPE_DIR_READ) 810 __ide_tape_discard_merge_buffer(drive); 811 idetape_wait_ready(drive, 60 * 5 * HZ); 812 idetape_create_locate_cmd(drive, &pc, block, partition, skip); 813 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 814 if (ret) 815 return ret; 816 817 ret = ide_tape_read_position(drive); 818 if (ret < 0) 819 return ret; 820 return 0; 821 } 822 823 static void ide_tape_discard_merge_buffer(ide_drive_t *drive, 824 int restore_position) 825 { 826 idetape_tape_t *tape = drive->driver_data; 827 int seek, position; 828 829 __ide_tape_discard_merge_buffer(drive); 830 if (restore_position) { 831 position = ide_tape_read_position(drive); 832 seek = position > 0 ? position : 0; 833 if (idetape_position_tape(drive, seek, 0, 0)) { 834 printk(KERN_INFO "ide-tape: %s: position_tape failed in" 835 " %s\n", tape->name, __func__); 836 return; 837 } 838 } 839 } 840 841 /* 842 * Generate a read/write request for the block device interface and wait for it 843 * to be serviced. 844 */ 845 static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) 846 { 847 idetape_tape_t *tape = drive->driver_data; 848 struct request *rq; 849 int ret; 850 851 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, size: %d", cmd, size); 852 853 BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); 854 BUG_ON(size < 0 || size % tape->blk_size); 855 856 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 857 rq->cmd_type = REQ_TYPE_DRV_PRIV; 858 rq->cmd[13] = cmd; 859 rq->rq_disk = tape->disk; 860 rq->__sector = tape->first_frame; 861 862 if (size) { 863 ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size, 864 __GFP_RECLAIM); 865 if (ret) 866 goto out_put; 867 } 868 869 blk_execute_rq(drive->queue, tape->disk, rq, 0); 870 871 /* calculate the number of transferred bytes and update buffer state */ 872 size -= rq->resid_len; 873 tape->cur = tape->buf; 874 if (cmd == REQ_IDETAPE_READ) 875 tape->valid = size; 876 else 877 tape->valid = 0; 878 879 ret = size; 880 if (rq->errors == IDE_DRV_ERROR_GENERAL) 881 ret = -EIO; 882 out_put: 883 blk_put_request(rq); 884 return ret; 885 } 886 887 static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) 888 { 889 ide_init_pc(pc); 890 pc->c[0] = INQUIRY; 891 pc->c[4] = 254; 892 pc->req_xfer = 254; 893 } 894 895 static void idetape_create_rewind_cmd(ide_drive_t *drive, 896 struct ide_atapi_pc *pc) 897 { 898 ide_init_pc(pc); 899 pc->c[0] = REZERO_UNIT; 900 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 901 } 902 903 static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) 904 { 905 ide_init_pc(pc); 906 pc->c[0] = ERASE; 907 pc->c[1] = 1; 908 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 909 } 910 911 static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) 912 { 913 ide_init_pc(pc); 914 pc->c[0] = SPACE; 915 put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); 916 pc->c[1] = cmd; 917 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 918 } 919 920 static void ide_tape_flush_merge_buffer(ide_drive_t *drive) 921 { 922 idetape_tape_t *tape = drive->driver_data; 923 924 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { 925 printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer" 926 " but we are not writing.\n"); 927 return; 928 } 929 if (tape->buf) { 930 size_t aligned = roundup(tape->valid, tape->blk_size); 931 932 memset(tape->cur, 0, aligned - tape->valid); 933 idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, aligned); 934 kfree(tape->buf); 935 tape->buf = NULL; 936 } 937 tape->chrdev_dir = IDETAPE_DIR_NONE; 938 } 939 940 static int idetape_init_rw(ide_drive_t *drive, int dir) 941 { 942 idetape_tape_t *tape = drive->driver_data; 943 int rc; 944 945 BUG_ON(dir != IDETAPE_DIR_READ && dir != IDETAPE_DIR_WRITE); 946 947 if (tape->chrdev_dir == dir) 948 return 0; 949 950 if (tape->chrdev_dir == IDETAPE_DIR_READ) 951 ide_tape_discard_merge_buffer(drive, 1); 952 else if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 953 ide_tape_flush_merge_buffer(drive); 954 idetape_flush_tape_buffers(drive); 955 } 956 957 if (tape->buf || tape->valid) { 958 printk(KERN_ERR "ide-tape: valid should be 0 now\n"); 959 tape->valid = 0; 960 } 961 962 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); 963 if (!tape->buf) 964 return -ENOMEM; 965 tape->chrdev_dir = dir; 966 tape->cur = tape->buf; 967 968 /* 969 * Issue a 0 rw command to ensure that DSC handshake is 970 * switched from completion mode to buffer available mode. No 971 * point in issuing this if DSC overlap isn't supported, some 972 * drives (Seagate STT3401A) will return an error. 973 */ 974 if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { 975 int cmd = dir == IDETAPE_DIR_READ ? REQ_IDETAPE_READ 976 : REQ_IDETAPE_WRITE; 977 978 rc = idetape_queue_rw_tail(drive, cmd, 0); 979 if (rc < 0) { 980 kfree(tape->buf); 981 tape->buf = NULL; 982 tape->chrdev_dir = IDETAPE_DIR_NONE; 983 return rc; 984 } 985 } 986 987 return 0; 988 } 989 990 static void idetape_pad_zeros(ide_drive_t *drive, int bcount) 991 { 992 idetape_tape_t *tape = drive->driver_data; 993 994 memset(tape->buf, 0, tape->buffer_size); 995 996 while (bcount) { 997 unsigned int count = min(tape->buffer_size, bcount); 998 999 idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, count); 1000 bcount -= count; 1001 } 1002 } 1003 1004 /* 1005 * Rewinds the tape to the Beginning Of the current Partition (BOP). We 1006 * currently support only one partition. 1007 */ 1008 static int idetape_rewind_tape(ide_drive_t *drive) 1009 { 1010 struct ide_tape_obj *tape = drive->driver_data; 1011 struct gendisk *disk = tape->disk; 1012 struct ide_atapi_pc pc; 1013 int ret; 1014 1015 ide_debug_log(IDE_DBG_FUNC, "enter"); 1016 1017 idetape_create_rewind_cmd(drive, &pc); 1018 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1019 if (ret) 1020 return ret; 1021 1022 ret = ide_tape_read_position(drive); 1023 if (ret < 0) 1024 return ret; 1025 return 0; 1026 } 1027 1028 /* mtio.h compatible commands should be issued to the chrdev interface. */ 1029 static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, 1030 unsigned long arg) 1031 { 1032 idetape_tape_t *tape = drive->driver_data; 1033 void __user *argp = (void __user *)arg; 1034 1035 struct idetape_config { 1036 int dsc_rw_frequency; 1037 int dsc_media_access_frequency; 1038 int nr_stages; 1039 } config; 1040 1041 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%04x", cmd); 1042 1043 switch (cmd) { 1044 case 0x0340: 1045 if (copy_from_user(&config, argp, sizeof(config))) 1046 return -EFAULT; 1047 tape->best_dsc_rw_freq = config.dsc_rw_frequency; 1048 break; 1049 case 0x0350: 1050 memset(&config, 0, sizeof(config)); 1051 config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; 1052 config.nr_stages = 1; 1053 if (copy_to_user(argp, &config, sizeof(config))) 1054 return -EFAULT; 1055 break; 1056 default: 1057 return -EIO; 1058 } 1059 return 0; 1060 } 1061 1062 static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, 1063 int mt_count) 1064 { 1065 idetape_tape_t *tape = drive->driver_data; 1066 struct gendisk *disk = tape->disk; 1067 struct ide_atapi_pc pc; 1068 int retval, count = 0; 1069 int sprev = !!(tape->caps[4] & 0x20); 1070 1071 1072 ide_debug_log(IDE_DBG_FUNC, "mt_op: %d, mt_count: %d", mt_op, mt_count); 1073 1074 if (mt_count == 0) 1075 return 0; 1076 if (MTBSF == mt_op || MTBSFM == mt_op) { 1077 if (!sprev) 1078 return -EIO; 1079 mt_count = -mt_count; 1080 } 1081 1082 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 1083 tape->valid = 0; 1084 if (test_and_clear_bit(ilog2(IDE_AFLAG_FILEMARK), 1085 &drive->atapi_flags)) 1086 ++count; 1087 ide_tape_discard_merge_buffer(drive, 0); 1088 } 1089 1090 switch (mt_op) { 1091 case MTFSF: 1092 case MTBSF: 1093 idetape_create_space_cmd(&pc, mt_count - count, 1094 IDETAPE_SPACE_OVER_FILEMARK); 1095 return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1096 case MTFSFM: 1097 case MTBSFM: 1098 if (!sprev) 1099 return -EIO; 1100 retval = idetape_space_over_filemarks(drive, MTFSF, 1101 mt_count - count); 1102 if (retval) 1103 return retval; 1104 count = (MTBSFM == mt_op ? 1 : -1); 1105 return idetape_space_over_filemarks(drive, MTFSF, count); 1106 default: 1107 printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", 1108 mt_op); 1109 return -EIO; 1110 } 1111 } 1112 1113 /* 1114 * Our character device read / write functions. 1115 * 1116 * The tape is optimized to maximize throughput when it is transferring an 1117 * integral number of the "continuous transfer limit", which is a parameter of 1118 * the specific tape (26kB on my particular tape, 32kB for Onstream). 1119 * 1120 * As of version 1.3 of the driver, the character device provides an abstract 1121 * continuous view of the media - any mix of block sizes (even 1 byte) on the 1122 * same backup/restore procedure is supported. The driver will internally 1123 * convert the requests to the recommended transfer unit, so that an unmatch 1124 * between the user's block size to the recommended size will only result in a 1125 * (slightly) increased driver overhead, but will no longer hit performance. 1126 * This is not applicable to Onstream. 1127 */ 1128 static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, 1129 size_t count, loff_t *ppos) 1130 { 1131 struct ide_tape_obj *tape = file->private_data; 1132 ide_drive_t *drive = tape->drive; 1133 size_t done = 0; 1134 ssize_t ret = 0; 1135 int rc; 1136 1137 ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); 1138 1139 if (tape->chrdev_dir != IDETAPE_DIR_READ) { 1140 if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) 1141 if (count > tape->blk_size && 1142 (count % tape->blk_size) == 0) 1143 tape->user_bs_factor = count / tape->blk_size; 1144 } 1145 1146 rc = idetape_init_rw(drive, IDETAPE_DIR_READ); 1147 if (rc < 0) 1148 return rc; 1149 1150 while (done < count) { 1151 size_t todo; 1152 1153 /* refill if staging buffer is empty */ 1154 if (!tape->valid) { 1155 /* If we are at a filemark, nothing more to read */ 1156 if (test_bit(ilog2(IDE_AFLAG_FILEMARK), 1157 &drive->atapi_flags)) 1158 break; 1159 /* read */ 1160 if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, 1161 tape->buffer_size) <= 0) 1162 break; 1163 } 1164 1165 /* copy out */ 1166 todo = min_t(size_t, count - done, tape->valid); 1167 if (copy_to_user(buf + done, tape->cur, todo)) 1168 ret = -EFAULT; 1169 1170 tape->cur += todo; 1171 tape->valid -= todo; 1172 done += todo; 1173 } 1174 1175 if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { 1176 idetape_space_over_filemarks(drive, MTFSF, 1); 1177 return 0; 1178 } 1179 1180 return ret ? ret : done; 1181 } 1182 1183 static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, 1184 size_t count, loff_t *ppos) 1185 { 1186 struct ide_tape_obj *tape = file->private_data; 1187 ide_drive_t *drive = tape->drive; 1188 size_t done = 0; 1189 ssize_t ret = 0; 1190 int rc; 1191 1192 /* The drive is write protected. */ 1193 if (tape->write_prot) 1194 return -EACCES; 1195 1196 ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); 1197 1198 /* Initialize write operation */ 1199 rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); 1200 if (rc < 0) 1201 return rc; 1202 1203 while (done < count) { 1204 size_t todo; 1205 1206 /* flush if staging buffer is full */ 1207 if (tape->valid == tape->buffer_size && 1208 idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, 1209 tape->buffer_size) <= 0) 1210 return rc; 1211 1212 /* copy in */ 1213 todo = min_t(size_t, count - done, 1214 tape->buffer_size - tape->valid); 1215 if (copy_from_user(tape->cur, buf + done, todo)) 1216 ret = -EFAULT; 1217 1218 tape->cur += todo; 1219 tape->valid += todo; 1220 done += todo; 1221 } 1222 1223 return ret ? ret : done; 1224 } 1225 1226 static int idetape_write_filemark(ide_drive_t *drive) 1227 { 1228 struct ide_tape_obj *tape = drive->driver_data; 1229 struct ide_atapi_pc pc; 1230 1231 /* Write a filemark */ 1232 idetape_create_write_filemark_cmd(drive, &pc, 1); 1233 if (ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0)) { 1234 printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); 1235 return -EIO; 1236 } 1237 return 0; 1238 } 1239 1240 /* 1241 * Called from idetape_chrdev_ioctl when the general mtio MTIOCTOP ioctl is 1242 * requested. 1243 * 1244 * Note: MTBSF and MTBSFM are not supported when the tape doesn't support 1245 * spacing over filemarks in the reverse direction. In this case, MTFSFM is also 1246 * usually not supported. 1247 * 1248 * The following commands are currently not supported: 1249 * 1250 * MTFSS, MTBSS, MTWSM, MTSETDENSITY, MTSETDRVBUFFER, MT_ST_BOOLEANS, 1251 * MT_ST_WRITE_THRESHOLD. 1252 */ 1253 static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) 1254 { 1255 idetape_tape_t *tape = drive->driver_data; 1256 struct gendisk *disk = tape->disk; 1257 struct ide_atapi_pc pc; 1258 int i, retval; 1259 1260 ide_debug_log(IDE_DBG_FUNC, "MTIOCTOP ioctl: mt_op: %d, mt_count: %d", 1261 mt_op, mt_count); 1262 1263 switch (mt_op) { 1264 case MTFSF: 1265 case MTFSFM: 1266 case MTBSF: 1267 case MTBSFM: 1268 if (!mt_count) 1269 return 0; 1270 return idetape_space_over_filemarks(drive, mt_op, mt_count); 1271 default: 1272 break; 1273 } 1274 1275 switch (mt_op) { 1276 case MTWEOF: 1277 if (tape->write_prot) 1278 return -EACCES; 1279 ide_tape_discard_merge_buffer(drive, 1); 1280 for (i = 0; i < mt_count; i++) { 1281 retval = idetape_write_filemark(drive); 1282 if (retval) 1283 return retval; 1284 } 1285 return 0; 1286 case MTREW: 1287 ide_tape_discard_merge_buffer(drive, 0); 1288 if (idetape_rewind_tape(drive)) 1289 return -EIO; 1290 return 0; 1291 case MTLOAD: 1292 ide_tape_discard_merge_buffer(drive, 0); 1293 return ide_do_start_stop(drive, disk, IDETAPE_LU_LOAD_MASK); 1294 case MTUNLOAD: 1295 case MTOFFL: 1296 /* 1297 * If door is locked, attempt to unlock before 1298 * attempting to eject. 1299 */ 1300 if (tape->door_locked) { 1301 if (!ide_set_media_lock(drive, disk, 0)) 1302 tape->door_locked = DOOR_UNLOCKED; 1303 } 1304 ide_tape_discard_merge_buffer(drive, 0); 1305 retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); 1306 if (!retval) 1307 clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), 1308 &drive->atapi_flags); 1309 return retval; 1310 case MTNOP: 1311 ide_tape_discard_merge_buffer(drive, 0); 1312 return idetape_flush_tape_buffers(drive); 1313 case MTRETEN: 1314 ide_tape_discard_merge_buffer(drive, 0); 1315 return ide_do_start_stop(drive, disk, 1316 IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); 1317 case MTEOM: 1318 idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); 1319 return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1320 case MTERASE: 1321 (void)idetape_rewind_tape(drive); 1322 idetape_create_erase_cmd(&pc); 1323 return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1324 case MTSETBLK: 1325 if (mt_count) { 1326 if (mt_count < tape->blk_size || 1327 mt_count % tape->blk_size) 1328 return -EIO; 1329 tape->user_bs_factor = mt_count / tape->blk_size; 1330 clear_bit(ilog2(IDE_AFLAG_DETECT_BS), 1331 &drive->atapi_flags); 1332 } else 1333 set_bit(ilog2(IDE_AFLAG_DETECT_BS), 1334 &drive->atapi_flags); 1335 return 0; 1336 case MTSEEK: 1337 ide_tape_discard_merge_buffer(drive, 0); 1338 return idetape_position_tape(drive, 1339 mt_count * tape->user_bs_factor, tape->partition, 0); 1340 case MTSETPART: 1341 ide_tape_discard_merge_buffer(drive, 0); 1342 return idetape_position_tape(drive, 0, mt_count, 0); 1343 case MTFSR: 1344 case MTBSR: 1345 case MTLOCK: 1346 retval = ide_set_media_lock(drive, disk, 1); 1347 if (retval) 1348 return retval; 1349 tape->door_locked = DOOR_EXPLICITLY_LOCKED; 1350 return 0; 1351 case MTUNLOCK: 1352 retval = ide_set_media_lock(drive, disk, 0); 1353 if (retval) 1354 return retval; 1355 tape->door_locked = DOOR_UNLOCKED; 1356 return 0; 1357 default: 1358 printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", 1359 mt_op); 1360 return -EIO; 1361 } 1362 } 1363 1364 /* 1365 * Our character device ioctls. General mtio.h magnetic io commands are 1366 * supported here, and not in the corresponding block interface. Our own 1367 * ide-tape ioctls are supported on both interfaces. 1368 */ 1369 static long do_idetape_chrdev_ioctl(struct file *file, 1370 unsigned int cmd, unsigned long arg) 1371 { 1372 struct ide_tape_obj *tape = file->private_data; 1373 ide_drive_t *drive = tape->drive; 1374 struct mtop mtop; 1375 struct mtget mtget; 1376 struct mtpos mtpos; 1377 int block_offset = 0, position = tape->first_frame; 1378 void __user *argp = (void __user *)arg; 1379 1380 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x", cmd); 1381 1382 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 1383 ide_tape_flush_merge_buffer(drive); 1384 idetape_flush_tape_buffers(drive); 1385 } 1386 if (cmd == MTIOCGET || cmd == MTIOCPOS) { 1387 block_offset = tape->valid / 1388 (tape->blk_size * tape->user_bs_factor); 1389 position = ide_tape_read_position(drive); 1390 if (position < 0) 1391 return -EIO; 1392 } 1393 switch (cmd) { 1394 case MTIOCTOP: 1395 if (copy_from_user(&mtop, argp, sizeof(struct mtop))) 1396 return -EFAULT; 1397 return idetape_mtioctop(drive, mtop.mt_op, mtop.mt_count); 1398 case MTIOCGET: 1399 memset(&mtget, 0, sizeof(struct mtget)); 1400 mtget.mt_type = MT_ISSCSI2; 1401 mtget.mt_blkno = position / tape->user_bs_factor - block_offset; 1402 mtget.mt_dsreg = 1403 ((tape->blk_size * tape->user_bs_factor) 1404 << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; 1405 1406 if (tape->drv_write_prot) 1407 mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); 1408 1409 if (copy_to_user(argp, &mtget, sizeof(struct mtget))) 1410 return -EFAULT; 1411 return 0; 1412 case MTIOCPOS: 1413 mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; 1414 if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) 1415 return -EFAULT; 1416 return 0; 1417 default: 1418 if (tape->chrdev_dir == IDETAPE_DIR_READ) 1419 ide_tape_discard_merge_buffer(drive, 1); 1420 return idetape_blkdev_ioctl(drive, cmd, arg); 1421 } 1422 } 1423 1424 static long idetape_chrdev_ioctl(struct file *file, 1425 unsigned int cmd, unsigned long arg) 1426 { 1427 long ret; 1428 mutex_lock(&ide_tape_mutex); 1429 ret = do_idetape_chrdev_ioctl(file, cmd, arg); 1430 mutex_unlock(&ide_tape_mutex); 1431 return ret; 1432 } 1433 1434 /* 1435 * Do a mode sense page 0 with block descriptor and if it succeeds set the tape 1436 * block size with the reported value. 1437 */ 1438 static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) 1439 { 1440 idetape_tape_t *tape = drive->driver_data; 1441 struct ide_atapi_pc pc; 1442 u8 buf[12]; 1443 1444 idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); 1445 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { 1446 printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); 1447 if (tape->blk_size == 0) { 1448 printk(KERN_WARNING "ide-tape: Cannot deal with zero " 1449 "block size, assuming 32k\n"); 1450 tape->blk_size = 32768; 1451 } 1452 return; 1453 } 1454 tape->blk_size = (buf[4 + 5] << 16) + 1455 (buf[4 + 6] << 8) + 1456 buf[4 + 7]; 1457 tape->drv_write_prot = (buf[2] & 0x80) >> 7; 1458 1459 ide_debug_log(IDE_DBG_FUNC, "blk_size: %d, write_prot: %d", 1460 tape->blk_size, tape->drv_write_prot); 1461 } 1462 1463 static int idetape_chrdev_open(struct inode *inode, struct file *filp) 1464 { 1465 unsigned int minor = iminor(inode), i = minor & ~0xc0; 1466 ide_drive_t *drive; 1467 idetape_tape_t *tape; 1468 int retval; 1469 1470 if (i >= MAX_HWIFS * MAX_DRIVES) 1471 return -ENXIO; 1472 1473 mutex_lock(&idetape_chrdev_mutex); 1474 1475 tape = ide_tape_get(NULL, true, i); 1476 if (!tape) { 1477 mutex_unlock(&idetape_chrdev_mutex); 1478 return -ENXIO; 1479 } 1480 1481 drive = tape->drive; 1482 filp->private_data = tape; 1483 1484 ide_debug_log(IDE_DBG_FUNC, "enter"); 1485 1486 /* 1487 * We really want to do nonseekable_open(inode, filp); here, but some 1488 * versions of tar incorrectly call lseek on tapes and bail out if that 1489 * fails. So we disallow pread() and pwrite(), but permit lseeks. 1490 */ 1491 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1492 1493 1494 if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { 1495 retval = -EBUSY; 1496 goto out_put_tape; 1497 } 1498 1499 retval = idetape_wait_ready(drive, 60 * HZ); 1500 if (retval) { 1501 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); 1502 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); 1503 goto out_put_tape; 1504 } 1505 1506 ide_tape_read_position(drive); 1507 if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags)) 1508 (void)idetape_rewind_tape(drive); 1509 1510 /* Read block size and write protect status from drive. */ 1511 ide_tape_get_bsize_from_bdesc(drive); 1512 1513 /* Set write protect flag if device is opened as read-only. */ 1514 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) 1515 tape->write_prot = 1; 1516 else 1517 tape->write_prot = tape->drv_write_prot; 1518 1519 /* Make sure drive isn't write protected if user wants to write. */ 1520 if (tape->write_prot) { 1521 if ((filp->f_flags & O_ACCMODE) == O_WRONLY || 1522 (filp->f_flags & O_ACCMODE) == O_RDWR) { 1523 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); 1524 retval = -EROFS; 1525 goto out_put_tape; 1526 } 1527 } 1528 1529 /* Lock the tape drive door so user can't eject. */ 1530 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 1531 if (!ide_set_media_lock(drive, tape->disk, 1)) { 1532 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) 1533 tape->door_locked = DOOR_LOCKED; 1534 } 1535 } 1536 mutex_unlock(&idetape_chrdev_mutex); 1537 1538 return 0; 1539 1540 out_put_tape: 1541 ide_tape_put(tape); 1542 1543 mutex_unlock(&idetape_chrdev_mutex); 1544 1545 return retval; 1546 } 1547 1548 static void idetape_write_release(ide_drive_t *drive, unsigned int minor) 1549 { 1550 idetape_tape_t *tape = drive->driver_data; 1551 1552 ide_tape_flush_merge_buffer(drive); 1553 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); 1554 if (tape->buf != NULL) { 1555 idetape_pad_zeros(drive, tape->blk_size * 1556 (tape->user_bs_factor - 1)); 1557 kfree(tape->buf); 1558 tape->buf = NULL; 1559 } 1560 idetape_write_filemark(drive); 1561 idetape_flush_tape_buffers(drive); 1562 idetape_flush_tape_buffers(drive); 1563 } 1564 1565 static int idetape_chrdev_release(struct inode *inode, struct file *filp) 1566 { 1567 struct ide_tape_obj *tape = filp->private_data; 1568 ide_drive_t *drive = tape->drive; 1569 unsigned int minor = iminor(inode); 1570 1571 mutex_lock(&idetape_chrdev_mutex); 1572 1573 tape = drive->driver_data; 1574 1575 ide_debug_log(IDE_DBG_FUNC, "enter"); 1576 1577 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) 1578 idetape_write_release(drive, minor); 1579 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 1580 if (minor < 128) 1581 ide_tape_discard_merge_buffer(drive, 1); 1582 } 1583 1584 if (minor < 128 && test_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), 1585 &drive->atapi_flags)) 1586 (void) idetape_rewind_tape(drive); 1587 1588 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 1589 if (tape->door_locked == DOOR_LOCKED) { 1590 if (!ide_set_media_lock(drive, tape->disk, 0)) 1591 tape->door_locked = DOOR_UNLOCKED; 1592 } 1593 } 1594 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); 1595 ide_tape_put(tape); 1596 1597 mutex_unlock(&idetape_chrdev_mutex); 1598 1599 return 0; 1600 } 1601 1602 static void idetape_get_inquiry_results(ide_drive_t *drive) 1603 { 1604 idetape_tape_t *tape = drive->driver_data; 1605 struct ide_atapi_pc pc; 1606 u8 pc_buf[256]; 1607 char fw_rev[4], vendor_id[8], product_id[16]; 1608 1609 idetape_create_inquiry_cmd(&pc); 1610 if (ide_queue_pc_tail(drive, tape->disk, &pc, pc_buf, pc.req_xfer)) { 1611 printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", 1612 tape->name); 1613 return; 1614 } 1615 memcpy(vendor_id, &pc_buf[8], 8); 1616 memcpy(product_id, &pc_buf[16], 16); 1617 memcpy(fw_rev, &pc_buf[32], 4); 1618 1619 ide_fixstring(vendor_id, 8, 0); 1620 ide_fixstring(product_id, 16, 0); 1621 ide_fixstring(fw_rev, 4, 0); 1622 1623 printk(KERN_INFO "ide-tape: %s <-> %s: %.8s %.16s rev %.4s\n", 1624 drive->name, tape->name, vendor_id, product_id, fw_rev); 1625 } 1626 1627 /* 1628 * Ask the tape about its various parameters. In particular, we will adjust our 1629 * data transfer buffer size to the recommended value as returned by the tape. 1630 */ 1631 static void idetape_get_mode_sense_results(ide_drive_t *drive) 1632 { 1633 idetape_tape_t *tape = drive->driver_data; 1634 struct ide_atapi_pc pc; 1635 u8 buf[24], *caps; 1636 u8 speed, max_speed; 1637 1638 idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); 1639 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { 1640 printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" 1641 " some default values\n"); 1642 tape->blk_size = 512; 1643 put_unaligned(52, (u16 *)&tape->caps[12]); 1644 put_unaligned(540, (u16 *)&tape->caps[14]); 1645 put_unaligned(6*52, (u16 *)&tape->caps[16]); 1646 return; 1647 } 1648 caps = buf + 4 + buf[3]; 1649 1650 /* convert to host order and save for later use */ 1651 speed = be16_to_cpup((__be16 *)&caps[14]); 1652 max_speed = be16_to_cpup((__be16 *)&caps[8]); 1653 1654 *(u16 *)&caps[8] = max_speed; 1655 *(u16 *)&caps[12] = be16_to_cpup((__be16 *)&caps[12]); 1656 *(u16 *)&caps[14] = speed; 1657 *(u16 *)&caps[16] = be16_to_cpup((__be16 *)&caps[16]); 1658 1659 if (!speed) { 1660 printk(KERN_INFO "ide-tape: %s: invalid tape speed " 1661 "(assuming 650KB/sec)\n", drive->name); 1662 *(u16 *)&caps[14] = 650; 1663 } 1664 if (!max_speed) { 1665 printk(KERN_INFO "ide-tape: %s: invalid max_speed " 1666 "(assuming 650KB/sec)\n", drive->name); 1667 *(u16 *)&caps[8] = 650; 1668 } 1669 1670 memcpy(&tape->caps, caps, 20); 1671 1672 /* device lacks locking support according to capabilities page */ 1673 if ((caps[6] & 1) == 0) 1674 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; 1675 1676 if (caps[7] & 0x02) 1677 tape->blk_size = 512; 1678 else if (caps[7] & 0x04) 1679 tape->blk_size = 1024; 1680 } 1681 1682 #ifdef CONFIG_IDE_PROC_FS 1683 #define ide_tape_devset_get(name, field) \ 1684 static int get_##name(ide_drive_t *drive) \ 1685 { \ 1686 idetape_tape_t *tape = drive->driver_data; \ 1687 return tape->field; \ 1688 } 1689 1690 #define ide_tape_devset_set(name, field) \ 1691 static int set_##name(ide_drive_t *drive, int arg) \ 1692 { \ 1693 idetape_tape_t *tape = drive->driver_data; \ 1694 tape->field = arg; \ 1695 return 0; \ 1696 } 1697 1698 #define ide_tape_devset_rw_field(_name, _field) \ 1699 ide_tape_devset_get(_name, _field) \ 1700 ide_tape_devset_set(_name, _field) \ 1701 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 1702 1703 #define ide_tape_devset_r_field(_name, _field) \ 1704 ide_tape_devset_get(_name, _field) \ 1705 IDE_DEVSET(_name, 0, get_##_name, NULL) 1706 1707 static int mulf_tdsc(ide_drive_t *drive) { return 1000; } 1708 static int divf_tdsc(ide_drive_t *drive) { return HZ; } 1709 static int divf_buffer(ide_drive_t *drive) { return 2; } 1710 static int divf_buffer_size(ide_drive_t *drive) { return 1024; } 1711 1712 ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); 1713 1714 ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); 1715 1716 ide_tape_devset_r_field(avg_speed, avg_speed); 1717 ide_tape_devset_r_field(speed, caps[14]); 1718 ide_tape_devset_r_field(buffer, caps[16]); 1719 ide_tape_devset_r_field(buffer_size, buffer_size); 1720 1721 static const struct ide_proc_devset idetape_settings[] = { 1722 __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), 1723 __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), 1724 __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), 1725 __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), 1726 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), 1727 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1728 mulf_tdsc, divf_tdsc), 1729 { NULL }, 1730 }; 1731 #endif 1732 1733 /* 1734 * The function below is called to: 1735 * 1736 * 1. Initialize our various state variables. 1737 * 2. Ask the tape for its capabilities. 1738 * 3. Allocate a buffer which will be used for data transfer. The buffer size 1739 * is chosen based on the recommendation which we received in step 2. 1740 * 1741 * Note that at this point ide.c already assigned us an irq, so that we can 1742 * queue requests here and wait for their completion. 1743 */ 1744 static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) 1745 { 1746 unsigned long t; 1747 int speed; 1748 int buffer_size; 1749 u16 *ctl = (u16 *)&tape->caps[12]; 1750 1751 ide_debug_log(IDE_DBG_FUNC, "minor: %d", minor); 1752 1753 drive->pc_callback = ide_tape_callback; 1754 1755 drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 1756 1757 if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { 1758 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", 1759 tape->name); 1760 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 1761 } 1762 1763 /* Seagate Travan drives do not support DSC overlap. */ 1764 if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401")) 1765 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 1766 1767 tape->minor = minor; 1768 tape->name[0] = 'h'; 1769 tape->name[1] = 't'; 1770 tape->name[2] = '0' + minor; 1771 tape->chrdev_dir = IDETAPE_DIR_NONE; 1772 1773 idetape_get_inquiry_results(drive); 1774 idetape_get_mode_sense_results(drive); 1775 ide_tape_get_bsize_from_bdesc(drive); 1776 tape->user_bs_factor = 1; 1777 tape->buffer_size = *ctl * tape->blk_size; 1778 while (tape->buffer_size > 0xffff) { 1779 printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); 1780 *ctl /= 2; 1781 tape->buffer_size = *ctl * tape->blk_size; 1782 } 1783 buffer_size = tape->buffer_size; 1784 1785 /* select the "best" DSC read/write polling freq */ 1786 speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); 1787 1788 t = (IDETAPE_FIFO_THRESHOLD * tape->buffer_size * HZ) / (speed * 1000); 1789 1790 /* 1791 * Ensure that the number we got makes sense; limit it within 1792 * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. 1793 */ 1794 tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN, 1795 IDETAPE_DSC_RW_MAX); 1796 printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " 1797 "%ums tDSC%s\n", 1798 drive->name, tape->name, *(u16 *)&tape->caps[14], 1799 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size, 1800 tape->buffer_size / 1024, 1801 jiffies_to_msecs(tape->best_dsc_rw_freq), 1802 (drive->dev_flags & IDE_DFLAG_USING_DMA) ? ", DMA" : ""); 1803 1804 ide_proc_register_driver(drive, tape->driver); 1805 } 1806 1807 static void ide_tape_remove(ide_drive_t *drive) 1808 { 1809 idetape_tape_t *tape = drive->driver_data; 1810 1811 ide_proc_unregister_driver(drive, tape->driver); 1812 device_del(&tape->dev); 1813 ide_unregister_region(tape->disk); 1814 1815 mutex_lock(&idetape_ref_mutex); 1816 put_device(&tape->dev); 1817 mutex_unlock(&idetape_ref_mutex); 1818 } 1819 1820 static void ide_tape_release(struct device *dev) 1821 { 1822 struct ide_tape_obj *tape = to_ide_drv(dev, ide_tape_obj); 1823 ide_drive_t *drive = tape->drive; 1824 struct gendisk *g = tape->disk; 1825 1826 BUG_ON(tape->valid); 1827 1828 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 1829 drive->driver_data = NULL; 1830 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); 1831 device_destroy(idetape_sysfs_class, 1832 MKDEV(IDETAPE_MAJOR, tape->minor + 128)); 1833 idetape_devs[tape->minor] = NULL; 1834 g->private_data = NULL; 1835 put_disk(g); 1836 kfree(tape); 1837 } 1838 1839 #ifdef CONFIG_IDE_PROC_FS 1840 static int idetape_name_proc_show(struct seq_file *m, void *v) 1841 { 1842 ide_drive_t *drive = (ide_drive_t *) m->private; 1843 idetape_tape_t *tape = drive->driver_data; 1844 1845 seq_printf(m, "%s\n", tape->name); 1846 return 0; 1847 } 1848 1849 static int idetape_name_proc_open(struct inode *inode, struct file *file) 1850 { 1851 return single_open(file, idetape_name_proc_show, PDE_DATA(inode)); 1852 } 1853 1854 static const struct file_operations idetape_name_proc_fops = { 1855 .owner = THIS_MODULE, 1856 .open = idetape_name_proc_open, 1857 .read = seq_read, 1858 .llseek = seq_lseek, 1859 .release = single_release, 1860 }; 1861 1862 static ide_proc_entry_t idetape_proc[] = { 1863 { "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops }, 1864 { "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops }, 1865 {} 1866 }; 1867 1868 static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) 1869 { 1870 return idetape_proc; 1871 } 1872 1873 static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive) 1874 { 1875 return idetape_settings; 1876 } 1877 #endif 1878 1879 static int ide_tape_probe(ide_drive_t *); 1880 1881 static struct ide_driver idetape_driver = { 1882 .gen_driver = { 1883 .owner = THIS_MODULE, 1884 .name = "ide-tape", 1885 .bus = &ide_bus_type, 1886 }, 1887 .probe = ide_tape_probe, 1888 .remove = ide_tape_remove, 1889 .version = IDETAPE_VERSION, 1890 .do_request = idetape_do_request, 1891 #ifdef CONFIG_IDE_PROC_FS 1892 .proc_entries = ide_tape_proc_entries, 1893 .proc_devsets = ide_tape_proc_devsets, 1894 #endif 1895 }; 1896 1897 /* Our character device supporting functions, passed to register_chrdev. */ 1898 static const struct file_operations idetape_fops = { 1899 .owner = THIS_MODULE, 1900 .read = idetape_chrdev_read, 1901 .write = idetape_chrdev_write, 1902 .unlocked_ioctl = idetape_chrdev_ioctl, 1903 .open = idetape_chrdev_open, 1904 .release = idetape_chrdev_release, 1905 .llseek = noop_llseek, 1906 }; 1907 1908 static int idetape_open(struct block_device *bdev, fmode_t mode) 1909 { 1910 struct ide_tape_obj *tape; 1911 1912 mutex_lock(&ide_tape_mutex); 1913 tape = ide_tape_get(bdev->bd_disk, false, 0); 1914 mutex_unlock(&ide_tape_mutex); 1915 1916 if (!tape) 1917 return -ENXIO; 1918 1919 return 0; 1920 } 1921 1922 static void idetape_release(struct gendisk *disk, fmode_t mode) 1923 { 1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 1925 1926 mutex_lock(&ide_tape_mutex); 1927 ide_tape_put(tape); 1928 mutex_unlock(&ide_tape_mutex); 1929 } 1930 1931 static int idetape_ioctl(struct block_device *bdev, fmode_t mode, 1932 unsigned int cmd, unsigned long arg) 1933 { 1934 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); 1935 ide_drive_t *drive = tape->drive; 1936 int err; 1937 1938 mutex_lock(&ide_tape_mutex); 1939 err = generic_ide_ioctl(drive, bdev, cmd, arg); 1940 if (err == -EINVAL) 1941 err = idetape_blkdev_ioctl(drive, cmd, arg); 1942 mutex_unlock(&ide_tape_mutex); 1943 1944 return err; 1945 } 1946 1947 static const struct block_device_operations idetape_block_ops = { 1948 .owner = THIS_MODULE, 1949 .open = idetape_open, 1950 .release = idetape_release, 1951 .ioctl = idetape_ioctl, 1952 }; 1953 1954 static int ide_tape_probe(ide_drive_t *drive) 1955 { 1956 idetape_tape_t *tape; 1957 struct gendisk *g; 1958 int minor; 1959 1960 ide_debug_log(IDE_DBG_FUNC, "enter"); 1961 1962 if (!strstr(DRV_NAME, drive->driver_req)) 1963 goto failed; 1964 1965 if (drive->media != ide_tape) 1966 goto failed; 1967 1968 if ((drive->dev_flags & IDE_DFLAG_ID_READ) && 1969 ide_check_atapi_device(drive, DRV_NAME) == 0) { 1970 printk(KERN_ERR "ide-tape: %s: not supported by this version of" 1971 " the driver\n", drive->name); 1972 goto failed; 1973 } 1974 tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); 1975 if (tape == NULL) { 1976 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", 1977 drive->name); 1978 goto failed; 1979 } 1980 1981 g = alloc_disk(1 << PARTN_BITS); 1982 if (!g) 1983 goto out_free_tape; 1984 1985 ide_init_disk(g, drive); 1986 1987 tape->dev.parent = &drive->gendev; 1988 tape->dev.release = ide_tape_release; 1989 dev_set_name(&tape->dev, "%s", dev_name(&drive->gendev)); 1990 1991 if (device_register(&tape->dev)) 1992 goto out_free_disk; 1993 1994 tape->drive = drive; 1995 tape->driver = &idetape_driver; 1996 tape->disk = g; 1997 1998 g->private_data = &tape->driver; 1999 2000 drive->driver_data = tape; 2001 2002 mutex_lock(&idetape_ref_mutex); 2003 for (minor = 0; idetape_devs[minor]; minor++) 2004 ; 2005 idetape_devs[minor] = tape; 2006 mutex_unlock(&idetape_ref_mutex); 2007 2008 idetape_setup(drive, tape, minor); 2009 2010 device_create(idetape_sysfs_class, &drive->gendev, 2011 MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name); 2012 device_create(idetape_sysfs_class, &drive->gendev, 2013 MKDEV(IDETAPE_MAJOR, minor + 128), NULL, 2014 "n%s", tape->name); 2015 2016 g->fops = &idetape_block_ops; 2017 ide_register_region(g); 2018 2019 return 0; 2020 2021 out_free_disk: 2022 put_disk(g); 2023 out_free_tape: 2024 kfree(tape); 2025 failed: 2026 return -ENODEV; 2027 } 2028 2029 static void __exit idetape_exit(void) 2030 { 2031 driver_unregister(&idetape_driver.gen_driver); 2032 class_destroy(idetape_sysfs_class); 2033 unregister_chrdev(IDETAPE_MAJOR, "ht"); 2034 } 2035 2036 static int __init idetape_init(void) 2037 { 2038 int error = 1; 2039 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape"); 2040 if (IS_ERR(idetape_sysfs_class)) { 2041 idetape_sysfs_class = NULL; 2042 printk(KERN_ERR "Unable to create sysfs class for ide tapes\n"); 2043 error = -EBUSY; 2044 goto out; 2045 } 2046 2047 if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { 2048 printk(KERN_ERR "ide-tape: Failed to register chrdev" 2049 " interface\n"); 2050 error = -EBUSY; 2051 goto out_free_class; 2052 } 2053 2054 error = driver_register(&idetape_driver.gen_driver); 2055 if (error) 2056 goto out_free_driver; 2057 2058 return 0; 2059 2060 out_free_driver: 2061 driver_unregister(&idetape_driver.gen_driver); 2062 out_free_class: 2063 class_destroy(idetape_sysfs_class); 2064 out: 2065 return error; 2066 } 2067 2068 MODULE_ALIAS("ide:*m-tape*"); 2069 module_init(idetape_init); 2070 module_exit(idetape_exit); 2071 MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR); 2072 MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); 2073 MODULE_LICENSE("GPL"); 2074 2075 2076 2077 2078 2079 /* LDV_COMMENT_BEGIN_MAIN */ 2080 #ifdef LDV_MAIN0_sequence_infinite_withcheck_stateful 2081 2082 /*###########################################################################*/ 2083 2084 /*############## Driver Environment Generator 0.2 output ####################*/ 2085 2086 /*###########################################################################*/ 2087 2088 2089 2090 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */ 2091 void ldv_check_final_state(void); 2092 2093 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 2094 void ldv_check_return_value(int res); 2095 2096 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 2097 void ldv_check_return_value_probe(int res); 2098 2099 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 2100 void ldv_initialize(void); 2101 2102 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 2103 void ldv_handler_precall(void); 2104 2105 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 2106 int nondet_int(void); 2107 2108 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 2109 int LDV_IN_INTERRUPT; 2110 2111 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 2112 void ldv_main0_sequence_infinite_withcheck_stateful(void) { 2113 2114 2115 2116 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 2117 /*============================= VARIABLE DECLARATION PART =============================*/ 2118 /** STRUCT: struct type: file_operations, struct name: idetape_name_proc_fops **/ 2119 /* content: static int idetape_name_proc_open(struct inode *inode, struct file *file)*/ 2120 /* LDV_COMMENT_BEGIN_PREP */ 2121 #define DRV_NAME "ide-tape" 2122 #define IDETAPE_VERSION "1.20" 2123 #undef IDETAPE_DEBUG_LOG 2124 #ifdef IDETAPE_DEBUG_LOG 2125 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2126 #else 2127 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2128 #endif 2129 #define IDETAPE_MAX_PC_RETRIES 3 2130 #define IDETAPE_FIFO_THRESHOLD 2 2131 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2132 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2133 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2134 #define IDETAPE_DSC_MA_FAST 2*HZ 2135 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2136 #define IDETAPE_DSC_MA_SLOW 30*HZ 2137 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2138 #define DOOR_UNLOCKED 0 2139 #define DOOR_LOCKED 1 2140 #define DOOR_EXPLICITLY_LOCKED 2 2141 #define IDETAPE_SPACE_OVER_FILEMARK 1 2142 #define IDETAPE_SPACE_TO_EOD 3 2143 #define IDETAPE_LU_LOAD_MASK 1 2144 #define IDETAPE_LU_RETENSION_MASK 2 2145 #define IDETAPE_LU_EOT_MASK 4 2146 #define IDETAPE_BLOCK_DESCRIPTOR 0 2147 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2148 #ifdef CONFIG_IDE_PROC_FS 2149 #define ide_tape_devset_get(name, field) \ 2150 static int get_##name(ide_drive_t *drive) \ 2151 { \ 2152 idetape_tape_t *tape = drive->driver_data; \ 2153 return tape->field; \ 2154 } 2155 #define ide_tape_devset_set(name, field) \ 2156 static int set_##name(ide_drive_t *drive, int arg) \ 2157 { \ 2158 idetape_tape_t *tape = drive->driver_data; \ 2159 tape->field = arg; \ 2160 return 0; \ 2161 } 2162 #define ide_tape_devset_rw_field(_name, _field) \ 2163 ide_tape_devset_get(_name, _field) \ 2164 ide_tape_devset_set(_name, _field) \ 2165 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2166 #define ide_tape_devset_r_field(_name, _field) \ 2167 ide_tape_devset_get(_name, _field) \ 2168 IDE_DEVSET(_name, 0, get_##_name, NULL) 2169 #endif 2170 #ifdef CONFIG_IDE_PROC_FS 2171 /* LDV_COMMENT_END_PREP */ 2172 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_name_proc_open" */ 2173 struct inode * var_group1; 2174 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_name_proc_open" */ 2175 struct file * var_group2; 2176 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_name_proc_open" */ 2177 static int res_idetape_name_proc_open_50; 2178 /* LDV_COMMENT_BEGIN_PREP */ 2179 #endif 2180 #ifdef CONFIG_IDE_PROC_FS 2181 #endif 2182 /* LDV_COMMENT_END_PREP */ 2183 2184 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 2185 /* content: static int ide_tape_probe(ide_drive_t *drive)*/ 2186 /* LDV_COMMENT_BEGIN_PREP */ 2187 #define DRV_NAME "ide-tape" 2188 #define IDETAPE_VERSION "1.20" 2189 #undef IDETAPE_DEBUG_LOG 2190 #ifdef IDETAPE_DEBUG_LOG 2191 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2192 #else 2193 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2194 #endif 2195 #define IDETAPE_MAX_PC_RETRIES 3 2196 #define IDETAPE_FIFO_THRESHOLD 2 2197 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2198 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2199 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2200 #define IDETAPE_DSC_MA_FAST 2*HZ 2201 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2202 #define IDETAPE_DSC_MA_SLOW 30*HZ 2203 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2204 #define DOOR_UNLOCKED 0 2205 #define DOOR_LOCKED 1 2206 #define DOOR_EXPLICITLY_LOCKED 2 2207 #define IDETAPE_SPACE_OVER_FILEMARK 1 2208 #define IDETAPE_SPACE_TO_EOD 3 2209 #define IDETAPE_LU_LOAD_MASK 1 2210 #define IDETAPE_LU_RETENSION_MASK 2 2211 #define IDETAPE_LU_EOT_MASK 4 2212 #define IDETAPE_BLOCK_DESCRIPTOR 0 2213 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2214 #ifdef CONFIG_IDE_PROC_FS 2215 #define ide_tape_devset_get(name, field) \ 2216 static int get_##name(ide_drive_t *drive) \ 2217 { \ 2218 idetape_tape_t *tape = drive->driver_data; \ 2219 return tape->field; \ 2220 } 2221 #define ide_tape_devset_set(name, field) \ 2222 static int set_##name(ide_drive_t *drive, int arg) \ 2223 { \ 2224 idetape_tape_t *tape = drive->driver_data; \ 2225 tape->field = arg; \ 2226 return 0; \ 2227 } 2228 #define ide_tape_devset_rw_field(_name, _field) \ 2229 ide_tape_devset_get(_name, _field) \ 2230 ide_tape_devset_set(_name, _field) \ 2231 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2232 #define ide_tape_devset_r_field(_name, _field) \ 2233 ide_tape_devset_get(_name, _field) \ 2234 IDE_DEVSET(_name, 0, get_##_name, NULL) 2235 #endif 2236 #ifdef CONFIG_IDE_PROC_FS 2237 #endif 2238 #ifdef CONFIG_IDE_PROC_FS 2239 #endif 2240 /* LDV_COMMENT_END_PREP */ 2241 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_probe" */ 2242 ide_drive_t * var_ide_tape_probe_56_p0; 2243 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "ide_tape_probe" */ 2244 static int res_ide_tape_probe_56; 2245 /* content: static void ide_tape_remove(ide_drive_t *drive)*/ 2246 /* LDV_COMMENT_BEGIN_PREP */ 2247 #define DRV_NAME "ide-tape" 2248 #define IDETAPE_VERSION "1.20" 2249 #undef IDETAPE_DEBUG_LOG 2250 #ifdef IDETAPE_DEBUG_LOG 2251 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2252 #else 2253 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2254 #endif 2255 #define IDETAPE_MAX_PC_RETRIES 3 2256 #define IDETAPE_FIFO_THRESHOLD 2 2257 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2258 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2259 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2260 #define IDETAPE_DSC_MA_FAST 2*HZ 2261 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2262 #define IDETAPE_DSC_MA_SLOW 30*HZ 2263 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2264 #define DOOR_UNLOCKED 0 2265 #define DOOR_LOCKED 1 2266 #define DOOR_EXPLICITLY_LOCKED 2 2267 #define IDETAPE_SPACE_OVER_FILEMARK 1 2268 #define IDETAPE_SPACE_TO_EOD 3 2269 #define IDETAPE_LU_LOAD_MASK 1 2270 #define IDETAPE_LU_RETENSION_MASK 2 2271 #define IDETAPE_LU_EOT_MASK 4 2272 #define IDETAPE_BLOCK_DESCRIPTOR 0 2273 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2274 #ifdef CONFIG_IDE_PROC_FS 2275 #define ide_tape_devset_get(name, field) \ 2276 static int get_##name(ide_drive_t *drive) \ 2277 { \ 2278 idetape_tape_t *tape = drive->driver_data; \ 2279 return tape->field; \ 2280 } 2281 #define ide_tape_devset_set(name, field) \ 2282 static int set_##name(ide_drive_t *drive, int arg) \ 2283 { \ 2284 idetape_tape_t *tape = drive->driver_data; \ 2285 tape->field = arg; \ 2286 return 0; \ 2287 } 2288 #define ide_tape_devset_rw_field(_name, _field) \ 2289 ide_tape_devset_get(_name, _field) \ 2290 ide_tape_devset_set(_name, _field) \ 2291 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2292 #define ide_tape_devset_r_field(_name, _field) \ 2293 ide_tape_devset_get(_name, _field) \ 2294 IDE_DEVSET(_name, 0, get_##_name, NULL) 2295 #endif 2296 /* LDV_COMMENT_END_PREP */ 2297 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_remove" */ 2298 ide_drive_t * var_ide_tape_remove_47_p0; 2299 /* LDV_COMMENT_BEGIN_PREP */ 2300 #ifdef CONFIG_IDE_PROC_FS 2301 #endif 2302 #ifdef CONFIG_IDE_PROC_FS 2303 #endif 2304 /* LDV_COMMENT_END_PREP */ 2305 /* content: static ide_startstop_t idetape_do_request(ide_drive_t *drive, struct request *rq, sector_t block)*/ 2306 /* LDV_COMMENT_BEGIN_PREP */ 2307 #define DRV_NAME "ide-tape" 2308 #define IDETAPE_VERSION "1.20" 2309 #undef IDETAPE_DEBUG_LOG 2310 #ifdef IDETAPE_DEBUG_LOG 2311 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2312 #else 2313 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2314 #endif 2315 #define IDETAPE_MAX_PC_RETRIES 3 2316 #define IDETAPE_FIFO_THRESHOLD 2 2317 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2318 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2319 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2320 #define IDETAPE_DSC_MA_FAST 2*HZ 2321 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2322 #define IDETAPE_DSC_MA_SLOW 30*HZ 2323 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2324 #define DOOR_UNLOCKED 0 2325 #define DOOR_LOCKED 1 2326 #define DOOR_EXPLICITLY_LOCKED 2 2327 #define IDETAPE_SPACE_OVER_FILEMARK 1 2328 #define IDETAPE_SPACE_TO_EOD 3 2329 #define IDETAPE_LU_LOAD_MASK 1 2330 #define IDETAPE_LU_RETENSION_MASK 2 2331 #define IDETAPE_LU_EOT_MASK 4 2332 #define IDETAPE_BLOCK_DESCRIPTOR 0 2333 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2334 /* LDV_COMMENT_END_PREP */ 2335 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_do_request" */ 2336 ide_drive_t * var_idetape_do_request_10_p0; 2337 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_do_request" */ 2338 struct request * var_group3; 2339 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_do_request" */ 2340 sector_t var_idetape_do_request_10_p2; 2341 /* LDV_COMMENT_BEGIN_PREP */ 2342 #ifdef CONFIG_IDE_PROC_FS 2343 #define ide_tape_devset_get(name, field) \ 2344 static int get_##name(ide_drive_t *drive) \ 2345 { \ 2346 idetape_tape_t *tape = drive->driver_data; \ 2347 return tape->field; \ 2348 } 2349 #define ide_tape_devset_set(name, field) \ 2350 static int set_##name(ide_drive_t *drive, int arg) \ 2351 { \ 2352 idetape_tape_t *tape = drive->driver_data; \ 2353 tape->field = arg; \ 2354 return 0; \ 2355 } 2356 #define ide_tape_devset_rw_field(_name, _field) \ 2357 ide_tape_devset_get(_name, _field) \ 2358 ide_tape_devset_set(_name, _field) \ 2359 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2360 #define ide_tape_devset_r_field(_name, _field) \ 2361 ide_tape_devset_get(_name, _field) \ 2362 IDE_DEVSET(_name, 0, get_##_name, NULL) 2363 #endif 2364 #ifdef CONFIG_IDE_PROC_FS 2365 #endif 2366 #ifdef CONFIG_IDE_PROC_FS 2367 #endif 2368 /* LDV_COMMENT_END_PREP */ 2369 /* content: static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)*/ 2370 /* LDV_COMMENT_BEGIN_PREP */ 2371 #define DRV_NAME "ide-tape" 2372 #define IDETAPE_VERSION "1.20" 2373 #undef IDETAPE_DEBUG_LOG 2374 #ifdef IDETAPE_DEBUG_LOG 2375 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2376 #else 2377 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2378 #endif 2379 #define IDETAPE_MAX_PC_RETRIES 3 2380 #define IDETAPE_FIFO_THRESHOLD 2 2381 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2382 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2383 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2384 #define IDETAPE_DSC_MA_FAST 2*HZ 2385 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2386 #define IDETAPE_DSC_MA_SLOW 30*HZ 2387 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2388 #define DOOR_UNLOCKED 0 2389 #define DOOR_LOCKED 1 2390 #define DOOR_EXPLICITLY_LOCKED 2 2391 #define IDETAPE_SPACE_OVER_FILEMARK 1 2392 #define IDETAPE_SPACE_TO_EOD 3 2393 #define IDETAPE_LU_LOAD_MASK 1 2394 #define IDETAPE_LU_RETENSION_MASK 2 2395 #define IDETAPE_LU_EOT_MASK 4 2396 #define IDETAPE_BLOCK_DESCRIPTOR 0 2397 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2398 #ifdef CONFIG_IDE_PROC_FS 2399 #define ide_tape_devset_get(name, field) \ 2400 static int get_##name(ide_drive_t *drive) \ 2401 { \ 2402 idetape_tape_t *tape = drive->driver_data; \ 2403 return tape->field; \ 2404 } 2405 #define ide_tape_devset_set(name, field) \ 2406 static int set_##name(ide_drive_t *drive, int arg) \ 2407 { \ 2408 idetape_tape_t *tape = drive->driver_data; \ 2409 tape->field = arg; \ 2410 return 0; \ 2411 } 2412 #define ide_tape_devset_rw_field(_name, _field) \ 2413 ide_tape_devset_get(_name, _field) \ 2414 ide_tape_devset_set(_name, _field) \ 2415 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2416 #define ide_tape_devset_r_field(_name, _field) \ 2417 ide_tape_devset_get(_name, _field) \ 2418 IDE_DEVSET(_name, 0, get_##_name, NULL) 2419 #endif 2420 #ifdef CONFIG_IDE_PROC_FS 2421 /* LDV_COMMENT_END_PREP */ 2422 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_proc_entries" */ 2423 ide_drive_t * var_ide_tape_proc_entries_51_p0; 2424 /* LDV_COMMENT_BEGIN_PREP */ 2425 #endif 2426 #ifdef CONFIG_IDE_PROC_FS 2427 #endif 2428 /* LDV_COMMENT_END_PREP */ 2429 /* content: static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive)*/ 2430 /* LDV_COMMENT_BEGIN_PREP */ 2431 #define DRV_NAME "ide-tape" 2432 #define IDETAPE_VERSION "1.20" 2433 #undef IDETAPE_DEBUG_LOG 2434 #ifdef IDETAPE_DEBUG_LOG 2435 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2436 #else 2437 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2438 #endif 2439 #define IDETAPE_MAX_PC_RETRIES 3 2440 #define IDETAPE_FIFO_THRESHOLD 2 2441 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2442 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2443 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2444 #define IDETAPE_DSC_MA_FAST 2*HZ 2445 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2446 #define IDETAPE_DSC_MA_SLOW 30*HZ 2447 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2448 #define DOOR_UNLOCKED 0 2449 #define DOOR_LOCKED 1 2450 #define DOOR_EXPLICITLY_LOCKED 2 2451 #define IDETAPE_SPACE_OVER_FILEMARK 1 2452 #define IDETAPE_SPACE_TO_EOD 3 2453 #define IDETAPE_LU_LOAD_MASK 1 2454 #define IDETAPE_LU_RETENSION_MASK 2 2455 #define IDETAPE_LU_EOT_MASK 4 2456 #define IDETAPE_BLOCK_DESCRIPTOR 0 2457 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2458 #ifdef CONFIG_IDE_PROC_FS 2459 #define ide_tape_devset_get(name, field) \ 2460 static int get_##name(ide_drive_t *drive) \ 2461 { \ 2462 idetape_tape_t *tape = drive->driver_data; \ 2463 return tape->field; \ 2464 } 2465 #define ide_tape_devset_set(name, field) \ 2466 static int set_##name(ide_drive_t *drive, int arg) \ 2467 { \ 2468 idetape_tape_t *tape = drive->driver_data; \ 2469 tape->field = arg; \ 2470 return 0; \ 2471 } 2472 #define ide_tape_devset_rw_field(_name, _field) \ 2473 ide_tape_devset_get(_name, _field) \ 2474 ide_tape_devset_set(_name, _field) \ 2475 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2476 #define ide_tape_devset_r_field(_name, _field) \ 2477 ide_tape_devset_get(_name, _field) \ 2478 IDE_DEVSET(_name, 0, get_##_name, NULL) 2479 #endif 2480 #ifdef CONFIG_IDE_PROC_FS 2481 /* LDV_COMMENT_END_PREP */ 2482 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_proc_devsets" */ 2483 ide_drive_t * var_ide_tape_proc_devsets_52_p0; 2484 /* LDV_COMMENT_BEGIN_PREP */ 2485 #endif 2486 #ifdef CONFIG_IDE_PROC_FS 2487 #endif 2488 /* LDV_COMMENT_END_PREP */ 2489 2490 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 2491 /* content: static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)*/ 2492 /* LDV_COMMENT_BEGIN_PREP */ 2493 #define DRV_NAME "ide-tape" 2494 #define IDETAPE_VERSION "1.20" 2495 #undef IDETAPE_DEBUG_LOG 2496 #ifdef IDETAPE_DEBUG_LOG 2497 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2498 #else 2499 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2500 #endif 2501 #define IDETAPE_MAX_PC_RETRIES 3 2502 #define IDETAPE_FIFO_THRESHOLD 2 2503 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2504 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2505 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2506 #define IDETAPE_DSC_MA_FAST 2*HZ 2507 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2508 #define IDETAPE_DSC_MA_SLOW 30*HZ 2509 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2510 #define DOOR_UNLOCKED 0 2511 #define DOOR_LOCKED 1 2512 #define DOOR_EXPLICITLY_LOCKED 2 2513 #define IDETAPE_SPACE_OVER_FILEMARK 1 2514 #define IDETAPE_SPACE_TO_EOD 3 2515 #define IDETAPE_LU_LOAD_MASK 1 2516 #define IDETAPE_LU_RETENSION_MASK 2 2517 #define IDETAPE_LU_EOT_MASK 4 2518 #define IDETAPE_BLOCK_DESCRIPTOR 0 2519 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2520 /* LDV_COMMENT_END_PREP */ 2521 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_read" */ 2522 char __user * var_idetape_chrdev_read_30_p1; 2523 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_read" */ 2524 size_t var_idetape_chrdev_read_30_p2; 2525 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_read" */ 2526 loff_t * var_idetape_chrdev_read_30_p3; 2527 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_chrdev_read" */ 2528 static ssize_t res_idetape_chrdev_read_30; 2529 /* LDV_COMMENT_BEGIN_PREP */ 2530 #ifdef CONFIG_IDE_PROC_FS 2531 #define ide_tape_devset_get(name, field) \ 2532 static int get_##name(ide_drive_t *drive) \ 2533 { \ 2534 idetape_tape_t *tape = drive->driver_data; \ 2535 return tape->field; \ 2536 } 2537 #define ide_tape_devset_set(name, field) \ 2538 static int set_##name(ide_drive_t *drive, int arg) \ 2539 { \ 2540 idetape_tape_t *tape = drive->driver_data; \ 2541 tape->field = arg; \ 2542 return 0; \ 2543 } 2544 #define ide_tape_devset_rw_field(_name, _field) \ 2545 ide_tape_devset_get(_name, _field) \ 2546 ide_tape_devset_set(_name, _field) \ 2547 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2548 #define ide_tape_devset_r_field(_name, _field) \ 2549 ide_tape_devset_get(_name, _field) \ 2550 IDE_DEVSET(_name, 0, get_##_name, NULL) 2551 #endif 2552 #ifdef CONFIG_IDE_PROC_FS 2553 #endif 2554 #ifdef CONFIG_IDE_PROC_FS 2555 #endif 2556 /* LDV_COMMENT_END_PREP */ 2557 /* content: static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)*/ 2558 /* LDV_COMMENT_BEGIN_PREP */ 2559 #define DRV_NAME "ide-tape" 2560 #define IDETAPE_VERSION "1.20" 2561 #undef IDETAPE_DEBUG_LOG 2562 #ifdef IDETAPE_DEBUG_LOG 2563 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2564 #else 2565 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2566 #endif 2567 #define IDETAPE_MAX_PC_RETRIES 3 2568 #define IDETAPE_FIFO_THRESHOLD 2 2569 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2570 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2571 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2572 #define IDETAPE_DSC_MA_FAST 2*HZ 2573 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2574 #define IDETAPE_DSC_MA_SLOW 30*HZ 2575 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2576 #define DOOR_UNLOCKED 0 2577 #define DOOR_LOCKED 1 2578 #define DOOR_EXPLICITLY_LOCKED 2 2579 #define IDETAPE_SPACE_OVER_FILEMARK 1 2580 #define IDETAPE_SPACE_TO_EOD 3 2581 #define IDETAPE_LU_LOAD_MASK 1 2582 #define IDETAPE_LU_RETENSION_MASK 2 2583 #define IDETAPE_LU_EOT_MASK 4 2584 #define IDETAPE_BLOCK_DESCRIPTOR 0 2585 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2586 /* LDV_COMMENT_END_PREP */ 2587 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_write" */ 2588 const char __user * var_idetape_chrdev_write_31_p1; 2589 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_write" */ 2590 size_t var_idetape_chrdev_write_31_p2; 2591 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_write" */ 2592 loff_t * var_idetape_chrdev_write_31_p3; 2593 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_chrdev_write" */ 2594 static ssize_t res_idetape_chrdev_write_31; 2595 /* LDV_COMMENT_BEGIN_PREP */ 2596 #ifdef CONFIG_IDE_PROC_FS 2597 #define ide_tape_devset_get(name, field) \ 2598 static int get_##name(ide_drive_t *drive) \ 2599 { \ 2600 idetape_tape_t *tape = drive->driver_data; \ 2601 return tape->field; \ 2602 } 2603 #define ide_tape_devset_set(name, field) \ 2604 static int set_##name(ide_drive_t *drive, int arg) \ 2605 { \ 2606 idetape_tape_t *tape = drive->driver_data; \ 2607 tape->field = arg; \ 2608 return 0; \ 2609 } 2610 #define ide_tape_devset_rw_field(_name, _field) \ 2611 ide_tape_devset_get(_name, _field) \ 2612 ide_tape_devset_set(_name, _field) \ 2613 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2614 #define ide_tape_devset_r_field(_name, _field) \ 2615 ide_tape_devset_get(_name, _field) \ 2616 IDE_DEVSET(_name, 0, get_##_name, NULL) 2617 #endif 2618 #ifdef CONFIG_IDE_PROC_FS 2619 #endif 2620 #ifdef CONFIG_IDE_PROC_FS 2621 #endif 2622 /* LDV_COMMENT_END_PREP */ 2623 /* content: static long idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)*/ 2624 /* LDV_COMMENT_BEGIN_PREP */ 2625 #define DRV_NAME "ide-tape" 2626 #define IDETAPE_VERSION "1.20" 2627 #undef IDETAPE_DEBUG_LOG 2628 #ifdef IDETAPE_DEBUG_LOG 2629 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2630 #else 2631 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2632 #endif 2633 #define IDETAPE_MAX_PC_RETRIES 3 2634 #define IDETAPE_FIFO_THRESHOLD 2 2635 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2636 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2637 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2638 #define IDETAPE_DSC_MA_FAST 2*HZ 2639 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2640 #define IDETAPE_DSC_MA_SLOW 30*HZ 2641 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2642 #define DOOR_UNLOCKED 0 2643 #define DOOR_LOCKED 1 2644 #define DOOR_EXPLICITLY_LOCKED 2 2645 #define IDETAPE_SPACE_OVER_FILEMARK 1 2646 #define IDETAPE_SPACE_TO_EOD 3 2647 #define IDETAPE_LU_LOAD_MASK 1 2648 #define IDETAPE_LU_RETENSION_MASK 2 2649 #define IDETAPE_LU_EOT_MASK 4 2650 #define IDETAPE_BLOCK_DESCRIPTOR 0 2651 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2652 /* LDV_COMMENT_END_PREP */ 2653 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_ioctl" */ 2654 unsigned int var_idetape_chrdev_ioctl_35_p1; 2655 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_ioctl" */ 2656 unsigned long var_idetape_chrdev_ioctl_35_p2; 2657 /* LDV_COMMENT_BEGIN_PREP */ 2658 #ifdef CONFIG_IDE_PROC_FS 2659 #define ide_tape_devset_get(name, field) \ 2660 static int get_##name(ide_drive_t *drive) \ 2661 { \ 2662 idetape_tape_t *tape = drive->driver_data; \ 2663 return tape->field; \ 2664 } 2665 #define ide_tape_devset_set(name, field) \ 2666 static int set_##name(ide_drive_t *drive, int arg) \ 2667 { \ 2668 idetape_tape_t *tape = drive->driver_data; \ 2669 tape->field = arg; \ 2670 return 0; \ 2671 } 2672 #define ide_tape_devset_rw_field(_name, _field) \ 2673 ide_tape_devset_get(_name, _field) \ 2674 ide_tape_devset_set(_name, _field) \ 2675 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2676 #define ide_tape_devset_r_field(_name, _field) \ 2677 ide_tape_devset_get(_name, _field) \ 2678 IDE_DEVSET(_name, 0, get_##_name, NULL) 2679 #endif 2680 #ifdef CONFIG_IDE_PROC_FS 2681 #endif 2682 #ifdef CONFIG_IDE_PROC_FS 2683 #endif 2684 /* LDV_COMMENT_END_PREP */ 2685 /* content: static int idetape_chrdev_open(struct inode *inode, struct file *filp)*/ 2686 /* LDV_COMMENT_BEGIN_PREP */ 2687 #define DRV_NAME "ide-tape" 2688 #define IDETAPE_VERSION "1.20" 2689 #undef IDETAPE_DEBUG_LOG 2690 #ifdef IDETAPE_DEBUG_LOG 2691 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2692 #else 2693 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2694 #endif 2695 #define IDETAPE_MAX_PC_RETRIES 3 2696 #define IDETAPE_FIFO_THRESHOLD 2 2697 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2698 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2699 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2700 #define IDETAPE_DSC_MA_FAST 2*HZ 2701 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2702 #define IDETAPE_DSC_MA_SLOW 30*HZ 2703 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2704 #define DOOR_UNLOCKED 0 2705 #define DOOR_LOCKED 1 2706 #define DOOR_EXPLICITLY_LOCKED 2 2707 #define IDETAPE_SPACE_OVER_FILEMARK 1 2708 #define IDETAPE_SPACE_TO_EOD 3 2709 #define IDETAPE_LU_LOAD_MASK 1 2710 #define IDETAPE_LU_RETENSION_MASK 2 2711 #define IDETAPE_LU_EOT_MASK 4 2712 #define IDETAPE_BLOCK_DESCRIPTOR 0 2713 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2714 /* LDV_COMMENT_END_PREP */ 2715 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_chrdev_open" */ 2716 static int res_idetape_chrdev_open_37; 2717 /* LDV_COMMENT_BEGIN_PREP */ 2718 #ifdef CONFIG_IDE_PROC_FS 2719 #define ide_tape_devset_get(name, field) \ 2720 static int get_##name(ide_drive_t *drive) \ 2721 { \ 2722 idetape_tape_t *tape = drive->driver_data; \ 2723 return tape->field; \ 2724 } 2725 #define ide_tape_devset_set(name, field) \ 2726 static int set_##name(ide_drive_t *drive, int arg) \ 2727 { \ 2728 idetape_tape_t *tape = drive->driver_data; \ 2729 tape->field = arg; \ 2730 return 0; \ 2731 } 2732 #define ide_tape_devset_rw_field(_name, _field) \ 2733 ide_tape_devset_get(_name, _field) \ 2734 ide_tape_devset_set(_name, _field) \ 2735 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2736 #define ide_tape_devset_r_field(_name, _field) \ 2737 ide_tape_devset_get(_name, _field) \ 2738 IDE_DEVSET(_name, 0, get_##_name, NULL) 2739 #endif 2740 #ifdef CONFIG_IDE_PROC_FS 2741 #endif 2742 #ifdef CONFIG_IDE_PROC_FS 2743 #endif 2744 /* LDV_COMMENT_END_PREP */ 2745 /* content: static int idetape_chrdev_release(struct inode *inode, struct file *filp)*/ 2746 /* LDV_COMMENT_BEGIN_PREP */ 2747 #define DRV_NAME "ide-tape" 2748 #define IDETAPE_VERSION "1.20" 2749 #undef IDETAPE_DEBUG_LOG 2750 #ifdef IDETAPE_DEBUG_LOG 2751 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2752 #else 2753 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2754 #endif 2755 #define IDETAPE_MAX_PC_RETRIES 3 2756 #define IDETAPE_FIFO_THRESHOLD 2 2757 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2758 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2759 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2760 #define IDETAPE_DSC_MA_FAST 2*HZ 2761 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2762 #define IDETAPE_DSC_MA_SLOW 30*HZ 2763 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2764 #define DOOR_UNLOCKED 0 2765 #define DOOR_LOCKED 1 2766 #define DOOR_EXPLICITLY_LOCKED 2 2767 #define IDETAPE_SPACE_OVER_FILEMARK 1 2768 #define IDETAPE_SPACE_TO_EOD 3 2769 #define IDETAPE_LU_LOAD_MASK 1 2770 #define IDETAPE_LU_RETENSION_MASK 2 2771 #define IDETAPE_LU_EOT_MASK 4 2772 #define IDETAPE_BLOCK_DESCRIPTOR 0 2773 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2774 /* LDV_COMMENT_END_PREP */ 2775 /* LDV_COMMENT_BEGIN_PREP */ 2776 #ifdef CONFIG_IDE_PROC_FS 2777 #define ide_tape_devset_get(name, field) \ 2778 static int get_##name(ide_drive_t *drive) \ 2779 { \ 2780 idetape_tape_t *tape = drive->driver_data; \ 2781 return tape->field; \ 2782 } 2783 #define ide_tape_devset_set(name, field) \ 2784 static int set_##name(ide_drive_t *drive, int arg) \ 2785 { \ 2786 idetape_tape_t *tape = drive->driver_data; \ 2787 tape->field = arg; \ 2788 return 0; \ 2789 } 2790 #define ide_tape_devset_rw_field(_name, _field) \ 2791 ide_tape_devset_get(_name, _field) \ 2792 ide_tape_devset_set(_name, _field) \ 2793 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2794 #define ide_tape_devset_r_field(_name, _field) \ 2795 ide_tape_devset_get(_name, _field) \ 2796 IDE_DEVSET(_name, 0, get_##_name, NULL) 2797 #endif 2798 #ifdef CONFIG_IDE_PROC_FS 2799 #endif 2800 #ifdef CONFIG_IDE_PROC_FS 2801 #endif 2802 /* LDV_COMMENT_END_PREP */ 2803 2804 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 2805 /* content: static int idetape_open(struct block_device *bdev, fmode_t mode)*/ 2806 /* LDV_COMMENT_BEGIN_PREP */ 2807 #define DRV_NAME "ide-tape" 2808 #define IDETAPE_VERSION "1.20" 2809 #undef IDETAPE_DEBUG_LOG 2810 #ifdef IDETAPE_DEBUG_LOG 2811 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2812 #else 2813 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2814 #endif 2815 #define IDETAPE_MAX_PC_RETRIES 3 2816 #define IDETAPE_FIFO_THRESHOLD 2 2817 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2818 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2819 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2820 #define IDETAPE_DSC_MA_FAST 2*HZ 2821 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2822 #define IDETAPE_DSC_MA_SLOW 30*HZ 2823 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2824 #define DOOR_UNLOCKED 0 2825 #define DOOR_LOCKED 1 2826 #define DOOR_EXPLICITLY_LOCKED 2 2827 #define IDETAPE_SPACE_OVER_FILEMARK 1 2828 #define IDETAPE_SPACE_TO_EOD 3 2829 #define IDETAPE_LU_LOAD_MASK 1 2830 #define IDETAPE_LU_RETENSION_MASK 2 2831 #define IDETAPE_LU_EOT_MASK 4 2832 #define IDETAPE_BLOCK_DESCRIPTOR 0 2833 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2834 #ifdef CONFIG_IDE_PROC_FS 2835 #define ide_tape_devset_get(name, field) \ 2836 static int get_##name(ide_drive_t *drive) \ 2837 { \ 2838 idetape_tape_t *tape = drive->driver_data; \ 2839 return tape->field; \ 2840 } 2841 #define ide_tape_devset_set(name, field) \ 2842 static int set_##name(ide_drive_t *drive, int arg) \ 2843 { \ 2844 idetape_tape_t *tape = drive->driver_data; \ 2845 tape->field = arg; \ 2846 return 0; \ 2847 } 2848 #define ide_tape_devset_rw_field(_name, _field) \ 2849 ide_tape_devset_get(_name, _field) \ 2850 ide_tape_devset_set(_name, _field) \ 2851 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2852 #define ide_tape_devset_r_field(_name, _field) \ 2853 ide_tape_devset_get(_name, _field) \ 2854 IDE_DEVSET(_name, 0, get_##_name, NULL) 2855 #endif 2856 #ifdef CONFIG_IDE_PROC_FS 2857 #endif 2858 #ifdef CONFIG_IDE_PROC_FS 2859 #endif 2860 /* LDV_COMMENT_END_PREP */ 2861 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_open" */ 2862 struct block_device * var_group4; 2863 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_open" */ 2864 fmode_t var_idetape_open_53_p1; 2865 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_open" */ 2866 static int res_idetape_open_53; 2867 /* content: static void idetape_release(struct gendisk *disk, fmode_t mode)*/ 2868 /* LDV_COMMENT_BEGIN_PREP */ 2869 #define DRV_NAME "ide-tape" 2870 #define IDETAPE_VERSION "1.20" 2871 #undef IDETAPE_DEBUG_LOG 2872 #ifdef IDETAPE_DEBUG_LOG 2873 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2874 #else 2875 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2876 #endif 2877 #define IDETAPE_MAX_PC_RETRIES 3 2878 #define IDETAPE_FIFO_THRESHOLD 2 2879 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2880 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2881 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2882 #define IDETAPE_DSC_MA_FAST 2*HZ 2883 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2884 #define IDETAPE_DSC_MA_SLOW 30*HZ 2885 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2886 #define DOOR_UNLOCKED 0 2887 #define DOOR_LOCKED 1 2888 #define DOOR_EXPLICITLY_LOCKED 2 2889 #define IDETAPE_SPACE_OVER_FILEMARK 1 2890 #define IDETAPE_SPACE_TO_EOD 3 2891 #define IDETAPE_LU_LOAD_MASK 1 2892 #define IDETAPE_LU_RETENSION_MASK 2 2893 #define IDETAPE_LU_EOT_MASK 4 2894 #define IDETAPE_BLOCK_DESCRIPTOR 0 2895 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2896 #ifdef CONFIG_IDE_PROC_FS 2897 #define ide_tape_devset_get(name, field) \ 2898 static int get_##name(ide_drive_t *drive) \ 2899 { \ 2900 idetape_tape_t *tape = drive->driver_data; \ 2901 return tape->field; \ 2902 } 2903 #define ide_tape_devset_set(name, field) \ 2904 static int set_##name(ide_drive_t *drive, int arg) \ 2905 { \ 2906 idetape_tape_t *tape = drive->driver_data; \ 2907 tape->field = arg; \ 2908 return 0; \ 2909 } 2910 #define ide_tape_devset_rw_field(_name, _field) \ 2911 ide_tape_devset_get(_name, _field) \ 2912 ide_tape_devset_set(_name, _field) \ 2913 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2914 #define ide_tape_devset_r_field(_name, _field) \ 2915 ide_tape_devset_get(_name, _field) \ 2916 IDE_DEVSET(_name, 0, get_##_name, NULL) 2917 #endif 2918 #ifdef CONFIG_IDE_PROC_FS 2919 #endif 2920 #ifdef CONFIG_IDE_PROC_FS 2921 #endif 2922 /* LDV_COMMENT_END_PREP */ 2923 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_release" */ 2924 struct gendisk * var_group5; 2925 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_release" */ 2926 fmode_t var_idetape_release_54_p1; 2927 /* content: static int idetape_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)*/ 2928 /* LDV_COMMENT_BEGIN_PREP */ 2929 #define DRV_NAME "ide-tape" 2930 #define IDETAPE_VERSION "1.20" 2931 #undef IDETAPE_DEBUG_LOG 2932 #ifdef IDETAPE_DEBUG_LOG 2933 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2934 #else 2935 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2936 #endif 2937 #define IDETAPE_MAX_PC_RETRIES 3 2938 #define IDETAPE_FIFO_THRESHOLD 2 2939 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2940 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2941 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2942 #define IDETAPE_DSC_MA_FAST 2*HZ 2943 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2944 #define IDETAPE_DSC_MA_SLOW 30*HZ 2945 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2946 #define DOOR_UNLOCKED 0 2947 #define DOOR_LOCKED 1 2948 #define DOOR_EXPLICITLY_LOCKED 2 2949 #define IDETAPE_SPACE_OVER_FILEMARK 1 2950 #define IDETAPE_SPACE_TO_EOD 3 2951 #define IDETAPE_LU_LOAD_MASK 1 2952 #define IDETAPE_LU_RETENSION_MASK 2 2953 #define IDETAPE_LU_EOT_MASK 4 2954 #define IDETAPE_BLOCK_DESCRIPTOR 0 2955 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2956 #ifdef CONFIG_IDE_PROC_FS 2957 #define ide_tape_devset_get(name, field) \ 2958 static int get_##name(ide_drive_t *drive) \ 2959 { \ 2960 idetape_tape_t *tape = drive->driver_data; \ 2961 return tape->field; \ 2962 } 2963 #define ide_tape_devset_set(name, field) \ 2964 static int set_##name(ide_drive_t *drive, int arg) \ 2965 { \ 2966 idetape_tape_t *tape = drive->driver_data; \ 2967 tape->field = arg; \ 2968 return 0; \ 2969 } 2970 #define ide_tape_devset_rw_field(_name, _field) \ 2971 ide_tape_devset_get(_name, _field) \ 2972 ide_tape_devset_set(_name, _field) \ 2973 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2974 #define ide_tape_devset_r_field(_name, _field) \ 2975 ide_tape_devset_get(_name, _field) \ 2976 IDE_DEVSET(_name, 0, get_##_name, NULL) 2977 #endif 2978 #ifdef CONFIG_IDE_PROC_FS 2979 #endif 2980 #ifdef CONFIG_IDE_PROC_FS 2981 #endif 2982 /* LDV_COMMENT_END_PREP */ 2983 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_ioctl" */ 2984 fmode_t var_idetape_ioctl_55_p1; 2985 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_ioctl" */ 2986 unsigned int var_idetape_ioctl_55_p2; 2987 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_ioctl" */ 2988 unsigned long var_idetape_ioctl_55_p3; 2989 2990 2991 2992 2993 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 2994 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 2995 /*============================= VARIABLE INITIALIZING PART =============================*/ 2996 LDV_IN_INTERRUPT=1; 2997 2998 2999 3000 3001 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 3002 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 3003 /*============================= FUNCTION CALL SECTION =============================*/ 3004 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 3005 ldv_initialize(); 3006 3007 /** INIT: init_type: ST_MODULE_INIT **/ 3008 /* content: static int __init idetape_init(void)*/ 3009 /* LDV_COMMENT_BEGIN_PREP */ 3010 #define DRV_NAME "ide-tape" 3011 #define IDETAPE_VERSION "1.20" 3012 #undef IDETAPE_DEBUG_LOG 3013 #ifdef IDETAPE_DEBUG_LOG 3014 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3015 #else 3016 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3017 #endif 3018 #define IDETAPE_MAX_PC_RETRIES 3 3019 #define IDETAPE_FIFO_THRESHOLD 2 3020 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3021 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3022 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3023 #define IDETAPE_DSC_MA_FAST 2*HZ 3024 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3025 #define IDETAPE_DSC_MA_SLOW 30*HZ 3026 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3027 #define DOOR_UNLOCKED 0 3028 #define DOOR_LOCKED 1 3029 #define DOOR_EXPLICITLY_LOCKED 2 3030 #define IDETAPE_SPACE_OVER_FILEMARK 1 3031 #define IDETAPE_SPACE_TO_EOD 3 3032 #define IDETAPE_LU_LOAD_MASK 1 3033 #define IDETAPE_LU_RETENSION_MASK 2 3034 #define IDETAPE_LU_EOT_MASK 4 3035 #define IDETAPE_BLOCK_DESCRIPTOR 0 3036 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3037 #ifdef CONFIG_IDE_PROC_FS 3038 #define ide_tape_devset_get(name, field) \ 3039 static int get_##name(ide_drive_t *drive) \ 3040 { \ 3041 idetape_tape_t *tape = drive->driver_data; \ 3042 return tape->field; \ 3043 } 3044 #define ide_tape_devset_set(name, field) \ 3045 static int set_##name(ide_drive_t *drive, int arg) \ 3046 { \ 3047 idetape_tape_t *tape = drive->driver_data; \ 3048 tape->field = arg; \ 3049 return 0; \ 3050 } 3051 #define ide_tape_devset_rw_field(_name, _field) \ 3052 ide_tape_devset_get(_name, _field) \ 3053 ide_tape_devset_set(_name, _field) \ 3054 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3055 #define ide_tape_devset_r_field(_name, _field) \ 3056 ide_tape_devset_get(_name, _field) \ 3057 IDE_DEVSET(_name, 0, get_##_name, NULL) 3058 #endif 3059 #ifdef CONFIG_IDE_PROC_FS 3060 #endif 3061 #ifdef CONFIG_IDE_PROC_FS 3062 #endif 3063 /* LDV_COMMENT_END_PREP */ 3064 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */ 3065 ldv_handler_precall(); 3066 if(idetape_init()) 3067 goto ldv_final; 3068 int ldv_s_idetape_name_proc_fops_file_operations = 0; 3069 3070 int ldv_s_idetape_driver_ide_driver = 0; 3071 3072 3073 int ldv_s_idetape_fops_file_operations = 0; 3074 3075 3076 int ldv_s_idetape_block_ops_block_device_operations = 0; 3077 3078 3079 3080 while( nondet_int() 3081 || !(ldv_s_idetape_name_proc_fops_file_operations == 0) 3082 || !(ldv_s_idetape_driver_ide_driver == 0) 3083 || !(ldv_s_idetape_fops_file_operations == 0) 3084 || !(ldv_s_idetape_block_ops_block_device_operations == 0) 3085 ) { 3086 3087 switch(nondet_int()) { 3088 3089 case 0: { 3090 3091 /** STRUCT: struct type: file_operations, struct name: idetape_name_proc_fops **/ 3092 if(ldv_s_idetape_name_proc_fops_file_operations==0) { 3093 3094 /* content: static int idetape_name_proc_open(struct inode *inode, struct file *file)*/ 3095 /* LDV_COMMENT_BEGIN_PREP */ 3096 #define DRV_NAME "ide-tape" 3097 #define IDETAPE_VERSION "1.20" 3098 #undef IDETAPE_DEBUG_LOG 3099 #ifdef IDETAPE_DEBUG_LOG 3100 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3101 #else 3102 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3103 #endif 3104 #define IDETAPE_MAX_PC_RETRIES 3 3105 #define IDETAPE_FIFO_THRESHOLD 2 3106 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3107 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3108 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3109 #define IDETAPE_DSC_MA_FAST 2*HZ 3110 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3111 #define IDETAPE_DSC_MA_SLOW 30*HZ 3112 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3113 #define DOOR_UNLOCKED 0 3114 #define DOOR_LOCKED 1 3115 #define DOOR_EXPLICITLY_LOCKED 2 3116 #define IDETAPE_SPACE_OVER_FILEMARK 1 3117 #define IDETAPE_SPACE_TO_EOD 3 3118 #define IDETAPE_LU_LOAD_MASK 1 3119 #define IDETAPE_LU_RETENSION_MASK 2 3120 #define IDETAPE_LU_EOT_MASK 4 3121 #define IDETAPE_BLOCK_DESCRIPTOR 0 3122 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3123 #ifdef CONFIG_IDE_PROC_FS 3124 #define ide_tape_devset_get(name, field) \ 3125 static int get_##name(ide_drive_t *drive) \ 3126 { \ 3127 idetape_tape_t *tape = drive->driver_data; \ 3128 return tape->field; \ 3129 } 3130 #define ide_tape_devset_set(name, field) \ 3131 static int set_##name(ide_drive_t *drive, int arg) \ 3132 { \ 3133 idetape_tape_t *tape = drive->driver_data; \ 3134 tape->field = arg; \ 3135 return 0; \ 3136 } 3137 #define ide_tape_devset_rw_field(_name, _field) \ 3138 ide_tape_devset_get(_name, _field) \ 3139 ide_tape_devset_set(_name, _field) \ 3140 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3141 #define ide_tape_devset_r_field(_name, _field) \ 3142 ide_tape_devset_get(_name, _field) \ 3143 IDE_DEVSET(_name, 0, get_##_name, NULL) 3144 #endif 3145 #ifdef CONFIG_IDE_PROC_FS 3146 /* LDV_COMMENT_END_PREP */ 3147 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "idetape_name_proc_fops". Standart function test for correct return result. */ 3148 ldv_handler_precall(); 3149 res_idetape_name_proc_open_50 = idetape_name_proc_open( var_group1, var_group2); 3150 ldv_check_return_value(res_idetape_name_proc_open_50); 3151 if(res_idetape_name_proc_open_50) 3152 goto ldv_module_exit; 3153 /* LDV_COMMENT_BEGIN_PREP */ 3154 #endif 3155 #ifdef CONFIG_IDE_PROC_FS 3156 #endif 3157 /* LDV_COMMENT_END_PREP */ 3158 ldv_s_idetape_name_proc_fops_file_operations=0; 3159 3160 } 3161 3162 } 3163 3164 break; 3165 case 1: { 3166 3167 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3168 if(ldv_s_idetape_driver_ide_driver==0) { 3169 3170 /* content: static int ide_tape_probe(ide_drive_t *drive)*/ 3171 /* LDV_COMMENT_BEGIN_PREP */ 3172 #define DRV_NAME "ide-tape" 3173 #define IDETAPE_VERSION "1.20" 3174 #undef IDETAPE_DEBUG_LOG 3175 #ifdef IDETAPE_DEBUG_LOG 3176 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3177 #else 3178 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3179 #endif 3180 #define IDETAPE_MAX_PC_RETRIES 3 3181 #define IDETAPE_FIFO_THRESHOLD 2 3182 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3183 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3184 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3185 #define IDETAPE_DSC_MA_FAST 2*HZ 3186 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3187 #define IDETAPE_DSC_MA_SLOW 30*HZ 3188 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3189 #define DOOR_UNLOCKED 0 3190 #define DOOR_LOCKED 1 3191 #define DOOR_EXPLICITLY_LOCKED 2 3192 #define IDETAPE_SPACE_OVER_FILEMARK 1 3193 #define IDETAPE_SPACE_TO_EOD 3 3194 #define IDETAPE_LU_LOAD_MASK 1 3195 #define IDETAPE_LU_RETENSION_MASK 2 3196 #define IDETAPE_LU_EOT_MASK 4 3197 #define IDETAPE_BLOCK_DESCRIPTOR 0 3198 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3199 #ifdef CONFIG_IDE_PROC_FS 3200 #define ide_tape_devset_get(name, field) \ 3201 static int get_##name(ide_drive_t *drive) \ 3202 { \ 3203 idetape_tape_t *tape = drive->driver_data; \ 3204 return tape->field; \ 3205 } 3206 #define ide_tape_devset_set(name, field) \ 3207 static int set_##name(ide_drive_t *drive, int arg) \ 3208 { \ 3209 idetape_tape_t *tape = drive->driver_data; \ 3210 tape->field = arg; \ 3211 return 0; \ 3212 } 3213 #define ide_tape_devset_rw_field(_name, _field) \ 3214 ide_tape_devset_get(_name, _field) \ 3215 ide_tape_devset_set(_name, _field) \ 3216 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3217 #define ide_tape_devset_r_field(_name, _field) \ 3218 ide_tape_devset_get(_name, _field) \ 3219 IDE_DEVSET(_name, 0, get_##_name, NULL) 3220 #endif 3221 #ifdef CONFIG_IDE_PROC_FS 3222 #endif 3223 #ifdef CONFIG_IDE_PROC_FS 3224 #endif 3225 /* LDV_COMMENT_END_PREP */ 3226 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "idetape_driver". Standart function test for correct return result. */ 3227 res_ide_tape_probe_56 = ide_tape_probe( var_ide_tape_probe_56_p0); 3228 ldv_check_return_value(res_ide_tape_probe_56); 3229 ldv_check_return_value_probe(res_ide_tape_probe_56); 3230 if(res_ide_tape_probe_56) 3231 goto ldv_module_exit; 3232 ldv_s_idetape_driver_ide_driver++; 3233 3234 } 3235 3236 } 3237 3238 break; 3239 case 2: { 3240 3241 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3242 if(ldv_s_idetape_driver_ide_driver==1) { 3243 3244 /* content: static void ide_tape_remove(ide_drive_t *drive)*/ 3245 /* LDV_COMMENT_BEGIN_PREP */ 3246 #define DRV_NAME "ide-tape" 3247 #define IDETAPE_VERSION "1.20" 3248 #undef IDETAPE_DEBUG_LOG 3249 #ifdef IDETAPE_DEBUG_LOG 3250 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3251 #else 3252 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3253 #endif 3254 #define IDETAPE_MAX_PC_RETRIES 3 3255 #define IDETAPE_FIFO_THRESHOLD 2 3256 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3257 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3258 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3259 #define IDETAPE_DSC_MA_FAST 2*HZ 3260 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3261 #define IDETAPE_DSC_MA_SLOW 30*HZ 3262 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3263 #define DOOR_UNLOCKED 0 3264 #define DOOR_LOCKED 1 3265 #define DOOR_EXPLICITLY_LOCKED 2 3266 #define IDETAPE_SPACE_OVER_FILEMARK 1 3267 #define IDETAPE_SPACE_TO_EOD 3 3268 #define IDETAPE_LU_LOAD_MASK 1 3269 #define IDETAPE_LU_RETENSION_MASK 2 3270 #define IDETAPE_LU_EOT_MASK 4 3271 #define IDETAPE_BLOCK_DESCRIPTOR 0 3272 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3273 #ifdef CONFIG_IDE_PROC_FS 3274 #define ide_tape_devset_get(name, field) \ 3275 static int get_##name(ide_drive_t *drive) \ 3276 { \ 3277 idetape_tape_t *tape = drive->driver_data; \ 3278 return tape->field; \ 3279 } 3280 #define ide_tape_devset_set(name, field) \ 3281 static int set_##name(ide_drive_t *drive, int arg) \ 3282 { \ 3283 idetape_tape_t *tape = drive->driver_data; \ 3284 tape->field = arg; \ 3285 return 0; \ 3286 } 3287 #define ide_tape_devset_rw_field(_name, _field) \ 3288 ide_tape_devset_get(_name, _field) \ 3289 ide_tape_devset_set(_name, _field) \ 3290 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3291 #define ide_tape_devset_r_field(_name, _field) \ 3292 ide_tape_devset_get(_name, _field) \ 3293 IDE_DEVSET(_name, 0, get_##_name, NULL) 3294 #endif 3295 /* LDV_COMMENT_END_PREP */ 3296 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "idetape_driver" */ 3297 ldv_handler_precall(); 3298 ide_tape_remove( var_ide_tape_remove_47_p0); 3299 /* LDV_COMMENT_BEGIN_PREP */ 3300 #ifdef CONFIG_IDE_PROC_FS 3301 #endif 3302 #ifdef CONFIG_IDE_PROC_FS 3303 #endif 3304 /* LDV_COMMENT_END_PREP */ 3305 ldv_s_idetape_driver_ide_driver=0; 3306 3307 } 3308 3309 } 3310 3311 break; 3312 case 3: { 3313 3314 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3315 3316 3317 /* content: static ide_startstop_t idetape_do_request(ide_drive_t *drive, struct request *rq, sector_t block)*/ 3318 /* LDV_COMMENT_BEGIN_PREP */ 3319 #define DRV_NAME "ide-tape" 3320 #define IDETAPE_VERSION "1.20" 3321 #undef IDETAPE_DEBUG_LOG 3322 #ifdef IDETAPE_DEBUG_LOG 3323 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3324 #else 3325 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3326 #endif 3327 #define IDETAPE_MAX_PC_RETRIES 3 3328 #define IDETAPE_FIFO_THRESHOLD 2 3329 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3330 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3331 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3332 #define IDETAPE_DSC_MA_FAST 2*HZ 3333 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3334 #define IDETAPE_DSC_MA_SLOW 30*HZ 3335 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3336 #define DOOR_UNLOCKED 0 3337 #define DOOR_LOCKED 1 3338 #define DOOR_EXPLICITLY_LOCKED 2 3339 #define IDETAPE_SPACE_OVER_FILEMARK 1 3340 #define IDETAPE_SPACE_TO_EOD 3 3341 #define IDETAPE_LU_LOAD_MASK 1 3342 #define IDETAPE_LU_RETENSION_MASK 2 3343 #define IDETAPE_LU_EOT_MASK 4 3344 #define IDETAPE_BLOCK_DESCRIPTOR 0 3345 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3346 /* LDV_COMMENT_END_PREP */ 3347 /* LDV_COMMENT_FUNCTION_CALL Function from field "do_request" from driver structure with callbacks "idetape_driver" */ 3348 ldv_handler_precall(); 3349 idetape_do_request( var_idetape_do_request_10_p0, var_group3, var_idetape_do_request_10_p2); 3350 /* LDV_COMMENT_BEGIN_PREP */ 3351 #ifdef CONFIG_IDE_PROC_FS 3352 #define ide_tape_devset_get(name, field) \ 3353 static int get_##name(ide_drive_t *drive) \ 3354 { \ 3355 idetape_tape_t *tape = drive->driver_data; \ 3356 return tape->field; \ 3357 } 3358 #define ide_tape_devset_set(name, field) \ 3359 static int set_##name(ide_drive_t *drive, int arg) \ 3360 { \ 3361 idetape_tape_t *tape = drive->driver_data; \ 3362 tape->field = arg; \ 3363 return 0; \ 3364 } 3365 #define ide_tape_devset_rw_field(_name, _field) \ 3366 ide_tape_devset_get(_name, _field) \ 3367 ide_tape_devset_set(_name, _field) \ 3368 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3369 #define ide_tape_devset_r_field(_name, _field) \ 3370 ide_tape_devset_get(_name, _field) \ 3371 IDE_DEVSET(_name, 0, get_##_name, NULL) 3372 #endif 3373 #ifdef CONFIG_IDE_PROC_FS 3374 #endif 3375 #ifdef CONFIG_IDE_PROC_FS 3376 #endif 3377 /* LDV_COMMENT_END_PREP */ 3378 3379 3380 3381 3382 } 3383 3384 break; 3385 case 4: { 3386 3387 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3388 3389 3390 /* content: static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)*/ 3391 /* LDV_COMMENT_BEGIN_PREP */ 3392 #define DRV_NAME "ide-tape" 3393 #define IDETAPE_VERSION "1.20" 3394 #undef IDETAPE_DEBUG_LOG 3395 #ifdef IDETAPE_DEBUG_LOG 3396 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3397 #else 3398 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3399 #endif 3400 #define IDETAPE_MAX_PC_RETRIES 3 3401 #define IDETAPE_FIFO_THRESHOLD 2 3402 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3403 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3404 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3405 #define IDETAPE_DSC_MA_FAST 2*HZ 3406 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3407 #define IDETAPE_DSC_MA_SLOW 30*HZ 3408 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3409 #define DOOR_UNLOCKED 0 3410 #define DOOR_LOCKED 1 3411 #define DOOR_EXPLICITLY_LOCKED 2 3412 #define IDETAPE_SPACE_OVER_FILEMARK 1 3413 #define IDETAPE_SPACE_TO_EOD 3 3414 #define IDETAPE_LU_LOAD_MASK 1 3415 #define IDETAPE_LU_RETENSION_MASK 2 3416 #define IDETAPE_LU_EOT_MASK 4 3417 #define IDETAPE_BLOCK_DESCRIPTOR 0 3418 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3419 #ifdef CONFIG_IDE_PROC_FS 3420 #define ide_tape_devset_get(name, field) \ 3421 static int get_##name(ide_drive_t *drive) \ 3422 { \ 3423 idetape_tape_t *tape = drive->driver_data; \ 3424 return tape->field; \ 3425 } 3426 #define ide_tape_devset_set(name, field) \ 3427 static int set_##name(ide_drive_t *drive, int arg) \ 3428 { \ 3429 idetape_tape_t *tape = drive->driver_data; \ 3430 tape->field = arg; \ 3431 return 0; \ 3432 } 3433 #define ide_tape_devset_rw_field(_name, _field) \ 3434 ide_tape_devset_get(_name, _field) \ 3435 ide_tape_devset_set(_name, _field) \ 3436 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3437 #define ide_tape_devset_r_field(_name, _field) \ 3438 ide_tape_devset_get(_name, _field) \ 3439 IDE_DEVSET(_name, 0, get_##_name, NULL) 3440 #endif 3441 #ifdef CONFIG_IDE_PROC_FS 3442 /* LDV_COMMENT_END_PREP */ 3443 /* LDV_COMMENT_FUNCTION_CALL Function from field "proc_entries" from driver structure with callbacks "idetape_driver" */ 3444 ldv_handler_precall(); 3445 ide_tape_proc_entries( var_ide_tape_proc_entries_51_p0); 3446 /* LDV_COMMENT_BEGIN_PREP */ 3447 #endif 3448 #ifdef CONFIG_IDE_PROC_FS 3449 #endif 3450 /* LDV_COMMENT_END_PREP */ 3451 3452 3453 3454 3455 } 3456 3457 break; 3458 case 5: { 3459 3460 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3461 3462 3463 /* content: static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive)*/ 3464 /* LDV_COMMENT_BEGIN_PREP */ 3465 #define DRV_NAME "ide-tape" 3466 #define IDETAPE_VERSION "1.20" 3467 #undef IDETAPE_DEBUG_LOG 3468 #ifdef IDETAPE_DEBUG_LOG 3469 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3470 #else 3471 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3472 #endif 3473 #define IDETAPE_MAX_PC_RETRIES 3 3474 #define IDETAPE_FIFO_THRESHOLD 2 3475 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3476 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3477 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3478 #define IDETAPE_DSC_MA_FAST 2*HZ 3479 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3480 #define IDETAPE_DSC_MA_SLOW 30*HZ 3481 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3482 #define DOOR_UNLOCKED 0 3483 #define DOOR_LOCKED 1 3484 #define DOOR_EXPLICITLY_LOCKED 2 3485 #define IDETAPE_SPACE_OVER_FILEMARK 1 3486 #define IDETAPE_SPACE_TO_EOD 3 3487 #define IDETAPE_LU_LOAD_MASK 1 3488 #define IDETAPE_LU_RETENSION_MASK 2 3489 #define IDETAPE_LU_EOT_MASK 4 3490 #define IDETAPE_BLOCK_DESCRIPTOR 0 3491 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3492 #ifdef CONFIG_IDE_PROC_FS 3493 #define ide_tape_devset_get(name, field) \ 3494 static int get_##name(ide_drive_t *drive) \ 3495 { \ 3496 idetape_tape_t *tape = drive->driver_data; \ 3497 return tape->field; \ 3498 } 3499 #define ide_tape_devset_set(name, field) \ 3500 static int set_##name(ide_drive_t *drive, int arg) \ 3501 { \ 3502 idetape_tape_t *tape = drive->driver_data; \ 3503 tape->field = arg; \ 3504 return 0; \ 3505 } 3506 #define ide_tape_devset_rw_field(_name, _field) \ 3507 ide_tape_devset_get(_name, _field) \ 3508 ide_tape_devset_set(_name, _field) \ 3509 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3510 #define ide_tape_devset_r_field(_name, _field) \ 3511 ide_tape_devset_get(_name, _field) \ 3512 IDE_DEVSET(_name, 0, get_##_name, NULL) 3513 #endif 3514 #ifdef CONFIG_IDE_PROC_FS 3515 /* LDV_COMMENT_END_PREP */ 3516 /* LDV_COMMENT_FUNCTION_CALL Function from field "proc_devsets" from driver structure with callbacks "idetape_driver" */ 3517 ldv_handler_precall(); 3518 ide_tape_proc_devsets( var_ide_tape_proc_devsets_52_p0); 3519 /* LDV_COMMENT_BEGIN_PREP */ 3520 #endif 3521 #ifdef CONFIG_IDE_PROC_FS 3522 #endif 3523 /* LDV_COMMENT_END_PREP */ 3524 3525 3526 3527 3528 } 3529 3530 break; 3531 case 6: { 3532 3533 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3534 if(ldv_s_idetape_fops_file_operations==0) { 3535 3536 /* content: static int idetape_chrdev_open(struct inode *inode, struct file *filp)*/ 3537 /* LDV_COMMENT_BEGIN_PREP */ 3538 #define DRV_NAME "ide-tape" 3539 #define IDETAPE_VERSION "1.20" 3540 #undef IDETAPE_DEBUG_LOG 3541 #ifdef IDETAPE_DEBUG_LOG 3542 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3543 #else 3544 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3545 #endif 3546 #define IDETAPE_MAX_PC_RETRIES 3 3547 #define IDETAPE_FIFO_THRESHOLD 2 3548 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3549 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3550 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3551 #define IDETAPE_DSC_MA_FAST 2*HZ 3552 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3553 #define IDETAPE_DSC_MA_SLOW 30*HZ 3554 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3555 #define DOOR_UNLOCKED 0 3556 #define DOOR_LOCKED 1 3557 #define DOOR_EXPLICITLY_LOCKED 2 3558 #define IDETAPE_SPACE_OVER_FILEMARK 1 3559 #define IDETAPE_SPACE_TO_EOD 3 3560 #define IDETAPE_LU_LOAD_MASK 1 3561 #define IDETAPE_LU_RETENSION_MASK 2 3562 #define IDETAPE_LU_EOT_MASK 4 3563 #define IDETAPE_BLOCK_DESCRIPTOR 0 3564 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3565 /* LDV_COMMENT_END_PREP */ 3566 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "idetape_fops". Standart function test for correct return result. */ 3567 ldv_handler_precall(); 3568 res_idetape_chrdev_open_37 = idetape_chrdev_open( var_group1, var_group2); 3569 ldv_check_return_value(res_idetape_chrdev_open_37); 3570 if(res_idetape_chrdev_open_37) 3571 goto ldv_module_exit; 3572 /* LDV_COMMENT_BEGIN_PREP */ 3573 #ifdef CONFIG_IDE_PROC_FS 3574 #define ide_tape_devset_get(name, field) \ 3575 static int get_##name(ide_drive_t *drive) \ 3576 { \ 3577 idetape_tape_t *tape = drive->driver_data; \ 3578 return tape->field; \ 3579 } 3580 #define ide_tape_devset_set(name, field) \ 3581 static int set_##name(ide_drive_t *drive, int arg) \ 3582 { \ 3583 idetape_tape_t *tape = drive->driver_data; \ 3584 tape->field = arg; \ 3585 return 0; \ 3586 } 3587 #define ide_tape_devset_rw_field(_name, _field) \ 3588 ide_tape_devset_get(_name, _field) \ 3589 ide_tape_devset_set(_name, _field) \ 3590 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3591 #define ide_tape_devset_r_field(_name, _field) \ 3592 ide_tape_devset_get(_name, _field) \ 3593 IDE_DEVSET(_name, 0, get_##_name, NULL) 3594 #endif 3595 #ifdef CONFIG_IDE_PROC_FS 3596 #endif 3597 #ifdef CONFIG_IDE_PROC_FS 3598 #endif 3599 /* LDV_COMMENT_END_PREP */ 3600 ldv_s_idetape_fops_file_operations++; 3601 3602 } 3603 3604 } 3605 3606 break; 3607 case 7: { 3608 3609 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3610 if(ldv_s_idetape_fops_file_operations==1) { 3611 3612 /* content: static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)*/ 3613 /* LDV_COMMENT_BEGIN_PREP */ 3614 #define DRV_NAME "ide-tape" 3615 #define IDETAPE_VERSION "1.20" 3616 #undef IDETAPE_DEBUG_LOG 3617 #ifdef IDETAPE_DEBUG_LOG 3618 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3619 #else 3620 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3621 #endif 3622 #define IDETAPE_MAX_PC_RETRIES 3 3623 #define IDETAPE_FIFO_THRESHOLD 2 3624 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3625 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3626 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3627 #define IDETAPE_DSC_MA_FAST 2*HZ 3628 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3629 #define IDETAPE_DSC_MA_SLOW 30*HZ 3630 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3631 #define DOOR_UNLOCKED 0 3632 #define DOOR_LOCKED 1 3633 #define DOOR_EXPLICITLY_LOCKED 2 3634 #define IDETAPE_SPACE_OVER_FILEMARK 1 3635 #define IDETAPE_SPACE_TO_EOD 3 3636 #define IDETAPE_LU_LOAD_MASK 1 3637 #define IDETAPE_LU_RETENSION_MASK 2 3638 #define IDETAPE_LU_EOT_MASK 4 3639 #define IDETAPE_BLOCK_DESCRIPTOR 0 3640 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3641 /* LDV_COMMENT_END_PREP */ 3642 /* LDV_COMMENT_FUNCTION_CALL Function from field "read" from driver structure with callbacks "idetape_fops". Standart function test for correct return result. */ 3643 ldv_handler_precall(); 3644 res_idetape_chrdev_read_30 = idetape_chrdev_read( var_group2, var_idetape_chrdev_read_30_p1, var_idetape_chrdev_read_30_p2, var_idetape_chrdev_read_30_p3); 3645 ldv_check_return_value(res_idetape_chrdev_read_30); 3646 if(res_idetape_chrdev_read_30 < 0) 3647 goto ldv_module_exit; 3648 /* LDV_COMMENT_BEGIN_PREP */ 3649 #ifdef CONFIG_IDE_PROC_FS 3650 #define ide_tape_devset_get(name, field) \ 3651 static int get_##name(ide_drive_t *drive) \ 3652 { \ 3653 idetape_tape_t *tape = drive->driver_data; \ 3654 return tape->field; \ 3655 } 3656 #define ide_tape_devset_set(name, field) \ 3657 static int set_##name(ide_drive_t *drive, int arg) \ 3658 { \ 3659 idetape_tape_t *tape = drive->driver_data; \ 3660 tape->field = arg; \ 3661 return 0; \ 3662 } 3663 #define ide_tape_devset_rw_field(_name, _field) \ 3664 ide_tape_devset_get(_name, _field) \ 3665 ide_tape_devset_set(_name, _field) \ 3666 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3667 #define ide_tape_devset_r_field(_name, _field) \ 3668 ide_tape_devset_get(_name, _field) \ 3669 IDE_DEVSET(_name, 0, get_##_name, NULL) 3670 #endif 3671 #ifdef CONFIG_IDE_PROC_FS 3672 #endif 3673 #ifdef CONFIG_IDE_PROC_FS 3674 #endif 3675 /* LDV_COMMENT_END_PREP */ 3676 ldv_s_idetape_fops_file_operations++; 3677 3678 } 3679 3680 } 3681 3682 break; 3683 case 8: { 3684 3685 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3686 if(ldv_s_idetape_fops_file_operations==2) { 3687 3688 /* content: static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)*/ 3689 /* LDV_COMMENT_BEGIN_PREP */ 3690 #define DRV_NAME "ide-tape" 3691 #define IDETAPE_VERSION "1.20" 3692 #undef IDETAPE_DEBUG_LOG 3693 #ifdef IDETAPE_DEBUG_LOG 3694 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3695 #else 3696 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3697 #endif 3698 #define IDETAPE_MAX_PC_RETRIES 3 3699 #define IDETAPE_FIFO_THRESHOLD 2 3700 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3701 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3702 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3703 #define IDETAPE_DSC_MA_FAST 2*HZ 3704 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3705 #define IDETAPE_DSC_MA_SLOW 30*HZ 3706 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3707 #define DOOR_UNLOCKED 0 3708 #define DOOR_LOCKED 1 3709 #define DOOR_EXPLICITLY_LOCKED 2 3710 #define IDETAPE_SPACE_OVER_FILEMARK 1 3711 #define IDETAPE_SPACE_TO_EOD 3 3712 #define IDETAPE_LU_LOAD_MASK 1 3713 #define IDETAPE_LU_RETENSION_MASK 2 3714 #define IDETAPE_LU_EOT_MASK 4 3715 #define IDETAPE_BLOCK_DESCRIPTOR 0 3716 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3717 /* LDV_COMMENT_END_PREP */ 3718 /* LDV_COMMENT_FUNCTION_CALL Function from field "write" from driver structure with callbacks "idetape_fops". Standart function test for correct return result. */ 3719 ldv_handler_precall(); 3720 res_idetape_chrdev_write_31 = idetape_chrdev_write( var_group2, var_idetape_chrdev_write_31_p1, var_idetape_chrdev_write_31_p2, var_idetape_chrdev_write_31_p3); 3721 ldv_check_return_value(res_idetape_chrdev_write_31); 3722 if(res_idetape_chrdev_write_31 < 0) 3723 goto ldv_module_exit; 3724 /* LDV_COMMENT_BEGIN_PREP */ 3725 #ifdef CONFIG_IDE_PROC_FS 3726 #define ide_tape_devset_get(name, field) \ 3727 static int get_##name(ide_drive_t *drive) \ 3728 { \ 3729 idetape_tape_t *tape = drive->driver_data; \ 3730 return tape->field; \ 3731 } 3732 #define ide_tape_devset_set(name, field) \ 3733 static int set_##name(ide_drive_t *drive, int arg) \ 3734 { \ 3735 idetape_tape_t *tape = drive->driver_data; \ 3736 tape->field = arg; \ 3737 return 0; \ 3738 } 3739 #define ide_tape_devset_rw_field(_name, _field) \ 3740 ide_tape_devset_get(_name, _field) \ 3741 ide_tape_devset_set(_name, _field) \ 3742 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3743 #define ide_tape_devset_r_field(_name, _field) \ 3744 ide_tape_devset_get(_name, _field) \ 3745 IDE_DEVSET(_name, 0, get_##_name, NULL) 3746 #endif 3747 #ifdef CONFIG_IDE_PROC_FS 3748 #endif 3749 #ifdef CONFIG_IDE_PROC_FS 3750 #endif 3751 /* LDV_COMMENT_END_PREP */ 3752 ldv_s_idetape_fops_file_operations++; 3753 3754 } 3755 3756 } 3757 3758 break; 3759 case 9: { 3760 3761 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3762 if(ldv_s_idetape_fops_file_operations==3) { 3763 3764 /* content: static int idetape_chrdev_release(struct inode *inode, struct file *filp)*/ 3765 /* LDV_COMMENT_BEGIN_PREP */ 3766 #define DRV_NAME "ide-tape" 3767 #define IDETAPE_VERSION "1.20" 3768 #undef IDETAPE_DEBUG_LOG 3769 #ifdef IDETAPE_DEBUG_LOG 3770 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3771 #else 3772 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3773 #endif 3774 #define IDETAPE_MAX_PC_RETRIES 3 3775 #define IDETAPE_FIFO_THRESHOLD 2 3776 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3777 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3778 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3779 #define IDETAPE_DSC_MA_FAST 2*HZ 3780 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3781 #define IDETAPE_DSC_MA_SLOW 30*HZ 3782 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3783 #define DOOR_UNLOCKED 0 3784 #define DOOR_LOCKED 1 3785 #define DOOR_EXPLICITLY_LOCKED 2 3786 #define IDETAPE_SPACE_OVER_FILEMARK 1 3787 #define IDETAPE_SPACE_TO_EOD 3 3788 #define IDETAPE_LU_LOAD_MASK 1 3789 #define IDETAPE_LU_RETENSION_MASK 2 3790 #define IDETAPE_LU_EOT_MASK 4 3791 #define IDETAPE_BLOCK_DESCRIPTOR 0 3792 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3793 /* LDV_COMMENT_END_PREP */ 3794 /* LDV_COMMENT_FUNCTION_CALL Function from field "release" from driver structure with callbacks "idetape_fops" */ 3795 ldv_handler_precall(); 3796 idetape_chrdev_release( var_group1, var_group2); 3797 /* LDV_COMMENT_BEGIN_PREP */ 3798 #ifdef CONFIG_IDE_PROC_FS 3799 #define ide_tape_devset_get(name, field) \ 3800 static int get_##name(ide_drive_t *drive) \ 3801 { \ 3802 idetape_tape_t *tape = drive->driver_data; \ 3803 return tape->field; \ 3804 } 3805 #define ide_tape_devset_set(name, field) \ 3806 static int set_##name(ide_drive_t *drive, int arg) \ 3807 { \ 3808 idetape_tape_t *tape = drive->driver_data; \ 3809 tape->field = arg; \ 3810 return 0; \ 3811 } 3812 #define ide_tape_devset_rw_field(_name, _field) \ 3813 ide_tape_devset_get(_name, _field) \ 3814 ide_tape_devset_set(_name, _field) \ 3815 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3816 #define ide_tape_devset_r_field(_name, _field) \ 3817 ide_tape_devset_get(_name, _field) \ 3818 IDE_DEVSET(_name, 0, get_##_name, NULL) 3819 #endif 3820 #ifdef CONFIG_IDE_PROC_FS 3821 #endif 3822 #ifdef CONFIG_IDE_PROC_FS 3823 #endif 3824 /* LDV_COMMENT_END_PREP */ 3825 ldv_s_idetape_fops_file_operations=0; 3826 3827 } 3828 3829 } 3830 3831 break; 3832 case 10: { 3833 3834 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3835 3836 3837 /* content: static long idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)*/ 3838 /* LDV_COMMENT_BEGIN_PREP */ 3839 #define DRV_NAME "ide-tape" 3840 #define IDETAPE_VERSION "1.20" 3841 #undef IDETAPE_DEBUG_LOG 3842 #ifdef IDETAPE_DEBUG_LOG 3843 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3844 #else 3845 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3846 #endif 3847 #define IDETAPE_MAX_PC_RETRIES 3 3848 #define IDETAPE_FIFO_THRESHOLD 2 3849 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3850 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3851 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3852 #define IDETAPE_DSC_MA_FAST 2*HZ 3853 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3854 #define IDETAPE_DSC_MA_SLOW 30*HZ 3855 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3856 #define DOOR_UNLOCKED 0 3857 #define DOOR_LOCKED 1 3858 #define DOOR_EXPLICITLY_LOCKED 2 3859 #define IDETAPE_SPACE_OVER_FILEMARK 1 3860 #define IDETAPE_SPACE_TO_EOD 3 3861 #define IDETAPE_LU_LOAD_MASK 1 3862 #define IDETAPE_LU_RETENSION_MASK 2 3863 #define IDETAPE_LU_EOT_MASK 4 3864 #define IDETAPE_BLOCK_DESCRIPTOR 0 3865 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3866 /* LDV_COMMENT_END_PREP */ 3867 /* LDV_COMMENT_FUNCTION_CALL Function from field "unlocked_ioctl" from driver structure with callbacks "idetape_fops" */ 3868 ldv_handler_precall(); 3869 idetape_chrdev_ioctl( var_group2, var_idetape_chrdev_ioctl_35_p1, var_idetape_chrdev_ioctl_35_p2); 3870 /* LDV_COMMENT_BEGIN_PREP */ 3871 #ifdef CONFIG_IDE_PROC_FS 3872 #define ide_tape_devset_get(name, field) \ 3873 static int get_##name(ide_drive_t *drive) \ 3874 { \ 3875 idetape_tape_t *tape = drive->driver_data; \ 3876 return tape->field; \ 3877 } 3878 #define ide_tape_devset_set(name, field) \ 3879 static int set_##name(ide_drive_t *drive, int arg) \ 3880 { \ 3881 idetape_tape_t *tape = drive->driver_data; \ 3882 tape->field = arg; \ 3883 return 0; \ 3884 } 3885 #define ide_tape_devset_rw_field(_name, _field) \ 3886 ide_tape_devset_get(_name, _field) \ 3887 ide_tape_devset_set(_name, _field) \ 3888 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3889 #define ide_tape_devset_r_field(_name, _field) \ 3890 ide_tape_devset_get(_name, _field) \ 3891 IDE_DEVSET(_name, 0, get_##_name, NULL) 3892 #endif 3893 #ifdef CONFIG_IDE_PROC_FS 3894 #endif 3895 #ifdef CONFIG_IDE_PROC_FS 3896 #endif 3897 /* LDV_COMMENT_END_PREP */ 3898 3899 3900 3901 3902 } 3903 3904 break; 3905 case 11: { 3906 3907 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 3908 if(ldv_s_idetape_block_ops_block_device_operations==0) { 3909 3910 /* content: static int idetape_open(struct block_device *bdev, fmode_t mode)*/ 3911 /* LDV_COMMENT_BEGIN_PREP */ 3912 #define DRV_NAME "ide-tape" 3913 #define IDETAPE_VERSION "1.20" 3914 #undef IDETAPE_DEBUG_LOG 3915 #ifdef IDETAPE_DEBUG_LOG 3916 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3917 #else 3918 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3919 #endif 3920 #define IDETAPE_MAX_PC_RETRIES 3 3921 #define IDETAPE_FIFO_THRESHOLD 2 3922 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3923 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3924 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3925 #define IDETAPE_DSC_MA_FAST 2*HZ 3926 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3927 #define IDETAPE_DSC_MA_SLOW 30*HZ 3928 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3929 #define DOOR_UNLOCKED 0 3930 #define DOOR_LOCKED 1 3931 #define DOOR_EXPLICITLY_LOCKED 2 3932 #define IDETAPE_SPACE_OVER_FILEMARK 1 3933 #define IDETAPE_SPACE_TO_EOD 3 3934 #define IDETAPE_LU_LOAD_MASK 1 3935 #define IDETAPE_LU_RETENSION_MASK 2 3936 #define IDETAPE_LU_EOT_MASK 4 3937 #define IDETAPE_BLOCK_DESCRIPTOR 0 3938 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3939 #ifdef CONFIG_IDE_PROC_FS 3940 #define ide_tape_devset_get(name, field) \ 3941 static int get_##name(ide_drive_t *drive) \ 3942 { \ 3943 idetape_tape_t *tape = drive->driver_data; \ 3944 return tape->field; \ 3945 } 3946 #define ide_tape_devset_set(name, field) \ 3947 static int set_##name(ide_drive_t *drive, int arg) \ 3948 { \ 3949 idetape_tape_t *tape = drive->driver_data; \ 3950 tape->field = arg; \ 3951 return 0; \ 3952 } 3953 #define ide_tape_devset_rw_field(_name, _field) \ 3954 ide_tape_devset_get(_name, _field) \ 3955 ide_tape_devset_set(_name, _field) \ 3956 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3957 #define ide_tape_devset_r_field(_name, _field) \ 3958 ide_tape_devset_get(_name, _field) \ 3959 IDE_DEVSET(_name, 0, get_##_name, NULL) 3960 #endif 3961 #ifdef CONFIG_IDE_PROC_FS 3962 #endif 3963 #ifdef CONFIG_IDE_PROC_FS 3964 #endif 3965 /* LDV_COMMENT_END_PREP */ 3966 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "idetape_block_ops". Standart function test for correct return result. */ 3967 ldv_handler_precall(); 3968 res_idetape_open_53 = idetape_open( var_group4, var_idetape_open_53_p1); 3969 ldv_check_return_value(res_idetape_open_53); 3970 if(res_idetape_open_53) 3971 goto ldv_module_exit; 3972 ldv_s_idetape_block_ops_block_device_operations++; 3973 3974 } 3975 3976 } 3977 3978 break; 3979 case 12: { 3980 3981 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 3982 if(ldv_s_idetape_block_ops_block_device_operations==1) { 3983 3984 /* content: static void idetape_release(struct gendisk *disk, fmode_t mode)*/ 3985 /* LDV_COMMENT_BEGIN_PREP */ 3986 #define DRV_NAME "ide-tape" 3987 #define IDETAPE_VERSION "1.20" 3988 #undef IDETAPE_DEBUG_LOG 3989 #ifdef IDETAPE_DEBUG_LOG 3990 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3991 #else 3992 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3993 #endif 3994 #define IDETAPE_MAX_PC_RETRIES 3 3995 #define IDETAPE_FIFO_THRESHOLD 2 3996 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3997 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3998 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3999 #define IDETAPE_DSC_MA_FAST 2*HZ 4000 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 4001 #define IDETAPE_DSC_MA_SLOW 30*HZ 4002 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 4003 #define DOOR_UNLOCKED 0 4004 #define DOOR_LOCKED 1 4005 #define DOOR_EXPLICITLY_LOCKED 2 4006 #define IDETAPE_SPACE_OVER_FILEMARK 1 4007 #define IDETAPE_SPACE_TO_EOD 3 4008 #define IDETAPE_LU_LOAD_MASK 1 4009 #define IDETAPE_LU_RETENSION_MASK 2 4010 #define IDETAPE_LU_EOT_MASK 4 4011 #define IDETAPE_BLOCK_DESCRIPTOR 0 4012 #define IDETAPE_CAPABILITIES_PAGE 0x2a 4013 #ifdef CONFIG_IDE_PROC_FS 4014 #define ide_tape_devset_get(name, field) \ 4015 static int get_##name(ide_drive_t *drive) \ 4016 { \ 4017 idetape_tape_t *tape = drive->driver_data; \ 4018 return tape->field; \ 4019 } 4020 #define ide_tape_devset_set(name, field) \ 4021 static int set_##name(ide_drive_t *drive, int arg) \ 4022 { \ 4023 idetape_tape_t *tape = drive->driver_data; \ 4024 tape->field = arg; \ 4025 return 0; \ 4026 } 4027 #define ide_tape_devset_rw_field(_name, _field) \ 4028 ide_tape_devset_get(_name, _field) \ 4029 ide_tape_devset_set(_name, _field) \ 4030 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 4031 #define ide_tape_devset_r_field(_name, _field) \ 4032 ide_tape_devset_get(_name, _field) \ 4033 IDE_DEVSET(_name, 0, get_##_name, NULL) 4034 #endif 4035 #ifdef CONFIG_IDE_PROC_FS 4036 #endif 4037 #ifdef CONFIG_IDE_PROC_FS 4038 #endif 4039 /* LDV_COMMENT_END_PREP */ 4040 /* LDV_COMMENT_FUNCTION_CALL Function from field "release" from driver structure with callbacks "idetape_block_ops" */ 4041 ldv_handler_precall(); 4042 idetape_release( var_group5, var_idetape_release_54_p1); 4043 ldv_s_idetape_block_ops_block_device_operations=0; 4044 4045 } 4046 4047 } 4048 4049 break; 4050 case 13: { 4051 4052 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 4053 4054 4055 /* content: static int idetape_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)*/ 4056 /* LDV_COMMENT_BEGIN_PREP */ 4057 #define DRV_NAME "ide-tape" 4058 #define IDETAPE_VERSION "1.20" 4059 #undef IDETAPE_DEBUG_LOG 4060 #ifdef IDETAPE_DEBUG_LOG 4061 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 4062 #else 4063 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 4064 #endif 4065 #define IDETAPE_MAX_PC_RETRIES 3 4066 #define IDETAPE_FIFO_THRESHOLD 2 4067 #define IDETAPE_DSC_RW_MIN 5*HZ/100 4068 #define IDETAPE_DSC_RW_MAX 40*HZ/100 4069 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 4070 #define IDETAPE_DSC_MA_FAST 2*HZ 4071 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 4072 #define IDETAPE_DSC_MA_SLOW 30*HZ 4073 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 4074 #define DOOR_UNLOCKED 0 4075 #define DOOR_LOCKED 1 4076 #define DOOR_EXPLICITLY_LOCKED 2 4077 #define IDETAPE_SPACE_OVER_FILEMARK 1 4078 #define IDETAPE_SPACE_TO_EOD 3 4079 #define IDETAPE_LU_LOAD_MASK 1 4080 #define IDETAPE_LU_RETENSION_MASK 2 4081 #define IDETAPE_LU_EOT_MASK 4 4082 #define IDETAPE_BLOCK_DESCRIPTOR 0 4083 #define IDETAPE_CAPABILITIES_PAGE 0x2a 4084 #ifdef CONFIG_IDE_PROC_FS 4085 #define ide_tape_devset_get(name, field) \ 4086 static int get_##name(ide_drive_t *drive) \ 4087 { \ 4088 idetape_tape_t *tape = drive->driver_data; \ 4089 return tape->field; \ 4090 } 4091 #define ide_tape_devset_set(name, field) \ 4092 static int set_##name(ide_drive_t *drive, int arg) \ 4093 { \ 4094 idetape_tape_t *tape = drive->driver_data; \ 4095 tape->field = arg; \ 4096 return 0; \ 4097 } 4098 #define ide_tape_devset_rw_field(_name, _field) \ 4099 ide_tape_devset_get(_name, _field) \ 4100 ide_tape_devset_set(_name, _field) \ 4101 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 4102 #define ide_tape_devset_r_field(_name, _field) \ 4103 ide_tape_devset_get(_name, _field) \ 4104 IDE_DEVSET(_name, 0, get_##_name, NULL) 4105 #endif 4106 #ifdef CONFIG_IDE_PROC_FS 4107 #endif 4108 #ifdef CONFIG_IDE_PROC_FS 4109 #endif 4110 /* LDV_COMMENT_END_PREP */ 4111 /* LDV_COMMENT_FUNCTION_CALL Function from field "ioctl" from driver structure with callbacks "idetape_block_ops" */ 4112 ldv_handler_precall(); 4113 idetape_ioctl( var_group4, var_idetape_ioctl_55_p1, var_idetape_ioctl_55_p2, var_idetape_ioctl_55_p3); 4114 4115 4116 4117 4118 } 4119 4120 break; 4121 default: break; 4122 4123 } 4124 4125 } 4126 4127 ldv_module_exit: 4128 4129 /** INIT: init_type: ST_MODULE_EXIT **/ 4130 /* content: static void __exit idetape_exit(void)*/ 4131 /* LDV_COMMENT_BEGIN_PREP */ 4132 #define DRV_NAME "ide-tape" 4133 #define IDETAPE_VERSION "1.20" 4134 #undef IDETAPE_DEBUG_LOG 4135 #ifdef IDETAPE_DEBUG_LOG 4136 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 4137 #else 4138 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 4139 #endif 4140 #define IDETAPE_MAX_PC_RETRIES 3 4141 #define IDETAPE_FIFO_THRESHOLD 2 4142 #define IDETAPE_DSC_RW_MIN 5*HZ/100 4143 #define IDETAPE_DSC_RW_MAX 40*HZ/100 4144 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 4145 #define IDETAPE_DSC_MA_FAST 2*HZ 4146 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 4147 #define IDETAPE_DSC_MA_SLOW 30*HZ 4148 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 4149 #define DOOR_UNLOCKED 0 4150 #define DOOR_LOCKED 1 4151 #define DOOR_EXPLICITLY_LOCKED 2 4152 #define IDETAPE_SPACE_OVER_FILEMARK 1 4153 #define IDETAPE_SPACE_TO_EOD 3 4154 #define IDETAPE_LU_LOAD_MASK 1 4155 #define IDETAPE_LU_RETENSION_MASK 2 4156 #define IDETAPE_LU_EOT_MASK 4 4157 #define IDETAPE_BLOCK_DESCRIPTOR 0 4158 #define IDETAPE_CAPABILITIES_PAGE 0x2a 4159 #ifdef CONFIG_IDE_PROC_FS 4160 #define ide_tape_devset_get(name, field) \ 4161 static int get_##name(ide_drive_t *drive) \ 4162 { \ 4163 idetape_tape_t *tape = drive->driver_data; \ 4164 return tape->field; \ 4165 } 4166 #define ide_tape_devset_set(name, field) \ 4167 static int set_##name(ide_drive_t *drive, int arg) \ 4168 { \ 4169 idetape_tape_t *tape = drive->driver_data; \ 4170 tape->field = arg; \ 4171 return 0; \ 4172 } 4173 #define ide_tape_devset_rw_field(_name, _field) \ 4174 ide_tape_devset_get(_name, _field) \ 4175 ide_tape_devset_set(_name, _field) \ 4176 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 4177 #define ide_tape_devset_r_field(_name, _field) \ 4178 ide_tape_devset_get(_name, _field) \ 4179 IDE_DEVSET(_name, 0, get_##_name, NULL) 4180 #endif 4181 #ifdef CONFIG_IDE_PROC_FS 4182 #endif 4183 #ifdef CONFIG_IDE_PROC_FS 4184 #endif 4185 /* LDV_COMMENT_END_PREP */ 4186 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */ 4187 ldv_handler_precall(); 4188 idetape_exit(); 4189 4190 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 4191 ldv_final: ldv_check_final_state(); 4192 4193 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 4194 return; 4195 4196 } 4197 #endif 4198 4199 /* LDV_COMMENT_END_MAIN */
1 2 #include <linux/kernel.h> 3 bool ldv_is_err(const void *ptr); 4 bool ldv_is_err_or_null(const void *ptr); 5 void* ldv_err_ptr(long error); 6 long ldv_ptr_err(const void *ptr); 7 8 9 // Provide model function prototypes before their usage. 10 11 void *ldv_create_class(void); 12 int ldv_register_class(void); 13 void ldv_unregister_class(void); 14 15 int ldv_register_chrdev(int major); 16 int ldv_register_chrdev_region(void); 17 void ldv_unregister_chrdev_region(void); 18 19 int ldv_register_usb_gadget(void); 20 void ldv_unregister_usb_gadget(void); 21 #line 1 "/home/ubuntu/launches/work/current--X--drivers--X--defaultlinux-4.7-rc1.tar.xz--X--106_1a--X--cpachecker/linux-4.7-rc1.tar.xz/csd_deg_dscv/8139/dscv_tempdir/dscv/ri/106_1a/drivers/ide/ide-tape.c" 22 23 /* 24 * IDE ATAPI streaming tape driver. 25 * 26 * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> 27 * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz 28 * 29 * This driver was constructed as a student project in the software laboratory 30 * of the faculty of electrical engineering in the Technion - Israel's 31 * Institute Of Technology, with the guide of Avner Lottem and Dr. Ilana David. 32 * 33 * It is hereby placed under the terms of the GNU general public license. 34 * (See linux/COPYING). 35 * 36 * For a historical changelog see 37 * Documentation/ide/ChangeLog.ide-tape.1995-2002 38 */ 39 40 #define DRV_NAME "ide-tape" 41 42 #define IDETAPE_VERSION "1.20" 43 44 #include <linux/module.h> 45 #include <linux/types.h> 46 #include <linux/string.h> 47 #include <linux/kernel.h> 48 #include <linux/delay.h> 49 #include <linux/timer.h> 50 #include <linux/mm.h> 51 #include <linux/interrupt.h> 52 #include <linux/jiffies.h> 53 #include <linux/major.h> 54 #include <linux/errno.h> 55 #include <linux/genhd.h> 56 #include <linux/seq_file.h> 57 #include <linux/slab.h> 58 #include <linux/pci.h> 59 #include <linux/ide.h> 60 #include <linux/completion.h> 61 #include <linux/bitops.h> 62 #include <linux/mutex.h> 63 #include <scsi/scsi.h> 64 65 #include <asm/byteorder.h> 66 #include <linux/uaccess.h> 67 #include <linux/io.h> 68 #include <asm/unaligned.h> 69 #include <linux/mtio.h> 70 71 /* define to see debug info */ 72 #undef IDETAPE_DEBUG_LOG 73 74 #ifdef IDETAPE_DEBUG_LOG 75 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 76 #else 77 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 78 #endif 79 80 /**************************** Tunable parameters *****************************/ 81 /* 82 * After each failed packet command we issue a request sense command and retry 83 * the packet command IDETAPE_MAX_PC_RETRIES times. 84 * 85 * Setting IDETAPE_MAX_PC_RETRIES to 0 will disable retries. 86 */ 87 #define IDETAPE_MAX_PC_RETRIES 3 88 89 /* 90 * The following parameter is used to select the point in the internal tape fifo 91 * in which we will start to refill the buffer. Decreasing the following 92 * parameter will improve the system's latency and interactive response, while 93 * using a high value might improve system throughput. 94 */ 95 #define IDETAPE_FIFO_THRESHOLD 2 96 97 /* 98 * DSC polling parameters. 99 * 100 * Polling for DSC (a single bit in the status register) is a very important 101 * function in ide-tape. There are two cases in which we poll for DSC: 102 * 103 * 1. Before a read/write packet command, to ensure that we can transfer data 104 * from/to the tape's data buffers, without causing an actual media access. 105 * In case the tape is not ready yet, we take out our request from the device 106 * request queue, so that ide.c could service requests from the other device 107 * on the same interface in the meantime. 108 * 109 * 2. After the successful initialization of a "media access packet command", 110 * which is a command that can take a long time to complete (the interval can 111 * range from several seconds to even an hour). Again, we postpone our request 112 * in the middle to free the bus for the other device. The polling frequency 113 * here should be lower than the read/write frequency since those media access 114 * commands are slow. We start from a "fast" frequency - IDETAPE_DSC_MA_FAST 115 * (1 second), and if we don't receive DSC after IDETAPE_DSC_MA_THRESHOLD 116 * (5 min), we switch it to a lower frequency - IDETAPE_DSC_MA_SLOW (1 min). 117 * 118 * We also set a timeout for the timer, in case something goes wrong. The 119 * timeout should be longer then the maximum execution time of a tape operation. 120 */ 121 122 /* DSC timings. */ 123 #define IDETAPE_DSC_RW_MIN 5*HZ/100 /* 50 msec */ 124 #define IDETAPE_DSC_RW_MAX 40*HZ/100 /* 400 msec */ 125 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ /* 2 minutes */ 126 #define IDETAPE_DSC_MA_FAST 2*HZ /* 2 seconds */ 127 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ /* 5 minutes */ 128 #define IDETAPE_DSC_MA_SLOW 30*HZ /* 30 seconds */ 129 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ /* 2 hours */ 130 131 /*************************** End of tunable parameters ***********************/ 132 133 /* tape directions */ 134 enum { 135 IDETAPE_DIR_NONE = (1 << 0), 136 IDETAPE_DIR_READ = (1 << 1), 137 IDETAPE_DIR_WRITE = (1 << 2), 138 }; 139 140 /* Tape door status */ 141 #define DOOR_UNLOCKED 0 142 #define DOOR_LOCKED 1 143 #define DOOR_EXPLICITLY_LOCKED 2 144 145 /* Some defines for the SPACE command */ 146 #define IDETAPE_SPACE_OVER_FILEMARK 1 147 #define IDETAPE_SPACE_TO_EOD 3 148 149 /* Some defines for the LOAD UNLOAD command */ 150 #define IDETAPE_LU_LOAD_MASK 1 151 #define IDETAPE_LU_RETENSION_MASK 2 152 #define IDETAPE_LU_EOT_MASK 4 153 154 /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ 155 #define IDETAPE_BLOCK_DESCRIPTOR 0 156 #define IDETAPE_CAPABILITIES_PAGE 0x2a 157 158 /* 159 * Most of our global data which we need to save even as we leave the driver due 160 * to an interrupt or a timer event is stored in the struct defined below. 161 */ 162 typedef struct ide_tape_obj { 163 ide_drive_t *drive; 164 struct ide_driver *driver; 165 struct gendisk *disk; 166 struct device dev; 167 168 /* used by REQ_IDETAPE_{READ,WRITE} requests */ 169 struct ide_atapi_pc queued_pc; 170 171 /* 172 * DSC polling variables. 173 * 174 * While polling for DSC we use postponed_rq to postpone the current 175 * request so that ide.c will be able to service pending requests on the 176 * other device. Note that at most we will have only one DSC (usually 177 * data transfer) request in the device request queue. 178 */ 179 bool postponed_rq; 180 181 /* The time in which we started polling for DSC */ 182 unsigned long dsc_polling_start; 183 /* Timer used to poll for dsc */ 184 struct timer_list dsc_timer; 185 /* Read/Write dsc polling frequency */ 186 unsigned long best_dsc_rw_freq; 187 unsigned long dsc_poll_freq; 188 unsigned long dsc_timeout; 189 190 /* Read position information */ 191 u8 partition; 192 /* Current block */ 193 unsigned int first_frame; 194 195 /* Last error information */ 196 u8 sense_key, asc, ascq; 197 198 /* Character device operation */ 199 unsigned int minor; 200 /* device name */ 201 char name[4]; 202 /* Current character device data transfer direction */ 203 u8 chrdev_dir; 204 205 /* tape block size, usually 512 or 1024 bytes */ 206 unsigned short blk_size; 207 int user_bs_factor; 208 209 /* Copy of the tape's Capabilities and Mechanical Page */ 210 u8 caps[20]; 211 212 /* 213 * Active data transfer request parameters. 214 * 215 * At most, there is only one ide-tape originated data transfer request 216 * in the device request queue. This allows ide.c to easily service 217 * requests from the other device when we postpone our active request. 218 */ 219 220 /* Data buffer size chosen based on the tape's recommendation */ 221 int buffer_size; 222 /* Staging buffer of buffer_size bytes */ 223 void *buf; 224 /* The read/write cursor */ 225 void *cur; 226 /* The number of valid bytes in buf */ 227 size_t valid; 228 229 /* Measures average tape speed */ 230 unsigned long avg_time; 231 int avg_size; 232 int avg_speed; 233 234 /* the door is currently locked */ 235 int door_locked; 236 /* the tape hardware is write protected */ 237 char drv_write_prot; 238 /* the tape is write protected (hardware or opened as read-only) */ 239 char write_prot; 240 } idetape_tape_t; 241 242 static DEFINE_MUTEX(ide_tape_mutex); 243 static DEFINE_MUTEX(idetape_ref_mutex); 244 245 static DEFINE_MUTEX(idetape_chrdev_mutex); 246 247 static struct class *idetape_sysfs_class; 248 249 static void ide_tape_release(struct device *); 250 251 static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; 252 253 static struct ide_tape_obj *ide_tape_get(struct gendisk *disk, bool cdev, 254 unsigned int i) 255 { 256 struct ide_tape_obj *tape = NULL; 257 258 mutex_lock(&idetape_ref_mutex); 259 260 if (cdev) 261 tape = idetape_devs[i]; 262 else 263 tape = ide_drv_g(disk, ide_tape_obj); 264 265 if (tape) { 266 if (ide_device_get(tape->drive)) 267 tape = NULL; 268 else 269 get_device(&tape->dev); 270 } 271 272 mutex_unlock(&idetape_ref_mutex); 273 return tape; 274 } 275 276 static void ide_tape_put(struct ide_tape_obj *tape) 277 { 278 ide_drive_t *drive = tape->drive; 279 280 mutex_lock(&idetape_ref_mutex); 281 put_device(&tape->dev); 282 ide_device_put(drive); 283 mutex_unlock(&idetape_ref_mutex); 284 } 285 286 /* 287 * called on each failed packet command retry to analyze the request sense. We 288 * currently do not utilize this information. 289 */ 290 static void idetape_analyze_error(ide_drive_t *drive) 291 { 292 idetape_tape_t *tape = drive->driver_data; 293 struct ide_atapi_pc *pc = drive->failed_pc; 294 struct request *rq = drive->hwif->rq; 295 u8 *sense = bio_data(rq->bio); 296 297 tape->sense_key = sense[2] & 0xF; 298 tape->asc = sense[12]; 299 tape->ascq = sense[13]; 300 301 ide_debug_log(IDE_DBG_FUNC, 302 "cmd: 0x%x, sense key = %x, asc = %x, ascq = %x", 303 rq->cmd[0], tape->sense_key, tape->asc, tape->ascq); 304 305 /* correct remaining bytes to transfer */ 306 if (pc->flags & PC_FLAG_DMA_ERROR) 307 rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); 308 309 /* 310 * If error was the result of a zero-length read or write command, 311 * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives 312 * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. 313 */ 314 if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6) 315 /* length == 0 */ 316 && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { 317 if (tape->sense_key == 5) { 318 /* don't report an error, everything's ok */ 319 pc->error = 0; 320 /* don't retry read/write */ 321 pc->flags |= PC_FLAG_ABORT; 322 } 323 } 324 if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { 325 pc->error = IDE_DRV_ERROR_FILEMARK; 326 pc->flags |= PC_FLAG_ABORT; 327 } 328 if (pc->c[0] == WRITE_6) { 329 if ((sense[2] & 0x40) || (tape->sense_key == 0xd 330 && tape->asc == 0x0 && tape->ascq == 0x2)) { 331 pc->error = IDE_DRV_ERROR_EOD; 332 pc->flags |= PC_FLAG_ABORT; 333 } 334 } 335 if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { 336 if (tape->sense_key == 8) { 337 pc->error = IDE_DRV_ERROR_EOD; 338 pc->flags |= PC_FLAG_ABORT; 339 } 340 if (!(pc->flags & PC_FLAG_ABORT) && 341 (blk_rq_bytes(rq) - rq->resid_len)) 342 pc->retries = IDETAPE_MAX_PC_RETRIES + 1; 343 } 344 } 345 346 static void ide_tape_handle_dsc(ide_drive_t *); 347 348 static int ide_tape_callback(ide_drive_t *drive, int dsc) 349 { 350 idetape_tape_t *tape = drive->driver_data; 351 struct ide_atapi_pc *pc = drive->pc; 352 struct request *rq = drive->hwif->rq; 353 int uptodate = pc->error ? 0 : 1; 354 int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; 355 356 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc: %d, err: %d", rq->cmd[0], 357 dsc, err); 358 359 if (dsc) 360 ide_tape_handle_dsc(drive); 361 362 if (drive->failed_pc == pc) 363 drive->failed_pc = NULL; 364 365 if (pc->c[0] == REQUEST_SENSE) { 366 if (uptodate) 367 idetape_analyze_error(drive); 368 else 369 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " 370 "itself - Aborting request!\n"); 371 } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { 372 unsigned int blocks = 373 (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; 374 375 tape->avg_size += blocks * tape->blk_size; 376 377 if (time_after_eq(jiffies, tape->avg_time + HZ)) { 378 tape->avg_speed = tape->avg_size * HZ / 379 (jiffies - tape->avg_time) / 1024; 380 tape->avg_size = 0; 381 tape->avg_time = jiffies; 382 } 383 384 tape->first_frame += blocks; 385 386 if (pc->error) { 387 uptodate = 0; 388 err = pc->error; 389 } 390 } 391 rq->errors = err; 392 393 return uptodate; 394 } 395 396 /* 397 * Postpone the current request so that ide.c will be able to service requests 398 * from another device on the same port while we are polling for DSC. 399 */ 400 static void ide_tape_stall_queue(ide_drive_t *drive) 401 { 402 idetape_tape_t *tape = drive->driver_data; 403 404 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu", 405 drive->hwif->rq->cmd[0], tape->dsc_poll_freq); 406 407 tape->postponed_rq = true; 408 409 ide_stall_queue(drive, tape->dsc_poll_freq); 410 } 411 412 static void ide_tape_handle_dsc(ide_drive_t *drive) 413 { 414 idetape_tape_t *tape = drive->driver_data; 415 416 /* Media access command */ 417 tape->dsc_polling_start = jiffies; 418 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; 419 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; 420 /* Allow ide.c to handle other requests */ 421 ide_tape_stall_queue(drive); 422 } 423 424 /* 425 * Packet Command Interface 426 * 427 * The current Packet Command is available in drive->pc, and will not change 428 * until we finish handling it. Each packet command is associated with a 429 * callback function that will be called when the command is finished. 430 * 431 * The handling will be done in three stages: 432 * 433 * 1. ide_tape_issue_pc will send the packet command to the drive, and will set 434 * the interrupt handler to ide_pc_intr. 435 * 436 * 2. On each interrupt, ide_pc_intr will be called. This step will be 437 * repeated until the device signals us that no more interrupts will be issued. 438 * 439 * 3. ATAPI Tape media access commands have immediate status with a delayed 440 * process. In case of a successful initiation of a media access packet command, 441 * the DSC bit will be set when the actual execution of the command is finished. 442 * Since the tape drive will not issue an interrupt, we have to poll for this 443 * event. In this case, we define the request as "low priority request" by 444 * setting rq_status to IDETAPE_RQ_POSTPONED, set a timer to poll for DSC and 445 * exit the driver. 446 * 447 * ide.c will then give higher priority to requests which originate from the 448 * other device, until will change rq_status to RQ_ACTIVE. 449 * 450 * 4. When the packet command is finished, it will be checked for errors. 451 * 452 * 5. In case an error was found, we queue a request sense packet command in 453 * front of the request queue and retry the operation up to 454 * IDETAPE_MAX_PC_RETRIES times. 455 * 456 * 6. In case no error was found, or we decided to give up and not to retry 457 * again, the callback function will be called and then we will handle the next 458 * request. 459 */ 460 461 static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, 462 struct ide_cmd *cmd, 463 struct ide_atapi_pc *pc) 464 { 465 idetape_tape_t *tape = drive->driver_data; 466 struct request *rq = drive->hwif->rq; 467 468 if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) 469 drive->failed_pc = pc; 470 471 /* Set the current packet command */ 472 drive->pc = pc; 473 474 if (pc->retries > IDETAPE_MAX_PC_RETRIES || 475 (pc->flags & PC_FLAG_ABORT)) { 476 477 /* 478 * We will "abort" retrying a packet command in case legitimate 479 * error code was received (crossing a filemark, or end of the 480 * media, for example). 481 */ 482 if (!(pc->flags & PC_FLAG_ABORT)) { 483 if (!(pc->c[0] == TEST_UNIT_READY && 484 tape->sense_key == 2 && tape->asc == 4 && 485 (tape->ascq == 1 || tape->ascq == 8))) { 486 printk(KERN_ERR "ide-tape: %s: I/O error, " 487 "pc = %2x, key = %2x, " 488 "asc = %2x, ascq = %2x\n", 489 tape->name, pc->c[0], 490 tape->sense_key, tape->asc, 491 tape->ascq); 492 } 493 /* Giving up */ 494 pc->error = IDE_DRV_ERROR_GENERAL; 495 } 496 497 drive->failed_pc = NULL; 498 drive->pc_callback(drive, 0); 499 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); 500 return ide_stopped; 501 } 502 ide_debug_log(IDE_DBG_SENSE, "retry #%d, cmd: 0x%02x", pc->retries, 503 pc->c[0]); 504 505 pc->retries++; 506 507 return ide_issue_pc(drive, cmd); 508 } 509 510 /* A mode sense command is used to "sense" tape parameters. */ 511 static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) 512 { 513 ide_init_pc(pc); 514 pc->c[0] = MODE_SENSE; 515 if (page_code != IDETAPE_BLOCK_DESCRIPTOR) 516 /* DBD = 1 - Don't return block descriptors */ 517 pc->c[1] = 8; 518 pc->c[2] = page_code; 519 /* 520 * Changed pc->c[3] to 0 (255 will at best return unused info). 521 * 522 * For SCSI this byte is defined as subpage instead of high byte 523 * of length and some IDE drives seem to interpret it this way 524 * and return an error when 255 is used. 525 */ 526 pc->c[3] = 0; 527 /* We will just discard data in that case */ 528 pc->c[4] = 255; 529 if (page_code == IDETAPE_BLOCK_DESCRIPTOR) 530 pc->req_xfer = 12; 531 else if (page_code == IDETAPE_CAPABILITIES_PAGE) 532 pc->req_xfer = 24; 533 else 534 pc->req_xfer = 50; 535 } 536 537 static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) 538 { 539 ide_hwif_t *hwif = drive->hwif; 540 idetape_tape_t *tape = drive->driver_data; 541 struct ide_atapi_pc *pc = drive->pc; 542 u8 stat; 543 544 stat = hwif->tp_ops->read_status(hwif); 545 546 if (stat & ATA_DSC) { 547 if (stat & ATA_ERR) { 548 /* Error detected */ 549 if (pc->c[0] != TEST_UNIT_READY) 550 printk(KERN_ERR "ide-tape: %s: I/O error, ", 551 tape->name); 552 /* Retry operation */ 553 ide_retry_pc(drive); 554 return ide_stopped; 555 } 556 pc->error = 0; 557 } else { 558 pc->error = IDE_DRV_ERROR_GENERAL; 559 drive->failed_pc = NULL; 560 } 561 drive->pc_callback(drive, 0); 562 return ide_stopped; 563 } 564 565 static void ide_tape_create_rw_cmd(idetape_tape_t *tape, 566 struct ide_atapi_pc *pc, struct request *rq, 567 u8 opcode) 568 { 569 unsigned int length = blk_rq_sectors(rq) / (tape->blk_size >> 9); 570 571 ide_init_pc(pc); 572 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); 573 pc->c[1] = 1; 574 575 if (blk_rq_bytes(rq) == tape->buffer_size) 576 pc->flags |= PC_FLAG_DMA_OK; 577 578 if (opcode == READ_6) 579 pc->c[0] = READ_6; 580 else if (opcode == WRITE_6) { 581 pc->c[0] = WRITE_6; 582 pc->flags |= PC_FLAG_WRITING; 583 } 584 585 memcpy(rq->cmd, pc->c, 12); 586 } 587 588 static ide_startstop_t idetape_do_request(ide_drive_t *drive, 589 struct request *rq, sector_t block) 590 { 591 ide_hwif_t *hwif = drive->hwif; 592 idetape_tape_t *tape = drive->driver_data; 593 struct ide_atapi_pc *pc = NULL; 594 struct ide_cmd cmd; 595 u8 stat; 596 597 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u", 598 rq->cmd[0], (unsigned long long)blk_rq_pos(rq), 599 blk_rq_sectors(rq)); 600 601 BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV || 602 rq->cmd_type == REQ_TYPE_ATA_SENSE)); 603 604 /* Retry a failed packet command */ 605 if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { 606 pc = drive->failed_pc; 607 goto out; 608 } 609 610 /* 611 * If the tape is still busy, postpone our request and service 612 * the other device meanwhile. 613 */ 614 stat = hwif->tp_ops->read_status(hwif); 615 616 if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && 617 (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) 618 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; 619 620 if (drive->dev_flags & IDE_DFLAG_POST_RESET) { 621 drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; 622 drive->dev_flags &= ~IDE_DFLAG_POST_RESET; 623 } 624 625 if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && 626 !(stat & ATA_DSC)) { 627 if (!tape->postponed_rq) { 628 tape->dsc_polling_start = jiffies; 629 tape->dsc_poll_freq = tape->best_dsc_rw_freq; 630 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; 631 } else if (time_after(jiffies, tape->dsc_timeout)) { 632 printk(KERN_ERR "ide-tape: %s: DSC timeout\n", 633 tape->name); 634 if (rq->cmd[13] & REQ_IDETAPE_PC2) { 635 idetape_media_access_finished(drive); 636 return ide_stopped; 637 } else { 638 return ide_do_reset(drive); 639 } 640 } else if (time_after(jiffies, 641 tape->dsc_polling_start + 642 IDETAPE_DSC_MA_THRESHOLD)) 643 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; 644 ide_tape_stall_queue(drive); 645 return ide_stopped; 646 } else { 647 drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; 648 tape->postponed_rq = false; 649 } 650 651 if (rq->cmd[13] & REQ_IDETAPE_READ) { 652 pc = &tape->queued_pc; 653 ide_tape_create_rw_cmd(tape, pc, rq, READ_6); 654 goto out; 655 } 656 if (rq->cmd[13] & REQ_IDETAPE_WRITE) { 657 pc = &tape->queued_pc; 658 ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); 659 goto out; 660 } 661 if (rq->cmd[13] & REQ_IDETAPE_PC1) { 662 pc = (struct ide_atapi_pc *)rq->special; 663 rq->cmd[13] &= ~(REQ_IDETAPE_PC1); 664 rq->cmd[13] |= REQ_IDETAPE_PC2; 665 goto out; 666 } 667 if (rq->cmd[13] & REQ_IDETAPE_PC2) { 668 idetape_media_access_finished(drive); 669 return ide_stopped; 670 } 671 BUG(); 672 673 out: 674 /* prepare sense request for this command */ 675 ide_prep_sense(drive, rq); 676 677 memset(&cmd, 0, sizeof(cmd)); 678 679 if (rq_data_dir(rq)) 680 cmd.tf_flags |= IDE_TFLAG_WRITE; 681 682 cmd.rq = rq; 683 684 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); 685 ide_map_sg(drive, &cmd); 686 687 return ide_tape_issue_pc(drive, &cmd, pc); 688 } 689 690 /* 691 * Write a filemark if write_filemark=1. Flush the device buffers without 692 * writing a filemark otherwise. 693 */ 694 static void idetape_create_write_filemark_cmd(ide_drive_t *drive, 695 struct ide_atapi_pc *pc, int write_filemark) 696 { 697 ide_init_pc(pc); 698 pc->c[0] = WRITE_FILEMARKS; 699 pc->c[4] = write_filemark; 700 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 701 } 702 703 static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) 704 { 705 idetape_tape_t *tape = drive->driver_data; 706 struct gendisk *disk = tape->disk; 707 int load_attempted = 0; 708 709 /* Wait for the tape to become ready */ 710 set_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), &drive->atapi_flags); 711 timeout += jiffies; 712 while (time_before(jiffies, timeout)) { 713 if (ide_do_test_unit_ready(drive, disk) == 0) 714 return 0; 715 if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) 716 || (tape->asc == 0x3A)) { 717 /* no media */ 718 if (load_attempted) 719 return -ENOMEDIUM; 720 ide_do_start_stop(drive, disk, IDETAPE_LU_LOAD_MASK); 721 load_attempted = 1; 722 /* not about to be ready */ 723 } else if (!(tape->sense_key == 2 && tape->asc == 4 && 724 (tape->ascq == 1 || tape->ascq == 8))) 725 return -EIO; 726 msleep(100); 727 } 728 return -EIO; 729 } 730 731 static int idetape_flush_tape_buffers(ide_drive_t *drive) 732 { 733 struct ide_tape_obj *tape = drive->driver_data; 734 struct ide_atapi_pc pc; 735 int rc; 736 737 idetape_create_write_filemark_cmd(drive, &pc, 0); 738 rc = ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0); 739 if (rc) 740 return rc; 741 idetape_wait_ready(drive, 60 * 5 * HZ); 742 return 0; 743 } 744 745 static int ide_tape_read_position(ide_drive_t *drive) 746 { 747 idetape_tape_t *tape = drive->driver_data; 748 struct ide_atapi_pc pc; 749 u8 buf[20]; 750 751 ide_debug_log(IDE_DBG_FUNC, "enter"); 752 753 /* prep cmd */ 754 ide_init_pc(&pc); 755 pc.c[0] = READ_POSITION; 756 pc.req_xfer = 20; 757 758 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) 759 return -1; 760 761 if (!pc.error) { 762 ide_debug_log(IDE_DBG_FUNC, "BOP - %s", 763 (buf[0] & 0x80) ? "Yes" : "No"); 764 ide_debug_log(IDE_DBG_FUNC, "EOP - %s", 765 (buf[0] & 0x40) ? "Yes" : "No"); 766 767 if (buf[0] & 0x4) { 768 printk(KERN_INFO "ide-tape: Block location is unknown" 769 "to the tape\n"); 770 clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), 771 &drive->atapi_flags); 772 return -1; 773 } else { 774 ide_debug_log(IDE_DBG_FUNC, "Block Location: %u", 775 be32_to_cpup((__be32 *)&buf[4])); 776 777 tape->partition = buf[1]; 778 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); 779 set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), 780 &drive->atapi_flags); 781 } 782 } 783 784 return tape->first_frame; 785 } 786 787 static void idetape_create_locate_cmd(ide_drive_t *drive, 788 struct ide_atapi_pc *pc, 789 unsigned int block, u8 partition, int skip) 790 { 791 ide_init_pc(pc); 792 pc->c[0] = POSITION_TO_ELEMENT; 793 pc->c[1] = 2; 794 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); 795 pc->c[8] = partition; 796 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 797 } 798 799 static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) 800 { 801 idetape_tape_t *tape = drive->driver_data; 802 803 if (tape->chrdev_dir != IDETAPE_DIR_READ) 804 return; 805 806 clear_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags); 807 tape->valid = 0; 808 if (tape->buf != NULL) { 809 kfree(tape->buf); 810 tape->buf = NULL; 811 } 812 813 tape->chrdev_dir = IDETAPE_DIR_NONE; 814 } 815 816 /* 817 * Position the tape to the requested block using the LOCATE packet command. 818 * A READ POSITION command is then issued to check where we are positioned. Like 819 * all higher level operations, we queue the commands at the tail of the request 820 * queue and wait for their completion. 821 */ 822 static int idetape_position_tape(ide_drive_t *drive, unsigned int block, 823 u8 partition, int skip) 824 { 825 idetape_tape_t *tape = drive->driver_data; 826 struct gendisk *disk = tape->disk; 827 int ret; 828 struct ide_atapi_pc pc; 829 830 if (tape->chrdev_dir == IDETAPE_DIR_READ) 831 __ide_tape_discard_merge_buffer(drive); 832 idetape_wait_ready(drive, 60 * 5 * HZ); 833 idetape_create_locate_cmd(drive, &pc, block, partition, skip); 834 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 835 if (ret) 836 return ret; 837 838 ret = ide_tape_read_position(drive); 839 if (ret < 0) 840 return ret; 841 return 0; 842 } 843 844 static void ide_tape_discard_merge_buffer(ide_drive_t *drive, 845 int restore_position) 846 { 847 idetape_tape_t *tape = drive->driver_data; 848 int seek, position; 849 850 __ide_tape_discard_merge_buffer(drive); 851 if (restore_position) { 852 position = ide_tape_read_position(drive); 853 seek = position > 0 ? position : 0; 854 if (idetape_position_tape(drive, seek, 0, 0)) { 855 printk(KERN_INFO "ide-tape: %s: position_tape failed in" 856 " %s\n", tape->name, __func__); 857 return; 858 } 859 } 860 } 861 862 /* 863 * Generate a read/write request for the block device interface and wait for it 864 * to be serviced. 865 */ 866 static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) 867 { 868 idetape_tape_t *tape = drive->driver_data; 869 struct request *rq; 870 int ret; 871 872 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, size: %d", cmd, size); 873 874 BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); 875 BUG_ON(size < 0 || size % tape->blk_size); 876 877 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 878 rq->cmd_type = REQ_TYPE_DRV_PRIV; 879 rq->cmd[13] = cmd; 880 rq->rq_disk = tape->disk; 881 rq->__sector = tape->first_frame; 882 883 if (size) { 884 ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size, 885 __GFP_RECLAIM); 886 if (ret) 887 goto out_put; 888 } 889 890 blk_execute_rq(drive->queue, tape->disk, rq, 0); 891 892 /* calculate the number of transferred bytes and update buffer state */ 893 size -= rq->resid_len; 894 tape->cur = tape->buf; 895 if (cmd == REQ_IDETAPE_READ) 896 tape->valid = size; 897 else 898 tape->valid = 0; 899 900 ret = size; 901 if (rq->errors == IDE_DRV_ERROR_GENERAL) 902 ret = -EIO; 903 out_put: 904 blk_put_request(rq); 905 return ret; 906 } 907 908 static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) 909 { 910 ide_init_pc(pc); 911 pc->c[0] = INQUIRY; 912 pc->c[4] = 254; 913 pc->req_xfer = 254; 914 } 915 916 static void idetape_create_rewind_cmd(ide_drive_t *drive, 917 struct ide_atapi_pc *pc) 918 { 919 ide_init_pc(pc); 920 pc->c[0] = REZERO_UNIT; 921 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 922 } 923 924 static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) 925 { 926 ide_init_pc(pc); 927 pc->c[0] = ERASE; 928 pc->c[1] = 1; 929 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 930 } 931 932 static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) 933 { 934 ide_init_pc(pc); 935 pc->c[0] = SPACE; 936 put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); 937 pc->c[1] = cmd; 938 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 939 } 940 941 static void ide_tape_flush_merge_buffer(ide_drive_t *drive) 942 { 943 idetape_tape_t *tape = drive->driver_data; 944 945 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { 946 printk(KERN_ERR "ide-tape: bug: Trying to empty merge buffer" 947 " but we are not writing.\n"); 948 return; 949 } 950 if (tape->buf) { 951 size_t aligned = roundup(tape->valid, tape->blk_size); 952 953 memset(tape->cur, 0, aligned - tape->valid); 954 idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, aligned); 955 kfree(tape->buf); 956 tape->buf = NULL; 957 } 958 tape->chrdev_dir = IDETAPE_DIR_NONE; 959 } 960 961 static int idetape_init_rw(ide_drive_t *drive, int dir) 962 { 963 idetape_tape_t *tape = drive->driver_data; 964 int rc; 965 966 BUG_ON(dir != IDETAPE_DIR_READ && dir != IDETAPE_DIR_WRITE); 967 968 if (tape->chrdev_dir == dir) 969 return 0; 970 971 if (tape->chrdev_dir == IDETAPE_DIR_READ) 972 ide_tape_discard_merge_buffer(drive, 1); 973 else if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 974 ide_tape_flush_merge_buffer(drive); 975 idetape_flush_tape_buffers(drive); 976 } 977 978 if (tape->buf || tape->valid) { 979 printk(KERN_ERR "ide-tape: valid should be 0 now\n"); 980 tape->valid = 0; 981 } 982 983 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); 984 if (!tape->buf) 985 return -ENOMEM; 986 tape->chrdev_dir = dir; 987 tape->cur = tape->buf; 988 989 /* 990 * Issue a 0 rw command to ensure that DSC handshake is 991 * switched from completion mode to buffer available mode. No 992 * point in issuing this if DSC overlap isn't supported, some 993 * drives (Seagate STT3401A) will return an error. 994 */ 995 if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { 996 int cmd = dir == IDETAPE_DIR_READ ? REQ_IDETAPE_READ 997 : REQ_IDETAPE_WRITE; 998 999 rc = idetape_queue_rw_tail(drive, cmd, 0); 1000 if (rc < 0) { 1001 kfree(tape->buf); 1002 tape->buf = NULL; 1003 tape->chrdev_dir = IDETAPE_DIR_NONE; 1004 return rc; 1005 } 1006 } 1007 1008 return 0; 1009 } 1010 1011 static void idetape_pad_zeros(ide_drive_t *drive, int bcount) 1012 { 1013 idetape_tape_t *tape = drive->driver_data; 1014 1015 memset(tape->buf, 0, tape->buffer_size); 1016 1017 while (bcount) { 1018 unsigned int count = min(tape->buffer_size, bcount); 1019 1020 idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, count); 1021 bcount -= count; 1022 } 1023 } 1024 1025 /* 1026 * Rewinds the tape to the Beginning Of the current Partition (BOP). We 1027 * currently support only one partition. 1028 */ 1029 static int idetape_rewind_tape(ide_drive_t *drive) 1030 { 1031 struct ide_tape_obj *tape = drive->driver_data; 1032 struct gendisk *disk = tape->disk; 1033 struct ide_atapi_pc pc; 1034 int ret; 1035 1036 ide_debug_log(IDE_DBG_FUNC, "enter"); 1037 1038 idetape_create_rewind_cmd(drive, &pc); 1039 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1040 if (ret) 1041 return ret; 1042 1043 ret = ide_tape_read_position(drive); 1044 if (ret < 0) 1045 return ret; 1046 return 0; 1047 } 1048 1049 /* mtio.h compatible commands should be issued to the chrdev interface. */ 1050 static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, 1051 unsigned long arg) 1052 { 1053 idetape_tape_t *tape = drive->driver_data; 1054 void __user *argp = (void __user *)arg; 1055 1056 struct idetape_config { 1057 int dsc_rw_frequency; 1058 int dsc_media_access_frequency; 1059 int nr_stages; 1060 } config; 1061 1062 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%04x", cmd); 1063 1064 switch (cmd) { 1065 case 0x0340: 1066 if (copy_from_user(&config, argp, sizeof(config))) 1067 return -EFAULT; 1068 tape->best_dsc_rw_freq = config.dsc_rw_frequency; 1069 break; 1070 case 0x0350: 1071 memset(&config, 0, sizeof(config)); 1072 config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; 1073 config.nr_stages = 1; 1074 if (copy_to_user(argp, &config, sizeof(config))) 1075 return -EFAULT; 1076 break; 1077 default: 1078 return -EIO; 1079 } 1080 return 0; 1081 } 1082 1083 static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, 1084 int mt_count) 1085 { 1086 idetape_tape_t *tape = drive->driver_data; 1087 struct gendisk *disk = tape->disk; 1088 struct ide_atapi_pc pc; 1089 int retval, count = 0; 1090 int sprev = !!(tape->caps[4] & 0x20); 1091 1092 1093 ide_debug_log(IDE_DBG_FUNC, "mt_op: %d, mt_count: %d", mt_op, mt_count); 1094 1095 if (mt_count == 0) 1096 return 0; 1097 if (MTBSF == mt_op || MTBSFM == mt_op) { 1098 if (!sprev) 1099 return -EIO; 1100 mt_count = -mt_count; 1101 } 1102 1103 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 1104 tape->valid = 0; 1105 if (test_and_clear_bit(ilog2(IDE_AFLAG_FILEMARK), 1106 &drive->atapi_flags)) 1107 ++count; 1108 ide_tape_discard_merge_buffer(drive, 0); 1109 } 1110 1111 switch (mt_op) { 1112 case MTFSF: 1113 case MTBSF: 1114 idetape_create_space_cmd(&pc, mt_count - count, 1115 IDETAPE_SPACE_OVER_FILEMARK); 1116 return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1117 case MTFSFM: 1118 case MTBSFM: 1119 if (!sprev) 1120 return -EIO; 1121 retval = idetape_space_over_filemarks(drive, MTFSF, 1122 mt_count - count); 1123 if (retval) 1124 return retval; 1125 count = (MTBSFM == mt_op ? 1 : -1); 1126 return idetape_space_over_filemarks(drive, MTFSF, count); 1127 default: 1128 printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", 1129 mt_op); 1130 return -EIO; 1131 } 1132 } 1133 1134 /* 1135 * Our character device read / write functions. 1136 * 1137 * The tape is optimized to maximize throughput when it is transferring an 1138 * integral number of the "continuous transfer limit", which is a parameter of 1139 * the specific tape (26kB on my particular tape, 32kB for Onstream). 1140 * 1141 * As of version 1.3 of the driver, the character device provides an abstract 1142 * continuous view of the media - any mix of block sizes (even 1 byte) on the 1143 * same backup/restore procedure is supported. The driver will internally 1144 * convert the requests to the recommended transfer unit, so that an unmatch 1145 * between the user's block size to the recommended size will only result in a 1146 * (slightly) increased driver overhead, but will no longer hit performance. 1147 * This is not applicable to Onstream. 1148 */ 1149 static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, 1150 size_t count, loff_t *ppos) 1151 { 1152 struct ide_tape_obj *tape = file->private_data; 1153 ide_drive_t *drive = tape->drive; 1154 size_t done = 0; 1155 ssize_t ret = 0; 1156 int rc; 1157 1158 ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); 1159 1160 if (tape->chrdev_dir != IDETAPE_DIR_READ) { 1161 if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) 1162 if (count > tape->blk_size && 1163 (count % tape->blk_size) == 0) 1164 tape->user_bs_factor = count / tape->blk_size; 1165 } 1166 1167 rc = idetape_init_rw(drive, IDETAPE_DIR_READ); 1168 if (rc < 0) 1169 return rc; 1170 1171 while (done < count) { 1172 size_t todo; 1173 1174 /* refill if staging buffer is empty */ 1175 if (!tape->valid) { 1176 /* If we are at a filemark, nothing more to read */ 1177 if (test_bit(ilog2(IDE_AFLAG_FILEMARK), 1178 &drive->atapi_flags)) 1179 break; 1180 /* read */ 1181 if (idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, 1182 tape->buffer_size) <= 0) 1183 break; 1184 } 1185 1186 /* copy out */ 1187 todo = min_t(size_t, count - done, tape->valid); 1188 if (copy_to_user(buf + done, tape->cur, todo)) 1189 ret = -EFAULT; 1190 1191 tape->cur += todo; 1192 tape->valid -= todo; 1193 done += todo; 1194 } 1195 1196 if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { 1197 idetape_space_over_filemarks(drive, MTFSF, 1); 1198 return 0; 1199 } 1200 1201 return ret ? ret : done; 1202 } 1203 1204 static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, 1205 size_t count, loff_t *ppos) 1206 { 1207 struct ide_tape_obj *tape = file->private_data; 1208 ide_drive_t *drive = tape->drive; 1209 size_t done = 0; 1210 ssize_t ret = 0; 1211 int rc; 1212 1213 /* The drive is write protected. */ 1214 if (tape->write_prot) 1215 return -EACCES; 1216 1217 ide_debug_log(IDE_DBG_FUNC, "count %Zd", count); 1218 1219 /* Initialize write operation */ 1220 rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); 1221 if (rc < 0) 1222 return rc; 1223 1224 while (done < count) { 1225 size_t todo; 1226 1227 /* flush if staging buffer is full */ 1228 if (tape->valid == tape->buffer_size && 1229 idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, 1230 tape->buffer_size) <= 0) 1231 return rc; 1232 1233 /* copy in */ 1234 todo = min_t(size_t, count - done, 1235 tape->buffer_size - tape->valid); 1236 if (copy_from_user(tape->cur, buf + done, todo)) 1237 ret = -EFAULT; 1238 1239 tape->cur += todo; 1240 tape->valid += todo; 1241 done += todo; 1242 } 1243 1244 return ret ? ret : done; 1245 } 1246 1247 static int idetape_write_filemark(ide_drive_t *drive) 1248 { 1249 struct ide_tape_obj *tape = drive->driver_data; 1250 struct ide_atapi_pc pc; 1251 1252 /* Write a filemark */ 1253 idetape_create_write_filemark_cmd(drive, &pc, 1); 1254 if (ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0)) { 1255 printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); 1256 return -EIO; 1257 } 1258 return 0; 1259 } 1260 1261 /* 1262 * Called from idetape_chrdev_ioctl when the general mtio MTIOCTOP ioctl is 1263 * requested. 1264 * 1265 * Note: MTBSF and MTBSFM are not supported when the tape doesn't support 1266 * spacing over filemarks in the reverse direction. In this case, MTFSFM is also 1267 * usually not supported. 1268 * 1269 * The following commands are currently not supported: 1270 * 1271 * MTFSS, MTBSS, MTWSM, MTSETDENSITY, MTSETDRVBUFFER, MT_ST_BOOLEANS, 1272 * MT_ST_WRITE_THRESHOLD. 1273 */ 1274 static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) 1275 { 1276 idetape_tape_t *tape = drive->driver_data; 1277 struct gendisk *disk = tape->disk; 1278 struct ide_atapi_pc pc; 1279 int i, retval; 1280 1281 ide_debug_log(IDE_DBG_FUNC, "MTIOCTOP ioctl: mt_op: %d, mt_count: %d", 1282 mt_op, mt_count); 1283 1284 switch (mt_op) { 1285 case MTFSF: 1286 case MTFSFM: 1287 case MTBSF: 1288 case MTBSFM: 1289 if (!mt_count) 1290 return 0; 1291 return idetape_space_over_filemarks(drive, mt_op, mt_count); 1292 default: 1293 break; 1294 } 1295 1296 switch (mt_op) { 1297 case MTWEOF: 1298 if (tape->write_prot) 1299 return -EACCES; 1300 ide_tape_discard_merge_buffer(drive, 1); 1301 for (i = 0; i < mt_count; i++) { 1302 retval = idetape_write_filemark(drive); 1303 if (retval) 1304 return retval; 1305 } 1306 return 0; 1307 case MTREW: 1308 ide_tape_discard_merge_buffer(drive, 0); 1309 if (idetape_rewind_tape(drive)) 1310 return -EIO; 1311 return 0; 1312 case MTLOAD: 1313 ide_tape_discard_merge_buffer(drive, 0); 1314 return ide_do_start_stop(drive, disk, IDETAPE_LU_LOAD_MASK); 1315 case MTUNLOAD: 1316 case MTOFFL: 1317 /* 1318 * If door is locked, attempt to unlock before 1319 * attempting to eject. 1320 */ 1321 if (tape->door_locked) { 1322 if (!ide_set_media_lock(drive, disk, 0)) 1323 tape->door_locked = DOOR_UNLOCKED; 1324 } 1325 ide_tape_discard_merge_buffer(drive, 0); 1326 retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); 1327 if (!retval) 1328 clear_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), 1329 &drive->atapi_flags); 1330 return retval; 1331 case MTNOP: 1332 ide_tape_discard_merge_buffer(drive, 0); 1333 return idetape_flush_tape_buffers(drive); 1334 case MTRETEN: 1335 ide_tape_discard_merge_buffer(drive, 0); 1336 return ide_do_start_stop(drive, disk, 1337 IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); 1338 case MTEOM: 1339 idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); 1340 return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1341 case MTERASE: 1342 (void)idetape_rewind_tape(drive); 1343 idetape_create_erase_cmd(&pc); 1344 return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1345 case MTSETBLK: 1346 if (mt_count) { 1347 if (mt_count < tape->blk_size || 1348 mt_count % tape->blk_size) 1349 return -EIO; 1350 tape->user_bs_factor = mt_count / tape->blk_size; 1351 clear_bit(ilog2(IDE_AFLAG_DETECT_BS), 1352 &drive->atapi_flags); 1353 } else 1354 set_bit(ilog2(IDE_AFLAG_DETECT_BS), 1355 &drive->atapi_flags); 1356 return 0; 1357 case MTSEEK: 1358 ide_tape_discard_merge_buffer(drive, 0); 1359 return idetape_position_tape(drive, 1360 mt_count * tape->user_bs_factor, tape->partition, 0); 1361 case MTSETPART: 1362 ide_tape_discard_merge_buffer(drive, 0); 1363 return idetape_position_tape(drive, 0, mt_count, 0); 1364 case MTFSR: 1365 case MTBSR: 1366 case MTLOCK: 1367 retval = ide_set_media_lock(drive, disk, 1); 1368 if (retval) 1369 return retval; 1370 tape->door_locked = DOOR_EXPLICITLY_LOCKED; 1371 return 0; 1372 case MTUNLOCK: 1373 retval = ide_set_media_lock(drive, disk, 0); 1374 if (retval) 1375 return retval; 1376 tape->door_locked = DOOR_UNLOCKED; 1377 return 0; 1378 default: 1379 printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", 1380 mt_op); 1381 return -EIO; 1382 } 1383 } 1384 1385 /* 1386 * Our character device ioctls. General mtio.h magnetic io commands are 1387 * supported here, and not in the corresponding block interface. Our own 1388 * ide-tape ioctls are supported on both interfaces. 1389 */ 1390 static long do_idetape_chrdev_ioctl(struct file *file, 1391 unsigned int cmd, unsigned long arg) 1392 { 1393 struct ide_tape_obj *tape = file->private_data; 1394 ide_drive_t *drive = tape->drive; 1395 struct mtop mtop; 1396 struct mtget mtget; 1397 struct mtpos mtpos; 1398 int block_offset = 0, position = tape->first_frame; 1399 void __user *argp = (void __user *)arg; 1400 1401 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x", cmd); 1402 1403 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 1404 ide_tape_flush_merge_buffer(drive); 1405 idetape_flush_tape_buffers(drive); 1406 } 1407 if (cmd == MTIOCGET || cmd == MTIOCPOS) { 1408 block_offset = tape->valid / 1409 (tape->blk_size * tape->user_bs_factor); 1410 position = ide_tape_read_position(drive); 1411 if (position < 0) 1412 return -EIO; 1413 } 1414 switch (cmd) { 1415 case MTIOCTOP: 1416 if (copy_from_user(&mtop, argp, sizeof(struct mtop))) 1417 return -EFAULT; 1418 return idetape_mtioctop(drive, mtop.mt_op, mtop.mt_count); 1419 case MTIOCGET: 1420 memset(&mtget, 0, sizeof(struct mtget)); 1421 mtget.mt_type = MT_ISSCSI2; 1422 mtget.mt_blkno = position / tape->user_bs_factor - block_offset; 1423 mtget.mt_dsreg = 1424 ((tape->blk_size * tape->user_bs_factor) 1425 << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; 1426 1427 if (tape->drv_write_prot) 1428 mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); 1429 1430 if (copy_to_user(argp, &mtget, sizeof(struct mtget))) 1431 return -EFAULT; 1432 return 0; 1433 case MTIOCPOS: 1434 mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; 1435 if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) 1436 return -EFAULT; 1437 return 0; 1438 default: 1439 if (tape->chrdev_dir == IDETAPE_DIR_READ) 1440 ide_tape_discard_merge_buffer(drive, 1); 1441 return idetape_blkdev_ioctl(drive, cmd, arg); 1442 } 1443 } 1444 1445 static long idetape_chrdev_ioctl(struct file *file, 1446 unsigned int cmd, unsigned long arg) 1447 { 1448 long ret; 1449 mutex_lock(&ide_tape_mutex); 1450 ret = do_idetape_chrdev_ioctl(file, cmd, arg); 1451 mutex_unlock(&ide_tape_mutex); 1452 return ret; 1453 } 1454 1455 /* 1456 * Do a mode sense page 0 with block descriptor and if it succeeds set the tape 1457 * block size with the reported value. 1458 */ 1459 static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) 1460 { 1461 idetape_tape_t *tape = drive->driver_data; 1462 struct ide_atapi_pc pc; 1463 u8 buf[12]; 1464 1465 idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); 1466 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { 1467 printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); 1468 if (tape->blk_size == 0) { 1469 printk(KERN_WARNING "ide-tape: Cannot deal with zero " 1470 "block size, assuming 32k\n"); 1471 tape->blk_size = 32768; 1472 } 1473 return; 1474 } 1475 tape->blk_size = (buf[4 + 5] << 16) + 1476 (buf[4 + 6] << 8) + 1477 buf[4 + 7]; 1478 tape->drv_write_prot = (buf[2] & 0x80) >> 7; 1479 1480 ide_debug_log(IDE_DBG_FUNC, "blk_size: %d, write_prot: %d", 1481 tape->blk_size, tape->drv_write_prot); 1482 } 1483 1484 static int idetape_chrdev_open(struct inode *inode, struct file *filp) 1485 { 1486 unsigned int minor = iminor(inode), i = minor & ~0xc0; 1487 ide_drive_t *drive; 1488 idetape_tape_t *tape; 1489 int retval; 1490 1491 if (i >= MAX_HWIFS * MAX_DRIVES) 1492 return -ENXIO; 1493 1494 mutex_lock(&idetape_chrdev_mutex); 1495 1496 tape = ide_tape_get(NULL, true, i); 1497 if (!tape) { 1498 mutex_unlock(&idetape_chrdev_mutex); 1499 return -ENXIO; 1500 } 1501 1502 drive = tape->drive; 1503 filp->private_data = tape; 1504 1505 ide_debug_log(IDE_DBG_FUNC, "enter"); 1506 1507 /* 1508 * We really want to do nonseekable_open(inode, filp); here, but some 1509 * versions of tar incorrectly call lseek on tapes and bail out if that 1510 * fails. So we disallow pread() and pwrite(), but permit lseeks. 1511 */ 1512 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1513 1514 1515 if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { 1516 retval = -EBUSY; 1517 goto out_put_tape; 1518 } 1519 1520 retval = idetape_wait_ready(drive, 60 * HZ); 1521 if (retval) { 1522 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); 1523 printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); 1524 goto out_put_tape; 1525 } 1526 1527 ide_tape_read_position(drive); 1528 if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags)) 1529 (void)idetape_rewind_tape(drive); 1530 1531 /* Read block size and write protect status from drive. */ 1532 ide_tape_get_bsize_from_bdesc(drive); 1533 1534 /* Set write protect flag if device is opened as read-only. */ 1535 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) 1536 tape->write_prot = 1; 1537 else 1538 tape->write_prot = tape->drv_write_prot; 1539 1540 /* Make sure drive isn't write protected if user wants to write. */ 1541 if (tape->write_prot) { 1542 if ((filp->f_flags & O_ACCMODE) == O_WRONLY || 1543 (filp->f_flags & O_ACCMODE) == O_RDWR) { 1544 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); 1545 retval = -EROFS; 1546 goto out_put_tape; 1547 } 1548 } 1549 1550 /* Lock the tape drive door so user can't eject. */ 1551 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 1552 if (!ide_set_media_lock(drive, tape->disk, 1)) { 1553 if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) 1554 tape->door_locked = DOOR_LOCKED; 1555 } 1556 } 1557 mutex_unlock(&idetape_chrdev_mutex); 1558 1559 return 0; 1560 1561 out_put_tape: 1562 ide_tape_put(tape); 1563 1564 mutex_unlock(&idetape_chrdev_mutex); 1565 1566 return retval; 1567 } 1568 1569 static void idetape_write_release(ide_drive_t *drive, unsigned int minor) 1570 { 1571 idetape_tape_t *tape = drive->driver_data; 1572 1573 ide_tape_flush_merge_buffer(drive); 1574 tape->buf = kmalloc(tape->buffer_size, GFP_KERNEL); 1575 if (tape->buf != NULL) { 1576 idetape_pad_zeros(drive, tape->blk_size * 1577 (tape->user_bs_factor - 1)); 1578 kfree(tape->buf); 1579 tape->buf = NULL; 1580 } 1581 idetape_write_filemark(drive); 1582 idetape_flush_tape_buffers(drive); 1583 idetape_flush_tape_buffers(drive); 1584 } 1585 1586 static int idetape_chrdev_release(struct inode *inode, struct file *filp) 1587 { 1588 struct ide_tape_obj *tape = filp->private_data; 1589 ide_drive_t *drive = tape->drive; 1590 unsigned int minor = iminor(inode); 1591 1592 mutex_lock(&idetape_chrdev_mutex); 1593 1594 tape = drive->driver_data; 1595 1596 ide_debug_log(IDE_DBG_FUNC, "enter"); 1597 1598 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) 1599 idetape_write_release(drive, minor); 1600 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 1601 if (minor < 128) 1602 ide_tape_discard_merge_buffer(drive, 1); 1603 } 1604 1605 if (minor < 128 && test_bit(ilog2(IDE_AFLAG_MEDIUM_PRESENT), 1606 &drive->atapi_flags)) 1607 (void) idetape_rewind_tape(drive); 1608 1609 if (tape->chrdev_dir == IDETAPE_DIR_NONE) { 1610 if (tape->door_locked == DOOR_LOCKED) { 1611 if (!ide_set_media_lock(drive, tape->disk, 0)) 1612 tape->door_locked = DOOR_UNLOCKED; 1613 } 1614 } 1615 clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); 1616 ide_tape_put(tape); 1617 1618 mutex_unlock(&idetape_chrdev_mutex); 1619 1620 return 0; 1621 } 1622 1623 static void idetape_get_inquiry_results(ide_drive_t *drive) 1624 { 1625 idetape_tape_t *tape = drive->driver_data; 1626 struct ide_atapi_pc pc; 1627 u8 pc_buf[256]; 1628 char fw_rev[4], vendor_id[8], product_id[16]; 1629 1630 idetape_create_inquiry_cmd(&pc); 1631 if (ide_queue_pc_tail(drive, tape->disk, &pc, pc_buf, pc.req_xfer)) { 1632 printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", 1633 tape->name); 1634 return; 1635 } 1636 memcpy(vendor_id, &pc_buf[8], 8); 1637 memcpy(product_id, &pc_buf[16], 16); 1638 memcpy(fw_rev, &pc_buf[32], 4); 1639 1640 ide_fixstring(vendor_id, 8, 0); 1641 ide_fixstring(product_id, 16, 0); 1642 ide_fixstring(fw_rev, 4, 0); 1643 1644 printk(KERN_INFO "ide-tape: %s <-> %s: %.8s %.16s rev %.4s\n", 1645 drive->name, tape->name, vendor_id, product_id, fw_rev); 1646 } 1647 1648 /* 1649 * Ask the tape about its various parameters. In particular, we will adjust our 1650 * data transfer buffer size to the recommended value as returned by the tape. 1651 */ 1652 static void idetape_get_mode_sense_results(ide_drive_t *drive) 1653 { 1654 idetape_tape_t *tape = drive->driver_data; 1655 struct ide_atapi_pc pc; 1656 u8 buf[24], *caps; 1657 u8 speed, max_speed; 1658 1659 idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); 1660 if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { 1661 printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" 1662 " some default values\n"); 1663 tape->blk_size = 512; 1664 put_unaligned(52, (u16 *)&tape->caps[12]); 1665 put_unaligned(540, (u16 *)&tape->caps[14]); 1666 put_unaligned(6*52, (u16 *)&tape->caps[16]); 1667 return; 1668 } 1669 caps = buf + 4 + buf[3]; 1670 1671 /* convert to host order and save for later use */ 1672 speed = be16_to_cpup((__be16 *)&caps[14]); 1673 max_speed = be16_to_cpup((__be16 *)&caps[8]); 1674 1675 *(u16 *)&caps[8] = max_speed; 1676 *(u16 *)&caps[12] = be16_to_cpup((__be16 *)&caps[12]); 1677 *(u16 *)&caps[14] = speed; 1678 *(u16 *)&caps[16] = be16_to_cpup((__be16 *)&caps[16]); 1679 1680 if (!speed) { 1681 printk(KERN_INFO "ide-tape: %s: invalid tape speed " 1682 "(assuming 650KB/sec)\n", drive->name); 1683 *(u16 *)&caps[14] = 650; 1684 } 1685 if (!max_speed) { 1686 printk(KERN_INFO "ide-tape: %s: invalid max_speed " 1687 "(assuming 650KB/sec)\n", drive->name); 1688 *(u16 *)&caps[8] = 650; 1689 } 1690 1691 memcpy(&tape->caps, caps, 20); 1692 1693 /* device lacks locking support according to capabilities page */ 1694 if ((caps[6] & 1) == 0) 1695 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; 1696 1697 if (caps[7] & 0x02) 1698 tape->blk_size = 512; 1699 else if (caps[7] & 0x04) 1700 tape->blk_size = 1024; 1701 } 1702 1703 #ifdef CONFIG_IDE_PROC_FS 1704 #define ide_tape_devset_get(name, field) \ 1705 static int get_##name(ide_drive_t *drive) \ 1706 { \ 1707 idetape_tape_t *tape = drive->driver_data; \ 1708 return tape->field; \ 1709 } 1710 1711 #define ide_tape_devset_set(name, field) \ 1712 static int set_##name(ide_drive_t *drive, int arg) \ 1713 { \ 1714 idetape_tape_t *tape = drive->driver_data; \ 1715 tape->field = arg; \ 1716 return 0; \ 1717 } 1718 1719 #define ide_tape_devset_rw_field(_name, _field) \ 1720 ide_tape_devset_get(_name, _field) \ 1721 ide_tape_devset_set(_name, _field) \ 1722 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 1723 1724 #define ide_tape_devset_r_field(_name, _field) \ 1725 ide_tape_devset_get(_name, _field) \ 1726 IDE_DEVSET(_name, 0, get_##_name, NULL) 1727 1728 static int mulf_tdsc(ide_drive_t *drive) { return 1000; } 1729 static int divf_tdsc(ide_drive_t *drive) { return HZ; } 1730 static int divf_buffer(ide_drive_t *drive) { return 2; } 1731 static int divf_buffer_size(ide_drive_t *drive) { return 1024; } 1732 1733 ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); 1734 1735 ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); 1736 1737 ide_tape_devset_r_field(avg_speed, avg_speed); 1738 ide_tape_devset_r_field(speed, caps[14]); 1739 ide_tape_devset_r_field(buffer, caps[16]); 1740 ide_tape_devset_r_field(buffer_size, buffer_size); 1741 1742 static const struct ide_proc_devset idetape_settings[] = { 1743 __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), 1744 __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), 1745 __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), 1746 __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), 1747 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), 1748 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1749 mulf_tdsc, divf_tdsc), 1750 { NULL }, 1751 }; 1752 #endif 1753 1754 /* 1755 * The function below is called to: 1756 * 1757 * 1. Initialize our various state variables. 1758 * 2. Ask the tape for its capabilities. 1759 * 3. Allocate a buffer which will be used for data transfer. The buffer size 1760 * is chosen based on the recommendation which we received in step 2. 1761 * 1762 * Note that at this point ide.c already assigned us an irq, so that we can 1763 * queue requests here and wait for their completion. 1764 */ 1765 static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) 1766 { 1767 unsigned long t; 1768 int speed; 1769 int buffer_size; 1770 u16 *ctl = (u16 *)&tape->caps[12]; 1771 1772 ide_debug_log(IDE_DBG_FUNC, "minor: %d", minor); 1773 1774 drive->pc_callback = ide_tape_callback; 1775 1776 drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 1777 1778 if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { 1779 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", 1780 tape->name); 1781 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 1782 } 1783 1784 /* Seagate Travan drives do not support DSC overlap. */ 1785 if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401")) 1786 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 1787 1788 tape->minor = minor; 1789 tape->name[0] = 'h'; 1790 tape->name[1] = 't'; 1791 tape->name[2] = '0' + minor; 1792 tape->chrdev_dir = IDETAPE_DIR_NONE; 1793 1794 idetape_get_inquiry_results(drive); 1795 idetape_get_mode_sense_results(drive); 1796 ide_tape_get_bsize_from_bdesc(drive); 1797 tape->user_bs_factor = 1; 1798 tape->buffer_size = *ctl * tape->blk_size; 1799 while (tape->buffer_size > 0xffff) { 1800 printk(KERN_NOTICE "ide-tape: decreasing stage size\n"); 1801 *ctl /= 2; 1802 tape->buffer_size = *ctl * tape->blk_size; 1803 } 1804 buffer_size = tape->buffer_size; 1805 1806 /* select the "best" DSC read/write polling freq */ 1807 speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]); 1808 1809 t = (IDETAPE_FIFO_THRESHOLD * tape->buffer_size * HZ) / (speed * 1000); 1810 1811 /* 1812 * Ensure that the number we got makes sense; limit it within 1813 * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. 1814 */ 1815 tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN, 1816 IDETAPE_DSC_RW_MAX); 1817 printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " 1818 "%ums tDSC%s\n", 1819 drive->name, tape->name, *(u16 *)&tape->caps[14], 1820 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size, 1821 tape->buffer_size / 1024, 1822 jiffies_to_msecs(tape->best_dsc_rw_freq), 1823 (drive->dev_flags & IDE_DFLAG_USING_DMA) ? ", DMA" : ""); 1824 1825 ide_proc_register_driver(drive, tape->driver); 1826 } 1827 1828 static void ide_tape_remove(ide_drive_t *drive) 1829 { 1830 idetape_tape_t *tape = drive->driver_data; 1831 1832 ide_proc_unregister_driver(drive, tape->driver); 1833 device_del(&tape->dev); 1834 ide_unregister_region(tape->disk); 1835 1836 mutex_lock(&idetape_ref_mutex); 1837 put_device(&tape->dev); 1838 mutex_unlock(&idetape_ref_mutex); 1839 } 1840 1841 static void ide_tape_release(struct device *dev) 1842 { 1843 struct ide_tape_obj *tape = to_ide_drv(dev, ide_tape_obj); 1844 ide_drive_t *drive = tape->drive; 1845 struct gendisk *g = tape->disk; 1846 1847 BUG_ON(tape->valid); 1848 1849 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 1850 drive->driver_data = NULL; 1851 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); 1852 device_destroy(idetape_sysfs_class, 1853 MKDEV(IDETAPE_MAJOR, tape->minor + 128)); 1854 idetape_devs[tape->minor] = NULL; 1855 g->private_data = NULL; 1856 put_disk(g); 1857 kfree(tape); 1858 } 1859 1860 #ifdef CONFIG_IDE_PROC_FS 1861 static int idetape_name_proc_show(struct seq_file *m, void *v) 1862 { 1863 ide_drive_t *drive = (ide_drive_t *) m->private; 1864 idetape_tape_t *tape = drive->driver_data; 1865 1866 seq_printf(m, "%s\n", tape->name); 1867 return 0; 1868 } 1869 1870 static int idetape_name_proc_open(struct inode *inode, struct file *file) 1871 { 1872 return single_open(file, idetape_name_proc_show, PDE_DATA(inode)); 1873 } 1874 1875 static const struct file_operations idetape_name_proc_fops = { 1876 .owner = THIS_MODULE, 1877 .open = idetape_name_proc_open, 1878 .read = seq_read, 1879 .llseek = seq_lseek, 1880 .release = single_release, 1881 }; 1882 1883 static ide_proc_entry_t idetape_proc[] = { 1884 { "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops }, 1885 { "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops }, 1886 {} 1887 }; 1888 1889 static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) 1890 { 1891 return idetape_proc; 1892 } 1893 1894 static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive) 1895 { 1896 return idetape_settings; 1897 } 1898 #endif 1899 1900 static int ide_tape_probe(ide_drive_t *); 1901 1902 static struct ide_driver idetape_driver = { 1903 .gen_driver = { 1904 .owner = THIS_MODULE, 1905 .name = "ide-tape", 1906 .bus = &ide_bus_type, 1907 }, 1908 .probe = ide_tape_probe, 1909 .remove = ide_tape_remove, 1910 .version = IDETAPE_VERSION, 1911 .do_request = idetape_do_request, 1912 #ifdef CONFIG_IDE_PROC_FS 1913 .proc_entries = ide_tape_proc_entries, 1914 .proc_devsets = ide_tape_proc_devsets, 1915 #endif 1916 }; 1917 1918 /* Our character device supporting functions, passed to register_chrdev. */ 1919 static const struct file_operations idetape_fops = { 1920 .owner = THIS_MODULE, 1921 .read = idetape_chrdev_read, 1922 .write = idetape_chrdev_write, 1923 .unlocked_ioctl = idetape_chrdev_ioctl, 1924 .open = idetape_chrdev_open, 1925 .release = idetape_chrdev_release, 1926 .llseek = noop_llseek, 1927 }; 1928 1929 static int idetape_open(struct block_device *bdev, fmode_t mode) 1930 { 1931 struct ide_tape_obj *tape; 1932 1933 mutex_lock(&ide_tape_mutex); 1934 tape = ide_tape_get(bdev->bd_disk, false, 0); 1935 mutex_unlock(&ide_tape_mutex); 1936 1937 if (!tape) 1938 return -ENXIO; 1939 1940 return 0; 1941 } 1942 1943 static void idetape_release(struct gendisk *disk, fmode_t mode) 1944 { 1945 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 1946 1947 mutex_lock(&ide_tape_mutex); 1948 ide_tape_put(tape); 1949 mutex_unlock(&ide_tape_mutex); 1950 } 1951 1952 static int idetape_ioctl(struct block_device *bdev, fmode_t mode, 1953 unsigned int cmd, unsigned long arg) 1954 { 1955 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); 1956 ide_drive_t *drive = tape->drive; 1957 int err; 1958 1959 mutex_lock(&ide_tape_mutex); 1960 err = generic_ide_ioctl(drive, bdev, cmd, arg); 1961 if (err == -EINVAL) 1962 err = idetape_blkdev_ioctl(drive, cmd, arg); 1963 mutex_unlock(&ide_tape_mutex); 1964 1965 return err; 1966 } 1967 1968 static const struct block_device_operations idetape_block_ops = { 1969 .owner = THIS_MODULE, 1970 .open = idetape_open, 1971 .release = idetape_release, 1972 .ioctl = idetape_ioctl, 1973 }; 1974 1975 static int ide_tape_probe(ide_drive_t *drive) 1976 { 1977 idetape_tape_t *tape; 1978 struct gendisk *g; 1979 int minor; 1980 1981 ide_debug_log(IDE_DBG_FUNC, "enter"); 1982 1983 if (!strstr(DRV_NAME, drive->driver_req)) 1984 goto failed; 1985 1986 if (drive->media != ide_tape) 1987 goto failed; 1988 1989 if ((drive->dev_flags & IDE_DFLAG_ID_READ) && 1990 ide_check_atapi_device(drive, DRV_NAME) == 0) { 1991 printk(KERN_ERR "ide-tape: %s: not supported by this version of" 1992 " the driver\n", drive->name); 1993 goto failed; 1994 } 1995 tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); 1996 if (tape == NULL) { 1997 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", 1998 drive->name); 1999 goto failed; 2000 } 2001 2002 g = alloc_disk(1 << PARTN_BITS); 2003 if (!g) 2004 goto out_free_tape; 2005 2006 ide_init_disk(g, drive); 2007 2008 tape->dev.parent = &drive->gendev; 2009 tape->dev.release = ide_tape_release; 2010 dev_set_name(&tape->dev, "%s", dev_name(&drive->gendev)); 2011 2012 if (device_register(&tape->dev)) 2013 goto out_free_disk; 2014 2015 tape->drive = drive; 2016 tape->driver = &idetape_driver; 2017 tape->disk = g; 2018 2019 g->private_data = &tape->driver; 2020 2021 drive->driver_data = tape; 2022 2023 mutex_lock(&idetape_ref_mutex); 2024 for (minor = 0; idetape_devs[minor]; minor++) 2025 ; 2026 idetape_devs[minor] = tape; 2027 mutex_unlock(&idetape_ref_mutex); 2028 2029 idetape_setup(drive, tape, minor); 2030 2031 device_create(idetape_sysfs_class, &drive->gendev, 2032 MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name); 2033 device_create(idetape_sysfs_class, &drive->gendev, 2034 MKDEV(IDETAPE_MAJOR, minor + 128), NULL, 2035 "n%s", tape->name); 2036 2037 g->fops = &idetape_block_ops; 2038 ide_register_region(g); 2039 2040 return 0; 2041 2042 out_free_disk: 2043 put_disk(g); 2044 out_free_tape: 2045 kfree(tape); 2046 failed: 2047 return -ENODEV; 2048 } 2049 2050 static void __exit idetape_exit(void) 2051 { 2052 driver_unregister(&idetape_driver.gen_driver); 2053 class_destroy(idetape_sysfs_class); 2054 unregister_chrdev(IDETAPE_MAJOR, "ht"); 2055 } 2056 2057 static int __init idetape_init(void) 2058 { 2059 int error = 1; 2060 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape"); 2061 if (IS_ERR(idetape_sysfs_class)) { 2062 idetape_sysfs_class = NULL; 2063 printk(KERN_ERR "Unable to create sysfs class for ide tapes\n"); 2064 error = -EBUSY; 2065 goto out; 2066 } 2067 2068 if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { 2069 printk(KERN_ERR "ide-tape: Failed to register chrdev" 2070 " interface\n"); 2071 error = -EBUSY; 2072 goto out_free_class; 2073 } 2074 2075 error = driver_register(&idetape_driver.gen_driver); 2076 if (error) 2077 goto out_free_driver; 2078 2079 return 0; 2080 2081 out_free_driver: 2082 driver_unregister(&idetape_driver.gen_driver); 2083 out_free_class: 2084 class_destroy(idetape_sysfs_class); 2085 out: 2086 return error; 2087 } 2088 2089 MODULE_ALIAS("ide:*m-tape*"); 2090 module_init(idetape_init); 2091 module_exit(idetape_exit); 2092 MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR); 2093 MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); 2094 MODULE_LICENSE("GPL"); 2095 2096 2097 2098 2099 2100 /* LDV_COMMENT_BEGIN_MAIN */ 2101 #ifdef LDV_MAIN0_sequence_infinite_withcheck_stateful 2102 2103 /*###########################################################################*/ 2104 2105 /*############## Driver Environment Generator 0.2 output ####################*/ 2106 2107 /*###########################################################################*/ 2108 2109 2110 2111 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */ 2112 void ldv_check_final_state(void); 2113 2114 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 2115 void ldv_check_return_value(int res); 2116 2117 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 2118 void ldv_check_return_value_probe(int res); 2119 2120 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 2121 void ldv_initialize(void); 2122 2123 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 2124 void ldv_handler_precall(void); 2125 2126 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 2127 int nondet_int(void); 2128 2129 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 2130 int LDV_IN_INTERRUPT; 2131 2132 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 2133 void ldv_main0_sequence_infinite_withcheck_stateful(void) { 2134 2135 2136 2137 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 2138 /*============================= VARIABLE DECLARATION PART =============================*/ 2139 /** STRUCT: struct type: file_operations, struct name: idetape_name_proc_fops **/ 2140 /* content: static int idetape_name_proc_open(struct inode *inode, struct file *file)*/ 2141 /* LDV_COMMENT_BEGIN_PREP */ 2142 #define DRV_NAME "ide-tape" 2143 #define IDETAPE_VERSION "1.20" 2144 #undef IDETAPE_DEBUG_LOG 2145 #ifdef IDETAPE_DEBUG_LOG 2146 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2147 #else 2148 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2149 #endif 2150 #define IDETAPE_MAX_PC_RETRIES 3 2151 #define IDETAPE_FIFO_THRESHOLD 2 2152 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2153 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2154 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2155 #define IDETAPE_DSC_MA_FAST 2*HZ 2156 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2157 #define IDETAPE_DSC_MA_SLOW 30*HZ 2158 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2159 #define DOOR_UNLOCKED 0 2160 #define DOOR_LOCKED 1 2161 #define DOOR_EXPLICITLY_LOCKED 2 2162 #define IDETAPE_SPACE_OVER_FILEMARK 1 2163 #define IDETAPE_SPACE_TO_EOD 3 2164 #define IDETAPE_LU_LOAD_MASK 1 2165 #define IDETAPE_LU_RETENSION_MASK 2 2166 #define IDETAPE_LU_EOT_MASK 4 2167 #define IDETAPE_BLOCK_DESCRIPTOR 0 2168 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2169 #ifdef CONFIG_IDE_PROC_FS 2170 #define ide_tape_devset_get(name, field) \ 2171 static int get_##name(ide_drive_t *drive) \ 2172 { \ 2173 idetape_tape_t *tape = drive->driver_data; \ 2174 return tape->field; \ 2175 } 2176 #define ide_tape_devset_set(name, field) \ 2177 static int set_##name(ide_drive_t *drive, int arg) \ 2178 { \ 2179 idetape_tape_t *tape = drive->driver_data; \ 2180 tape->field = arg; \ 2181 return 0; \ 2182 } 2183 #define ide_tape_devset_rw_field(_name, _field) \ 2184 ide_tape_devset_get(_name, _field) \ 2185 ide_tape_devset_set(_name, _field) \ 2186 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2187 #define ide_tape_devset_r_field(_name, _field) \ 2188 ide_tape_devset_get(_name, _field) \ 2189 IDE_DEVSET(_name, 0, get_##_name, NULL) 2190 #endif 2191 #ifdef CONFIG_IDE_PROC_FS 2192 /* LDV_COMMENT_END_PREP */ 2193 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_name_proc_open" */ 2194 struct inode * var_group1; 2195 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_name_proc_open" */ 2196 struct file * var_group2; 2197 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_name_proc_open" */ 2198 static int res_idetape_name_proc_open_50; 2199 /* LDV_COMMENT_BEGIN_PREP */ 2200 #endif 2201 #ifdef CONFIG_IDE_PROC_FS 2202 #endif 2203 /* LDV_COMMENT_END_PREP */ 2204 2205 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 2206 /* content: static int ide_tape_probe(ide_drive_t *drive)*/ 2207 /* LDV_COMMENT_BEGIN_PREP */ 2208 #define DRV_NAME "ide-tape" 2209 #define IDETAPE_VERSION "1.20" 2210 #undef IDETAPE_DEBUG_LOG 2211 #ifdef IDETAPE_DEBUG_LOG 2212 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2213 #else 2214 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2215 #endif 2216 #define IDETAPE_MAX_PC_RETRIES 3 2217 #define IDETAPE_FIFO_THRESHOLD 2 2218 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2219 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2220 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2221 #define IDETAPE_DSC_MA_FAST 2*HZ 2222 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2223 #define IDETAPE_DSC_MA_SLOW 30*HZ 2224 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2225 #define DOOR_UNLOCKED 0 2226 #define DOOR_LOCKED 1 2227 #define DOOR_EXPLICITLY_LOCKED 2 2228 #define IDETAPE_SPACE_OVER_FILEMARK 1 2229 #define IDETAPE_SPACE_TO_EOD 3 2230 #define IDETAPE_LU_LOAD_MASK 1 2231 #define IDETAPE_LU_RETENSION_MASK 2 2232 #define IDETAPE_LU_EOT_MASK 4 2233 #define IDETAPE_BLOCK_DESCRIPTOR 0 2234 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2235 #ifdef CONFIG_IDE_PROC_FS 2236 #define ide_tape_devset_get(name, field) \ 2237 static int get_##name(ide_drive_t *drive) \ 2238 { \ 2239 idetape_tape_t *tape = drive->driver_data; \ 2240 return tape->field; \ 2241 } 2242 #define ide_tape_devset_set(name, field) \ 2243 static int set_##name(ide_drive_t *drive, int arg) \ 2244 { \ 2245 idetape_tape_t *tape = drive->driver_data; \ 2246 tape->field = arg; \ 2247 return 0; \ 2248 } 2249 #define ide_tape_devset_rw_field(_name, _field) \ 2250 ide_tape_devset_get(_name, _field) \ 2251 ide_tape_devset_set(_name, _field) \ 2252 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2253 #define ide_tape_devset_r_field(_name, _field) \ 2254 ide_tape_devset_get(_name, _field) \ 2255 IDE_DEVSET(_name, 0, get_##_name, NULL) 2256 #endif 2257 #ifdef CONFIG_IDE_PROC_FS 2258 #endif 2259 #ifdef CONFIG_IDE_PROC_FS 2260 #endif 2261 /* LDV_COMMENT_END_PREP */ 2262 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_probe" */ 2263 ide_drive_t * var_ide_tape_probe_56_p0; 2264 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "ide_tape_probe" */ 2265 static int res_ide_tape_probe_56; 2266 /* content: static void ide_tape_remove(ide_drive_t *drive)*/ 2267 /* LDV_COMMENT_BEGIN_PREP */ 2268 #define DRV_NAME "ide-tape" 2269 #define IDETAPE_VERSION "1.20" 2270 #undef IDETAPE_DEBUG_LOG 2271 #ifdef IDETAPE_DEBUG_LOG 2272 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2273 #else 2274 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2275 #endif 2276 #define IDETAPE_MAX_PC_RETRIES 3 2277 #define IDETAPE_FIFO_THRESHOLD 2 2278 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2279 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2280 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2281 #define IDETAPE_DSC_MA_FAST 2*HZ 2282 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2283 #define IDETAPE_DSC_MA_SLOW 30*HZ 2284 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2285 #define DOOR_UNLOCKED 0 2286 #define DOOR_LOCKED 1 2287 #define DOOR_EXPLICITLY_LOCKED 2 2288 #define IDETAPE_SPACE_OVER_FILEMARK 1 2289 #define IDETAPE_SPACE_TO_EOD 3 2290 #define IDETAPE_LU_LOAD_MASK 1 2291 #define IDETAPE_LU_RETENSION_MASK 2 2292 #define IDETAPE_LU_EOT_MASK 4 2293 #define IDETAPE_BLOCK_DESCRIPTOR 0 2294 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2295 #ifdef CONFIG_IDE_PROC_FS 2296 #define ide_tape_devset_get(name, field) \ 2297 static int get_##name(ide_drive_t *drive) \ 2298 { \ 2299 idetape_tape_t *tape = drive->driver_data; \ 2300 return tape->field; \ 2301 } 2302 #define ide_tape_devset_set(name, field) \ 2303 static int set_##name(ide_drive_t *drive, int arg) \ 2304 { \ 2305 idetape_tape_t *tape = drive->driver_data; \ 2306 tape->field = arg; \ 2307 return 0; \ 2308 } 2309 #define ide_tape_devset_rw_field(_name, _field) \ 2310 ide_tape_devset_get(_name, _field) \ 2311 ide_tape_devset_set(_name, _field) \ 2312 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2313 #define ide_tape_devset_r_field(_name, _field) \ 2314 ide_tape_devset_get(_name, _field) \ 2315 IDE_DEVSET(_name, 0, get_##_name, NULL) 2316 #endif 2317 /* LDV_COMMENT_END_PREP */ 2318 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_remove" */ 2319 ide_drive_t * var_ide_tape_remove_47_p0; 2320 /* LDV_COMMENT_BEGIN_PREP */ 2321 #ifdef CONFIG_IDE_PROC_FS 2322 #endif 2323 #ifdef CONFIG_IDE_PROC_FS 2324 #endif 2325 /* LDV_COMMENT_END_PREP */ 2326 /* content: static ide_startstop_t idetape_do_request(ide_drive_t *drive, struct request *rq, sector_t block)*/ 2327 /* LDV_COMMENT_BEGIN_PREP */ 2328 #define DRV_NAME "ide-tape" 2329 #define IDETAPE_VERSION "1.20" 2330 #undef IDETAPE_DEBUG_LOG 2331 #ifdef IDETAPE_DEBUG_LOG 2332 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2333 #else 2334 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2335 #endif 2336 #define IDETAPE_MAX_PC_RETRIES 3 2337 #define IDETAPE_FIFO_THRESHOLD 2 2338 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2339 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2340 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2341 #define IDETAPE_DSC_MA_FAST 2*HZ 2342 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2343 #define IDETAPE_DSC_MA_SLOW 30*HZ 2344 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2345 #define DOOR_UNLOCKED 0 2346 #define DOOR_LOCKED 1 2347 #define DOOR_EXPLICITLY_LOCKED 2 2348 #define IDETAPE_SPACE_OVER_FILEMARK 1 2349 #define IDETAPE_SPACE_TO_EOD 3 2350 #define IDETAPE_LU_LOAD_MASK 1 2351 #define IDETAPE_LU_RETENSION_MASK 2 2352 #define IDETAPE_LU_EOT_MASK 4 2353 #define IDETAPE_BLOCK_DESCRIPTOR 0 2354 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2355 /* LDV_COMMENT_END_PREP */ 2356 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_do_request" */ 2357 ide_drive_t * var_idetape_do_request_10_p0; 2358 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_do_request" */ 2359 struct request * var_group3; 2360 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_do_request" */ 2361 sector_t var_idetape_do_request_10_p2; 2362 /* LDV_COMMENT_BEGIN_PREP */ 2363 #ifdef CONFIG_IDE_PROC_FS 2364 #define ide_tape_devset_get(name, field) \ 2365 static int get_##name(ide_drive_t *drive) \ 2366 { \ 2367 idetape_tape_t *tape = drive->driver_data; \ 2368 return tape->field; \ 2369 } 2370 #define ide_tape_devset_set(name, field) \ 2371 static int set_##name(ide_drive_t *drive, int arg) \ 2372 { \ 2373 idetape_tape_t *tape = drive->driver_data; \ 2374 tape->field = arg; \ 2375 return 0; \ 2376 } 2377 #define ide_tape_devset_rw_field(_name, _field) \ 2378 ide_tape_devset_get(_name, _field) \ 2379 ide_tape_devset_set(_name, _field) \ 2380 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2381 #define ide_tape_devset_r_field(_name, _field) \ 2382 ide_tape_devset_get(_name, _field) \ 2383 IDE_DEVSET(_name, 0, get_##_name, NULL) 2384 #endif 2385 #ifdef CONFIG_IDE_PROC_FS 2386 #endif 2387 #ifdef CONFIG_IDE_PROC_FS 2388 #endif 2389 /* LDV_COMMENT_END_PREP */ 2390 /* content: static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)*/ 2391 /* LDV_COMMENT_BEGIN_PREP */ 2392 #define DRV_NAME "ide-tape" 2393 #define IDETAPE_VERSION "1.20" 2394 #undef IDETAPE_DEBUG_LOG 2395 #ifdef IDETAPE_DEBUG_LOG 2396 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2397 #else 2398 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2399 #endif 2400 #define IDETAPE_MAX_PC_RETRIES 3 2401 #define IDETAPE_FIFO_THRESHOLD 2 2402 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2403 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2404 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2405 #define IDETAPE_DSC_MA_FAST 2*HZ 2406 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2407 #define IDETAPE_DSC_MA_SLOW 30*HZ 2408 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2409 #define DOOR_UNLOCKED 0 2410 #define DOOR_LOCKED 1 2411 #define DOOR_EXPLICITLY_LOCKED 2 2412 #define IDETAPE_SPACE_OVER_FILEMARK 1 2413 #define IDETAPE_SPACE_TO_EOD 3 2414 #define IDETAPE_LU_LOAD_MASK 1 2415 #define IDETAPE_LU_RETENSION_MASK 2 2416 #define IDETAPE_LU_EOT_MASK 4 2417 #define IDETAPE_BLOCK_DESCRIPTOR 0 2418 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2419 #ifdef CONFIG_IDE_PROC_FS 2420 #define ide_tape_devset_get(name, field) \ 2421 static int get_##name(ide_drive_t *drive) \ 2422 { \ 2423 idetape_tape_t *tape = drive->driver_data; \ 2424 return tape->field; \ 2425 } 2426 #define ide_tape_devset_set(name, field) \ 2427 static int set_##name(ide_drive_t *drive, int arg) \ 2428 { \ 2429 idetape_tape_t *tape = drive->driver_data; \ 2430 tape->field = arg; \ 2431 return 0; \ 2432 } 2433 #define ide_tape_devset_rw_field(_name, _field) \ 2434 ide_tape_devset_get(_name, _field) \ 2435 ide_tape_devset_set(_name, _field) \ 2436 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2437 #define ide_tape_devset_r_field(_name, _field) \ 2438 ide_tape_devset_get(_name, _field) \ 2439 IDE_DEVSET(_name, 0, get_##_name, NULL) 2440 #endif 2441 #ifdef CONFIG_IDE_PROC_FS 2442 /* LDV_COMMENT_END_PREP */ 2443 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_proc_entries" */ 2444 ide_drive_t * var_ide_tape_proc_entries_51_p0; 2445 /* LDV_COMMENT_BEGIN_PREP */ 2446 #endif 2447 #ifdef CONFIG_IDE_PROC_FS 2448 #endif 2449 /* LDV_COMMENT_END_PREP */ 2450 /* content: static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive)*/ 2451 /* LDV_COMMENT_BEGIN_PREP */ 2452 #define DRV_NAME "ide-tape" 2453 #define IDETAPE_VERSION "1.20" 2454 #undef IDETAPE_DEBUG_LOG 2455 #ifdef IDETAPE_DEBUG_LOG 2456 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2457 #else 2458 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2459 #endif 2460 #define IDETAPE_MAX_PC_RETRIES 3 2461 #define IDETAPE_FIFO_THRESHOLD 2 2462 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2463 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2464 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2465 #define IDETAPE_DSC_MA_FAST 2*HZ 2466 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2467 #define IDETAPE_DSC_MA_SLOW 30*HZ 2468 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2469 #define DOOR_UNLOCKED 0 2470 #define DOOR_LOCKED 1 2471 #define DOOR_EXPLICITLY_LOCKED 2 2472 #define IDETAPE_SPACE_OVER_FILEMARK 1 2473 #define IDETAPE_SPACE_TO_EOD 3 2474 #define IDETAPE_LU_LOAD_MASK 1 2475 #define IDETAPE_LU_RETENSION_MASK 2 2476 #define IDETAPE_LU_EOT_MASK 4 2477 #define IDETAPE_BLOCK_DESCRIPTOR 0 2478 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2479 #ifdef CONFIG_IDE_PROC_FS 2480 #define ide_tape_devset_get(name, field) \ 2481 static int get_##name(ide_drive_t *drive) \ 2482 { \ 2483 idetape_tape_t *tape = drive->driver_data; \ 2484 return tape->field; \ 2485 } 2486 #define ide_tape_devset_set(name, field) \ 2487 static int set_##name(ide_drive_t *drive, int arg) \ 2488 { \ 2489 idetape_tape_t *tape = drive->driver_data; \ 2490 tape->field = arg; \ 2491 return 0; \ 2492 } 2493 #define ide_tape_devset_rw_field(_name, _field) \ 2494 ide_tape_devset_get(_name, _field) \ 2495 ide_tape_devset_set(_name, _field) \ 2496 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2497 #define ide_tape_devset_r_field(_name, _field) \ 2498 ide_tape_devset_get(_name, _field) \ 2499 IDE_DEVSET(_name, 0, get_##_name, NULL) 2500 #endif 2501 #ifdef CONFIG_IDE_PROC_FS 2502 /* LDV_COMMENT_END_PREP */ 2503 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "ide_tape_proc_devsets" */ 2504 ide_drive_t * var_ide_tape_proc_devsets_52_p0; 2505 /* LDV_COMMENT_BEGIN_PREP */ 2506 #endif 2507 #ifdef CONFIG_IDE_PROC_FS 2508 #endif 2509 /* LDV_COMMENT_END_PREP */ 2510 2511 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 2512 /* content: static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)*/ 2513 /* LDV_COMMENT_BEGIN_PREP */ 2514 #define DRV_NAME "ide-tape" 2515 #define IDETAPE_VERSION "1.20" 2516 #undef IDETAPE_DEBUG_LOG 2517 #ifdef IDETAPE_DEBUG_LOG 2518 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2519 #else 2520 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2521 #endif 2522 #define IDETAPE_MAX_PC_RETRIES 3 2523 #define IDETAPE_FIFO_THRESHOLD 2 2524 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2525 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2526 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2527 #define IDETAPE_DSC_MA_FAST 2*HZ 2528 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2529 #define IDETAPE_DSC_MA_SLOW 30*HZ 2530 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2531 #define DOOR_UNLOCKED 0 2532 #define DOOR_LOCKED 1 2533 #define DOOR_EXPLICITLY_LOCKED 2 2534 #define IDETAPE_SPACE_OVER_FILEMARK 1 2535 #define IDETAPE_SPACE_TO_EOD 3 2536 #define IDETAPE_LU_LOAD_MASK 1 2537 #define IDETAPE_LU_RETENSION_MASK 2 2538 #define IDETAPE_LU_EOT_MASK 4 2539 #define IDETAPE_BLOCK_DESCRIPTOR 0 2540 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2541 /* LDV_COMMENT_END_PREP */ 2542 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_read" */ 2543 char __user * var_idetape_chrdev_read_30_p1; 2544 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_read" */ 2545 size_t var_idetape_chrdev_read_30_p2; 2546 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_read" */ 2547 loff_t * var_idetape_chrdev_read_30_p3; 2548 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_chrdev_read" */ 2549 static ssize_t res_idetape_chrdev_read_30; 2550 /* LDV_COMMENT_BEGIN_PREP */ 2551 #ifdef CONFIG_IDE_PROC_FS 2552 #define ide_tape_devset_get(name, field) \ 2553 static int get_##name(ide_drive_t *drive) \ 2554 { \ 2555 idetape_tape_t *tape = drive->driver_data; \ 2556 return tape->field; \ 2557 } 2558 #define ide_tape_devset_set(name, field) \ 2559 static int set_##name(ide_drive_t *drive, int arg) \ 2560 { \ 2561 idetape_tape_t *tape = drive->driver_data; \ 2562 tape->field = arg; \ 2563 return 0; \ 2564 } 2565 #define ide_tape_devset_rw_field(_name, _field) \ 2566 ide_tape_devset_get(_name, _field) \ 2567 ide_tape_devset_set(_name, _field) \ 2568 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2569 #define ide_tape_devset_r_field(_name, _field) \ 2570 ide_tape_devset_get(_name, _field) \ 2571 IDE_DEVSET(_name, 0, get_##_name, NULL) 2572 #endif 2573 #ifdef CONFIG_IDE_PROC_FS 2574 #endif 2575 #ifdef CONFIG_IDE_PROC_FS 2576 #endif 2577 /* LDV_COMMENT_END_PREP */ 2578 /* content: static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)*/ 2579 /* LDV_COMMENT_BEGIN_PREP */ 2580 #define DRV_NAME "ide-tape" 2581 #define IDETAPE_VERSION "1.20" 2582 #undef IDETAPE_DEBUG_LOG 2583 #ifdef IDETAPE_DEBUG_LOG 2584 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2585 #else 2586 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2587 #endif 2588 #define IDETAPE_MAX_PC_RETRIES 3 2589 #define IDETAPE_FIFO_THRESHOLD 2 2590 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2591 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2592 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2593 #define IDETAPE_DSC_MA_FAST 2*HZ 2594 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2595 #define IDETAPE_DSC_MA_SLOW 30*HZ 2596 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2597 #define DOOR_UNLOCKED 0 2598 #define DOOR_LOCKED 1 2599 #define DOOR_EXPLICITLY_LOCKED 2 2600 #define IDETAPE_SPACE_OVER_FILEMARK 1 2601 #define IDETAPE_SPACE_TO_EOD 3 2602 #define IDETAPE_LU_LOAD_MASK 1 2603 #define IDETAPE_LU_RETENSION_MASK 2 2604 #define IDETAPE_LU_EOT_MASK 4 2605 #define IDETAPE_BLOCK_DESCRIPTOR 0 2606 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2607 /* LDV_COMMENT_END_PREP */ 2608 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_write" */ 2609 const char __user * var_idetape_chrdev_write_31_p1; 2610 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_write" */ 2611 size_t var_idetape_chrdev_write_31_p2; 2612 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_write" */ 2613 loff_t * var_idetape_chrdev_write_31_p3; 2614 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_chrdev_write" */ 2615 static ssize_t res_idetape_chrdev_write_31; 2616 /* LDV_COMMENT_BEGIN_PREP */ 2617 #ifdef CONFIG_IDE_PROC_FS 2618 #define ide_tape_devset_get(name, field) \ 2619 static int get_##name(ide_drive_t *drive) \ 2620 { \ 2621 idetape_tape_t *tape = drive->driver_data; \ 2622 return tape->field; \ 2623 } 2624 #define ide_tape_devset_set(name, field) \ 2625 static int set_##name(ide_drive_t *drive, int arg) \ 2626 { \ 2627 idetape_tape_t *tape = drive->driver_data; \ 2628 tape->field = arg; \ 2629 return 0; \ 2630 } 2631 #define ide_tape_devset_rw_field(_name, _field) \ 2632 ide_tape_devset_get(_name, _field) \ 2633 ide_tape_devset_set(_name, _field) \ 2634 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2635 #define ide_tape_devset_r_field(_name, _field) \ 2636 ide_tape_devset_get(_name, _field) \ 2637 IDE_DEVSET(_name, 0, get_##_name, NULL) 2638 #endif 2639 #ifdef CONFIG_IDE_PROC_FS 2640 #endif 2641 #ifdef CONFIG_IDE_PROC_FS 2642 #endif 2643 /* LDV_COMMENT_END_PREP */ 2644 /* content: static long idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)*/ 2645 /* LDV_COMMENT_BEGIN_PREP */ 2646 #define DRV_NAME "ide-tape" 2647 #define IDETAPE_VERSION "1.20" 2648 #undef IDETAPE_DEBUG_LOG 2649 #ifdef IDETAPE_DEBUG_LOG 2650 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2651 #else 2652 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2653 #endif 2654 #define IDETAPE_MAX_PC_RETRIES 3 2655 #define IDETAPE_FIFO_THRESHOLD 2 2656 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2657 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2658 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2659 #define IDETAPE_DSC_MA_FAST 2*HZ 2660 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2661 #define IDETAPE_DSC_MA_SLOW 30*HZ 2662 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2663 #define DOOR_UNLOCKED 0 2664 #define DOOR_LOCKED 1 2665 #define DOOR_EXPLICITLY_LOCKED 2 2666 #define IDETAPE_SPACE_OVER_FILEMARK 1 2667 #define IDETAPE_SPACE_TO_EOD 3 2668 #define IDETAPE_LU_LOAD_MASK 1 2669 #define IDETAPE_LU_RETENSION_MASK 2 2670 #define IDETAPE_LU_EOT_MASK 4 2671 #define IDETAPE_BLOCK_DESCRIPTOR 0 2672 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2673 /* LDV_COMMENT_END_PREP */ 2674 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_ioctl" */ 2675 unsigned int var_idetape_chrdev_ioctl_35_p1; 2676 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_chrdev_ioctl" */ 2677 unsigned long var_idetape_chrdev_ioctl_35_p2; 2678 /* LDV_COMMENT_BEGIN_PREP */ 2679 #ifdef CONFIG_IDE_PROC_FS 2680 #define ide_tape_devset_get(name, field) \ 2681 static int get_##name(ide_drive_t *drive) \ 2682 { \ 2683 idetape_tape_t *tape = drive->driver_data; \ 2684 return tape->field; \ 2685 } 2686 #define ide_tape_devset_set(name, field) \ 2687 static int set_##name(ide_drive_t *drive, int arg) \ 2688 { \ 2689 idetape_tape_t *tape = drive->driver_data; \ 2690 tape->field = arg; \ 2691 return 0; \ 2692 } 2693 #define ide_tape_devset_rw_field(_name, _field) \ 2694 ide_tape_devset_get(_name, _field) \ 2695 ide_tape_devset_set(_name, _field) \ 2696 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2697 #define ide_tape_devset_r_field(_name, _field) \ 2698 ide_tape_devset_get(_name, _field) \ 2699 IDE_DEVSET(_name, 0, get_##_name, NULL) 2700 #endif 2701 #ifdef CONFIG_IDE_PROC_FS 2702 #endif 2703 #ifdef CONFIG_IDE_PROC_FS 2704 #endif 2705 /* LDV_COMMENT_END_PREP */ 2706 /* content: static int idetape_chrdev_open(struct inode *inode, struct file *filp)*/ 2707 /* LDV_COMMENT_BEGIN_PREP */ 2708 #define DRV_NAME "ide-tape" 2709 #define IDETAPE_VERSION "1.20" 2710 #undef IDETAPE_DEBUG_LOG 2711 #ifdef IDETAPE_DEBUG_LOG 2712 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2713 #else 2714 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2715 #endif 2716 #define IDETAPE_MAX_PC_RETRIES 3 2717 #define IDETAPE_FIFO_THRESHOLD 2 2718 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2719 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2720 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2721 #define IDETAPE_DSC_MA_FAST 2*HZ 2722 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2723 #define IDETAPE_DSC_MA_SLOW 30*HZ 2724 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2725 #define DOOR_UNLOCKED 0 2726 #define DOOR_LOCKED 1 2727 #define DOOR_EXPLICITLY_LOCKED 2 2728 #define IDETAPE_SPACE_OVER_FILEMARK 1 2729 #define IDETAPE_SPACE_TO_EOD 3 2730 #define IDETAPE_LU_LOAD_MASK 1 2731 #define IDETAPE_LU_RETENSION_MASK 2 2732 #define IDETAPE_LU_EOT_MASK 4 2733 #define IDETAPE_BLOCK_DESCRIPTOR 0 2734 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2735 /* LDV_COMMENT_END_PREP */ 2736 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_chrdev_open" */ 2737 static int res_idetape_chrdev_open_37; 2738 /* LDV_COMMENT_BEGIN_PREP */ 2739 #ifdef CONFIG_IDE_PROC_FS 2740 #define ide_tape_devset_get(name, field) \ 2741 static int get_##name(ide_drive_t *drive) \ 2742 { \ 2743 idetape_tape_t *tape = drive->driver_data; \ 2744 return tape->field; \ 2745 } 2746 #define ide_tape_devset_set(name, field) \ 2747 static int set_##name(ide_drive_t *drive, int arg) \ 2748 { \ 2749 idetape_tape_t *tape = drive->driver_data; \ 2750 tape->field = arg; \ 2751 return 0; \ 2752 } 2753 #define ide_tape_devset_rw_field(_name, _field) \ 2754 ide_tape_devset_get(_name, _field) \ 2755 ide_tape_devset_set(_name, _field) \ 2756 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2757 #define ide_tape_devset_r_field(_name, _field) \ 2758 ide_tape_devset_get(_name, _field) \ 2759 IDE_DEVSET(_name, 0, get_##_name, NULL) 2760 #endif 2761 #ifdef CONFIG_IDE_PROC_FS 2762 #endif 2763 #ifdef CONFIG_IDE_PROC_FS 2764 #endif 2765 /* LDV_COMMENT_END_PREP */ 2766 /* content: static int idetape_chrdev_release(struct inode *inode, struct file *filp)*/ 2767 /* LDV_COMMENT_BEGIN_PREP */ 2768 #define DRV_NAME "ide-tape" 2769 #define IDETAPE_VERSION "1.20" 2770 #undef IDETAPE_DEBUG_LOG 2771 #ifdef IDETAPE_DEBUG_LOG 2772 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2773 #else 2774 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2775 #endif 2776 #define IDETAPE_MAX_PC_RETRIES 3 2777 #define IDETAPE_FIFO_THRESHOLD 2 2778 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2779 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2780 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2781 #define IDETAPE_DSC_MA_FAST 2*HZ 2782 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2783 #define IDETAPE_DSC_MA_SLOW 30*HZ 2784 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2785 #define DOOR_UNLOCKED 0 2786 #define DOOR_LOCKED 1 2787 #define DOOR_EXPLICITLY_LOCKED 2 2788 #define IDETAPE_SPACE_OVER_FILEMARK 1 2789 #define IDETAPE_SPACE_TO_EOD 3 2790 #define IDETAPE_LU_LOAD_MASK 1 2791 #define IDETAPE_LU_RETENSION_MASK 2 2792 #define IDETAPE_LU_EOT_MASK 4 2793 #define IDETAPE_BLOCK_DESCRIPTOR 0 2794 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2795 /* LDV_COMMENT_END_PREP */ 2796 /* LDV_COMMENT_BEGIN_PREP */ 2797 #ifdef CONFIG_IDE_PROC_FS 2798 #define ide_tape_devset_get(name, field) \ 2799 static int get_##name(ide_drive_t *drive) \ 2800 { \ 2801 idetape_tape_t *tape = drive->driver_data; \ 2802 return tape->field; \ 2803 } 2804 #define ide_tape_devset_set(name, field) \ 2805 static int set_##name(ide_drive_t *drive, int arg) \ 2806 { \ 2807 idetape_tape_t *tape = drive->driver_data; \ 2808 tape->field = arg; \ 2809 return 0; \ 2810 } 2811 #define ide_tape_devset_rw_field(_name, _field) \ 2812 ide_tape_devset_get(_name, _field) \ 2813 ide_tape_devset_set(_name, _field) \ 2814 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2815 #define ide_tape_devset_r_field(_name, _field) \ 2816 ide_tape_devset_get(_name, _field) \ 2817 IDE_DEVSET(_name, 0, get_##_name, NULL) 2818 #endif 2819 #ifdef CONFIG_IDE_PROC_FS 2820 #endif 2821 #ifdef CONFIG_IDE_PROC_FS 2822 #endif 2823 /* LDV_COMMENT_END_PREP */ 2824 2825 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 2826 /* content: static int idetape_open(struct block_device *bdev, fmode_t mode)*/ 2827 /* LDV_COMMENT_BEGIN_PREP */ 2828 #define DRV_NAME "ide-tape" 2829 #define IDETAPE_VERSION "1.20" 2830 #undef IDETAPE_DEBUG_LOG 2831 #ifdef IDETAPE_DEBUG_LOG 2832 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2833 #else 2834 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2835 #endif 2836 #define IDETAPE_MAX_PC_RETRIES 3 2837 #define IDETAPE_FIFO_THRESHOLD 2 2838 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2839 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2840 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2841 #define IDETAPE_DSC_MA_FAST 2*HZ 2842 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2843 #define IDETAPE_DSC_MA_SLOW 30*HZ 2844 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2845 #define DOOR_UNLOCKED 0 2846 #define DOOR_LOCKED 1 2847 #define DOOR_EXPLICITLY_LOCKED 2 2848 #define IDETAPE_SPACE_OVER_FILEMARK 1 2849 #define IDETAPE_SPACE_TO_EOD 3 2850 #define IDETAPE_LU_LOAD_MASK 1 2851 #define IDETAPE_LU_RETENSION_MASK 2 2852 #define IDETAPE_LU_EOT_MASK 4 2853 #define IDETAPE_BLOCK_DESCRIPTOR 0 2854 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2855 #ifdef CONFIG_IDE_PROC_FS 2856 #define ide_tape_devset_get(name, field) \ 2857 static int get_##name(ide_drive_t *drive) \ 2858 { \ 2859 idetape_tape_t *tape = drive->driver_data; \ 2860 return tape->field; \ 2861 } 2862 #define ide_tape_devset_set(name, field) \ 2863 static int set_##name(ide_drive_t *drive, int arg) \ 2864 { \ 2865 idetape_tape_t *tape = drive->driver_data; \ 2866 tape->field = arg; \ 2867 return 0; \ 2868 } 2869 #define ide_tape_devset_rw_field(_name, _field) \ 2870 ide_tape_devset_get(_name, _field) \ 2871 ide_tape_devset_set(_name, _field) \ 2872 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2873 #define ide_tape_devset_r_field(_name, _field) \ 2874 ide_tape_devset_get(_name, _field) \ 2875 IDE_DEVSET(_name, 0, get_##_name, NULL) 2876 #endif 2877 #ifdef CONFIG_IDE_PROC_FS 2878 #endif 2879 #ifdef CONFIG_IDE_PROC_FS 2880 #endif 2881 /* LDV_COMMENT_END_PREP */ 2882 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_open" */ 2883 struct block_device * var_group4; 2884 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_open" */ 2885 fmode_t var_idetape_open_53_p1; 2886 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "idetape_open" */ 2887 static int res_idetape_open_53; 2888 /* content: static void idetape_release(struct gendisk *disk, fmode_t mode)*/ 2889 /* LDV_COMMENT_BEGIN_PREP */ 2890 #define DRV_NAME "ide-tape" 2891 #define IDETAPE_VERSION "1.20" 2892 #undef IDETAPE_DEBUG_LOG 2893 #ifdef IDETAPE_DEBUG_LOG 2894 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2895 #else 2896 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2897 #endif 2898 #define IDETAPE_MAX_PC_RETRIES 3 2899 #define IDETAPE_FIFO_THRESHOLD 2 2900 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2901 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2902 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2903 #define IDETAPE_DSC_MA_FAST 2*HZ 2904 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2905 #define IDETAPE_DSC_MA_SLOW 30*HZ 2906 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2907 #define DOOR_UNLOCKED 0 2908 #define DOOR_LOCKED 1 2909 #define DOOR_EXPLICITLY_LOCKED 2 2910 #define IDETAPE_SPACE_OVER_FILEMARK 1 2911 #define IDETAPE_SPACE_TO_EOD 3 2912 #define IDETAPE_LU_LOAD_MASK 1 2913 #define IDETAPE_LU_RETENSION_MASK 2 2914 #define IDETAPE_LU_EOT_MASK 4 2915 #define IDETAPE_BLOCK_DESCRIPTOR 0 2916 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2917 #ifdef CONFIG_IDE_PROC_FS 2918 #define ide_tape_devset_get(name, field) \ 2919 static int get_##name(ide_drive_t *drive) \ 2920 { \ 2921 idetape_tape_t *tape = drive->driver_data; \ 2922 return tape->field; \ 2923 } 2924 #define ide_tape_devset_set(name, field) \ 2925 static int set_##name(ide_drive_t *drive, int arg) \ 2926 { \ 2927 idetape_tape_t *tape = drive->driver_data; \ 2928 tape->field = arg; \ 2929 return 0; \ 2930 } 2931 #define ide_tape_devset_rw_field(_name, _field) \ 2932 ide_tape_devset_get(_name, _field) \ 2933 ide_tape_devset_set(_name, _field) \ 2934 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2935 #define ide_tape_devset_r_field(_name, _field) \ 2936 ide_tape_devset_get(_name, _field) \ 2937 IDE_DEVSET(_name, 0, get_##_name, NULL) 2938 #endif 2939 #ifdef CONFIG_IDE_PROC_FS 2940 #endif 2941 #ifdef CONFIG_IDE_PROC_FS 2942 #endif 2943 /* LDV_COMMENT_END_PREP */ 2944 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_release" */ 2945 struct gendisk * var_group5; 2946 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_release" */ 2947 fmode_t var_idetape_release_54_p1; 2948 /* content: static int idetape_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)*/ 2949 /* LDV_COMMENT_BEGIN_PREP */ 2950 #define DRV_NAME "ide-tape" 2951 #define IDETAPE_VERSION "1.20" 2952 #undef IDETAPE_DEBUG_LOG 2953 #ifdef IDETAPE_DEBUG_LOG 2954 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 2955 #else 2956 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 2957 #endif 2958 #define IDETAPE_MAX_PC_RETRIES 3 2959 #define IDETAPE_FIFO_THRESHOLD 2 2960 #define IDETAPE_DSC_RW_MIN 5*HZ/100 2961 #define IDETAPE_DSC_RW_MAX 40*HZ/100 2962 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 2963 #define IDETAPE_DSC_MA_FAST 2*HZ 2964 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 2965 #define IDETAPE_DSC_MA_SLOW 30*HZ 2966 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 2967 #define DOOR_UNLOCKED 0 2968 #define DOOR_LOCKED 1 2969 #define DOOR_EXPLICITLY_LOCKED 2 2970 #define IDETAPE_SPACE_OVER_FILEMARK 1 2971 #define IDETAPE_SPACE_TO_EOD 3 2972 #define IDETAPE_LU_LOAD_MASK 1 2973 #define IDETAPE_LU_RETENSION_MASK 2 2974 #define IDETAPE_LU_EOT_MASK 4 2975 #define IDETAPE_BLOCK_DESCRIPTOR 0 2976 #define IDETAPE_CAPABILITIES_PAGE 0x2a 2977 #ifdef CONFIG_IDE_PROC_FS 2978 #define ide_tape_devset_get(name, field) \ 2979 static int get_##name(ide_drive_t *drive) \ 2980 { \ 2981 idetape_tape_t *tape = drive->driver_data; \ 2982 return tape->field; \ 2983 } 2984 #define ide_tape_devset_set(name, field) \ 2985 static int set_##name(ide_drive_t *drive, int arg) \ 2986 { \ 2987 idetape_tape_t *tape = drive->driver_data; \ 2988 tape->field = arg; \ 2989 return 0; \ 2990 } 2991 #define ide_tape_devset_rw_field(_name, _field) \ 2992 ide_tape_devset_get(_name, _field) \ 2993 ide_tape_devset_set(_name, _field) \ 2994 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 2995 #define ide_tape_devset_r_field(_name, _field) \ 2996 ide_tape_devset_get(_name, _field) \ 2997 IDE_DEVSET(_name, 0, get_##_name, NULL) 2998 #endif 2999 #ifdef CONFIG_IDE_PROC_FS 3000 #endif 3001 #ifdef CONFIG_IDE_PROC_FS 3002 #endif 3003 /* LDV_COMMENT_END_PREP */ 3004 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_ioctl" */ 3005 fmode_t var_idetape_ioctl_55_p1; 3006 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_ioctl" */ 3007 unsigned int var_idetape_ioctl_55_p2; 3008 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "idetape_ioctl" */ 3009 unsigned long var_idetape_ioctl_55_p3; 3010 3011 3012 3013 3014 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 3015 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 3016 /*============================= VARIABLE INITIALIZING PART =============================*/ 3017 LDV_IN_INTERRUPT=1; 3018 3019 3020 3021 3022 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 3023 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 3024 /*============================= FUNCTION CALL SECTION =============================*/ 3025 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 3026 ldv_initialize(); 3027 3028 /** INIT: init_type: ST_MODULE_INIT **/ 3029 /* content: static int __init idetape_init(void)*/ 3030 /* LDV_COMMENT_BEGIN_PREP */ 3031 #define DRV_NAME "ide-tape" 3032 #define IDETAPE_VERSION "1.20" 3033 #undef IDETAPE_DEBUG_LOG 3034 #ifdef IDETAPE_DEBUG_LOG 3035 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3036 #else 3037 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3038 #endif 3039 #define IDETAPE_MAX_PC_RETRIES 3 3040 #define IDETAPE_FIFO_THRESHOLD 2 3041 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3042 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3043 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3044 #define IDETAPE_DSC_MA_FAST 2*HZ 3045 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3046 #define IDETAPE_DSC_MA_SLOW 30*HZ 3047 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3048 #define DOOR_UNLOCKED 0 3049 #define DOOR_LOCKED 1 3050 #define DOOR_EXPLICITLY_LOCKED 2 3051 #define IDETAPE_SPACE_OVER_FILEMARK 1 3052 #define IDETAPE_SPACE_TO_EOD 3 3053 #define IDETAPE_LU_LOAD_MASK 1 3054 #define IDETAPE_LU_RETENSION_MASK 2 3055 #define IDETAPE_LU_EOT_MASK 4 3056 #define IDETAPE_BLOCK_DESCRIPTOR 0 3057 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3058 #ifdef CONFIG_IDE_PROC_FS 3059 #define ide_tape_devset_get(name, field) \ 3060 static int get_##name(ide_drive_t *drive) \ 3061 { \ 3062 idetape_tape_t *tape = drive->driver_data; \ 3063 return tape->field; \ 3064 } 3065 #define ide_tape_devset_set(name, field) \ 3066 static int set_##name(ide_drive_t *drive, int arg) \ 3067 { \ 3068 idetape_tape_t *tape = drive->driver_data; \ 3069 tape->field = arg; \ 3070 return 0; \ 3071 } 3072 #define ide_tape_devset_rw_field(_name, _field) \ 3073 ide_tape_devset_get(_name, _field) \ 3074 ide_tape_devset_set(_name, _field) \ 3075 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3076 #define ide_tape_devset_r_field(_name, _field) \ 3077 ide_tape_devset_get(_name, _field) \ 3078 IDE_DEVSET(_name, 0, get_##_name, NULL) 3079 #endif 3080 #ifdef CONFIG_IDE_PROC_FS 3081 #endif 3082 #ifdef CONFIG_IDE_PROC_FS 3083 #endif 3084 /* LDV_COMMENT_END_PREP */ 3085 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */ 3086 ldv_handler_precall(); 3087 if(idetape_init()) 3088 goto ldv_final; 3089 int ldv_s_idetape_name_proc_fops_file_operations = 0; 3090 3091 int ldv_s_idetape_driver_ide_driver = 0; 3092 3093 3094 int ldv_s_idetape_fops_file_operations = 0; 3095 3096 3097 int ldv_s_idetape_block_ops_block_device_operations = 0; 3098 3099 3100 3101 while( nondet_int() 3102 || !(ldv_s_idetape_name_proc_fops_file_operations == 0) 3103 || !(ldv_s_idetape_driver_ide_driver == 0) 3104 || !(ldv_s_idetape_fops_file_operations == 0) 3105 || !(ldv_s_idetape_block_ops_block_device_operations == 0) 3106 ) { 3107 3108 switch(nondet_int()) { 3109 3110 case 0: { 3111 3112 /** STRUCT: struct type: file_operations, struct name: idetape_name_proc_fops **/ 3113 if(ldv_s_idetape_name_proc_fops_file_operations==0) { 3114 3115 /* content: static int idetape_name_proc_open(struct inode *inode, struct file *file)*/ 3116 /* LDV_COMMENT_BEGIN_PREP */ 3117 #define DRV_NAME "ide-tape" 3118 #define IDETAPE_VERSION "1.20" 3119 #undef IDETAPE_DEBUG_LOG 3120 #ifdef IDETAPE_DEBUG_LOG 3121 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3122 #else 3123 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3124 #endif 3125 #define IDETAPE_MAX_PC_RETRIES 3 3126 #define IDETAPE_FIFO_THRESHOLD 2 3127 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3128 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3129 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3130 #define IDETAPE_DSC_MA_FAST 2*HZ 3131 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3132 #define IDETAPE_DSC_MA_SLOW 30*HZ 3133 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3134 #define DOOR_UNLOCKED 0 3135 #define DOOR_LOCKED 1 3136 #define DOOR_EXPLICITLY_LOCKED 2 3137 #define IDETAPE_SPACE_OVER_FILEMARK 1 3138 #define IDETAPE_SPACE_TO_EOD 3 3139 #define IDETAPE_LU_LOAD_MASK 1 3140 #define IDETAPE_LU_RETENSION_MASK 2 3141 #define IDETAPE_LU_EOT_MASK 4 3142 #define IDETAPE_BLOCK_DESCRIPTOR 0 3143 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3144 #ifdef CONFIG_IDE_PROC_FS 3145 #define ide_tape_devset_get(name, field) \ 3146 static int get_##name(ide_drive_t *drive) \ 3147 { \ 3148 idetape_tape_t *tape = drive->driver_data; \ 3149 return tape->field; \ 3150 } 3151 #define ide_tape_devset_set(name, field) \ 3152 static int set_##name(ide_drive_t *drive, int arg) \ 3153 { \ 3154 idetape_tape_t *tape = drive->driver_data; \ 3155 tape->field = arg; \ 3156 return 0; \ 3157 } 3158 #define ide_tape_devset_rw_field(_name, _field) \ 3159 ide_tape_devset_get(_name, _field) \ 3160 ide_tape_devset_set(_name, _field) \ 3161 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3162 #define ide_tape_devset_r_field(_name, _field) \ 3163 ide_tape_devset_get(_name, _field) \ 3164 IDE_DEVSET(_name, 0, get_##_name, NULL) 3165 #endif 3166 #ifdef CONFIG_IDE_PROC_FS 3167 /* LDV_COMMENT_END_PREP */ 3168 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "idetape_name_proc_fops". Standart function test for correct return result. */ 3169 ldv_handler_precall(); 3170 res_idetape_name_proc_open_50 = idetape_name_proc_open( var_group1, var_group2); 3171 ldv_check_return_value(res_idetape_name_proc_open_50); 3172 if(res_idetape_name_proc_open_50) 3173 goto ldv_module_exit; 3174 /* LDV_COMMENT_BEGIN_PREP */ 3175 #endif 3176 #ifdef CONFIG_IDE_PROC_FS 3177 #endif 3178 /* LDV_COMMENT_END_PREP */ 3179 ldv_s_idetape_name_proc_fops_file_operations=0; 3180 3181 } 3182 3183 } 3184 3185 break; 3186 case 1: { 3187 3188 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3189 if(ldv_s_idetape_driver_ide_driver==0) { 3190 3191 /* content: static int ide_tape_probe(ide_drive_t *drive)*/ 3192 /* LDV_COMMENT_BEGIN_PREP */ 3193 #define DRV_NAME "ide-tape" 3194 #define IDETAPE_VERSION "1.20" 3195 #undef IDETAPE_DEBUG_LOG 3196 #ifdef IDETAPE_DEBUG_LOG 3197 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3198 #else 3199 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3200 #endif 3201 #define IDETAPE_MAX_PC_RETRIES 3 3202 #define IDETAPE_FIFO_THRESHOLD 2 3203 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3204 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3205 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3206 #define IDETAPE_DSC_MA_FAST 2*HZ 3207 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3208 #define IDETAPE_DSC_MA_SLOW 30*HZ 3209 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3210 #define DOOR_UNLOCKED 0 3211 #define DOOR_LOCKED 1 3212 #define DOOR_EXPLICITLY_LOCKED 2 3213 #define IDETAPE_SPACE_OVER_FILEMARK 1 3214 #define IDETAPE_SPACE_TO_EOD 3 3215 #define IDETAPE_LU_LOAD_MASK 1 3216 #define IDETAPE_LU_RETENSION_MASK 2 3217 #define IDETAPE_LU_EOT_MASK 4 3218 #define IDETAPE_BLOCK_DESCRIPTOR 0 3219 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3220 #ifdef CONFIG_IDE_PROC_FS 3221 #define ide_tape_devset_get(name, field) \ 3222 static int get_##name(ide_drive_t *drive) \ 3223 { \ 3224 idetape_tape_t *tape = drive->driver_data; \ 3225 return tape->field; \ 3226 } 3227 #define ide_tape_devset_set(name, field) \ 3228 static int set_##name(ide_drive_t *drive, int arg) \ 3229 { \ 3230 idetape_tape_t *tape = drive->driver_data; \ 3231 tape->field = arg; \ 3232 return 0; \ 3233 } 3234 #define ide_tape_devset_rw_field(_name, _field) \ 3235 ide_tape_devset_get(_name, _field) \ 3236 ide_tape_devset_set(_name, _field) \ 3237 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3238 #define ide_tape_devset_r_field(_name, _field) \ 3239 ide_tape_devset_get(_name, _field) \ 3240 IDE_DEVSET(_name, 0, get_##_name, NULL) 3241 #endif 3242 #ifdef CONFIG_IDE_PROC_FS 3243 #endif 3244 #ifdef CONFIG_IDE_PROC_FS 3245 #endif 3246 /* LDV_COMMENT_END_PREP */ 3247 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "idetape_driver". Standart function test for correct return result. */ 3248 res_ide_tape_probe_56 = ide_tape_probe( var_ide_tape_probe_56_p0); 3249 ldv_check_return_value(res_ide_tape_probe_56); 3250 ldv_check_return_value_probe(res_ide_tape_probe_56); 3251 if(res_ide_tape_probe_56) 3252 goto ldv_module_exit; 3253 ldv_s_idetape_driver_ide_driver++; 3254 3255 } 3256 3257 } 3258 3259 break; 3260 case 2: { 3261 3262 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3263 if(ldv_s_idetape_driver_ide_driver==1) { 3264 3265 /* content: static void ide_tape_remove(ide_drive_t *drive)*/ 3266 /* LDV_COMMENT_BEGIN_PREP */ 3267 #define DRV_NAME "ide-tape" 3268 #define IDETAPE_VERSION "1.20" 3269 #undef IDETAPE_DEBUG_LOG 3270 #ifdef IDETAPE_DEBUG_LOG 3271 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3272 #else 3273 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3274 #endif 3275 #define IDETAPE_MAX_PC_RETRIES 3 3276 #define IDETAPE_FIFO_THRESHOLD 2 3277 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3278 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3279 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3280 #define IDETAPE_DSC_MA_FAST 2*HZ 3281 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3282 #define IDETAPE_DSC_MA_SLOW 30*HZ 3283 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3284 #define DOOR_UNLOCKED 0 3285 #define DOOR_LOCKED 1 3286 #define DOOR_EXPLICITLY_LOCKED 2 3287 #define IDETAPE_SPACE_OVER_FILEMARK 1 3288 #define IDETAPE_SPACE_TO_EOD 3 3289 #define IDETAPE_LU_LOAD_MASK 1 3290 #define IDETAPE_LU_RETENSION_MASK 2 3291 #define IDETAPE_LU_EOT_MASK 4 3292 #define IDETAPE_BLOCK_DESCRIPTOR 0 3293 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3294 #ifdef CONFIG_IDE_PROC_FS 3295 #define ide_tape_devset_get(name, field) \ 3296 static int get_##name(ide_drive_t *drive) \ 3297 { \ 3298 idetape_tape_t *tape = drive->driver_data; \ 3299 return tape->field; \ 3300 } 3301 #define ide_tape_devset_set(name, field) \ 3302 static int set_##name(ide_drive_t *drive, int arg) \ 3303 { \ 3304 idetape_tape_t *tape = drive->driver_data; \ 3305 tape->field = arg; \ 3306 return 0; \ 3307 } 3308 #define ide_tape_devset_rw_field(_name, _field) \ 3309 ide_tape_devset_get(_name, _field) \ 3310 ide_tape_devset_set(_name, _field) \ 3311 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3312 #define ide_tape_devset_r_field(_name, _field) \ 3313 ide_tape_devset_get(_name, _field) \ 3314 IDE_DEVSET(_name, 0, get_##_name, NULL) 3315 #endif 3316 /* LDV_COMMENT_END_PREP */ 3317 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "idetape_driver" */ 3318 ldv_handler_precall(); 3319 ide_tape_remove( var_ide_tape_remove_47_p0); 3320 /* LDV_COMMENT_BEGIN_PREP */ 3321 #ifdef CONFIG_IDE_PROC_FS 3322 #endif 3323 #ifdef CONFIG_IDE_PROC_FS 3324 #endif 3325 /* LDV_COMMENT_END_PREP */ 3326 ldv_s_idetape_driver_ide_driver=0; 3327 3328 } 3329 3330 } 3331 3332 break; 3333 case 3: { 3334 3335 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3336 3337 3338 /* content: static ide_startstop_t idetape_do_request(ide_drive_t *drive, struct request *rq, sector_t block)*/ 3339 /* LDV_COMMENT_BEGIN_PREP */ 3340 #define DRV_NAME "ide-tape" 3341 #define IDETAPE_VERSION "1.20" 3342 #undef IDETAPE_DEBUG_LOG 3343 #ifdef IDETAPE_DEBUG_LOG 3344 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3345 #else 3346 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3347 #endif 3348 #define IDETAPE_MAX_PC_RETRIES 3 3349 #define IDETAPE_FIFO_THRESHOLD 2 3350 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3351 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3352 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3353 #define IDETAPE_DSC_MA_FAST 2*HZ 3354 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3355 #define IDETAPE_DSC_MA_SLOW 30*HZ 3356 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3357 #define DOOR_UNLOCKED 0 3358 #define DOOR_LOCKED 1 3359 #define DOOR_EXPLICITLY_LOCKED 2 3360 #define IDETAPE_SPACE_OVER_FILEMARK 1 3361 #define IDETAPE_SPACE_TO_EOD 3 3362 #define IDETAPE_LU_LOAD_MASK 1 3363 #define IDETAPE_LU_RETENSION_MASK 2 3364 #define IDETAPE_LU_EOT_MASK 4 3365 #define IDETAPE_BLOCK_DESCRIPTOR 0 3366 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3367 /* LDV_COMMENT_END_PREP */ 3368 /* LDV_COMMENT_FUNCTION_CALL Function from field "do_request" from driver structure with callbacks "idetape_driver" */ 3369 ldv_handler_precall(); 3370 idetape_do_request( var_idetape_do_request_10_p0, var_group3, var_idetape_do_request_10_p2); 3371 /* LDV_COMMENT_BEGIN_PREP */ 3372 #ifdef CONFIG_IDE_PROC_FS 3373 #define ide_tape_devset_get(name, field) \ 3374 static int get_##name(ide_drive_t *drive) \ 3375 { \ 3376 idetape_tape_t *tape = drive->driver_data; \ 3377 return tape->field; \ 3378 } 3379 #define ide_tape_devset_set(name, field) \ 3380 static int set_##name(ide_drive_t *drive, int arg) \ 3381 { \ 3382 idetape_tape_t *tape = drive->driver_data; \ 3383 tape->field = arg; \ 3384 return 0; \ 3385 } 3386 #define ide_tape_devset_rw_field(_name, _field) \ 3387 ide_tape_devset_get(_name, _field) \ 3388 ide_tape_devset_set(_name, _field) \ 3389 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3390 #define ide_tape_devset_r_field(_name, _field) \ 3391 ide_tape_devset_get(_name, _field) \ 3392 IDE_DEVSET(_name, 0, get_##_name, NULL) 3393 #endif 3394 #ifdef CONFIG_IDE_PROC_FS 3395 #endif 3396 #ifdef CONFIG_IDE_PROC_FS 3397 #endif 3398 /* LDV_COMMENT_END_PREP */ 3399 3400 3401 3402 3403 } 3404 3405 break; 3406 case 4: { 3407 3408 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3409 3410 3411 /* content: static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)*/ 3412 /* LDV_COMMENT_BEGIN_PREP */ 3413 #define DRV_NAME "ide-tape" 3414 #define IDETAPE_VERSION "1.20" 3415 #undef IDETAPE_DEBUG_LOG 3416 #ifdef IDETAPE_DEBUG_LOG 3417 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3418 #else 3419 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3420 #endif 3421 #define IDETAPE_MAX_PC_RETRIES 3 3422 #define IDETAPE_FIFO_THRESHOLD 2 3423 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3424 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3425 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3426 #define IDETAPE_DSC_MA_FAST 2*HZ 3427 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3428 #define IDETAPE_DSC_MA_SLOW 30*HZ 3429 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3430 #define DOOR_UNLOCKED 0 3431 #define DOOR_LOCKED 1 3432 #define DOOR_EXPLICITLY_LOCKED 2 3433 #define IDETAPE_SPACE_OVER_FILEMARK 1 3434 #define IDETAPE_SPACE_TO_EOD 3 3435 #define IDETAPE_LU_LOAD_MASK 1 3436 #define IDETAPE_LU_RETENSION_MASK 2 3437 #define IDETAPE_LU_EOT_MASK 4 3438 #define IDETAPE_BLOCK_DESCRIPTOR 0 3439 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3440 #ifdef CONFIG_IDE_PROC_FS 3441 #define ide_tape_devset_get(name, field) \ 3442 static int get_##name(ide_drive_t *drive) \ 3443 { \ 3444 idetape_tape_t *tape = drive->driver_data; \ 3445 return tape->field; \ 3446 } 3447 #define ide_tape_devset_set(name, field) \ 3448 static int set_##name(ide_drive_t *drive, int arg) \ 3449 { \ 3450 idetape_tape_t *tape = drive->driver_data; \ 3451 tape->field = arg; \ 3452 return 0; \ 3453 } 3454 #define ide_tape_devset_rw_field(_name, _field) \ 3455 ide_tape_devset_get(_name, _field) \ 3456 ide_tape_devset_set(_name, _field) \ 3457 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3458 #define ide_tape_devset_r_field(_name, _field) \ 3459 ide_tape_devset_get(_name, _field) \ 3460 IDE_DEVSET(_name, 0, get_##_name, NULL) 3461 #endif 3462 #ifdef CONFIG_IDE_PROC_FS 3463 /* LDV_COMMENT_END_PREP */ 3464 /* LDV_COMMENT_FUNCTION_CALL Function from field "proc_entries" from driver structure with callbacks "idetape_driver" */ 3465 ldv_handler_precall(); 3466 ide_tape_proc_entries( var_ide_tape_proc_entries_51_p0); 3467 /* LDV_COMMENT_BEGIN_PREP */ 3468 #endif 3469 #ifdef CONFIG_IDE_PROC_FS 3470 #endif 3471 /* LDV_COMMENT_END_PREP */ 3472 3473 3474 3475 3476 } 3477 3478 break; 3479 case 5: { 3480 3481 /** STRUCT: struct type: ide_driver, struct name: idetape_driver **/ 3482 3483 3484 /* content: static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive)*/ 3485 /* LDV_COMMENT_BEGIN_PREP */ 3486 #define DRV_NAME "ide-tape" 3487 #define IDETAPE_VERSION "1.20" 3488 #undef IDETAPE_DEBUG_LOG 3489 #ifdef IDETAPE_DEBUG_LOG 3490 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3491 #else 3492 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3493 #endif 3494 #define IDETAPE_MAX_PC_RETRIES 3 3495 #define IDETAPE_FIFO_THRESHOLD 2 3496 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3497 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3498 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3499 #define IDETAPE_DSC_MA_FAST 2*HZ 3500 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3501 #define IDETAPE_DSC_MA_SLOW 30*HZ 3502 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3503 #define DOOR_UNLOCKED 0 3504 #define DOOR_LOCKED 1 3505 #define DOOR_EXPLICITLY_LOCKED 2 3506 #define IDETAPE_SPACE_OVER_FILEMARK 1 3507 #define IDETAPE_SPACE_TO_EOD 3 3508 #define IDETAPE_LU_LOAD_MASK 1 3509 #define IDETAPE_LU_RETENSION_MASK 2 3510 #define IDETAPE_LU_EOT_MASK 4 3511 #define IDETAPE_BLOCK_DESCRIPTOR 0 3512 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3513 #ifdef CONFIG_IDE_PROC_FS 3514 #define ide_tape_devset_get(name, field) \ 3515 static int get_##name(ide_drive_t *drive) \ 3516 { \ 3517 idetape_tape_t *tape = drive->driver_data; \ 3518 return tape->field; \ 3519 } 3520 #define ide_tape_devset_set(name, field) \ 3521 static int set_##name(ide_drive_t *drive, int arg) \ 3522 { \ 3523 idetape_tape_t *tape = drive->driver_data; \ 3524 tape->field = arg; \ 3525 return 0; \ 3526 } 3527 #define ide_tape_devset_rw_field(_name, _field) \ 3528 ide_tape_devset_get(_name, _field) \ 3529 ide_tape_devset_set(_name, _field) \ 3530 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3531 #define ide_tape_devset_r_field(_name, _field) \ 3532 ide_tape_devset_get(_name, _field) \ 3533 IDE_DEVSET(_name, 0, get_##_name, NULL) 3534 #endif 3535 #ifdef CONFIG_IDE_PROC_FS 3536 /* LDV_COMMENT_END_PREP */ 3537 /* LDV_COMMENT_FUNCTION_CALL Function from field "proc_devsets" from driver structure with callbacks "idetape_driver" */ 3538 ldv_handler_precall(); 3539 ide_tape_proc_devsets( var_ide_tape_proc_devsets_52_p0); 3540 /* LDV_COMMENT_BEGIN_PREP */ 3541 #endif 3542 #ifdef CONFIG_IDE_PROC_FS 3543 #endif 3544 /* LDV_COMMENT_END_PREP */ 3545 3546 3547 3548 3549 } 3550 3551 break; 3552 case 6: { 3553 3554 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3555 if(ldv_s_idetape_fops_file_operations==0) { 3556 3557 /* content: static int idetape_chrdev_open(struct inode *inode, struct file *filp)*/ 3558 /* LDV_COMMENT_BEGIN_PREP */ 3559 #define DRV_NAME "ide-tape" 3560 #define IDETAPE_VERSION "1.20" 3561 #undef IDETAPE_DEBUG_LOG 3562 #ifdef IDETAPE_DEBUG_LOG 3563 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3564 #else 3565 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3566 #endif 3567 #define IDETAPE_MAX_PC_RETRIES 3 3568 #define IDETAPE_FIFO_THRESHOLD 2 3569 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3570 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3571 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3572 #define IDETAPE_DSC_MA_FAST 2*HZ 3573 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3574 #define IDETAPE_DSC_MA_SLOW 30*HZ 3575 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3576 #define DOOR_UNLOCKED 0 3577 #define DOOR_LOCKED 1 3578 #define DOOR_EXPLICITLY_LOCKED 2 3579 #define IDETAPE_SPACE_OVER_FILEMARK 1 3580 #define IDETAPE_SPACE_TO_EOD 3 3581 #define IDETAPE_LU_LOAD_MASK 1 3582 #define IDETAPE_LU_RETENSION_MASK 2 3583 #define IDETAPE_LU_EOT_MASK 4 3584 #define IDETAPE_BLOCK_DESCRIPTOR 0 3585 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3586 /* LDV_COMMENT_END_PREP */ 3587 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "idetape_fops". Standart function test for correct return result. */ 3588 ldv_handler_precall(); 3589 res_idetape_chrdev_open_37 = idetape_chrdev_open( var_group1, var_group2); 3590 ldv_check_return_value(res_idetape_chrdev_open_37); 3591 if(res_idetape_chrdev_open_37) 3592 goto ldv_module_exit; 3593 /* LDV_COMMENT_BEGIN_PREP */ 3594 #ifdef CONFIG_IDE_PROC_FS 3595 #define ide_tape_devset_get(name, field) \ 3596 static int get_##name(ide_drive_t *drive) \ 3597 { \ 3598 idetape_tape_t *tape = drive->driver_data; \ 3599 return tape->field; \ 3600 } 3601 #define ide_tape_devset_set(name, field) \ 3602 static int set_##name(ide_drive_t *drive, int arg) \ 3603 { \ 3604 idetape_tape_t *tape = drive->driver_data; \ 3605 tape->field = arg; \ 3606 return 0; \ 3607 } 3608 #define ide_tape_devset_rw_field(_name, _field) \ 3609 ide_tape_devset_get(_name, _field) \ 3610 ide_tape_devset_set(_name, _field) \ 3611 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3612 #define ide_tape_devset_r_field(_name, _field) \ 3613 ide_tape_devset_get(_name, _field) \ 3614 IDE_DEVSET(_name, 0, get_##_name, NULL) 3615 #endif 3616 #ifdef CONFIG_IDE_PROC_FS 3617 #endif 3618 #ifdef CONFIG_IDE_PROC_FS 3619 #endif 3620 /* LDV_COMMENT_END_PREP */ 3621 ldv_s_idetape_fops_file_operations++; 3622 3623 } 3624 3625 } 3626 3627 break; 3628 case 7: { 3629 3630 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3631 if(ldv_s_idetape_fops_file_operations==1) { 3632 3633 /* content: static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)*/ 3634 /* LDV_COMMENT_BEGIN_PREP */ 3635 #define DRV_NAME "ide-tape" 3636 #define IDETAPE_VERSION "1.20" 3637 #undef IDETAPE_DEBUG_LOG 3638 #ifdef IDETAPE_DEBUG_LOG 3639 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3640 #else 3641 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3642 #endif 3643 #define IDETAPE_MAX_PC_RETRIES 3 3644 #define IDETAPE_FIFO_THRESHOLD 2 3645 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3646 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3647 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3648 #define IDETAPE_DSC_MA_FAST 2*HZ 3649 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3650 #define IDETAPE_DSC_MA_SLOW 30*HZ 3651 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3652 #define DOOR_UNLOCKED 0 3653 #define DOOR_LOCKED 1 3654 #define DOOR_EXPLICITLY_LOCKED 2 3655 #define IDETAPE_SPACE_OVER_FILEMARK 1 3656 #define IDETAPE_SPACE_TO_EOD 3 3657 #define IDETAPE_LU_LOAD_MASK 1 3658 #define IDETAPE_LU_RETENSION_MASK 2 3659 #define IDETAPE_LU_EOT_MASK 4 3660 #define IDETAPE_BLOCK_DESCRIPTOR 0 3661 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3662 /* LDV_COMMENT_END_PREP */ 3663 /* LDV_COMMENT_FUNCTION_CALL Function from field "read" from driver structure with callbacks "idetape_fops". Standart function test for correct return result. */ 3664 ldv_handler_precall(); 3665 res_idetape_chrdev_read_30 = idetape_chrdev_read( var_group2, var_idetape_chrdev_read_30_p1, var_idetape_chrdev_read_30_p2, var_idetape_chrdev_read_30_p3); 3666 ldv_check_return_value(res_idetape_chrdev_read_30); 3667 if(res_idetape_chrdev_read_30 < 0) 3668 goto ldv_module_exit; 3669 /* LDV_COMMENT_BEGIN_PREP */ 3670 #ifdef CONFIG_IDE_PROC_FS 3671 #define ide_tape_devset_get(name, field) \ 3672 static int get_##name(ide_drive_t *drive) \ 3673 { \ 3674 idetape_tape_t *tape = drive->driver_data; \ 3675 return tape->field; \ 3676 } 3677 #define ide_tape_devset_set(name, field) \ 3678 static int set_##name(ide_drive_t *drive, int arg) \ 3679 { \ 3680 idetape_tape_t *tape = drive->driver_data; \ 3681 tape->field = arg; \ 3682 return 0; \ 3683 } 3684 #define ide_tape_devset_rw_field(_name, _field) \ 3685 ide_tape_devset_get(_name, _field) \ 3686 ide_tape_devset_set(_name, _field) \ 3687 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3688 #define ide_tape_devset_r_field(_name, _field) \ 3689 ide_tape_devset_get(_name, _field) \ 3690 IDE_DEVSET(_name, 0, get_##_name, NULL) 3691 #endif 3692 #ifdef CONFIG_IDE_PROC_FS 3693 #endif 3694 #ifdef CONFIG_IDE_PROC_FS 3695 #endif 3696 /* LDV_COMMENT_END_PREP */ 3697 ldv_s_idetape_fops_file_operations++; 3698 3699 } 3700 3701 } 3702 3703 break; 3704 case 8: { 3705 3706 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3707 if(ldv_s_idetape_fops_file_operations==2) { 3708 3709 /* content: static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)*/ 3710 /* LDV_COMMENT_BEGIN_PREP */ 3711 #define DRV_NAME "ide-tape" 3712 #define IDETAPE_VERSION "1.20" 3713 #undef IDETAPE_DEBUG_LOG 3714 #ifdef IDETAPE_DEBUG_LOG 3715 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3716 #else 3717 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3718 #endif 3719 #define IDETAPE_MAX_PC_RETRIES 3 3720 #define IDETAPE_FIFO_THRESHOLD 2 3721 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3722 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3723 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3724 #define IDETAPE_DSC_MA_FAST 2*HZ 3725 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3726 #define IDETAPE_DSC_MA_SLOW 30*HZ 3727 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3728 #define DOOR_UNLOCKED 0 3729 #define DOOR_LOCKED 1 3730 #define DOOR_EXPLICITLY_LOCKED 2 3731 #define IDETAPE_SPACE_OVER_FILEMARK 1 3732 #define IDETAPE_SPACE_TO_EOD 3 3733 #define IDETAPE_LU_LOAD_MASK 1 3734 #define IDETAPE_LU_RETENSION_MASK 2 3735 #define IDETAPE_LU_EOT_MASK 4 3736 #define IDETAPE_BLOCK_DESCRIPTOR 0 3737 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3738 /* LDV_COMMENT_END_PREP */ 3739 /* LDV_COMMENT_FUNCTION_CALL Function from field "write" from driver structure with callbacks "idetape_fops". Standart function test for correct return result. */ 3740 ldv_handler_precall(); 3741 res_idetape_chrdev_write_31 = idetape_chrdev_write( var_group2, var_idetape_chrdev_write_31_p1, var_idetape_chrdev_write_31_p2, var_idetape_chrdev_write_31_p3); 3742 ldv_check_return_value(res_idetape_chrdev_write_31); 3743 if(res_idetape_chrdev_write_31 < 0) 3744 goto ldv_module_exit; 3745 /* LDV_COMMENT_BEGIN_PREP */ 3746 #ifdef CONFIG_IDE_PROC_FS 3747 #define ide_tape_devset_get(name, field) \ 3748 static int get_##name(ide_drive_t *drive) \ 3749 { \ 3750 idetape_tape_t *tape = drive->driver_data; \ 3751 return tape->field; \ 3752 } 3753 #define ide_tape_devset_set(name, field) \ 3754 static int set_##name(ide_drive_t *drive, int arg) \ 3755 { \ 3756 idetape_tape_t *tape = drive->driver_data; \ 3757 tape->field = arg; \ 3758 return 0; \ 3759 } 3760 #define ide_tape_devset_rw_field(_name, _field) \ 3761 ide_tape_devset_get(_name, _field) \ 3762 ide_tape_devset_set(_name, _field) \ 3763 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3764 #define ide_tape_devset_r_field(_name, _field) \ 3765 ide_tape_devset_get(_name, _field) \ 3766 IDE_DEVSET(_name, 0, get_##_name, NULL) 3767 #endif 3768 #ifdef CONFIG_IDE_PROC_FS 3769 #endif 3770 #ifdef CONFIG_IDE_PROC_FS 3771 #endif 3772 /* LDV_COMMENT_END_PREP */ 3773 ldv_s_idetape_fops_file_operations++; 3774 3775 } 3776 3777 } 3778 3779 break; 3780 case 9: { 3781 3782 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3783 if(ldv_s_idetape_fops_file_operations==3) { 3784 3785 /* content: static int idetape_chrdev_release(struct inode *inode, struct file *filp)*/ 3786 /* LDV_COMMENT_BEGIN_PREP */ 3787 #define DRV_NAME "ide-tape" 3788 #define IDETAPE_VERSION "1.20" 3789 #undef IDETAPE_DEBUG_LOG 3790 #ifdef IDETAPE_DEBUG_LOG 3791 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3792 #else 3793 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3794 #endif 3795 #define IDETAPE_MAX_PC_RETRIES 3 3796 #define IDETAPE_FIFO_THRESHOLD 2 3797 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3798 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3799 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3800 #define IDETAPE_DSC_MA_FAST 2*HZ 3801 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3802 #define IDETAPE_DSC_MA_SLOW 30*HZ 3803 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3804 #define DOOR_UNLOCKED 0 3805 #define DOOR_LOCKED 1 3806 #define DOOR_EXPLICITLY_LOCKED 2 3807 #define IDETAPE_SPACE_OVER_FILEMARK 1 3808 #define IDETAPE_SPACE_TO_EOD 3 3809 #define IDETAPE_LU_LOAD_MASK 1 3810 #define IDETAPE_LU_RETENSION_MASK 2 3811 #define IDETAPE_LU_EOT_MASK 4 3812 #define IDETAPE_BLOCK_DESCRIPTOR 0 3813 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3814 /* LDV_COMMENT_END_PREP */ 3815 /* LDV_COMMENT_FUNCTION_CALL Function from field "release" from driver structure with callbacks "idetape_fops" */ 3816 ldv_handler_precall(); 3817 idetape_chrdev_release( var_group1, var_group2); 3818 /* LDV_COMMENT_BEGIN_PREP */ 3819 #ifdef CONFIG_IDE_PROC_FS 3820 #define ide_tape_devset_get(name, field) \ 3821 static int get_##name(ide_drive_t *drive) \ 3822 { \ 3823 idetape_tape_t *tape = drive->driver_data; \ 3824 return tape->field; \ 3825 } 3826 #define ide_tape_devset_set(name, field) \ 3827 static int set_##name(ide_drive_t *drive, int arg) \ 3828 { \ 3829 idetape_tape_t *tape = drive->driver_data; \ 3830 tape->field = arg; \ 3831 return 0; \ 3832 } 3833 #define ide_tape_devset_rw_field(_name, _field) \ 3834 ide_tape_devset_get(_name, _field) \ 3835 ide_tape_devset_set(_name, _field) \ 3836 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3837 #define ide_tape_devset_r_field(_name, _field) \ 3838 ide_tape_devset_get(_name, _field) \ 3839 IDE_DEVSET(_name, 0, get_##_name, NULL) 3840 #endif 3841 #ifdef CONFIG_IDE_PROC_FS 3842 #endif 3843 #ifdef CONFIG_IDE_PROC_FS 3844 #endif 3845 /* LDV_COMMENT_END_PREP */ 3846 ldv_s_idetape_fops_file_operations=0; 3847 3848 } 3849 3850 } 3851 3852 break; 3853 case 10: { 3854 3855 /** STRUCT: struct type: file_operations, struct name: idetape_fops **/ 3856 3857 3858 /* content: static long idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)*/ 3859 /* LDV_COMMENT_BEGIN_PREP */ 3860 #define DRV_NAME "ide-tape" 3861 #define IDETAPE_VERSION "1.20" 3862 #undef IDETAPE_DEBUG_LOG 3863 #ifdef IDETAPE_DEBUG_LOG 3864 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3865 #else 3866 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3867 #endif 3868 #define IDETAPE_MAX_PC_RETRIES 3 3869 #define IDETAPE_FIFO_THRESHOLD 2 3870 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3871 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3872 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3873 #define IDETAPE_DSC_MA_FAST 2*HZ 3874 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3875 #define IDETAPE_DSC_MA_SLOW 30*HZ 3876 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3877 #define DOOR_UNLOCKED 0 3878 #define DOOR_LOCKED 1 3879 #define DOOR_EXPLICITLY_LOCKED 2 3880 #define IDETAPE_SPACE_OVER_FILEMARK 1 3881 #define IDETAPE_SPACE_TO_EOD 3 3882 #define IDETAPE_LU_LOAD_MASK 1 3883 #define IDETAPE_LU_RETENSION_MASK 2 3884 #define IDETAPE_LU_EOT_MASK 4 3885 #define IDETAPE_BLOCK_DESCRIPTOR 0 3886 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3887 /* LDV_COMMENT_END_PREP */ 3888 /* LDV_COMMENT_FUNCTION_CALL Function from field "unlocked_ioctl" from driver structure with callbacks "idetape_fops" */ 3889 ldv_handler_precall(); 3890 idetape_chrdev_ioctl( var_group2, var_idetape_chrdev_ioctl_35_p1, var_idetape_chrdev_ioctl_35_p2); 3891 /* LDV_COMMENT_BEGIN_PREP */ 3892 #ifdef CONFIG_IDE_PROC_FS 3893 #define ide_tape_devset_get(name, field) \ 3894 static int get_##name(ide_drive_t *drive) \ 3895 { \ 3896 idetape_tape_t *tape = drive->driver_data; \ 3897 return tape->field; \ 3898 } 3899 #define ide_tape_devset_set(name, field) \ 3900 static int set_##name(ide_drive_t *drive, int arg) \ 3901 { \ 3902 idetape_tape_t *tape = drive->driver_data; \ 3903 tape->field = arg; \ 3904 return 0; \ 3905 } 3906 #define ide_tape_devset_rw_field(_name, _field) \ 3907 ide_tape_devset_get(_name, _field) \ 3908 ide_tape_devset_set(_name, _field) \ 3909 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3910 #define ide_tape_devset_r_field(_name, _field) \ 3911 ide_tape_devset_get(_name, _field) \ 3912 IDE_DEVSET(_name, 0, get_##_name, NULL) 3913 #endif 3914 #ifdef CONFIG_IDE_PROC_FS 3915 #endif 3916 #ifdef CONFIG_IDE_PROC_FS 3917 #endif 3918 /* LDV_COMMENT_END_PREP */ 3919 3920 3921 3922 3923 } 3924 3925 break; 3926 case 11: { 3927 3928 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 3929 if(ldv_s_idetape_block_ops_block_device_operations==0) { 3930 3931 /* content: static int idetape_open(struct block_device *bdev, fmode_t mode)*/ 3932 /* LDV_COMMENT_BEGIN_PREP */ 3933 #define DRV_NAME "ide-tape" 3934 #define IDETAPE_VERSION "1.20" 3935 #undef IDETAPE_DEBUG_LOG 3936 #ifdef IDETAPE_DEBUG_LOG 3937 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 3938 #else 3939 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 3940 #endif 3941 #define IDETAPE_MAX_PC_RETRIES 3 3942 #define IDETAPE_FIFO_THRESHOLD 2 3943 #define IDETAPE_DSC_RW_MIN 5*HZ/100 3944 #define IDETAPE_DSC_RW_MAX 40*HZ/100 3945 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 3946 #define IDETAPE_DSC_MA_FAST 2*HZ 3947 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 3948 #define IDETAPE_DSC_MA_SLOW 30*HZ 3949 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 3950 #define DOOR_UNLOCKED 0 3951 #define DOOR_LOCKED 1 3952 #define DOOR_EXPLICITLY_LOCKED 2 3953 #define IDETAPE_SPACE_OVER_FILEMARK 1 3954 #define IDETAPE_SPACE_TO_EOD 3 3955 #define IDETAPE_LU_LOAD_MASK 1 3956 #define IDETAPE_LU_RETENSION_MASK 2 3957 #define IDETAPE_LU_EOT_MASK 4 3958 #define IDETAPE_BLOCK_DESCRIPTOR 0 3959 #define IDETAPE_CAPABILITIES_PAGE 0x2a 3960 #ifdef CONFIG_IDE_PROC_FS 3961 #define ide_tape_devset_get(name, field) \ 3962 static int get_##name(ide_drive_t *drive) \ 3963 { \ 3964 idetape_tape_t *tape = drive->driver_data; \ 3965 return tape->field; \ 3966 } 3967 #define ide_tape_devset_set(name, field) \ 3968 static int set_##name(ide_drive_t *drive, int arg) \ 3969 { \ 3970 idetape_tape_t *tape = drive->driver_data; \ 3971 tape->field = arg; \ 3972 return 0; \ 3973 } 3974 #define ide_tape_devset_rw_field(_name, _field) \ 3975 ide_tape_devset_get(_name, _field) \ 3976 ide_tape_devset_set(_name, _field) \ 3977 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 3978 #define ide_tape_devset_r_field(_name, _field) \ 3979 ide_tape_devset_get(_name, _field) \ 3980 IDE_DEVSET(_name, 0, get_##_name, NULL) 3981 #endif 3982 #ifdef CONFIG_IDE_PROC_FS 3983 #endif 3984 #ifdef CONFIG_IDE_PROC_FS 3985 #endif 3986 /* LDV_COMMENT_END_PREP */ 3987 /* LDV_COMMENT_FUNCTION_CALL Function from field "open" from driver structure with callbacks "idetape_block_ops". Standart function test for correct return result. */ 3988 ldv_handler_precall(); 3989 res_idetape_open_53 = idetape_open( var_group4, var_idetape_open_53_p1); 3990 ldv_check_return_value(res_idetape_open_53); 3991 if(res_idetape_open_53) 3992 goto ldv_module_exit; 3993 ldv_s_idetape_block_ops_block_device_operations++; 3994 3995 } 3996 3997 } 3998 3999 break; 4000 case 12: { 4001 4002 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 4003 if(ldv_s_idetape_block_ops_block_device_operations==1) { 4004 4005 /* content: static void idetape_release(struct gendisk *disk, fmode_t mode)*/ 4006 /* LDV_COMMENT_BEGIN_PREP */ 4007 #define DRV_NAME "ide-tape" 4008 #define IDETAPE_VERSION "1.20" 4009 #undef IDETAPE_DEBUG_LOG 4010 #ifdef IDETAPE_DEBUG_LOG 4011 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 4012 #else 4013 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 4014 #endif 4015 #define IDETAPE_MAX_PC_RETRIES 3 4016 #define IDETAPE_FIFO_THRESHOLD 2 4017 #define IDETAPE_DSC_RW_MIN 5*HZ/100 4018 #define IDETAPE_DSC_RW_MAX 40*HZ/100 4019 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 4020 #define IDETAPE_DSC_MA_FAST 2*HZ 4021 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 4022 #define IDETAPE_DSC_MA_SLOW 30*HZ 4023 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 4024 #define DOOR_UNLOCKED 0 4025 #define DOOR_LOCKED 1 4026 #define DOOR_EXPLICITLY_LOCKED 2 4027 #define IDETAPE_SPACE_OVER_FILEMARK 1 4028 #define IDETAPE_SPACE_TO_EOD 3 4029 #define IDETAPE_LU_LOAD_MASK 1 4030 #define IDETAPE_LU_RETENSION_MASK 2 4031 #define IDETAPE_LU_EOT_MASK 4 4032 #define IDETAPE_BLOCK_DESCRIPTOR 0 4033 #define IDETAPE_CAPABILITIES_PAGE 0x2a 4034 #ifdef CONFIG_IDE_PROC_FS 4035 #define ide_tape_devset_get(name, field) \ 4036 static int get_##name(ide_drive_t *drive) \ 4037 { \ 4038 idetape_tape_t *tape = drive->driver_data; \ 4039 return tape->field; \ 4040 } 4041 #define ide_tape_devset_set(name, field) \ 4042 static int set_##name(ide_drive_t *drive, int arg) \ 4043 { \ 4044 idetape_tape_t *tape = drive->driver_data; \ 4045 tape->field = arg; \ 4046 return 0; \ 4047 } 4048 #define ide_tape_devset_rw_field(_name, _field) \ 4049 ide_tape_devset_get(_name, _field) \ 4050 ide_tape_devset_set(_name, _field) \ 4051 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 4052 #define ide_tape_devset_r_field(_name, _field) \ 4053 ide_tape_devset_get(_name, _field) \ 4054 IDE_DEVSET(_name, 0, get_##_name, NULL) 4055 #endif 4056 #ifdef CONFIG_IDE_PROC_FS 4057 #endif 4058 #ifdef CONFIG_IDE_PROC_FS 4059 #endif 4060 /* LDV_COMMENT_END_PREP */ 4061 /* LDV_COMMENT_FUNCTION_CALL Function from field "release" from driver structure with callbacks "idetape_block_ops" */ 4062 ldv_handler_precall(); 4063 idetape_release( var_group5, var_idetape_release_54_p1); 4064 ldv_s_idetape_block_ops_block_device_operations=0; 4065 4066 } 4067 4068 } 4069 4070 break; 4071 case 13: { 4072 4073 /** STRUCT: struct type: block_device_operations, struct name: idetape_block_ops **/ 4074 4075 4076 /* content: static int idetape_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)*/ 4077 /* LDV_COMMENT_BEGIN_PREP */ 4078 #define DRV_NAME "ide-tape" 4079 #define IDETAPE_VERSION "1.20" 4080 #undef IDETAPE_DEBUG_LOG 4081 #ifdef IDETAPE_DEBUG_LOG 4082 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 4083 #else 4084 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 4085 #endif 4086 #define IDETAPE_MAX_PC_RETRIES 3 4087 #define IDETAPE_FIFO_THRESHOLD 2 4088 #define IDETAPE_DSC_RW_MIN 5*HZ/100 4089 #define IDETAPE_DSC_RW_MAX 40*HZ/100 4090 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 4091 #define IDETAPE_DSC_MA_FAST 2*HZ 4092 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 4093 #define IDETAPE_DSC_MA_SLOW 30*HZ 4094 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 4095 #define DOOR_UNLOCKED 0 4096 #define DOOR_LOCKED 1 4097 #define DOOR_EXPLICITLY_LOCKED 2 4098 #define IDETAPE_SPACE_OVER_FILEMARK 1 4099 #define IDETAPE_SPACE_TO_EOD 3 4100 #define IDETAPE_LU_LOAD_MASK 1 4101 #define IDETAPE_LU_RETENSION_MASK 2 4102 #define IDETAPE_LU_EOT_MASK 4 4103 #define IDETAPE_BLOCK_DESCRIPTOR 0 4104 #define IDETAPE_CAPABILITIES_PAGE 0x2a 4105 #ifdef CONFIG_IDE_PROC_FS 4106 #define ide_tape_devset_get(name, field) \ 4107 static int get_##name(ide_drive_t *drive) \ 4108 { \ 4109 idetape_tape_t *tape = drive->driver_data; \ 4110 return tape->field; \ 4111 } 4112 #define ide_tape_devset_set(name, field) \ 4113 static int set_##name(ide_drive_t *drive, int arg) \ 4114 { \ 4115 idetape_tape_t *tape = drive->driver_data; \ 4116 tape->field = arg; \ 4117 return 0; \ 4118 } 4119 #define ide_tape_devset_rw_field(_name, _field) \ 4120 ide_tape_devset_get(_name, _field) \ 4121 ide_tape_devset_set(_name, _field) \ 4122 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 4123 #define ide_tape_devset_r_field(_name, _field) \ 4124 ide_tape_devset_get(_name, _field) \ 4125 IDE_DEVSET(_name, 0, get_##_name, NULL) 4126 #endif 4127 #ifdef CONFIG_IDE_PROC_FS 4128 #endif 4129 #ifdef CONFIG_IDE_PROC_FS 4130 #endif 4131 /* LDV_COMMENT_END_PREP */ 4132 /* LDV_COMMENT_FUNCTION_CALL Function from field "ioctl" from driver structure with callbacks "idetape_block_ops" */ 4133 ldv_handler_precall(); 4134 idetape_ioctl( var_group4, var_idetape_ioctl_55_p1, var_idetape_ioctl_55_p2, var_idetape_ioctl_55_p3); 4135 4136 4137 4138 4139 } 4140 4141 break; 4142 default: break; 4143 4144 } 4145 4146 } 4147 4148 ldv_module_exit: 4149 4150 /** INIT: init_type: ST_MODULE_EXIT **/ 4151 /* content: static void __exit idetape_exit(void)*/ 4152 /* LDV_COMMENT_BEGIN_PREP */ 4153 #define DRV_NAME "ide-tape" 4154 #define IDETAPE_VERSION "1.20" 4155 #undef IDETAPE_DEBUG_LOG 4156 #ifdef IDETAPE_DEBUG_LOG 4157 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 4158 #else 4159 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 4160 #endif 4161 #define IDETAPE_MAX_PC_RETRIES 3 4162 #define IDETAPE_FIFO_THRESHOLD 2 4163 #define IDETAPE_DSC_RW_MIN 5*HZ/100 4164 #define IDETAPE_DSC_RW_MAX 40*HZ/100 4165 #define IDETAPE_DSC_RW_TIMEOUT 2*60*HZ 4166 #define IDETAPE_DSC_MA_FAST 2*HZ 4167 #define IDETAPE_DSC_MA_THRESHOLD 5*60*HZ 4168 #define IDETAPE_DSC_MA_SLOW 30*HZ 4169 #define IDETAPE_DSC_MA_TIMEOUT 2*60*60*HZ 4170 #define DOOR_UNLOCKED 0 4171 #define DOOR_LOCKED 1 4172 #define DOOR_EXPLICITLY_LOCKED 2 4173 #define IDETAPE_SPACE_OVER_FILEMARK 1 4174 #define IDETAPE_SPACE_TO_EOD 3 4175 #define IDETAPE_LU_LOAD_MASK 1 4176 #define IDETAPE_LU_RETENSION_MASK 2 4177 #define IDETAPE_LU_EOT_MASK 4 4178 #define IDETAPE_BLOCK_DESCRIPTOR 0 4179 #define IDETAPE_CAPABILITIES_PAGE 0x2a 4180 #ifdef CONFIG_IDE_PROC_FS 4181 #define ide_tape_devset_get(name, field) \ 4182 static int get_##name(ide_drive_t *drive) \ 4183 { \ 4184 idetape_tape_t *tape = drive->driver_data; \ 4185 return tape->field; \ 4186 } 4187 #define ide_tape_devset_set(name, field) \ 4188 static int set_##name(ide_drive_t *drive, int arg) \ 4189 { \ 4190 idetape_tape_t *tape = drive->driver_data; \ 4191 tape->field = arg; \ 4192 return 0; \ 4193 } 4194 #define ide_tape_devset_rw_field(_name, _field) \ 4195 ide_tape_devset_get(_name, _field) \ 4196 ide_tape_devset_set(_name, _field) \ 4197 IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 4198 #define ide_tape_devset_r_field(_name, _field) \ 4199 ide_tape_devset_get(_name, _field) \ 4200 IDE_DEVSET(_name, 0, get_##_name, NULL) 4201 #endif 4202 #ifdef CONFIG_IDE_PROC_FS 4203 #endif 4204 #ifdef CONFIG_IDE_PROC_FS 4205 #endif 4206 /* LDV_COMMENT_END_PREP */ 4207 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */ 4208 ldv_handler_precall(); 4209 idetape_exit(); 4210 4211 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 4212 ldv_final: ldv_check_final_state(); 4213 4214 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 4215 return; 4216 4217 } 4218 #endif 4219 4220 /* LDV_COMMENT_END_MAIN */ 4221 4222 #line 21 "/home/ubuntu/launches/work/current--X--drivers--X--defaultlinux-4.7-rc1.tar.xz--X--106_1a--X--cpachecker/linux-4.7-rc1.tar.xz/csd_deg_dscv/8139/dscv_tempdir/dscv/ri/106_1a/drivers/ide/ide-tape.o.c.prepared"
1 2 3 #include <verifier/rcv.h> 4 #include <kernel-model/ERR.inc> 5 6 // There are 2 possible states of usb gadget class registration. 7 enum 8 { 9 LDV_USB_GADGET_CLASS_ZERO_STATE, // Usb gadget class is not registered. 10 LDV_USB_GADGET_CLASS_REGISTERED // Usb gadget class is registered. 11 }; 12 13 // There are 2 possible states of char device region registration. 14 enum 15 { 16 LDV_USB_GADGET_CHRDEV_ZERO_STATE, // Char device region is not registered for usb gadget. 17 LDV_USB_GADGET_CHRDEV_REGISTERED // Char device region is registered for usb gadget. 18 }; 19 20 // There are 2 possible states of usb gadget registration. 21 enum 22 { 23 LDV_USB_GADGET_ZERO_STATE, // Usb gadget is not registered. 24 LDV_USB_GADGET_REGISTERED // Usb gadget is registered. 25 }; 26 27 /* LDV_COMMENT_CHANGE_STATE Usb gadget class is not registered at the beginning. */ 28 int ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_ZERO_STATE; 29 30 /* LDV_COMMENT_CHANGE_STATE Char device region is not registered at the beginning. */ 31 int ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_ZERO_STATE; 32 33 /* LDV_COMMENT_CHANGE_STATE Usb gadget is not registered at the beginning. */ 34 int ldv_usb_gadget = LDV_USB_GADGET_ZERO_STATE; 35 36 37 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_create_class') Check that usb gadget class was not registered. Then create and register class for it. */ 38 void *ldv_create_class(void) 39 { 40 void *is_got; 41 42 /* LDV_COMMENT_OTHER Get blk request in the nondeterministic way. */ 43 is_got = ldv_undef_ptr(); 44 45 /* LDV_COMMENT_ASSERT Get blk request just in case when an error did not happen. */ 46 if (is_got <= LDV_PTR_MAX) 47 { 48 /* LDV_COMMENT_ASSERT Registring usb gadget class is only allowed if usb gadget is not registered. */ 49 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 50 /* LDV_COMMENT_ASSERT Check that usb gadget class is unregistered. */ 51 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_ZERO_STATE); 52 /* LDV_COMMENT_CHANGE_STATE Register class for usb gadget. */ 53 ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_REGISTERED; 54 } 55 56 /* LDV_COMMENT_RETURN Return obtained blk request. */ 57 return is_got; 58 } 59 60 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_class') Check that usb gadget class was not registered and register class for it. */ 61 int ldv_register_class(void) 62 { 63 int is_reg; 64 65 /* LDV_COMMENT_OTHER Register gadget class in the nondeterministic way. */ 66 is_reg = ldv_undef_int_nonpositive(); 67 68 /* LDV_COMMENT_ASSERT Get blk request just in case when an error did not happen. */ 69 if (!is_reg) 70 { 71 /* LDV_COMMENT_ASSERT Registering usb gadget class is only allowed if usb gadget is not registered. */ 72 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 73 /* LDV_COMMENT_ASSERT Check that usb gadget class is unregistered. */ 74 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_ZERO_STATE); 75 /* LDV_COMMENT_CHANGE_STATE Register class for usb gadget. */ 76 ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_REGISTERED; 77 } 78 79 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 80 return is_reg; 81 } 82 83 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_unregister_class') Check that usb gadget class was registered and unregister it. */ 84 void ldv_unregister_class(void) 85 { 86 /* LDV_COMMENT_ASSERT Unregistering usb gadget class is only allowed if usb gadget is not registered. */ 87 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 88 /* LDV_COMMENT_ASSERT Check that usb gadget class is registered. */ 89 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_REGISTERED); 90 /* LDV_COMMENT_CHANGE_STATE Unregister class for usb gadget. */ 91 ldv_usb_gadget_class = LDV_USB_GADGET_CLASS_ZERO_STATE; 92 } 93 94 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_chrdev') Check that chrdev region was not registered and register it. */ 95 int ldv_register_chrdev(int major) 96 { 97 int is_reg; 98 99 /* LDV_COMMENT_OTHER Register chrdev in the nondeterministic way. */ 100 is_reg = ldv_undef_int_nonpositive(); 101 102 /* LDV_COMMENT_ASSERT Register chrdev just in case when an error did not happen. */ 103 if (!is_reg) 104 { 105 /* LDV_COMMENT_ASSERT Usb gadget should be unregistered at this point. */ 106 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 107 /* LDV_COMMENT_ASSERT Check that chrdev region is unregistered. */ 108 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_ZERO_STATE); 109 /* LDV_COMMENT_CHANGE_STATE Register chrdev region for usb gadget. */ 110 ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_REGISTERED; 111 if (major == 0) 112 { 113 /* LDV_COMMENT_OTHER Function returns allocated major number. */ 114 is_reg = ldv_undef_int(); 115 ldv_assume (is_reg > 0); 116 } 117 } 118 119 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 120 return is_reg; 121 } 122 123 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_chrdev_region') Check that chrdev region was not registered and register it. */ 124 int ldv_register_chrdev_region(void) 125 { 126 int is_reg; 127 128 /* LDV_COMMENT_OTHER Register chrdev in the nondeterministic way. */ 129 is_reg = ldv_undef_int_nonpositive(); 130 131 /* LDV_COMMENT_ASSERT Register chrdev just in case when an error did not happen. */ 132 if (!is_reg) 133 { 134 /* LDV_COMMENT_ASSERT Usb gadget should be unregistered at this point. */ 135 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 136 /* LDV_COMMENT_ASSERT Check that chrdev region is unregistered. */ 137 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_ZERO_STATE); 138 /* LDV_COMMENT_CHANGE_STATE Register chrdev region for usb gadget. */ 139 ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_REGISTERED; 140 } 141 142 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 143 return is_reg; 144 } 145 146 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_unregister_chrdev_region') Check that chrdev region was registered and unregister it. */ 147 void ldv_unregister_chrdev_region(void) 148 { 149 /* LDV_COMMENT_ASSERT Usb gadget should not be registered at this point. */ 150 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 151 /* LDV_COMMENT_ASSERT Check that chrdev region is registered. */ 152 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_REGISTERED); 153 /* LDV_COMMENT_CHANGE_STATE Unregister chrdev. */ 154 ldv_usb_gadget_chrdev = LDV_USB_GADGET_CHRDEV_ZERO_STATE; 155 } 156 157 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_register_usb_gadget') Check that usb gadget was not registered and register it. */ 158 int ldv_register_usb_gadget(void) 159 { 160 int is_reg; 161 162 /* LDV_COMMENT_OTHER Register usb gadget in the nondeterministic way. */ 163 is_reg = ldv_undef_int_nonpositive(); 164 165 /* LDV_COMMENT_ASSERT Register usb gadget just in case when an error did not happen. */ 166 if (!is_reg) 167 { 168 /* LDV_COMMENT_ASSERT Gadget should not be registered at this point. */ 169 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 170 /* LDV_COMMENT_CHANGE_STATE Register usb gadget. */ 171 ldv_usb_gadget = LDV_USB_GADGET_REGISTERED; 172 } 173 174 /* LDV_COMMENT_RETURN Return registration status (0 is success). */ 175 return is_reg; 176 } 177 178 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_unregister_usb_gadget') Check that usb gadget was registered and unregister it. */ 179 void ldv_unregister_usb_gadget(void) 180 { 181 /* LDV_COMMENT_ASSERT Usb gadget should be registered at this point. */ 182 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_REGISTERED); 183 /* LDV_COMMENT_CHANGE_STATE Unregister usb gadget. */ 184 ldv_usb_gadget = LDV_USB_GADGET_ZERO_STATE; 185 } 186 187 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_check_final_state') Check that usb gadget is fully unregistered at the end. */ 188 void ldv_check_final_state(void) 189 { 190 /* LDV_COMMENT_ASSERT Usb gadget class should be unregistered at the end. */ 191 ldv_assert(ldv_usb_gadget_class == LDV_USB_GADGET_CLASS_ZERO_STATE); 192 /* LDV_COMMENT_ASSERT Chrdev region should be unregistered at the end. */ 193 ldv_assert(ldv_usb_gadget_chrdev == LDV_USB_GADGET_CHRDEV_ZERO_STATE); 194 /* LDV_COMMENT_ASSERT Usb gadget should be unregistered at the end. */ 195 ldv_assert(ldv_usb_gadget == LDV_USB_GADGET_ZERO_STATE); 196 }
1 #ifndef _LDV_ERR_ 2 #define _LDV_ERR_ 3 4 #include <linux/kernel.h> 5 6 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_is_err') This function return result of checking if pointer is impossible. */ 7 bool ldv_is_err(const void *ptr) 8 { 9 /*LDV_COMMENT_RETURN Return value of function ldv_is_err_val().*/ 10 return ((unsigned long)ptr > LDV_PTR_MAX); 11 } 12 13 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_err_ptr') This function return pointer. */ 14 void* ldv_err_ptr(long error) 15 { 16 /*LDV_COMMENT_RETURN Return error pointer.*/ 17 return (void *)(LDV_PTR_MAX - error); 18 } 19 20 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_ptr_err') This function return error if pointer is impossible. */ 21 long ldv_ptr_err(const void *ptr) 22 { 23 /*LDV_COMMENT_RETURN Return error code.*/ 24 return (long)(LDV_PTR_MAX - (unsigned long)ptr); 25 } 26 27 /* LDV_COMMENT_MODEL_FUNCTION_DEFENITION(name='ldv_is_err_or_null') This function check if pointer is impossible or null. */ 28 bool ldv_is_err_or_null(const void *ptr) 29 { 30 /*LDV_COMMENT_RETURN Return 0 if pointer is possible and not zero, and 1 in other cases*/ 31 return !ptr || ldv_is_err((unsigned long)ptr); 32 } 33 34 #endif /* _LDV_ERR_ */
1 #ifndef _LDV_RCV_H_ 2 #define _LDV_RCV_H_ 3 4 /* If expr evaluates to zero, ldv_assert() causes a program to reach the error 5 label like the standard assert(). */ 6 #define ldv_assert(expr) ((expr) ? 0 : ldv_error()) 7 8 /* The error label wrapper. It is used because of some static verifiers (like 9 BLAST) don't accept multiple error labels through a program. */ 10 static inline void ldv_error(void) 11 { 12 LDV_ERROR: goto LDV_ERROR; 13 } 14 15 /* If expr evaluates to zero, ldv_assume() causes an infinite loop that is 16 avoided by verifiers. */ 17 #define ldv_assume(expr) ((expr) ? 0 : ldv_stop()) 18 19 /* Infinite loop, that causes verifiers to skip such paths. */ 20 static inline void ldv_stop(void) { 21 LDV_STOP: goto LDV_STOP; 22 } 23 24 /* Special nondeterministic functions. */ 25 int ldv_undef_int(void); 26 void *ldv_undef_ptr(void); 27 unsigned long ldv_undef_ulong(void); 28 long ldv_undef_long(void); 29 /* Return nondeterministic negative integer number. */ 30 static inline int ldv_undef_int_negative(void) 31 { 32 int ret = ldv_undef_int(); 33 34 ldv_assume(ret < 0); 35 36 return ret; 37 } 38 /* Return nondeterministic nonpositive integer number. */ 39 static inline int ldv_undef_int_nonpositive(void) 40 { 41 int ret = ldv_undef_int(); 42 43 ldv_assume(ret <= 0); 44 45 return ret; 46 } 47 48 /* Add explicit model for __builin_expect GCC function. Without the model a 49 return value will be treated as nondetermined by verifiers. */ 50 static inline long __builtin_expect(long exp, long c) 51 { 52 return exp; 53 } 54 55 /* This function causes the program to exit abnormally. GCC implements this 56 function by using a target-dependent mechanism (such as intentionally executing 57 an illegal instruction) or by calling abort. The mechanism used may vary from 58 release to release so you should not rely on any particular implementation. 59 http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */ 60 static inline void __builtin_trap(void) 61 { 62 ldv_assert(0); 63 } 64 65 /* The constant is for simulating an error of ldv_undef_ptr() function. */ 66 #define LDV_PTR_MAX 2012 67 68 #endif /* _LDV_RCV_H_ */
1 #ifndef _LINUX_FS_H 2 #define _LINUX_FS_H 3 4 #include <linux/linkage.h> 5 #include <linux/wait.h> 6 #include <linux/kdev_t.h> 7 #include <linux/dcache.h> 8 #include <linux/path.h> 9 #include <linux/stat.h> 10 #include <linux/cache.h> 11 #include <linux/list.h> 12 #include <linux/list_lru.h> 13 #include <linux/llist.h> 14 #include <linux/radix-tree.h> 15 #include <linux/rbtree.h> 16 #include <linux/init.h> 17 #include <linux/pid.h> 18 #include <linux/bug.h> 19 #include <linux/mutex.h> 20 #include <linux/rwsem.h> 21 #include <linux/capability.h> 22 #include <linux/semaphore.h> 23 #include <linux/fiemap.h> 24 #include <linux/rculist_bl.h> 25 #include <linux/atomic.h> 26 #include <linux/shrinker.h> 27 #include <linux/migrate_mode.h> 28 #include <linux/uidgid.h> 29 #include <linux/lockdep.h> 30 #include <linux/percpu-rwsem.h> 31 #include <linux/blk_types.h> 32 #include <linux/workqueue.h> 33 #include <linux/percpu-rwsem.h> 34 #include <linux/delayed_call.h> 35 36 #include <asm/byteorder.h> 37 #include <uapi/linux/fs.h> 38 39 struct backing_dev_info; 40 struct bdi_writeback; 41 struct export_operations; 42 struct hd_geometry; 43 struct iovec; 44 struct kiocb; 45 struct kobject; 46 struct pipe_inode_info; 47 struct poll_table_struct; 48 struct kstatfs; 49 struct vm_area_struct; 50 struct vfsmount; 51 struct cred; 52 struct swap_info_struct; 53 struct seq_file; 54 struct workqueue_struct; 55 struct iov_iter; 56 struct fscrypt_info; 57 struct fscrypt_operations; 58 59 extern void __init inode_init(void); 60 extern void __init inode_init_early(void); 61 extern void __init files_init(void); 62 extern void __init files_maxfiles_init(void); 63 64 extern struct files_stat_struct files_stat; 65 extern unsigned long get_max_files(void); 66 extern int sysctl_nr_open; 67 extern struct inodes_stat_t inodes_stat; 68 extern int leases_enable, lease_break_time; 69 extern int sysctl_protected_symlinks; 70 extern int sysctl_protected_hardlinks; 71 72 struct buffer_head; 73 typedef int (get_block_t)(struct inode *inode, sector_t iblock, 74 struct buffer_head *bh_result, int create); 75 typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, 76 ssize_t bytes, void *private); 77 78 #define MAY_EXEC 0x00000001 79 #define MAY_WRITE 0x00000002 80 #define MAY_READ 0x00000004 81 #define MAY_APPEND 0x00000008 82 #define MAY_ACCESS 0x00000010 83 #define MAY_OPEN 0x00000020 84 #define MAY_CHDIR 0x00000040 85 /* called from RCU mode, don't block */ 86 #define MAY_NOT_BLOCK 0x00000080 87 88 /* 89 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond 90 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open() 91 */ 92 93 /* file is open for reading */ 94 #define FMODE_READ ((__force fmode_t)0x1) 95 /* file is open for writing */ 96 #define FMODE_WRITE ((__force fmode_t)0x2) 97 /* file is seekable */ 98 #define FMODE_LSEEK ((__force fmode_t)0x4) 99 /* file can be accessed using pread */ 100 #define FMODE_PREAD ((__force fmode_t)0x8) 101 /* file can be accessed using pwrite */ 102 #define FMODE_PWRITE ((__force fmode_t)0x10) 103 /* File is opened for execution with sys_execve / sys_uselib */ 104 #define FMODE_EXEC ((__force fmode_t)0x20) 105 /* File is opened with O_NDELAY (only set for block devices) */ 106 #define FMODE_NDELAY ((__force fmode_t)0x40) 107 /* File is opened with O_EXCL (only set for block devices) */ 108 #define FMODE_EXCL ((__force fmode_t)0x80) 109 /* File is opened using open(.., 3, ..) and is writeable only for ioctls 110 (specialy hack for floppy.c) */ 111 #define FMODE_WRITE_IOCTL ((__force fmode_t)0x100) 112 /* 32bit hashes as llseek() offset (for directories) */ 113 #define FMODE_32BITHASH ((__force fmode_t)0x200) 114 /* 64bit hashes as llseek() offset (for directories) */ 115 #define FMODE_64BITHASH ((__force fmode_t)0x400) 116 117 /* 118 * Don't update ctime and mtime. 119 * 120 * Currently a special hack for the XFS open_by_handle ioctl, but we'll 121 * hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon. 122 */ 123 #define FMODE_NOCMTIME ((__force fmode_t)0x800) 124 125 /* Expect random access pattern */ 126 #define FMODE_RANDOM ((__force fmode_t)0x1000) 127 128 /* File is huge (eg. /dev/kmem): treat loff_t as unsigned */ 129 #define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000) 130 131 /* File is opened with O_PATH; almost nothing can be done with it */ 132 #define FMODE_PATH ((__force fmode_t)0x4000) 133 134 /* File needs atomic accesses to f_pos */ 135 #define FMODE_ATOMIC_POS ((__force fmode_t)0x8000) 136 /* Write access to underlying fs */ 137 #define FMODE_WRITER ((__force fmode_t)0x10000) 138 /* Has read method(s) */ 139 #define FMODE_CAN_READ ((__force fmode_t)0x20000) 140 /* Has write method(s) */ 141 #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) 142 143 /* File was opened by fanotify and shouldn't generate fanotify events */ 144 #define FMODE_NONOTIFY ((__force fmode_t)0x4000000) 145 146 /* 147 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector 148 * that indicates that they should check the contents of the iovec are 149 * valid, but not check the memory that the iovec elements 150 * points too. 151 */ 152 #define CHECK_IOVEC_ONLY -1 153 154 /* 155 * The below are the various read and write types that we support. Some of 156 * them include behavioral modifiers that send information down to the 157 * block layer and IO scheduler. Terminology: 158 * 159 * The block layer uses device plugging to defer IO a little bit, in 160 * the hope that we will see more IO very shortly. This increases 161 * coalescing of adjacent IO and thus reduces the number of IOs we 162 * have to send to the device. It also allows for better queuing, 163 * if the IO isn't mergeable. If the caller is going to be waiting 164 * for the IO, then he must ensure that the device is unplugged so 165 * that the IO is dispatched to the driver. 166 * 167 * All IO is handled async in Linux. This is fine for background 168 * writes, but for reads or writes that someone waits for completion 169 * on, we want to notify the block layer and IO scheduler so that they 170 * know about it. That allows them to make better scheduling 171 * decisions. So when the below references 'sync' and 'async', it 172 * is referencing this priority hint. 173 * 174 * With that in mind, the available types are: 175 * 176 * READ A normal read operation. Device will be plugged. 177 * READ_SYNC A synchronous read. Device is not plugged, caller can 178 * immediately wait on this read without caring about 179 * unplugging. 180 * READA Used for read-ahead operations. Lower priority, and the 181 * block layer could (in theory) choose to ignore this 182 * request if it runs into resource problems. 183 * WRITE A normal async write. Device will be plugged. 184 * WRITE_SYNC Synchronous write. Identical to WRITE, but passes down 185 * the hint that someone will be waiting on this IO 186 * shortly. The write equivalent of READ_SYNC. 187 * WRITE_ODIRECT Special case write for O_DIRECT only. 188 * WRITE_FLUSH Like WRITE_SYNC but with preceding cache flush. 189 * WRITE_FUA Like WRITE_SYNC but data is guaranteed to be on 190 * non-volatile media on completion. 191 * WRITE_FLUSH_FUA Combination of WRITE_FLUSH and FUA. The IO is preceded 192 * by a cache flush and data is guaranteed to be on 193 * non-volatile media on completion. 194 * 195 */ 196 #define RW_MASK REQ_WRITE 197 #define RWA_MASK REQ_RAHEAD 198 199 #define READ 0 200 #define WRITE RW_MASK 201 #define READA RWA_MASK 202 203 #define READ_SYNC (READ | REQ_SYNC) 204 #define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE) 205 #define WRITE_ODIRECT (WRITE | REQ_SYNC) 206 #define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH) 207 #define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA) 208 #define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 209 210 /* 211 * Attribute flags. These should be or-ed together to figure out what 212 * has been changed! 213 */ 214 #define ATTR_MODE (1 << 0) 215 #define ATTR_UID (1 << 1) 216 #define ATTR_GID (1 << 2) 217 #define ATTR_SIZE (1 << 3) 218 #define ATTR_ATIME (1 << 4) 219 #define ATTR_MTIME (1 << 5) 220 #define ATTR_CTIME (1 << 6) 221 #define ATTR_ATIME_SET (1 << 7) 222 #define ATTR_MTIME_SET (1 << 8) 223 #define ATTR_FORCE (1 << 9) /* Not a change, but a change it */ 224 #define ATTR_ATTR_FLAG (1 << 10) 225 #define ATTR_KILL_SUID (1 << 11) 226 #define ATTR_KILL_SGID (1 << 12) 227 #define ATTR_FILE (1 << 13) 228 #define ATTR_KILL_PRIV (1 << 14) 229 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ 230 #define ATTR_TIMES_SET (1 << 16) 231 232 /* 233 * Whiteout is represented by a char device. The following constants define the 234 * mode and device number to use. 235 */ 236 #define WHITEOUT_MODE 0 237 #define WHITEOUT_DEV 0 238 239 /* 240 * This is the Inode Attributes structure, used for notify_change(). It 241 * uses the above definitions as flags, to know which values have changed. 242 * Also, in this manner, a Filesystem can look at only the values it cares 243 * about. Basically, these are the attributes that the VFS layer can 244 * request to change from the FS layer. 245 * 246 * Derek Atkins <warlord@MIT.EDU> 94-10-20 247 */ 248 struct iattr { 249 unsigned int ia_valid; 250 umode_t ia_mode; 251 kuid_t ia_uid; 252 kgid_t ia_gid; 253 loff_t ia_size; 254 struct timespec ia_atime; 255 struct timespec ia_mtime; 256 struct timespec ia_ctime; 257 258 /* 259 * Not an attribute, but an auxiliary info for filesystems wanting to 260 * implement an ftruncate() like method. NOTE: filesystem should 261 * check for (ia_valid & ATTR_FILE), and not for (ia_file != NULL). 262 */ 263 struct file *ia_file; 264 }; 265 266 /* 267 * Includes for diskquotas. 268 */ 269 #include <linux/quota.h> 270 271 /* 272 * Maximum number of layers of fs stack. Needs to be limited to 273 * prevent kernel stack overflow 274 */ 275 #define FILESYSTEM_MAX_STACK_DEPTH 2 276 277 /** 278 * enum positive_aop_returns - aop return codes with specific semantics 279 * 280 * @AOP_WRITEPAGE_ACTIVATE: Informs the caller that page writeback has 281 * completed, that the page is still locked, and 282 * should be considered active. The VM uses this hint 283 * to return the page to the active list -- it won't 284 * be a candidate for writeback again in the near 285 * future. Other callers must be careful to unlock 286 * the page if they get this return. Returned by 287 * writepage(); 288 * 289 * @AOP_TRUNCATED_PAGE: The AOP method that was handed a locked page has 290 * unlocked it and the page might have been truncated. 291 * The caller should back up to acquiring a new page and 292 * trying again. The aop will be taking reasonable 293 * precautions not to livelock. If the caller held a page 294 * reference, it should drop it before retrying. Returned 295 * by readpage(). 296 * 297 * address_space_operation functions return these large constants to indicate 298 * special semantics to the caller. These are much larger than the bytes in a 299 * page to allow for functions that return the number of bytes operated on in a 300 * given page. 301 */ 302 303 enum positive_aop_returns { 304 AOP_WRITEPAGE_ACTIVATE = 0x80000, 305 AOP_TRUNCATED_PAGE = 0x80001, 306 }; 307 308 #define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */ 309 #define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */ 310 #define AOP_FLAG_NOFS 0x0004 /* used by filesystem to direct 311 * helper code (eg buffer layer) 312 * to clear GFP_FS from alloc */ 313 314 /* 315 * oh the beauties of C type declarations. 316 */ 317 struct page; 318 struct address_space; 319 struct writeback_control; 320 321 #define IOCB_EVENTFD (1 << 0) 322 #define IOCB_APPEND (1 << 1) 323 #define IOCB_DIRECT (1 << 2) 324 #define IOCB_HIPRI (1 << 3) 325 #define IOCB_DSYNC (1 << 4) 326 #define IOCB_SYNC (1 << 5) 327 328 struct kiocb { 329 struct file *ki_filp; 330 loff_t ki_pos; 331 void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); 332 void *private; 333 int ki_flags; 334 }; 335 336 static inline bool is_sync_kiocb(struct kiocb *kiocb) 337 { 338 return kiocb->ki_complete == NULL; 339 } 340 341 static inline int iocb_flags(struct file *file); 342 343 static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) 344 { 345 *kiocb = (struct kiocb) { 346 .ki_filp = filp, 347 .ki_flags = iocb_flags(filp), 348 }; 349 } 350 351 /* 352 * "descriptor" for what we're up to with a read. 353 * This allows us to use the same read code yet 354 * have multiple different users of the data that 355 * we read from a file. 356 * 357 * The simplest case just copies the data to user 358 * mode. 359 */ 360 typedef struct { 361 size_t written; 362 size_t count; 363 union { 364 char __user *buf; 365 void *data; 366 } arg; 367 int error; 368 } read_descriptor_t; 369 370 typedef int (*read_actor_t)(read_descriptor_t *, struct page *, 371 unsigned long, unsigned long); 372 373 struct address_space_operations { 374 int (*writepage)(struct page *page, struct writeback_control *wbc); 375 int (*readpage)(struct file *, struct page *); 376 377 /* Write back some dirty pages from this mapping. */ 378 int (*writepages)(struct address_space *, struct writeback_control *); 379 380 /* Set a page dirty. Return true if this dirtied it */ 381 int (*set_page_dirty)(struct page *page); 382 383 int (*readpages)(struct file *filp, struct address_space *mapping, 384 struct list_head *pages, unsigned nr_pages); 385 386 int (*write_begin)(struct file *, struct address_space *mapping, 387 loff_t pos, unsigned len, unsigned flags, 388 struct page **pagep, void **fsdata); 389 int (*write_end)(struct file *, struct address_space *mapping, 390 loff_t pos, unsigned len, unsigned copied, 391 struct page *page, void *fsdata); 392 393 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */ 394 sector_t (*bmap)(struct address_space *, sector_t); 395 void (*invalidatepage) (struct page *, unsigned int, unsigned int); 396 int (*releasepage) (struct page *, gfp_t); 397 void (*freepage)(struct page *); 398 ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter); 399 /* 400 * migrate the contents of a page to the specified target. If 401 * migrate_mode is MIGRATE_ASYNC, it must not block. 402 */ 403 int (*migratepage) (struct address_space *, 404 struct page *, struct page *, enum migrate_mode); 405 int (*launder_page) (struct page *); 406 int (*is_partially_uptodate) (struct page *, unsigned long, 407 unsigned long); 408 void (*is_dirty_writeback) (struct page *, bool *, bool *); 409 int (*error_remove_page)(struct address_space *, struct page *); 410 411 /* swapfile support */ 412 int (*swap_activate)(struct swap_info_struct *sis, struct file *file, 413 sector_t *span); 414 void (*swap_deactivate)(struct file *file); 415 }; 416 417 extern const struct address_space_operations empty_aops; 418 419 /* 420 * pagecache_write_begin/pagecache_write_end must be used by general code 421 * to write into the pagecache. 422 */ 423 int pagecache_write_begin(struct file *, struct address_space *mapping, 424 loff_t pos, unsigned len, unsigned flags, 425 struct page **pagep, void **fsdata); 426 427 int pagecache_write_end(struct file *, struct address_space *mapping, 428 loff_t pos, unsigned len, unsigned copied, 429 struct page *page, void *fsdata); 430 431 struct address_space { 432 struct inode *host; /* owner: inode, block_device */ 433 struct radix_tree_root page_tree; /* radix tree of all pages */ 434 spinlock_t tree_lock; /* and lock protecting it */ 435 atomic_t i_mmap_writable;/* count VM_SHARED mappings */ 436 struct rb_root i_mmap; /* tree of private and shared mappings */ 437 struct rw_semaphore i_mmap_rwsem; /* protect tree, count, list */ 438 /* Protected by tree_lock together with the radix tree */ 439 unsigned long nrpages; /* number of total pages */ 440 /* number of shadow or DAX exceptional entries */ 441 unsigned long nrexceptional; 442 pgoff_t writeback_index;/* writeback starts here */ 443 const struct address_space_operations *a_ops; /* methods */ 444 unsigned long flags; /* error bits/gfp mask */ 445 spinlock_t private_lock; /* for use by the address_space */ 446 struct list_head private_list; /* ditto */ 447 void *private_data; /* ditto */ 448 } __attribute__((aligned(sizeof(long)))); 449 /* 450 * On most architectures that alignment is already the case; but 451 * must be enforced here for CRIS, to let the least significant bit 452 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. 453 */ 454 struct request_queue; 455 456 struct block_device { 457 dev_t bd_dev; /* not a kdev_t - it's a search key */ 458 int bd_openers; 459 struct inode * bd_inode; /* will die */ 460 struct super_block * bd_super; 461 struct mutex bd_mutex; /* open/close mutex */ 462 struct list_head bd_inodes; 463 void * bd_claiming; 464 void * bd_holder; 465 int bd_holders; 466 bool bd_write_holder; 467 #ifdef CONFIG_SYSFS 468 struct list_head bd_holder_disks; 469 #endif 470 struct block_device * bd_contains; 471 unsigned bd_block_size; 472 struct hd_struct * bd_part; 473 /* number of times partitions within this device have been opened. */ 474 unsigned bd_part_count; 475 int bd_invalidated; 476 struct gendisk * bd_disk; 477 struct request_queue * bd_queue; 478 struct list_head bd_list; 479 /* 480 * Private data. You must have bd_claim'ed the block_device 481 * to use this. NOTE: bd_claim allows an owner to claim 482 * the same device multiple times, the owner must take special 483 * care to not mess up bd_private for that case. 484 */ 485 unsigned long bd_private; 486 487 /* The counter of freeze processes */ 488 int bd_fsfreeze_count; 489 /* Mutex for freeze */ 490 struct mutex bd_fsfreeze_mutex; 491 }; 492 493 /* 494 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache 495 * radix trees 496 */ 497 #define PAGECACHE_TAG_DIRTY 0 498 #define PAGECACHE_TAG_WRITEBACK 1 499 #define PAGECACHE_TAG_TOWRITE 2 500 501 int mapping_tagged(struct address_space *mapping, int tag); 502 503 static inline void i_mmap_lock_write(struct address_space *mapping) 504 { 505 down_write(&mapping->i_mmap_rwsem); 506 } 507 508 static inline void i_mmap_unlock_write(struct address_space *mapping) 509 { 510 up_write(&mapping->i_mmap_rwsem); 511 } 512 513 static inline void i_mmap_lock_read(struct address_space *mapping) 514 { 515 down_read(&mapping->i_mmap_rwsem); 516 } 517 518 static inline void i_mmap_unlock_read(struct address_space *mapping) 519 { 520 up_read(&mapping->i_mmap_rwsem); 521 } 522 523 /* 524 * Might pages of this file be mapped into userspace? 525 */ 526 static inline int mapping_mapped(struct address_space *mapping) 527 { 528 return !RB_EMPTY_ROOT(&mapping->i_mmap); 529 } 530 531 /* 532 * Might pages of this file have been modified in userspace? 533 * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff 534 * marks vma as VM_SHARED if it is shared, and the file was opened for 535 * writing i.e. vma may be mprotected writable even if now readonly. 536 * 537 * If i_mmap_writable is negative, no new writable mappings are allowed. You 538 * can only deny writable mappings, if none exists right now. 539 */ 540 static inline int mapping_writably_mapped(struct address_space *mapping) 541 { 542 return atomic_read(&mapping->i_mmap_writable) > 0; 543 } 544 545 static inline int mapping_map_writable(struct address_space *mapping) 546 { 547 return atomic_inc_unless_negative(&mapping->i_mmap_writable) ? 548 0 : -EPERM; 549 } 550 551 static inline void mapping_unmap_writable(struct address_space *mapping) 552 { 553 atomic_dec(&mapping->i_mmap_writable); 554 } 555 556 static inline int mapping_deny_writable(struct address_space *mapping) 557 { 558 return atomic_dec_unless_positive(&mapping->i_mmap_writable) ? 559 0 : -EBUSY; 560 } 561 562 static inline void mapping_allow_writable(struct address_space *mapping) 563 { 564 atomic_inc(&mapping->i_mmap_writable); 565 } 566 567 /* 568 * Use sequence counter to get consistent i_size on 32-bit processors. 569 */ 570 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 571 #include <linux/seqlock.h> 572 #define __NEED_I_SIZE_ORDERED 573 #define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount) 574 #else 575 #define i_size_ordered_init(inode) do { } while (0) 576 #endif 577 578 struct posix_acl; 579 #define ACL_NOT_CACHED ((void *)(-1)) 580 581 static inline struct posix_acl * 582 uncached_acl_sentinel(struct task_struct *task) 583 { 584 return (void *)task + 1; 585 } 586 587 static inline bool 588 is_uncached_acl(struct posix_acl *acl) 589 { 590 return (long)acl & 1; 591 } 592 593 #define IOP_FASTPERM 0x0001 594 #define IOP_LOOKUP 0x0002 595 #define IOP_NOFOLLOW 0x0004 596 597 /* 598 * Keep mostly read-only and often accessed (especially for 599 * the RCU path lookup and 'stat' data) fields at the beginning 600 * of the 'struct inode' 601 */ 602 struct inode { 603 umode_t i_mode; 604 unsigned short i_opflags; 605 kuid_t i_uid; 606 kgid_t i_gid; 607 unsigned int i_flags; 608 609 #ifdef CONFIG_FS_POSIX_ACL 610 struct posix_acl *i_acl; 611 struct posix_acl *i_default_acl; 612 #endif 613 614 const struct inode_operations *i_op; 615 struct super_block *i_sb; 616 struct address_space *i_mapping; 617 618 #ifdef CONFIG_SECURITY 619 void *i_security; 620 #endif 621 622 /* Stat data, not accessed from path walking */ 623 unsigned long i_ino; 624 /* 625 * Filesystems may only read i_nlink directly. They shall use the 626 * following functions for modification: 627 * 628 * (set|clear|inc|drop)_nlink 629 * inode_(inc|dec)_link_count 630 */ 631 union { 632 const unsigned int i_nlink; 633 unsigned int __i_nlink; 634 }; 635 dev_t i_rdev; 636 loff_t i_size; 637 struct timespec i_atime; 638 struct timespec i_mtime; 639 struct timespec i_ctime; 640 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 641 unsigned short i_bytes; 642 unsigned int i_blkbits; 643 blkcnt_t i_blocks; 644 645 #ifdef __NEED_I_SIZE_ORDERED 646 seqcount_t i_size_seqcount; 647 #endif 648 649 /* Misc */ 650 unsigned long i_state; 651 struct rw_semaphore i_rwsem; 652 653 unsigned long dirtied_when; /* jiffies of first dirtying */ 654 unsigned long dirtied_time_when; 655 656 struct hlist_node i_hash; 657 struct list_head i_io_list; /* backing dev IO list */ 658 #ifdef CONFIG_CGROUP_WRITEBACK 659 struct bdi_writeback *i_wb; /* the associated cgroup wb */ 660 661 /* foreign inode detection, see wbc_detach_inode() */ 662 int i_wb_frn_winner; 663 u16 i_wb_frn_avg_time; 664 u16 i_wb_frn_history; 665 #endif 666 struct list_head i_lru; /* inode LRU list */ 667 struct list_head i_sb_list; 668 union { 669 struct hlist_head i_dentry; 670 struct rcu_head i_rcu; 671 }; 672 u64 i_version; 673 atomic_t i_count; 674 atomic_t i_dio_count; 675 atomic_t i_writecount; 676 #ifdef CONFIG_IMA 677 atomic_t i_readcount; /* struct files open RO */ 678 #endif 679 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 680 struct file_lock_context *i_flctx; 681 struct address_space i_data; 682 struct list_head i_devices; 683 union { 684 struct pipe_inode_info *i_pipe; 685 struct block_device *i_bdev; 686 struct cdev *i_cdev; 687 char *i_link; 688 unsigned i_dir_seq; 689 }; 690 691 __u32 i_generation; 692 693 #ifdef CONFIG_FSNOTIFY 694 __u32 i_fsnotify_mask; /* all events this inode cares about */ 695 struct hlist_head i_fsnotify_marks; 696 #endif 697 698 #if IS_ENABLED(CONFIG_FS_ENCRYPTION) 699 struct fscrypt_info *i_crypt_info; 700 #endif 701 702 void *i_private; /* fs or device private pointer */ 703 }; 704 705 static inline int inode_unhashed(struct inode *inode) 706 { 707 return hlist_unhashed(&inode->i_hash); 708 } 709 710 /* 711 * inode->i_mutex nesting subclasses for the lock validator: 712 * 713 * 0: the object of the current VFS operation 714 * 1: parent 715 * 2: child/target 716 * 3: xattr 717 * 4: second non-directory 718 * 5: second parent (when locking independent directories in rename) 719 * 720 * I_MUTEX_NONDIR2 is for certain operations (such as rename) which lock two 721 * non-directories at once. 722 * 723 * The locking order between these classes is 724 * parent[2] -> child -> grandchild -> normal -> xattr -> second non-directory 725 */ 726 enum inode_i_mutex_lock_class 727 { 728 I_MUTEX_NORMAL, 729 I_MUTEX_PARENT, 730 I_MUTEX_CHILD, 731 I_MUTEX_XATTR, 732 I_MUTEX_NONDIR2, 733 I_MUTEX_PARENT2, 734 }; 735 736 static inline void inode_lock(struct inode *inode) 737 { 738 down_write(&inode->i_rwsem); 739 } 740 741 static inline void inode_unlock(struct inode *inode) 742 { 743 up_write(&inode->i_rwsem); 744 } 745 746 static inline void inode_lock_shared(struct inode *inode) 747 { 748 down_read(&inode->i_rwsem); 749 } 750 751 static inline void inode_unlock_shared(struct inode *inode) 752 { 753 up_read(&inode->i_rwsem); 754 } 755 756 static inline int inode_trylock(struct inode *inode) 757 { 758 return down_write_trylock(&inode->i_rwsem); 759 } 760 761 static inline int inode_trylock_shared(struct inode *inode) 762 { 763 return down_read_trylock(&inode->i_rwsem); 764 } 765 766 static inline int inode_is_locked(struct inode *inode) 767 { 768 return rwsem_is_locked(&inode->i_rwsem); 769 } 770 771 static inline void inode_lock_nested(struct inode *inode, unsigned subclass) 772 { 773 down_write_nested(&inode->i_rwsem, subclass); 774 } 775 776 void lock_two_nondirectories(struct inode *, struct inode*); 777 void unlock_two_nondirectories(struct inode *, struct inode*); 778 779 /* 780 * NOTE: in a 32bit arch with a preemptable kernel and 781 * an UP compile the i_size_read/write must be atomic 782 * with respect to the local cpu (unlike with preempt disabled), 783 * but they don't need to be atomic with respect to other cpus like in 784 * true SMP (so they need either to either locally disable irq around 785 * the read or for example on x86 they can be still implemented as a 786 * cmpxchg8b without the need of the lock prefix). For SMP compiles 787 * and 64bit archs it makes no difference if preempt is enabled or not. 788 */ 789 static inline loff_t i_size_read(const struct inode *inode) 790 { 791 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 792 loff_t i_size; 793 unsigned int seq; 794 795 do { 796 seq = read_seqcount_begin(&inode->i_size_seqcount); 797 i_size = inode->i_size; 798 } while (read_seqcount_retry(&inode->i_size_seqcount, seq)); 799 return i_size; 800 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT) 801 loff_t i_size; 802 803 preempt_disable(); 804 i_size = inode->i_size; 805 preempt_enable(); 806 return i_size; 807 #else 808 return inode->i_size; 809 #endif 810 } 811 812 /* 813 * NOTE: unlike i_size_read(), i_size_write() does need locking around it 814 * (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount 815 * can be lost, resulting in subsequent i_size_read() calls spinning forever. 816 */ 817 static inline void i_size_write(struct inode *inode, loff_t i_size) 818 { 819 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 820 preempt_disable(); 821 write_seqcount_begin(&inode->i_size_seqcount); 822 inode->i_size = i_size; 823 write_seqcount_end(&inode->i_size_seqcount); 824 preempt_enable(); 825 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT) 826 preempt_disable(); 827 inode->i_size = i_size; 828 preempt_enable(); 829 #else 830 inode->i_size = i_size; 831 #endif 832 } 833 834 /* Helper functions so that in most cases filesystems will 835 * not need to deal directly with kuid_t and kgid_t and can 836 * instead deal with the raw numeric values that are stored 837 * in the filesystem. 838 */ 839 static inline uid_t i_uid_read(const struct inode *inode) 840 { 841 return from_kuid(&init_user_ns, inode->i_uid); 842 } 843 844 static inline gid_t i_gid_read(const struct inode *inode) 845 { 846 return from_kgid(&init_user_ns, inode->i_gid); 847 } 848 849 static inline void i_uid_write(struct inode *inode, uid_t uid) 850 { 851 inode->i_uid = make_kuid(&init_user_ns, uid); 852 } 853 854 static inline void i_gid_write(struct inode *inode, gid_t gid) 855 { 856 inode->i_gid = make_kgid(&init_user_ns, gid); 857 } 858 859 static inline unsigned iminor(const struct inode *inode) 860 { 861 return MINOR(inode->i_rdev); 862 } 863 864 static inline unsigned imajor(const struct inode *inode) 865 { 866 return MAJOR(inode->i_rdev); 867 } 868 869 extern struct block_device *I_BDEV(struct inode *inode); 870 871 struct fown_struct { 872 rwlock_t lock; /* protects pid, uid, euid fields */ 873 struct pid *pid; /* pid or -pgrp where SIGIO should be sent */ 874 enum pid_type pid_type; /* Kind of process group SIGIO should be sent to */ 875 kuid_t uid, euid; /* uid/euid of process setting the owner */ 876 int signum; /* posix.1b rt signal to be delivered on IO */ 877 }; 878 879 /* 880 * Track a single file's readahead state 881 */ 882 struct file_ra_state { 883 pgoff_t start; /* where readahead started */ 884 unsigned int size; /* # of readahead pages */ 885 unsigned int async_size; /* do asynchronous readahead when 886 there are only # of pages ahead */ 887 888 unsigned int ra_pages; /* Maximum readahead window */ 889 unsigned int mmap_miss; /* Cache miss stat for mmap accesses */ 890 loff_t prev_pos; /* Cache last read() position */ 891 }; 892 893 /* 894 * Check if @index falls in the readahead windows. 895 */ 896 static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) 897 { 898 return (index >= ra->start && 899 index < ra->start + ra->size); 900 } 901 902 struct file { 903 union { 904 struct llist_node fu_llist; 905 struct rcu_head fu_rcuhead; 906 } f_u; 907 struct path f_path; 908 struct inode *f_inode; /* cached value */ 909 const struct file_operations *f_op; 910 911 /* 912 * Protects f_ep_links, f_flags. 913 * Must not be taken from IRQ context. 914 */ 915 spinlock_t f_lock; 916 atomic_long_t f_count; 917 unsigned int f_flags; 918 fmode_t f_mode; 919 struct mutex f_pos_lock; 920 loff_t f_pos; 921 struct fown_struct f_owner; 922 const struct cred *f_cred; 923 struct file_ra_state f_ra; 924 925 u64 f_version; 926 #ifdef CONFIG_SECURITY 927 void *f_security; 928 #endif 929 /* needed for tty driver, and maybe others */ 930 void *private_data; 931 932 #ifdef CONFIG_EPOLL 933 /* Used by fs/eventpoll.c to link all the hooks to this file */ 934 struct list_head f_ep_links; 935 struct list_head f_tfile_llink; 936 #endif /* #ifdef CONFIG_EPOLL */ 937 struct address_space *f_mapping; 938 } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ 939 940 struct file_handle { 941 __u32 handle_bytes; 942 int handle_type; 943 /* file identifier */ 944 unsigned char f_handle[0]; 945 }; 946 947 static inline struct file *get_file(struct file *f) 948 { 949 atomic_long_inc(&f->f_count); 950 return f; 951 } 952 #define get_file_rcu(x) atomic_long_inc_not_zero(&(x)->f_count) 953 #define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) 954 #define file_count(x) atomic_long_read(&(x)->f_count) 955 956 #define MAX_NON_LFS ((1UL<<31) - 1) 957 958 /* Page cache limit. The filesystems should put that into their s_maxbytes 959 limits, otherwise bad things can happen in VM. */ 960 #if BITS_PER_LONG==32 961 #define MAX_LFS_FILESIZE (((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1) 962 #elif BITS_PER_LONG==64 963 #define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL) 964 #endif 965 966 #define FL_POSIX 1 967 #define FL_FLOCK 2 968 #define FL_DELEG 4 /* NFSv4 delegation */ 969 #define FL_ACCESS 8 /* not trying to lock, just looking */ 970 #define FL_EXISTS 16 /* when unlocking, test for existence */ 971 #define FL_LEASE 32 /* lease held on this file */ 972 #define FL_CLOSE 64 /* unlock on close */ 973 #define FL_SLEEP 128 /* A blocking lock */ 974 #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ 975 #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ 976 #define FL_OFDLCK 1024 /* lock is "owned" by struct file */ 977 #define FL_LAYOUT 2048 /* outstanding pNFS layout */ 978 979 /* 980 * Special return value from posix_lock_file() and vfs_lock_file() for 981 * asynchronous locking. 982 */ 983 #define FILE_LOCK_DEFERRED 1 984 985 /* legacy typedef, should eventually be removed */ 986 typedef void *fl_owner_t; 987 988 struct file_lock; 989 990 struct file_lock_operations { 991 void (*fl_copy_lock)(struct file_lock *, struct file_lock *); 992 void (*fl_release_private)(struct file_lock *); 993 }; 994 995 struct lock_manager_operations { 996 int (*lm_compare_owner)(struct file_lock *, struct file_lock *); 997 unsigned long (*lm_owner_key)(struct file_lock *); 998 fl_owner_t (*lm_get_owner)(fl_owner_t); 999 void (*lm_put_owner)(fl_owner_t); 1000 void (*lm_notify)(struct file_lock *); /* unblock callback */ 1001 int (*lm_grant)(struct file_lock *, int); 1002 bool (*lm_break)(struct file_lock *); 1003 int (*lm_change)(struct file_lock *, int, struct list_head *); 1004 void (*lm_setup)(struct file_lock *, void **); 1005 }; 1006 1007 struct lock_manager { 1008 struct list_head list; 1009 /* 1010 * NFSv4 and up also want opens blocked during the grace period; 1011 * NLM doesn't care: 1012 */ 1013 bool block_opens; 1014 }; 1015 1016 struct net; 1017 void locks_start_grace(struct net *, struct lock_manager *); 1018 void locks_end_grace(struct lock_manager *); 1019 int locks_in_grace(struct net *); 1020 int opens_in_grace(struct net *); 1021 1022 /* that will die - we need it for nfs_lock_info */ 1023 #include <linux/nfs_fs_i.h> 1024 1025 /* 1026 * struct file_lock represents a generic "file lock". It's used to represent 1027 * POSIX byte range locks, BSD (flock) locks, and leases. It's important to 1028 * note that the same struct is used to represent both a request for a lock and 1029 * the lock itself, but the same object is never used for both. 1030 * 1031 * FIXME: should we create a separate "struct lock_request" to help distinguish 1032 * these two uses? 1033 * 1034 * The varous i_flctx lists are ordered by: 1035 * 1036 * 1) lock owner 1037 * 2) lock range start 1038 * 3) lock range end 1039 * 1040 * Obviously, the last two criteria only matter for POSIX locks. 1041 */ 1042 struct file_lock { 1043 struct file_lock *fl_next; /* singly linked list for this inode */ 1044 struct list_head fl_list; /* link into file_lock_context */ 1045 struct hlist_node fl_link; /* node in global lists */ 1046 struct list_head fl_block; /* circular list of blocked processes */ 1047 fl_owner_t fl_owner; 1048 unsigned int fl_flags; 1049 unsigned char fl_type; 1050 unsigned int fl_pid; 1051 int fl_link_cpu; /* what cpu's list is this on? */ 1052 struct pid *fl_nspid; 1053 wait_queue_head_t fl_wait; 1054 struct file *fl_file; 1055 loff_t fl_start; 1056 loff_t fl_end; 1057 1058 struct fasync_struct * fl_fasync; /* for lease break notifications */ 1059 /* for lease breaks: */ 1060 unsigned long fl_break_time; 1061 unsigned long fl_downgrade_time; 1062 1063 const struct file_lock_operations *fl_ops; /* Callbacks for filesystems */ 1064 const struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ 1065 union { 1066 struct nfs_lock_info nfs_fl; 1067 struct nfs4_lock_info nfs4_fl; 1068 struct { 1069 struct list_head link; /* link in AFS vnode's pending_locks list */ 1070 int state; /* state of grant or error if -ve */ 1071 } afs; 1072 } fl_u; 1073 }; 1074 1075 struct file_lock_context { 1076 spinlock_t flc_lock; 1077 struct list_head flc_flock; 1078 struct list_head flc_posix; 1079 struct list_head flc_lease; 1080 }; 1081 1082 /* The following constant reflects the upper bound of the file/locking space */ 1083 #ifndef OFFSET_MAX 1084 #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) 1085 #define OFFSET_MAX INT_LIMIT(loff_t) 1086 #define OFFT_OFFSET_MAX INT_LIMIT(off_t) 1087 #endif 1088 1089 #include <linux/fcntl.h> 1090 1091 extern void send_sigio(struct fown_struct *fown, int fd, int band); 1092 1093 #ifdef CONFIG_FILE_LOCKING 1094 extern int fcntl_getlk(struct file *, unsigned int, struct flock __user *); 1095 extern int fcntl_setlk(unsigned int, struct file *, unsigned int, 1096 struct flock __user *); 1097 1098 #if BITS_PER_LONG == 32 1099 extern int fcntl_getlk64(struct file *, unsigned int, struct flock64 __user *); 1100 extern int fcntl_setlk64(unsigned int, struct file *, unsigned int, 1101 struct flock64 __user *); 1102 #endif 1103 1104 extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); 1105 extern int fcntl_getlease(struct file *filp); 1106 1107 /* fs/locks.c */ 1108 void locks_free_lock_context(struct inode *inode); 1109 void locks_free_lock(struct file_lock *fl); 1110 extern void locks_init_lock(struct file_lock *); 1111 extern struct file_lock * locks_alloc_lock(void); 1112 extern void locks_copy_lock(struct file_lock *, struct file_lock *); 1113 extern void locks_copy_conflock(struct file_lock *, struct file_lock *); 1114 extern void locks_remove_posix(struct file *, fl_owner_t); 1115 extern void locks_remove_file(struct file *); 1116 extern void locks_release_private(struct file_lock *); 1117 extern void posix_test_lock(struct file *, struct file_lock *); 1118 extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); 1119 extern int posix_unblock_lock(struct file_lock *); 1120 extern int vfs_test_lock(struct file *, struct file_lock *); 1121 extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); 1122 extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); 1123 extern int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl); 1124 extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type); 1125 extern void lease_get_mtime(struct inode *, struct timespec *time); 1126 extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); 1127 extern int vfs_setlease(struct file *, long, struct file_lock **, void **); 1128 extern int lease_modify(struct file_lock *, int, struct list_head *); 1129 struct files_struct; 1130 extern void show_fd_locks(struct seq_file *f, 1131 struct file *filp, struct files_struct *files); 1132 #else /* !CONFIG_FILE_LOCKING */ 1133 static inline int fcntl_getlk(struct file *file, unsigned int cmd, 1134 struct flock __user *user) 1135 { 1136 return -EINVAL; 1137 } 1138 1139 static inline int fcntl_setlk(unsigned int fd, struct file *file, 1140 unsigned int cmd, struct flock __user *user) 1141 { 1142 return -EACCES; 1143 } 1144 1145 #if BITS_PER_LONG == 32 1146 static inline int fcntl_getlk64(struct file *file, unsigned int cmd, 1147 struct flock64 __user *user) 1148 { 1149 return -EINVAL; 1150 } 1151 1152 static inline int fcntl_setlk64(unsigned int fd, struct file *file, 1153 unsigned int cmd, struct flock64 __user *user) 1154 { 1155 return -EACCES; 1156 } 1157 #endif 1158 static inline int fcntl_setlease(unsigned int fd, struct file *filp, long arg) 1159 { 1160 return -EINVAL; 1161 } 1162 1163 static inline int fcntl_getlease(struct file *filp) 1164 { 1165 return F_UNLCK; 1166 } 1167 1168 static inline void 1169 locks_free_lock_context(struct inode *inode) 1170 { 1171 } 1172 1173 static inline void locks_init_lock(struct file_lock *fl) 1174 { 1175 return; 1176 } 1177 1178 static inline void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) 1179 { 1180 return; 1181 } 1182 1183 static inline void locks_copy_lock(struct file_lock *new, struct file_lock *fl) 1184 { 1185 return; 1186 } 1187 1188 static inline void locks_remove_posix(struct file *filp, fl_owner_t owner) 1189 { 1190 return; 1191 } 1192 1193 static inline void locks_remove_file(struct file *filp) 1194 { 1195 return; 1196 } 1197 1198 static inline void posix_test_lock(struct file *filp, struct file_lock *fl) 1199 { 1200 return; 1201 } 1202 1203 static inline int posix_lock_file(struct file *filp, struct file_lock *fl, 1204 struct file_lock *conflock) 1205 { 1206 return -ENOLCK; 1207 } 1208 1209 static inline int posix_unblock_lock(struct file_lock *waiter) 1210 { 1211 return -ENOENT; 1212 } 1213 1214 static inline int vfs_test_lock(struct file *filp, struct file_lock *fl) 1215 { 1216 return 0; 1217 } 1218 1219 static inline int vfs_lock_file(struct file *filp, unsigned int cmd, 1220 struct file_lock *fl, struct file_lock *conf) 1221 { 1222 return -ENOLCK; 1223 } 1224 1225 static inline int vfs_cancel_lock(struct file *filp, struct file_lock *fl) 1226 { 1227 return 0; 1228 } 1229 1230 static inline int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl) 1231 { 1232 return -ENOLCK; 1233 } 1234 1235 static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) 1236 { 1237 return 0; 1238 } 1239 1240 static inline void lease_get_mtime(struct inode *inode, struct timespec *time) 1241 { 1242 return; 1243 } 1244 1245 static inline int generic_setlease(struct file *filp, long arg, 1246 struct file_lock **flp, void **priv) 1247 { 1248 return -EINVAL; 1249 } 1250 1251 static inline int vfs_setlease(struct file *filp, long arg, 1252 struct file_lock **lease, void **priv) 1253 { 1254 return -EINVAL; 1255 } 1256 1257 static inline int lease_modify(struct file_lock *fl, int arg, 1258 struct list_head *dispose) 1259 { 1260 return -EINVAL; 1261 } 1262 1263 struct files_struct; 1264 static inline void show_fd_locks(struct seq_file *f, 1265 struct file *filp, struct files_struct *files) {} 1266 #endif /* !CONFIG_FILE_LOCKING */ 1267 1268 static inline struct inode *file_inode(const struct file *f) 1269 { 1270 return f->f_inode; 1271 } 1272 1273 static inline struct dentry *file_dentry(const struct file *file) 1274 { 1275 struct dentry *dentry = file->f_path.dentry; 1276 1277 if (unlikely(dentry->d_flags & DCACHE_OP_REAL)) 1278 return dentry->d_op->d_real(dentry, file_inode(file)); 1279 else 1280 return dentry; 1281 } 1282 1283 static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) 1284 { 1285 return locks_lock_inode_wait(file_inode(filp), fl); 1286 } 1287 1288 struct fasync_struct { 1289 spinlock_t fa_lock; 1290 int magic; 1291 int fa_fd; 1292 struct fasync_struct *fa_next; /* singly linked list */ 1293 struct file *fa_file; 1294 struct rcu_head fa_rcu; 1295 }; 1296 1297 #define FASYNC_MAGIC 0x4601 1298 1299 /* SMP safe fasync helpers: */ 1300 extern int fasync_helper(int, struct file *, int, struct fasync_struct **); 1301 extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *); 1302 extern int fasync_remove_entry(struct file *, struct fasync_struct **); 1303 extern struct fasync_struct *fasync_alloc(void); 1304 extern void fasync_free(struct fasync_struct *); 1305 1306 /* can be called from interrupts */ 1307 extern void kill_fasync(struct fasync_struct **, int, int); 1308 1309 extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int force); 1310 extern void f_setown(struct file *filp, unsigned long arg, int force); 1311 extern void f_delown(struct file *filp); 1312 extern pid_t f_getown(struct file *filp); 1313 extern int send_sigurg(struct fown_struct *fown); 1314 1315 struct mm_struct; 1316 1317 /* 1318 * Umount options 1319 */ 1320 1321 #define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */ 1322 #define MNT_DETACH 0x00000002 /* Just detach from the tree */ 1323 #define MNT_EXPIRE 0x00000004 /* Mark for expiry */ 1324 #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ 1325 #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ 1326 1327 /* sb->s_iflags */ 1328 #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ 1329 #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ 1330 1331 /* Possible states of 'frozen' field */ 1332 enum { 1333 SB_UNFROZEN = 0, /* FS is unfrozen */ 1334 SB_FREEZE_WRITE = 1, /* Writes, dir ops, ioctls frozen */ 1335 SB_FREEZE_PAGEFAULT = 2, /* Page faults stopped as well */ 1336 SB_FREEZE_FS = 3, /* For internal FS use (e.g. to stop 1337 * internal threads if needed) */ 1338 SB_FREEZE_COMPLETE = 4, /* ->freeze_fs finished successfully */ 1339 }; 1340 1341 #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1) 1342 1343 struct sb_writers { 1344 int frozen; /* Is sb frozen? */ 1345 wait_queue_head_t wait_unfrozen; /* for get_super_thawed() */ 1346 struct percpu_rw_semaphore rw_sem[SB_FREEZE_LEVELS]; 1347 }; 1348 1349 struct super_block { 1350 struct list_head s_list; /* Keep this first */ 1351 dev_t s_dev; /* search index; _not_ kdev_t */ 1352 unsigned char s_blocksize_bits; 1353 unsigned long s_blocksize; 1354 loff_t s_maxbytes; /* Max file size */ 1355 struct file_system_type *s_type; 1356 const struct super_operations *s_op; 1357 const struct dquot_operations *dq_op; 1358 const struct quotactl_ops *s_qcop; 1359 const struct export_operations *s_export_op; 1360 unsigned long s_flags; 1361 unsigned long s_iflags; /* internal SB_I_* flags */ 1362 unsigned long s_magic; 1363 struct dentry *s_root; 1364 struct rw_semaphore s_umount; 1365 int s_count; 1366 atomic_t s_active; 1367 #ifdef CONFIG_SECURITY 1368 void *s_security; 1369 #endif 1370 const struct xattr_handler **s_xattr; 1371 1372 const struct fscrypt_operations *s_cop; 1373 1374 struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ 1375 struct list_head s_mounts; /* list of mounts; _not_ for fs use */ 1376 struct block_device *s_bdev; 1377 struct backing_dev_info *s_bdi; 1378 struct mtd_info *s_mtd; 1379 struct hlist_node s_instances; 1380 unsigned int s_quota_types; /* Bitmask of supported quota types */ 1381 struct quota_info s_dquot; /* Diskquota specific options */ 1382 1383 struct sb_writers s_writers; 1384 1385 char s_id[32]; /* Informational name */ 1386 u8 s_uuid[16]; /* UUID */ 1387 1388 void *s_fs_info; /* Filesystem private info */ 1389 unsigned int s_max_links; 1390 fmode_t s_mode; 1391 1392 /* Granularity of c/m/atime in ns. 1393 Cannot be worse than a second */ 1394 u32 s_time_gran; 1395 1396 /* 1397 * The next field is for VFS *only*. No filesystems have any business 1398 * even looking at it. You had been warned. 1399 */ 1400 struct mutex s_vfs_rename_mutex; /* Kludge */ 1401 1402 /* 1403 * Filesystem subtype. If non-empty the filesystem type field 1404 * in /proc/mounts will be "type.subtype" 1405 */ 1406 char *s_subtype; 1407 1408 /* 1409 * Saved mount options for lazy filesystems using 1410 * generic_show_options() 1411 */ 1412 char __rcu *s_options; 1413 const struct dentry_operations *s_d_op; /* default d_op for dentries */ 1414 1415 /* 1416 * Saved pool identifier for cleancache (-1 means none) 1417 */ 1418 int cleancache_poolid; 1419 1420 struct shrinker s_shrink; /* per-sb shrinker handle */ 1421 1422 /* Number of inodes with nlink == 0 but still referenced */ 1423 atomic_long_t s_remove_count; 1424 1425 /* Being remounted read-only */ 1426 int s_readonly_remount; 1427 1428 /* AIO completions deferred from interrupt context */ 1429 struct workqueue_struct *s_dio_done_wq; 1430 struct hlist_head s_pins; 1431 1432 /* 1433 * Keep the lru lists last in the structure so they always sit on their 1434 * own individual cachelines. 1435 */ 1436 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; 1437 struct list_lru s_inode_lru ____cacheline_aligned_in_smp; 1438 struct rcu_head rcu; 1439 struct work_struct destroy_work; 1440 1441 struct mutex s_sync_lock; /* sync serialisation lock */ 1442 1443 /* 1444 * Indicates how deep in a filesystem stack this SB is 1445 */ 1446 int s_stack_depth; 1447 1448 /* s_inode_list_lock protects s_inodes */ 1449 spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp; 1450 struct list_head s_inodes; /* all inodes */ 1451 }; 1452 1453 extern struct timespec current_fs_time(struct super_block *sb); 1454 1455 /* 1456 * Snapshotting support. 1457 */ 1458 1459 void __sb_end_write(struct super_block *sb, int level); 1460 int __sb_start_write(struct super_block *sb, int level, bool wait); 1461 1462 #define __sb_writers_acquired(sb, lev) \ 1463 percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) 1464 #define __sb_writers_release(sb, lev) \ 1465 percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) 1466 1467 /** 1468 * sb_end_write - drop write access to a superblock 1469 * @sb: the super we wrote to 1470 * 1471 * Decrement number of writers to the filesystem. Wake up possible waiters 1472 * wanting to freeze the filesystem. 1473 */ 1474 static inline void sb_end_write(struct super_block *sb) 1475 { 1476 __sb_end_write(sb, SB_FREEZE_WRITE); 1477 } 1478 1479 /** 1480 * sb_end_pagefault - drop write access to a superblock from a page fault 1481 * @sb: the super we wrote to 1482 * 1483 * Decrement number of processes handling write page fault to the filesystem. 1484 * Wake up possible waiters wanting to freeze the filesystem. 1485 */ 1486 static inline void sb_end_pagefault(struct super_block *sb) 1487 { 1488 __sb_end_write(sb, SB_FREEZE_PAGEFAULT); 1489 } 1490 1491 /** 1492 * sb_end_intwrite - drop write access to a superblock for internal fs purposes 1493 * @sb: the super we wrote to 1494 * 1495 * Decrement fs-internal number of writers to the filesystem. Wake up possible 1496 * waiters wanting to freeze the filesystem. 1497 */ 1498 static inline void sb_end_intwrite(struct super_block *sb) 1499 { 1500 __sb_end_write(sb, SB_FREEZE_FS); 1501 } 1502 1503 /** 1504 * sb_start_write - get write access to a superblock 1505 * @sb: the super we write to 1506 * 1507 * When a process wants to write data or metadata to a file system (i.e. dirty 1508 * a page or an inode), it should embed the operation in a sb_start_write() - 1509 * sb_end_write() pair to get exclusion against file system freezing. This 1510 * function increments number of writers preventing freezing. If the file 1511 * system is already frozen, the function waits until the file system is 1512 * thawed. 1513 * 1514 * Since freeze protection behaves as a lock, users have to preserve 1515 * ordering of freeze protection and other filesystem locks. Generally, 1516 * freeze protection should be the outermost lock. In particular, we have: 1517 * 1518 * sb_start_write 1519 * -> i_mutex (write path, truncate, directory ops, ...) 1520 * -> s_umount (freeze_super, thaw_super) 1521 */ 1522 static inline void sb_start_write(struct super_block *sb) 1523 { 1524 __sb_start_write(sb, SB_FREEZE_WRITE, true); 1525 } 1526 1527 static inline int sb_start_write_trylock(struct super_block *sb) 1528 { 1529 return __sb_start_write(sb, SB_FREEZE_WRITE, false); 1530 } 1531 1532 /** 1533 * sb_start_pagefault - get write access to a superblock from a page fault 1534 * @sb: the super we write to 1535 * 1536 * When a process starts handling write page fault, it should embed the 1537 * operation into sb_start_pagefault() - sb_end_pagefault() pair to get 1538 * exclusion against file system freezing. This is needed since the page fault 1539 * is going to dirty a page. This function increments number of running page 1540 * faults preventing freezing. If the file system is already frozen, the 1541 * function waits until the file system is thawed. 1542 * 1543 * Since page fault freeze protection behaves as a lock, users have to preserve 1544 * ordering of freeze protection and other filesystem locks. It is advised to 1545 * put sb_start_pagefault() close to mmap_sem in lock ordering. Page fault 1546 * handling code implies lock dependency: 1547 * 1548 * mmap_sem 1549 * -> sb_start_pagefault 1550 */ 1551 static inline void sb_start_pagefault(struct super_block *sb) 1552 { 1553 __sb_start_write(sb, SB_FREEZE_PAGEFAULT, true); 1554 } 1555 1556 /* 1557 * sb_start_intwrite - get write access to a superblock for internal fs purposes 1558 * @sb: the super we write to 1559 * 1560 * This is the third level of protection against filesystem freezing. It is 1561 * free for use by a filesystem. The only requirement is that it must rank 1562 * below sb_start_pagefault. 1563 * 1564 * For example filesystem can call sb_start_intwrite() when starting a 1565 * transaction which somewhat eases handling of freezing for internal sources 1566 * of filesystem changes (internal fs threads, discarding preallocation on file 1567 * close, etc.). 1568 */ 1569 static inline void sb_start_intwrite(struct super_block *sb) 1570 { 1571 __sb_start_write(sb, SB_FREEZE_FS, true); 1572 } 1573 1574 1575 extern bool inode_owner_or_capable(const struct inode *inode); 1576 1577 /* 1578 * VFS helper functions.. 1579 */ 1580 extern int vfs_create(struct inode *, struct dentry *, umode_t, bool); 1581 extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); 1582 extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); 1583 extern int vfs_symlink(struct inode *, struct dentry *, const char *); 1584 extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **); 1585 extern int vfs_rmdir(struct inode *, struct dentry *); 1586 extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); 1587 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); 1588 extern int vfs_whiteout(struct inode *, struct dentry *); 1589 1590 /* 1591 * VFS file helper functions. 1592 */ 1593 extern void inode_init_owner(struct inode *inode, const struct inode *dir, 1594 umode_t mode); 1595 /* 1596 * VFS FS_IOC_FIEMAP helper definitions. 1597 */ 1598 struct fiemap_extent_info { 1599 unsigned int fi_flags; /* Flags as passed from user */ 1600 unsigned int fi_extents_mapped; /* Number of mapped extents */ 1601 unsigned int fi_extents_max; /* Size of fiemap_extent array */ 1602 struct fiemap_extent __user *fi_extents_start; /* Start of 1603 fiemap_extent array */ 1604 }; 1605 int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, 1606 u64 phys, u64 len, u32 flags); 1607 int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); 1608 1609 /* 1610 * File types 1611 * 1612 * NOTE! These match bits 12..15 of stat.st_mode 1613 * (ie "(i_mode >> 12) & 15"). 1614 */ 1615 #define DT_UNKNOWN 0 1616 #define DT_FIFO 1 1617 #define DT_CHR 2 1618 #define DT_DIR 4 1619 #define DT_BLK 6 1620 #define DT_REG 8 1621 #define DT_LNK 10 1622 #define DT_SOCK 12 1623 #define DT_WHT 14 1624 1625 /* 1626 * This is the "filldir" function type, used by readdir() to let 1627 * the kernel specify what kind of dirent layout it wants to have. 1628 * This allows the kernel to read directories into kernel space or 1629 * to have different dirent layouts depending on the binary type. 1630 */ 1631 struct dir_context; 1632 typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64, 1633 unsigned); 1634 1635 struct dir_context { 1636 const filldir_t actor; 1637 loff_t pos; 1638 }; 1639 1640 struct block_device_operations; 1641 1642 /* These macros are for out of kernel modules to test that 1643 * the kernel supports the unlocked_ioctl and compat_ioctl 1644 * fields in struct file_operations. */ 1645 #define HAVE_COMPAT_IOCTL 1 1646 #define HAVE_UNLOCKED_IOCTL 1 1647 1648 /* 1649 * These flags let !MMU mmap() govern direct device mapping vs immediate 1650 * copying more easily for MAP_PRIVATE, especially for ROM filesystems. 1651 * 1652 * NOMMU_MAP_COPY: Copy can be mapped (MAP_PRIVATE) 1653 * NOMMU_MAP_DIRECT: Can be mapped directly (MAP_SHARED) 1654 * NOMMU_MAP_READ: Can be mapped for reading 1655 * NOMMU_MAP_WRITE: Can be mapped for writing 1656 * NOMMU_MAP_EXEC: Can be mapped for execution 1657 */ 1658 #define NOMMU_MAP_COPY 0x00000001 1659 #define NOMMU_MAP_DIRECT 0x00000008 1660 #define NOMMU_MAP_READ VM_MAYREAD 1661 #define NOMMU_MAP_WRITE VM_MAYWRITE 1662 #define NOMMU_MAP_EXEC VM_MAYEXEC 1663 1664 #define NOMMU_VMFLAGS \ 1665 (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC) 1666 1667 1668 struct iov_iter; 1669 1670 struct file_operations { 1671 struct module *owner; 1672 loff_t (*llseek) (struct file *, loff_t, int); 1673 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 1674 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 1675 ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); 1676 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); 1677 int (*iterate) (struct file *, struct dir_context *); 1678 int (*iterate_shared) (struct file *, struct dir_context *); 1679 unsigned int (*poll) (struct file *, struct poll_table_struct *); 1680 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1681 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1682 int (*mmap) (struct file *, struct vm_area_struct *); 1683 int (*open) (struct inode *, struct file *); 1684 int (*flush) (struct file *, fl_owner_t id); 1685 int (*release) (struct inode *, struct file *); 1686 int (*fsync) (struct file *, loff_t, loff_t, int datasync); 1687 int (*aio_fsync) (struct kiocb *, int datasync); 1688 int (*fasync) (int, struct file *, int); 1689 int (*lock) (struct file *, int, struct file_lock *); 1690 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 1691 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1692 int (*check_flags)(int); 1693 int (*flock) (struct file *, int, struct file_lock *); 1694 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1695 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 1696 int (*setlease)(struct file *, long, struct file_lock **, void **); 1697 long (*fallocate)(struct file *file, int mode, loff_t offset, 1698 loff_t len); 1699 void (*show_fdinfo)(struct seq_file *m, struct file *f); 1700 #ifndef CONFIG_MMU 1701 unsigned (*mmap_capabilities)(struct file *); 1702 #endif 1703 ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, 1704 loff_t, size_t, unsigned int); 1705 int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, 1706 u64); 1707 ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, 1708 u64); 1709 }; 1710 1711 struct inode_operations { 1712 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); 1713 const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *); 1714 int (*permission) (struct inode *, int); 1715 struct posix_acl * (*get_acl)(struct inode *, int); 1716 1717 int (*readlink) (struct dentry *, char __user *,int); 1718 1719 int (*create) (struct inode *,struct dentry *, umode_t, bool); 1720 int (*link) (struct dentry *,struct inode *,struct dentry *); 1721 int (*unlink) (struct inode *,struct dentry *); 1722 int (*symlink) (struct inode *,struct dentry *,const char *); 1723 int (*mkdir) (struct inode *,struct dentry *,umode_t); 1724 int (*rmdir) (struct inode *,struct dentry *); 1725 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); 1726 int (*rename) (struct inode *, struct dentry *, 1727 struct inode *, struct dentry *); 1728 int (*rename2) (struct inode *, struct dentry *, 1729 struct inode *, struct dentry *, unsigned int); 1730 int (*setattr) (struct dentry *, struct iattr *); 1731 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1732 int (*setxattr) (struct dentry *, struct inode *, 1733 const char *, const void *, size_t, int); 1734 ssize_t (*getxattr) (struct dentry *, struct inode *, 1735 const char *, void *, size_t); 1736 ssize_t (*listxattr) (struct dentry *, char *, size_t); 1737 int (*removexattr) (struct dentry *, const char *); 1738 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 1739 u64 len); 1740 int (*update_time)(struct inode *, struct timespec *, int); 1741 int (*atomic_open)(struct inode *, struct dentry *, 1742 struct file *, unsigned open_flag, 1743 umode_t create_mode, int *opened); 1744 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 1745 int (*set_acl)(struct inode *, struct posix_acl *, int); 1746 } ____cacheline_aligned; 1747 1748 ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1749 unsigned long nr_segs, unsigned long fast_segs, 1750 struct iovec *fast_pointer, 1751 struct iovec **ret_pointer); 1752 1753 extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *); 1754 extern ssize_t __vfs_write(struct file *, const char __user *, size_t, loff_t *); 1755 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); 1756 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); 1757 extern ssize_t vfs_readv(struct file *, const struct iovec __user *, 1758 unsigned long, loff_t *, int); 1759 extern ssize_t vfs_writev(struct file *, const struct iovec __user *, 1760 unsigned long, loff_t *, int); 1761 extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, 1762 loff_t, size_t, unsigned int); 1763 extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, 1764 struct file *file_out, loff_t pos_out, u64 len); 1765 extern int vfs_dedupe_file_range(struct file *file, 1766 struct file_dedupe_range *same); 1767 1768 struct super_operations { 1769 struct inode *(*alloc_inode)(struct super_block *sb); 1770 void (*destroy_inode)(struct inode *); 1771 1772 void (*dirty_inode) (struct inode *, int flags); 1773 int (*write_inode) (struct inode *, struct writeback_control *wbc); 1774 int (*drop_inode) (struct inode *); 1775 void (*evict_inode) (struct inode *); 1776 void (*put_super) (struct super_block *); 1777 int (*sync_fs)(struct super_block *sb, int wait); 1778 int (*freeze_super) (struct super_block *); 1779 int (*freeze_fs) (struct super_block *); 1780 int (*thaw_super) (struct super_block *); 1781 int (*unfreeze_fs) (struct super_block *); 1782 int (*statfs) (struct dentry *, struct kstatfs *); 1783 int (*remount_fs) (struct super_block *, int *, char *); 1784 void (*umount_begin) (struct super_block *); 1785 1786 int (*show_options)(struct seq_file *, struct dentry *); 1787 int (*show_devname)(struct seq_file *, struct dentry *); 1788 int (*show_path)(struct seq_file *, struct dentry *); 1789 int (*show_stats)(struct seq_file *, struct dentry *); 1790 #ifdef CONFIG_QUOTA 1791 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 1792 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1793 struct dquot **(*get_dquots)(struct inode *); 1794 #endif 1795 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1796 long (*nr_cached_objects)(struct super_block *, 1797 struct shrink_control *); 1798 long (*free_cached_objects)(struct super_block *, 1799 struct shrink_control *); 1800 }; 1801 1802 /* 1803 * Inode flags - they have no relation to superblock flags now 1804 */ 1805 #define S_SYNC 1 /* Writes are synced at once */ 1806 #define S_NOATIME 2 /* Do not update access times */ 1807 #define S_APPEND 4 /* Append-only file */ 1808 #define S_IMMUTABLE 8 /* Immutable file */ 1809 #define S_DEAD 16 /* removed, but still open directory */ 1810 #define S_NOQUOTA 32 /* Inode is not counted to quota */ 1811 #define S_DIRSYNC 64 /* Directory modifications are synchronous */ 1812 #define S_NOCMTIME 128 /* Do not update file c/mtime */ 1813 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ 1814 #define S_PRIVATE 512 /* Inode is fs-internal */ 1815 #define S_IMA 1024 /* Inode has an associated IMA struct */ 1816 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ 1817 #define S_NOSEC 4096 /* no suid or xattr security attributes */ 1818 #ifdef CONFIG_FS_DAX 1819 #define S_DAX 8192 /* Direct Access, avoiding the page cache */ 1820 #else 1821 #define S_DAX 0 /* Make all the DAX code disappear */ 1822 #endif 1823 1824 /* 1825 * Note that nosuid etc flags are inode-specific: setting some file-system 1826 * flags just means all the inodes inherit those flags by default. It might be 1827 * possible to override it selectively if you really wanted to with some 1828 * ioctl() that is not currently implemented. 1829 * 1830 * Exception: MS_RDONLY is always applied to the entire file system. 1831 * 1832 * Unfortunately, it is possible to change a filesystems flags with it mounted 1833 * with files in use. This means that all of the inodes will not have their 1834 * i_flags updated. Hence, i_flags no longer inherit the superblock mount 1835 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org 1836 */ 1837 #define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg)) 1838 1839 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY) 1840 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \ 1841 ((inode)->i_flags & S_SYNC)) 1842 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \ 1843 ((inode)->i_flags & (S_SYNC|S_DIRSYNC))) 1844 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK) 1845 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME) 1846 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION) 1847 1848 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) 1849 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) 1850 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) 1851 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL) 1852 1853 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD) 1854 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) 1855 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) 1856 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) 1857 #define IS_IMA(inode) ((inode)->i_flags & S_IMA) 1858 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) 1859 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) 1860 #define IS_DAX(inode) ((inode)->i_flags & S_DAX) 1861 1862 #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ 1863 (inode)->i_rdev == WHITEOUT_DEV) 1864 1865 /* 1866 * Inode state bits. Protected by inode->i_lock 1867 * 1868 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC, 1869 * I_DIRTY_DATASYNC and I_DIRTY_PAGES. 1870 * 1871 * Four bits define the lifetime of an inode. Initially, inodes are I_NEW, 1872 * until that flag is cleared. I_WILL_FREE, I_FREEING and I_CLEAR are set at 1873 * various stages of removing an inode. 1874 * 1875 * Two bits are used for locking and completion notification, I_NEW and I_SYNC. 1876 * 1877 * I_DIRTY_SYNC Inode is dirty, but doesn't have to be written on 1878 * fdatasync(). i_atime is the usual cause. 1879 * I_DIRTY_DATASYNC Data-related inode changes pending. We keep track of 1880 * these changes separately from I_DIRTY_SYNC so that we 1881 * don't have to write inode on fdatasync() when only 1882 * mtime has changed in it. 1883 * I_DIRTY_PAGES Inode has dirty pages. Inode itself may be clean. 1884 * I_NEW Serves as both a mutex and completion notification. 1885 * New inodes set I_NEW. If two processes both create 1886 * the same inode, one of them will release its inode and 1887 * wait for I_NEW to be released before returning. 1888 * Inodes in I_WILL_FREE, I_FREEING or I_CLEAR state can 1889 * also cause waiting on I_NEW, without I_NEW actually 1890 * being set. find_inode() uses this to prevent returning 1891 * nearly-dead inodes. 1892 * I_WILL_FREE Must be set when calling write_inode_now() if i_count 1893 * is zero. I_FREEING must be set when I_WILL_FREE is 1894 * cleared. 1895 * I_FREEING Set when inode is about to be freed but still has dirty 1896 * pages or buffers attached or the inode itself is still 1897 * dirty. 1898 * I_CLEAR Added by clear_inode(). In this state the inode is 1899 * clean and can be destroyed. Inode keeps I_FREEING. 1900 * 1901 * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are 1902 * prohibited for many purposes. iget() must wait for 1903 * the inode to be completely released, then create it 1904 * anew. Other functions will just ignore such inodes, 1905 * if appropriate. I_NEW is used for waiting. 1906 * 1907 * I_SYNC Writeback of inode is running. The bit is set during 1908 * data writeback, and cleared with a wakeup on the bit 1909 * address once it is done. The bit is also used to pin 1910 * the inode in memory for flusher thread. 1911 * 1912 * I_REFERENCED Marks the inode as recently references on the LRU list. 1913 * 1914 * I_DIO_WAKEUP Never set. Only used as a key for wait_on_bit(). 1915 * 1916 * I_WB_SWITCH Cgroup bdi_writeback switching in progress. Used to 1917 * synchronize competing switching instances and to tell 1918 * wb stat updates to grab mapping->tree_lock. See 1919 * inode_switch_wb_work_fn() for details. 1920 * 1921 * Q: What is the difference between I_WILL_FREE and I_FREEING? 1922 */ 1923 #define I_DIRTY_SYNC (1 << 0) 1924 #define I_DIRTY_DATASYNC (1 << 1) 1925 #define I_DIRTY_PAGES (1 << 2) 1926 #define __I_NEW 3 1927 #define I_NEW (1 << __I_NEW) 1928 #define I_WILL_FREE (1 << 4) 1929 #define I_FREEING (1 << 5) 1930 #define I_CLEAR (1 << 6) 1931 #define __I_SYNC 7 1932 #define I_SYNC (1 << __I_SYNC) 1933 #define I_REFERENCED (1 << 8) 1934 #define __I_DIO_WAKEUP 9 1935 #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP) 1936 #define I_LINKABLE (1 << 10) 1937 #define I_DIRTY_TIME (1 << 11) 1938 #define __I_DIRTY_TIME_EXPIRED 12 1939 #define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) 1940 #define I_WB_SWITCH (1 << 13) 1941 1942 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 1943 #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME) 1944 1945 extern void __mark_inode_dirty(struct inode *, int); 1946 static inline void mark_inode_dirty(struct inode *inode) 1947 { 1948 __mark_inode_dirty(inode, I_DIRTY); 1949 } 1950 1951 static inline void mark_inode_dirty_sync(struct inode *inode) 1952 { 1953 __mark_inode_dirty(inode, I_DIRTY_SYNC); 1954 } 1955 1956 extern void inc_nlink(struct inode *inode); 1957 extern void drop_nlink(struct inode *inode); 1958 extern void clear_nlink(struct inode *inode); 1959 extern void set_nlink(struct inode *inode, unsigned int nlink); 1960 1961 static inline void inode_inc_link_count(struct inode *inode) 1962 { 1963 inc_nlink(inode); 1964 mark_inode_dirty(inode); 1965 } 1966 1967 static inline void inode_dec_link_count(struct inode *inode) 1968 { 1969 drop_nlink(inode); 1970 mark_inode_dirty(inode); 1971 } 1972 1973 /** 1974 * inode_inc_iversion - increments i_version 1975 * @inode: inode that need to be updated 1976 * 1977 * Every time the inode is modified, the i_version field will be incremented. 1978 * The filesystem has to be mounted with i_version flag 1979 */ 1980 1981 static inline void inode_inc_iversion(struct inode *inode) 1982 { 1983 spin_lock(&inode->i_lock); 1984 inode->i_version++; 1985 spin_unlock(&inode->i_lock); 1986 } 1987 1988 enum file_time_flags { 1989 S_ATIME = 1, 1990 S_MTIME = 2, 1991 S_CTIME = 4, 1992 S_VERSION = 8, 1993 }; 1994 1995 extern bool atime_needs_update(const struct path *, struct inode *); 1996 extern void touch_atime(const struct path *); 1997 static inline void file_accessed(struct file *file) 1998 { 1999 if (!(file->f_flags & O_NOATIME)) 2000 touch_atime(&file->f_path); 2001 } 2002 2003 int sync_inode(struct inode *inode, struct writeback_control *wbc); 2004 int sync_inode_metadata(struct inode *inode, int wait); 2005 2006 struct file_system_type { 2007 const char *name; 2008 int fs_flags; 2009 #define FS_REQUIRES_DEV 1 2010 #define FS_BINARY_MOUNTDATA 2 2011 #define FS_HAS_SUBTYPE 4 2012 #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ 2013 #define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */ 2014 #define FS_USERNS_VISIBLE 32 /* FS must already be visible */ 2015 #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ 2016 struct dentry *(*mount) (struct file_system_type *, int, 2017 const char *, void *); 2018 void (*kill_sb) (struct super_block *); 2019 struct module *owner; 2020 struct file_system_type * next; 2021 struct hlist_head fs_supers; 2022 2023 struct lock_class_key s_lock_key; 2024 struct lock_class_key s_umount_key; 2025 struct lock_class_key s_vfs_rename_key; 2026 struct lock_class_key s_writers_key[SB_FREEZE_LEVELS]; 2027 2028 struct lock_class_key i_lock_key; 2029 struct lock_class_key i_mutex_key; 2030 struct lock_class_key i_mutex_dir_key; 2031 }; 2032 2033 #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME) 2034 2035 extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags, 2036 void *data, int (*fill_super)(struct super_block *, void *, int)); 2037 extern struct dentry *mount_bdev(struct file_system_type *fs_type, 2038 int flags, const char *dev_name, void *data, 2039 int (*fill_super)(struct super_block *, void *, int)); 2040 extern struct dentry *mount_single(struct file_system_type *fs_type, 2041 int flags, void *data, 2042 int (*fill_super)(struct super_block *, void *, int)); 2043 extern struct dentry *mount_nodev(struct file_system_type *fs_type, 2044 int flags, void *data, 2045 int (*fill_super)(struct super_block *, void *, int)); 2046 extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path); 2047 void generic_shutdown_super(struct super_block *sb); 2048 void kill_block_super(struct super_block *sb); 2049 void kill_anon_super(struct super_block *sb); 2050 void kill_litter_super(struct super_block *sb); 2051 void deactivate_super(struct super_block *sb); 2052 void deactivate_locked_super(struct super_block *sb); 2053 int set_anon_super(struct super_block *s, void *data); 2054 int get_anon_bdev(dev_t *); 2055 void free_anon_bdev(dev_t); 2056 struct super_block *sget(struct file_system_type *type, 2057 int (*test)(struct super_block *,void *), 2058 int (*set)(struct super_block *,void *), 2059 int flags, void *data); 2060 extern struct dentry *mount_pseudo(struct file_system_type *, char *, 2061 const struct super_operations *ops, 2062 const struct dentry_operations *dops, 2063 unsigned long); 2064 2065 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 2066 #define fops_get(fops) \ 2067 (((fops) && try_module_get((fops)->owner) ? (fops) : NULL)) 2068 #define fops_put(fops) \ 2069 do { if (fops) module_put((fops)->owner); } while(0) 2070 /* 2071 * This one is to be used *ONLY* from ->open() instances. 2072 * fops must be non-NULL, pinned down *and* module dependencies 2073 * should be sufficient to pin the caller down as well. 2074 */ 2075 #define replace_fops(f, fops) \ 2076 do { \ 2077 struct file *__file = (f); \ 2078 fops_put(__file->f_op); \ 2079 BUG_ON(!(__file->f_op = (fops))); \ 2080 } while(0) 2081 2082 extern int register_filesystem(struct file_system_type *); 2083 extern int unregister_filesystem(struct file_system_type *); 2084 extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data); 2085 #define kern_mount(type) kern_mount_data(type, NULL) 2086 extern void kern_unmount(struct vfsmount *mnt); 2087 extern int may_umount_tree(struct vfsmount *); 2088 extern int may_umount(struct vfsmount *); 2089 extern long do_mount(const char *, const char __user *, 2090 const char *, unsigned long, void *); 2091 extern struct vfsmount *collect_mounts(struct path *); 2092 extern void drop_collected_mounts(struct vfsmount *); 2093 extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, 2094 struct vfsmount *); 2095 extern int vfs_statfs(struct path *, struct kstatfs *); 2096 extern int user_statfs(const char __user *, struct kstatfs *); 2097 extern int fd_statfs(int, struct kstatfs *); 2098 extern int vfs_ustat(dev_t, struct kstatfs *); 2099 extern int freeze_super(struct super_block *super); 2100 extern int thaw_super(struct super_block *super); 2101 extern bool our_mnt(struct vfsmount *mnt); 2102 2103 extern int current_umask(void); 2104 2105 extern void ihold(struct inode * inode); 2106 extern void iput(struct inode *); 2107 extern int generic_update_time(struct inode *, struct timespec *, int); 2108 2109 /* /sys/fs */ 2110 extern struct kobject *fs_kobj; 2111 2112 #define MAX_RW_COUNT (INT_MAX & PAGE_MASK) 2113 2114 #ifdef CONFIG_MANDATORY_FILE_LOCKING 2115 extern int locks_mandatory_locked(struct file *); 2116 extern int locks_mandatory_area(struct inode *, struct file *, loff_t, loff_t, unsigned char); 2117 2118 /* 2119 * Candidates for mandatory locking have the setgid bit set 2120 * but no group execute bit - an otherwise meaningless combination. 2121 */ 2122 2123 static inline int __mandatory_lock(struct inode *ino) 2124 { 2125 return (ino->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID; 2126 } 2127 2128 /* 2129 * ... and these candidates should be on MS_MANDLOCK mounted fs, 2130 * otherwise these will be advisory locks 2131 */ 2132 2133 static inline int mandatory_lock(struct inode *ino) 2134 { 2135 return IS_MANDLOCK(ino) && __mandatory_lock(ino); 2136 } 2137 2138 static inline int locks_verify_locked(struct file *file) 2139 { 2140 if (mandatory_lock(file_inode(file))) 2141 return locks_mandatory_locked(file); 2142 return 0; 2143 } 2144 2145 static inline int locks_verify_truncate(struct inode *inode, 2146 struct file *f, 2147 loff_t size) 2148 { 2149 if (!inode->i_flctx || !mandatory_lock(inode)) 2150 return 0; 2151 2152 if (size < inode->i_size) { 2153 return locks_mandatory_area(inode, f, size, inode->i_size - 1, 2154 F_WRLCK); 2155 } else { 2156 return locks_mandatory_area(inode, f, inode->i_size, size - 1, 2157 F_WRLCK); 2158 } 2159 } 2160 2161 #else /* !CONFIG_MANDATORY_FILE_LOCKING */ 2162 2163 static inline int locks_mandatory_locked(struct file *file) 2164 { 2165 return 0; 2166 } 2167 2168 static inline int locks_mandatory_area(struct inode *inode, struct file *filp, 2169 loff_t start, loff_t end, unsigned char type) 2170 { 2171 return 0; 2172 } 2173 2174 static inline int __mandatory_lock(struct inode *inode) 2175 { 2176 return 0; 2177 } 2178 2179 static inline int mandatory_lock(struct inode *inode) 2180 { 2181 return 0; 2182 } 2183 2184 static inline int locks_verify_locked(struct file *file) 2185 { 2186 return 0; 2187 } 2188 2189 static inline int locks_verify_truncate(struct inode *inode, struct file *filp, 2190 size_t size) 2191 { 2192 return 0; 2193 } 2194 2195 #endif /* CONFIG_MANDATORY_FILE_LOCKING */ 2196 2197 2198 #ifdef CONFIG_FILE_LOCKING 2199 static inline int break_lease(struct inode *inode, unsigned int mode) 2200 { 2201 /* 2202 * Since this check is lockless, we must ensure that any refcounts 2203 * taken are done before checking i_flctx->flc_lease. Otherwise, we 2204 * could end up racing with tasks trying to set a new lease on this 2205 * file. 2206 */ 2207 smp_mb(); 2208 if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) 2209 return __break_lease(inode, mode, FL_LEASE); 2210 return 0; 2211 } 2212 2213 static inline int break_deleg(struct inode *inode, unsigned int mode) 2214 { 2215 /* 2216 * Since this check is lockless, we must ensure that any refcounts 2217 * taken are done before checking i_flctx->flc_lease. Otherwise, we 2218 * could end up racing with tasks trying to set a new lease on this 2219 * file. 2220 */ 2221 smp_mb(); 2222 if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) 2223 return __break_lease(inode, mode, FL_DELEG); 2224 return 0; 2225 } 2226 2227 static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) 2228 { 2229 int ret; 2230 2231 ret = break_deleg(inode, O_WRONLY|O_NONBLOCK); 2232 if (ret == -EWOULDBLOCK && delegated_inode) { 2233 *delegated_inode = inode; 2234 ihold(inode); 2235 } 2236 return ret; 2237 } 2238 2239 static inline int break_deleg_wait(struct inode **delegated_inode) 2240 { 2241 int ret; 2242 2243 ret = break_deleg(*delegated_inode, O_WRONLY); 2244 iput(*delegated_inode); 2245 *delegated_inode = NULL; 2246 return ret; 2247 } 2248 2249 static inline int break_layout(struct inode *inode, bool wait) 2250 { 2251 smp_mb(); 2252 if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) 2253 return __break_lease(inode, 2254 wait ? O_WRONLY : O_WRONLY | O_NONBLOCK, 2255 FL_LAYOUT); 2256 return 0; 2257 } 2258 2259 #else /* !CONFIG_FILE_LOCKING */ 2260 static inline int break_lease(struct inode *inode, unsigned int mode) 2261 { 2262 return 0; 2263 } 2264 2265 static inline int break_deleg(struct inode *inode, unsigned int mode) 2266 { 2267 return 0; 2268 } 2269 2270 static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) 2271 { 2272 return 0; 2273 } 2274 2275 static inline int break_deleg_wait(struct inode **delegated_inode) 2276 { 2277 BUG(); 2278 return 0; 2279 } 2280 2281 static inline int break_layout(struct inode *inode, bool wait) 2282 { 2283 return 0; 2284 } 2285 2286 #endif /* CONFIG_FILE_LOCKING */ 2287 2288 /* fs/open.c */ 2289 struct audit_names; 2290 struct filename { 2291 const char *name; /* pointer to actual string */ 2292 const __user char *uptr; /* original userland pointer */ 2293 struct audit_names *aname; 2294 int refcnt; 2295 const char iname[]; 2296 }; 2297 2298 extern long vfs_truncate(const struct path *, loff_t); 2299 extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, 2300 struct file *filp); 2301 extern int vfs_fallocate(struct file *file, int mode, loff_t offset, 2302 loff_t len); 2303 extern long do_sys_open(int dfd, const char __user *filename, int flags, 2304 umode_t mode); 2305 extern struct file *file_open_name(struct filename *, int, umode_t); 2306 extern struct file *filp_open(const char *, int, umode_t); 2307 extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2308 const char *, int, umode_t); 2309 extern struct file * dentry_open(const struct path *, int, const struct cred *); 2310 extern int filp_close(struct file *, fl_owner_t id); 2311 2312 extern struct filename *getname_flags(const char __user *, int, int *); 2313 extern struct filename *getname(const char __user *); 2314 extern struct filename *getname_kernel(const char *); 2315 extern void putname(struct filename *name); 2316 2317 enum { 2318 FILE_CREATED = 1, 2319 FILE_OPENED = 2 2320 }; 2321 extern int finish_open(struct file *file, struct dentry *dentry, 2322 int (*open)(struct inode *, struct file *), 2323 int *opened); 2324 extern int finish_no_open(struct file *file, struct dentry *dentry); 2325 2326 /* fs/ioctl.c */ 2327 2328 extern int ioctl_preallocate(struct file *filp, void __user *argp); 2329 2330 /* fs/dcache.c */ 2331 extern void __init vfs_caches_init_early(void); 2332 extern void __init vfs_caches_init(void); 2333 2334 extern struct kmem_cache *names_cachep; 2335 2336 #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) 2337 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 2338 2339 #ifdef CONFIG_BLOCK 2340 extern int register_blkdev(unsigned int, const char *); 2341 extern void unregister_blkdev(unsigned int, const char *); 2342 extern struct block_device *bdget(dev_t); 2343 extern struct block_device *bdgrab(struct block_device *bdev); 2344 extern void bd_set_size(struct block_device *, loff_t size); 2345 extern void bd_forget(struct inode *inode); 2346 extern void bdput(struct block_device *); 2347 extern void invalidate_bdev(struct block_device *); 2348 extern void iterate_bdevs(void (*)(struct block_device *, void *), void *); 2349 extern int sync_blockdev(struct block_device *bdev); 2350 extern void kill_bdev(struct block_device *); 2351 extern struct super_block *freeze_bdev(struct block_device *); 2352 extern void emergency_thaw_all(void); 2353 extern int thaw_bdev(struct block_device *bdev, struct super_block *sb); 2354 extern int fsync_bdev(struct block_device *); 2355 2356 extern struct super_block *blockdev_superblock; 2357 2358 static inline bool sb_is_blkdev_sb(struct super_block *sb) 2359 { 2360 return sb == blockdev_superblock; 2361 } 2362 #else 2363 static inline void bd_forget(struct inode *inode) {} 2364 static inline int sync_blockdev(struct block_device *bdev) { return 0; } 2365 static inline void kill_bdev(struct block_device *bdev) {} 2366 static inline void invalidate_bdev(struct block_device *bdev) {} 2367 2368 static inline struct super_block *freeze_bdev(struct block_device *sb) 2369 { 2370 return NULL; 2371 } 2372 2373 static inline int thaw_bdev(struct block_device *bdev, struct super_block *sb) 2374 { 2375 return 0; 2376 } 2377 2378 static inline void iterate_bdevs(void (*f)(struct block_device *, void *), void *arg) 2379 { 2380 } 2381 2382 static inline bool sb_is_blkdev_sb(struct super_block *sb) 2383 { 2384 return false; 2385 } 2386 #endif 2387 extern int sync_filesystem(struct super_block *); 2388 extern const struct file_operations def_blk_fops; 2389 extern const struct file_operations def_chr_fops; 2390 #ifdef CONFIG_BLOCK 2391 extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 2392 extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 2393 extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 2394 extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder); 2395 extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, 2396 void *holder); 2397 extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, 2398 void *holder); 2399 extern void blkdev_put(struct block_device *bdev, fmode_t mode); 2400 extern int __blkdev_reread_part(struct block_device *bdev); 2401 extern int blkdev_reread_part(struct block_device *bdev); 2402 2403 #ifdef CONFIG_SYSFS 2404 extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk); 2405 extern void bd_unlink_disk_holder(struct block_device *bdev, 2406 struct gendisk *disk); 2407 #else 2408 static inline int bd_link_disk_holder(struct block_device *bdev, 2409 struct gendisk *disk) 2410 { 2411 return 0; 2412 } 2413 static inline void bd_unlink_disk_holder(struct block_device *bdev, 2414 struct gendisk *disk) 2415 { 2416 } 2417 #endif 2418 #endif 2419 2420 /* fs/char_dev.c */ 2421 #define CHRDEV_MAJOR_HASH_SIZE 255 2422 /* Marks the bottom of the first segment of free char majors */ 2423 #define CHRDEV_MAJOR_DYN_END 234 2424 extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); 2425 extern int register_chrdev_region(dev_t, unsigned, const char *); 2426 extern int __register_chrdev(unsigned int major, unsigned int baseminor, 2427 unsigned int count, const char *name, 2428 const struct file_operations *fops); 2429 extern void __unregister_chrdev(unsigned int major, unsigned int baseminor, 2430 unsigned int count, const char *name); 2431 extern void unregister_chrdev_region(dev_t, unsigned); 2432 extern void chrdev_show(struct seq_file *,off_t); 2433 2434 static inline int register_chrdev(unsigned int major, const char *name, 2435 const struct file_operations *fops) 2436 { 2437 return __register_chrdev(major, 0, 256, name, fops); 2438 } 2439 2440 static inline void unregister_chrdev(unsigned int major, const char *name) 2441 { 2442 __unregister_chrdev(major, 0, 256, name); 2443 } 2444 2445 /* fs/block_dev.c */ 2446 #define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ 2447 #define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */ 2448 2449 #ifdef CONFIG_BLOCK 2450 #define BLKDEV_MAJOR_HASH_SIZE 255 2451 extern const char *__bdevname(dev_t, char *buffer); 2452 extern const char *bdevname(struct block_device *bdev, char *buffer); 2453 extern struct block_device *lookup_bdev(const char *); 2454 extern void blkdev_show(struct seq_file *,off_t); 2455 2456 #else 2457 #define BLKDEV_MAJOR_HASH_SIZE 0 2458 #endif 2459 2460 extern void init_special_inode(struct inode *, umode_t, dev_t); 2461 2462 /* Invalid inode operations -- fs/bad_inode.c */ 2463 extern void make_bad_inode(struct inode *); 2464 extern bool is_bad_inode(struct inode *); 2465 2466 #ifdef CONFIG_BLOCK 2467 /* 2468 * return READ, READA, or WRITE 2469 */ 2470 #define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK)) 2471 2472 /* 2473 * return data direction, READ or WRITE 2474 */ 2475 #define bio_data_dir(bio) ((bio)->bi_rw & 1) 2476 2477 extern void check_disk_size_change(struct gendisk *disk, 2478 struct block_device *bdev); 2479 extern int revalidate_disk(struct gendisk *); 2480 extern int check_disk_change(struct block_device *); 2481 extern int __invalidate_device(struct block_device *, bool); 2482 extern int invalidate_partition(struct gendisk *, int); 2483 #endif 2484 unsigned long invalidate_mapping_pages(struct address_space *mapping, 2485 pgoff_t start, pgoff_t end); 2486 2487 static inline void invalidate_remote_inode(struct inode *inode) 2488 { 2489 if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 2490 S_ISLNK(inode->i_mode)) 2491 invalidate_mapping_pages(inode->i_mapping, 0, -1); 2492 } 2493 extern int invalidate_inode_pages2(struct address_space *mapping); 2494 extern int invalidate_inode_pages2_range(struct address_space *mapping, 2495 pgoff_t start, pgoff_t end); 2496 extern int write_inode_now(struct inode *, int); 2497 extern int filemap_fdatawrite(struct address_space *); 2498 extern int filemap_flush(struct address_space *); 2499 extern int filemap_fdatawait(struct address_space *); 2500 extern void filemap_fdatawait_keep_errors(struct address_space *); 2501 extern int filemap_fdatawait_range(struct address_space *, loff_t lstart, 2502 loff_t lend); 2503 extern int filemap_write_and_wait(struct address_space *mapping); 2504 extern int filemap_write_and_wait_range(struct address_space *mapping, 2505 loff_t lstart, loff_t lend); 2506 extern int __filemap_fdatawrite_range(struct address_space *mapping, 2507 loff_t start, loff_t end, int sync_mode); 2508 extern int filemap_fdatawrite_range(struct address_space *mapping, 2509 loff_t start, loff_t end); 2510 2511 extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, 2512 int datasync); 2513 extern int vfs_fsync(struct file *file, int datasync); 2514 2515 /* 2516 * Sync the bytes written if this was a synchronous write. Expect ki_pos 2517 * to already be updated for the write, and will return either the amount 2518 * of bytes passed in, or an error if syncing the file failed. 2519 */ 2520 static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count) 2521 { 2522 if (iocb->ki_flags & IOCB_DSYNC) { 2523 int ret = vfs_fsync_range(iocb->ki_filp, 2524 iocb->ki_pos - count, iocb->ki_pos - 1, 2525 (iocb->ki_flags & IOCB_SYNC) ? 0 : 1); 2526 if (ret) 2527 return ret; 2528 } 2529 2530 return count; 2531 } 2532 2533 extern void emergency_sync(void); 2534 extern void emergency_remount(void); 2535 #ifdef CONFIG_BLOCK 2536 extern sector_t bmap(struct inode *, sector_t); 2537 #endif 2538 extern int notify_change(struct dentry *, struct iattr *, struct inode **); 2539 extern int inode_permission(struct inode *, int); 2540 extern int __inode_permission(struct inode *, int); 2541 extern int generic_permission(struct inode *, int); 2542 extern int __check_sticky(struct inode *dir, struct inode *inode); 2543 2544 static inline bool execute_ok(struct inode *inode) 2545 { 2546 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode); 2547 } 2548 2549 static inline void file_start_write(struct file *file) 2550 { 2551 if (!S_ISREG(file_inode(file)->i_mode)) 2552 return; 2553 __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true); 2554 } 2555 2556 static inline bool file_start_write_trylock(struct file *file) 2557 { 2558 if (!S_ISREG(file_inode(file)->i_mode)) 2559 return true; 2560 return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false); 2561 } 2562 2563 static inline void file_end_write(struct file *file) 2564 { 2565 if (!S_ISREG(file_inode(file)->i_mode)) 2566 return; 2567 __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE); 2568 } 2569 2570 /* 2571 * get_write_access() gets write permission for a file. 2572 * put_write_access() releases this write permission. 2573 * This is used for regular files. 2574 * We cannot support write (and maybe mmap read-write shared) accesses and 2575 * MAP_DENYWRITE mmappings simultaneously. The i_writecount field of an inode 2576 * can have the following values: 2577 * 0: no writers, no VM_DENYWRITE mappings 2578 * < 0: (-i_writecount) vm_area_structs with VM_DENYWRITE set exist 2579 * > 0: (i_writecount) users are writing to the file. 2580 * 2581 * Normally we operate on that counter with atomic_{inc,dec} and it's safe 2582 * except for the cases where we don't hold i_writecount yet. Then we need to 2583 * use {get,deny}_write_access() - these functions check the sign and refuse 2584 * to do the change if sign is wrong. 2585 */ 2586 static inline int get_write_access(struct inode *inode) 2587 { 2588 return atomic_inc_unless_negative(&inode->i_writecount) ? 0 : -ETXTBSY; 2589 } 2590 static inline int deny_write_access(struct file *file) 2591 { 2592 struct inode *inode = file_inode(file); 2593 return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY; 2594 } 2595 static inline void put_write_access(struct inode * inode) 2596 { 2597 atomic_dec(&inode->i_writecount); 2598 } 2599 static inline void allow_write_access(struct file *file) 2600 { 2601 if (file) 2602 atomic_inc(&file_inode(file)->i_writecount); 2603 } 2604 static inline bool inode_is_open_for_write(const struct inode *inode) 2605 { 2606 return atomic_read(&inode->i_writecount) > 0; 2607 } 2608 2609 #ifdef CONFIG_IMA 2610 static inline void i_readcount_dec(struct inode *inode) 2611 { 2612 BUG_ON(!atomic_read(&inode->i_readcount)); 2613 atomic_dec(&inode->i_readcount); 2614 } 2615 static inline void i_readcount_inc(struct inode *inode) 2616 { 2617 atomic_inc(&inode->i_readcount); 2618 } 2619 #else 2620 static inline void i_readcount_dec(struct inode *inode) 2621 { 2622 return; 2623 } 2624 static inline void i_readcount_inc(struct inode *inode) 2625 { 2626 return; 2627 } 2628 #endif 2629 extern int do_pipe_flags(int *, int); 2630 2631 #define __kernel_read_file_id(id) \ 2632 id(UNKNOWN, unknown) \ 2633 id(FIRMWARE, firmware) \ 2634 id(MODULE, kernel-module) \ 2635 id(KEXEC_IMAGE, kexec-image) \ 2636 id(KEXEC_INITRAMFS, kexec-initramfs) \ 2637 id(POLICY, security-policy) \ 2638 id(MAX_ID, ) 2639 2640 #define __fid_enumify(ENUM, dummy) READING_ ## ENUM, 2641 #define __fid_stringify(dummy, str) #str, 2642 2643 enum kernel_read_file_id { 2644 __kernel_read_file_id(__fid_enumify) 2645 }; 2646 2647 static const char * const kernel_read_file_str[] = { 2648 __kernel_read_file_id(__fid_stringify) 2649 }; 2650 2651 static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id) 2652 { 2653 if (id < 0 || id >= READING_MAX_ID) 2654 return kernel_read_file_str[READING_UNKNOWN]; 2655 2656 return kernel_read_file_str[id]; 2657 } 2658 2659 extern int kernel_read(struct file *, loff_t, char *, unsigned long); 2660 extern int kernel_read_file(struct file *, void **, loff_t *, loff_t, 2661 enum kernel_read_file_id); 2662 extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t, 2663 enum kernel_read_file_id); 2664 extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t, 2665 enum kernel_read_file_id); 2666 extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t); 2667 extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); 2668 extern struct file * open_exec(const char *); 2669 2670 /* fs/dcache.c -- generic fs support functions */ 2671 extern bool is_subdir(struct dentry *, struct dentry *); 2672 extern bool path_is_under(struct path *, struct path *); 2673 2674 extern char *file_path(struct file *, char *, int); 2675 2676 #include <linux/err.h> 2677 2678 /* needed for stackable file system support */ 2679 extern loff_t default_llseek(struct file *file, loff_t offset, int whence); 2680 2681 extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence); 2682 2683 extern int inode_init_always(struct super_block *, struct inode *); 2684 extern void inode_init_once(struct inode *); 2685 extern void address_space_init_once(struct address_space *mapping); 2686 extern struct inode * igrab(struct inode *); 2687 extern ino_t iunique(struct super_block *, ino_t); 2688 extern int inode_needs_sync(struct inode *inode); 2689 extern int generic_delete_inode(struct inode *inode); 2690 static inline int generic_drop_inode(struct inode *inode) 2691 { 2692 return !inode->i_nlink || inode_unhashed(inode); 2693 } 2694 2695 extern struct inode *ilookup5_nowait(struct super_block *sb, 2696 unsigned long hashval, int (*test)(struct inode *, void *), 2697 void *data); 2698 extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval, 2699 int (*test)(struct inode *, void *), void *data); 2700 extern struct inode *ilookup(struct super_block *sb, unsigned long ino); 2701 2702 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); 2703 extern struct inode * iget_locked(struct super_block *, unsigned long); 2704 extern struct inode *find_inode_nowait(struct super_block *, 2705 unsigned long, 2706 int (*match)(struct inode *, 2707 unsigned long, void *), 2708 void *data); 2709 extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); 2710 extern int insert_inode_locked(struct inode *); 2711 #ifdef CONFIG_DEBUG_LOCK_ALLOC 2712 extern void lockdep_annotate_inode_mutex_key(struct inode *inode); 2713 #else 2714 static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { }; 2715 #endif 2716 extern void unlock_new_inode(struct inode *); 2717 extern unsigned int get_next_ino(void); 2718 2719 extern void __iget(struct inode * inode); 2720 extern void iget_failed(struct inode *); 2721 extern void clear_inode(struct inode *); 2722 extern void __destroy_inode(struct inode *); 2723 extern struct inode *new_inode_pseudo(struct super_block *sb); 2724 extern struct inode *new_inode(struct super_block *sb); 2725 extern void free_inode_nonrcu(struct inode *inode); 2726 extern int should_remove_suid(struct dentry *); 2727 extern int file_remove_privs(struct file *); 2728 extern int dentry_needs_remove_privs(struct dentry *dentry); 2729 static inline int file_needs_remove_privs(struct file *file) 2730 { 2731 return dentry_needs_remove_privs(file->f_path.dentry); 2732 } 2733 2734 extern void __insert_inode_hash(struct inode *, unsigned long hashval); 2735 static inline void insert_inode_hash(struct inode *inode) 2736 { 2737 __insert_inode_hash(inode, inode->i_ino); 2738 } 2739 2740 extern void __remove_inode_hash(struct inode *); 2741 static inline void remove_inode_hash(struct inode *inode) 2742 { 2743 if (!inode_unhashed(inode) && !hlist_fake(&inode->i_hash)) 2744 __remove_inode_hash(inode); 2745 } 2746 2747 extern void inode_sb_list_add(struct inode *inode); 2748 2749 #ifdef CONFIG_BLOCK 2750 extern blk_qc_t submit_bio(int, struct bio *); 2751 extern int bdev_read_only(struct block_device *); 2752 #endif 2753 extern int set_blocksize(struct block_device *, int); 2754 extern int sb_set_blocksize(struct super_block *, int); 2755 extern int sb_min_blocksize(struct super_block *, int); 2756 2757 extern int generic_file_mmap(struct file *, struct vm_area_struct *); 2758 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); 2759 extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); 2760 extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); 2761 extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); 2762 extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); 2763 extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *); 2764 extern ssize_t generic_perform_write(struct file *, struct iov_iter *, loff_t); 2765 2766 ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos); 2767 ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos); 2768 2769 /* fs/block_dev.c */ 2770 extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to); 2771 extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); 2772 extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2773 int datasync); 2774 extern void block_sync_page(struct page *page); 2775 2776 /* fs/splice.c */ 2777 extern ssize_t generic_file_splice_read(struct file *, loff_t *, 2778 struct pipe_inode_info *, size_t, unsigned int); 2779 extern ssize_t default_file_splice_read(struct file *, loff_t *, 2780 struct pipe_inode_info *, size_t, unsigned int); 2781 extern ssize_t iter_file_splice_write(struct pipe_inode_info *, 2782 struct file *, loff_t *, size_t, unsigned int); 2783 extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, 2784 struct file *out, loff_t *, size_t len, unsigned int flags); 2785 extern long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, 2786 loff_t *opos, size_t len, unsigned int flags); 2787 2788 2789 extern void 2790 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); 2791 extern loff_t noop_llseek(struct file *file, loff_t offset, int whence); 2792 extern loff_t no_llseek(struct file *file, loff_t offset, int whence); 2793 extern loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize); 2794 extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence); 2795 extern loff_t generic_file_llseek_size(struct file *file, loff_t offset, 2796 int whence, loff_t maxsize, loff_t eof); 2797 extern loff_t fixed_size_llseek(struct file *file, loff_t offset, 2798 int whence, loff_t size); 2799 extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t); 2800 extern loff_t no_seek_end_llseek(struct file *, loff_t, int); 2801 extern int generic_file_open(struct inode * inode, struct file * filp); 2802 extern int nonseekable_open(struct inode * inode, struct file * filp); 2803 2804 #ifdef CONFIG_BLOCK 2805 typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode, 2806 loff_t file_offset); 2807 2808 enum { 2809 /* need locking between buffered and direct access */ 2810 DIO_LOCKING = 0x01, 2811 2812 /* filesystem does not support filling holes */ 2813 DIO_SKIP_HOLES = 0x02, 2814 2815 /* filesystem can handle aio writes beyond i_size */ 2816 DIO_ASYNC_EXTEND = 0x04, 2817 2818 /* inode/fs/bdev does not need truncate protection */ 2819 DIO_SKIP_DIO_COUNT = 0x08, 2820 }; 2821 2822 void dio_end_io(struct bio *bio, int error); 2823 2824 ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, 2825 struct block_device *bdev, struct iov_iter *iter, 2826 get_block_t get_block, 2827 dio_iodone_t end_io, dio_submit_t submit_io, 2828 int flags); 2829 2830 static inline ssize_t blockdev_direct_IO(struct kiocb *iocb, 2831 struct inode *inode, 2832 struct iov_iter *iter, 2833 get_block_t get_block) 2834 { 2835 return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter, 2836 get_block, NULL, NULL, DIO_LOCKING | DIO_SKIP_HOLES); 2837 } 2838 #endif 2839 2840 void inode_dio_wait(struct inode *inode); 2841 2842 /* 2843 * inode_dio_begin - signal start of a direct I/O requests 2844 * @inode: inode the direct I/O happens on 2845 * 2846 * This is called once we've finished processing a direct I/O request, 2847 * and is used to wake up callers waiting for direct I/O to be quiesced. 2848 */ 2849 static inline void inode_dio_begin(struct inode *inode) 2850 { 2851 atomic_inc(&inode->i_dio_count); 2852 } 2853 2854 /* 2855 * inode_dio_end - signal finish of a direct I/O requests 2856 * @inode: inode the direct I/O happens on 2857 * 2858 * This is called once we've finished processing a direct I/O request, 2859 * and is used to wake up callers waiting for direct I/O to be quiesced. 2860 */ 2861 static inline void inode_dio_end(struct inode *inode) 2862 { 2863 if (atomic_dec_and_test(&inode->i_dio_count)) 2864 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); 2865 } 2866 2867 extern void inode_set_flags(struct inode *inode, unsigned int flags, 2868 unsigned int mask); 2869 2870 extern const struct file_operations generic_ro_fops; 2871 2872 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m)) 2873 2874 extern int readlink_copy(char __user *, int, const char *); 2875 extern int page_readlink(struct dentry *, char __user *, int); 2876 extern const char *page_get_link(struct dentry *, struct inode *, 2877 struct delayed_call *); 2878 extern void page_put_link(void *); 2879 extern int __page_symlink(struct inode *inode, const char *symname, int len, 2880 int nofs); 2881 extern int page_symlink(struct inode *inode, const char *symname, int len); 2882 extern const struct inode_operations page_symlink_inode_operations; 2883 extern void kfree_link(void *); 2884 extern int generic_readlink(struct dentry *, char __user *, int); 2885 extern void generic_fillattr(struct inode *, struct kstat *); 2886 int vfs_getattr_nosec(struct path *path, struct kstat *stat); 2887 extern int vfs_getattr(struct path *, struct kstat *); 2888 void __inode_add_bytes(struct inode *inode, loff_t bytes); 2889 void inode_add_bytes(struct inode *inode, loff_t bytes); 2890 void __inode_sub_bytes(struct inode *inode, loff_t bytes); 2891 void inode_sub_bytes(struct inode *inode, loff_t bytes); 2892 loff_t inode_get_bytes(struct inode *inode); 2893 void inode_set_bytes(struct inode *inode, loff_t bytes); 2894 const char *simple_get_link(struct dentry *, struct inode *, 2895 struct delayed_call *); 2896 extern const struct inode_operations simple_symlink_inode_operations; 2897 2898 extern int iterate_dir(struct file *, struct dir_context *); 2899 2900 extern int vfs_stat(const char __user *, struct kstat *); 2901 extern int vfs_lstat(const char __user *, struct kstat *); 2902 extern int vfs_fstat(unsigned int, struct kstat *); 2903 extern int vfs_fstatat(int , const char __user *, struct kstat *, int); 2904 2905 extern int __generic_block_fiemap(struct inode *inode, 2906 struct fiemap_extent_info *fieinfo, 2907 loff_t start, loff_t len, 2908 get_block_t *get_block); 2909 extern int generic_block_fiemap(struct inode *inode, 2910 struct fiemap_extent_info *fieinfo, u64 start, 2911 u64 len, get_block_t *get_block); 2912 2913 extern void get_filesystem(struct file_system_type *fs); 2914 extern void put_filesystem(struct file_system_type *fs); 2915 extern struct file_system_type *get_fs_type(const char *name); 2916 extern struct super_block *get_super(struct block_device *); 2917 extern struct super_block *get_super_thawed(struct block_device *); 2918 extern struct super_block *get_active_super(struct block_device *bdev); 2919 extern void drop_super(struct super_block *sb); 2920 extern void iterate_supers(void (*)(struct super_block *, void *), void *); 2921 extern void iterate_supers_type(struct file_system_type *, 2922 void (*)(struct super_block *, void *), void *); 2923 2924 extern int dcache_dir_open(struct inode *, struct file *); 2925 extern int dcache_dir_close(struct inode *, struct file *); 2926 extern loff_t dcache_dir_lseek(struct file *, loff_t, int); 2927 extern int dcache_readdir(struct file *, struct dir_context *); 2928 extern int simple_setattr(struct dentry *, struct iattr *); 2929 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *); 2930 extern int simple_statfs(struct dentry *, struct kstatfs *); 2931 extern int simple_open(struct inode *inode, struct file *file); 2932 extern int simple_link(struct dentry *, struct inode *, struct dentry *); 2933 extern int simple_unlink(struct inode *, struct dentry *); 2934 extern int simple_rmdir(struct inode *, struct dentry *); 2935 extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 2936 extern int noop_fsync(struct file *, loff_t, loff_t, int); 2937 extern int simple_empty(struct dentry *); 2938 extern int simple_readpage(struct file *file, struct page *page); 2939 extern int simple_write_begin(struct file *file, struct address_space *mapping, 2940 loff_t pos, unsigned len, unsigned flags, 2941 struct page **pagep, void **fsdata); 2942 extern int simple_write_end(struct file *file, struct address_space *mapping, 2943 loff_t pos, unsigned len, unsigned copied, 2944 struct page *page, void *fsdata); 2945 extern int always_delete_dentry(const struct dentry *); 2946 extern struct inode *alloc_anon_inode(struct super_block *); 2947 extern int simple_nosetlease(struct file *, long, struct file_lock **, void **); 2948 extern const struct dentry_operations simple_dentry_operations; 2949 2950 extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); 2951 extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); 2952 extern const struct file_operations simple_dir_operations; 2953 extern const struct inode_operations simple_dir_inode_operations; 2954 extern void make_empty_dir_inode(struct inode *inode); 2955 extern bool is_empty_dir_inode(struct inode *inode); 2956 struct tree_descr { char *name; const struct file_operations *ops; int mode; }; 2957 struct dentry *d_alloc_name(struct dentry *, const char *); 2958 extern int simple_fill_super(struct super_block *, unsigned long, struct tree_descr *); 2959 extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); 2960 extern void simple_release_fs(struct vfsmount **mount, int *count); 2961 2962 extern ssize_t simple_read_from_buffer(void __user *to, size_t count, 2963 loff_t *ppos, const void *from, size_t available); 2964 extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, 2965 const void __user *from, size_t count); 2966 2967 extern int __generic_file_fsync(struct file *, loff_t, loff_t, int); 2968 extern int generic_file_fsync(struct file *, loff_t, loff_t, int); 2969 2970 extern int generic_check_addressable(unsigned, u64); 2971 2972 #ifdef CONFIG_MIGRATION 2973 extern int buffer_migrate_page(struct address_space *, 2974 struct page *, struct page *, 2975 enum migrate_mode); 2976 #else 2977 #define buffer_migrate_page NULL 2978 #endif 2979 2980 extern int inode_change_ok(const struct inode *, struct iattr *); 2981 extern int inode_newsize_ok(const struct inode *, loff_t offset); 2982 extern void setattr_copy(struct inode *inode, const struct iattr *attr); 2983 2984 extern int file_update_time(struct file *file); 2985 2986 extern int generic_show_options(struct seq_file *m, struct dentry *root); 2987 extern void save_mount_options(struct super_block *sb, char *options); 2988 extern void replace_mount_options(struct super_block *sb, char *options); 2989 2990 static inline bool io_is_direct(struct file *filp) 2991 { 2992 return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host); 2993 } 2994 2995 static inline int iocb_flags(struct file *file) 2996 { 2997 int res = 0; 2998 if (file->f_flags & O_APPEND) 2999 res |= IOCB_APPEND; 3000 if (io_is_direct(file)) 3001 res |= IOCB_DIRECT; 3002 if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host)) 3003 res |= IOCB_DSYNC; 3004 if (file->f_flags & __O_SYNC) 3005 res |= IOCB_SYNC; 3006 return res; 3007 } 3008 3009 static inline ino_t parent_ino(struct dentry *dentry) 3010 { 3011 ino_t res; 3012 3013 /* 3014 * Don't strictly need d_lock here? If the parent ino could change 3015 * then surely we'd have a deeper race in the caller? 3016 */ 3017 spin_lock(&dentry->d_lock); 3018 res = dentry->d_parent->d_inode->i_ino; 3019 spin_unlock(&dentry->d_lock); 3020 return res; 3021 } 3022 3023 /* Transaction based IO helpers */ 3024 3025 /* 3026 * An argresp is stored in an allocated page and holds the 3027 * size of the argument or response, along with its content 3028 */ 3029 struct simple_transaction_argresp { 3030 ssize_t size; 3031 char data[0]; 3032 }; 3033 3034 #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp)) 3035 3036 char *simple_transaction_get(struct file *file, const char __user *buf, 3037 size_t size); 3038 ssize_t simple_transaction_read(struct file *file, char __user *buf, 3039 size_t size, loff_t *pos); 3040 int simple_transaction_release(struct inode *inode, struct file *file); 3041 3042 void simple_transaction_set(struct file *file, size_t n); 3043 3044 /* 3045 * simple attribute files 3046 * 3047 * These attributes behave similar to those in sysfs: 3048 * 3049 * Writing to an attribute immediately sets a value, an open file can be 3050 * written to multiple times. 3051 * 3052 * Reading from an attribute creates a buffer from the value that might get 3053 * read with multiple read calls. When the attribute has been read 3054 * completely, no further read calls are possible until the file is opened 3055 * again. 3056 * 3057 * All attributes contain a text representation of a numeric value 3058 * that are accessed with the get() and set() functions. 3059 */ 3060 #define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \ 3061 static int __fops ## _open(struct inode *inode, struct file *file) \ 3062 { \ 3063 __simple_attr_check_format(__fmt, 0ull); \ 3064 return simple_attr_open(inode, file, __get, __set, __fmt); \ 3065 } \ 3066 static const struct file_operations __fops = { \ 3067 .owner = THIS_MODULE, \ 3068 .open = __fops ## _open, \ 3069 .release = simple_attr_release, \ 3070 .read = simple_attr_read, \ 3071 .write = simple_attr_write, \ 3072 .llseek = generic_file_llseek, \ 3073 } 3074 3075 static inline __printf(1, 2) 3076 void __simple_attr_check_format(const char *fmt, ...) 3077 { 3078 /* don't do anything, just let the compiler check the arguments; */ 3079 } 3080 3081 int simple_attr_open(struct inode *inode, struct file *file, 3082 int (*get)(void *, u64 *), int (*set)(void *, u64), 3083 const char *fmt); 3084 int simple_attr_release(struct inode *inode, struct file *file); 3085 ssize_t simple_attr_read(struct file *file, char __user *buf, 3086 size_t len, loff_t *ppos); 3087 ssize_t simple_attr_write(struct file *file, const char __user *buf, 3088 size_t len, loff_t *ppos); 3089 3090 struct ctl_table; 3091 int proc_nr_files(struct ctl_table *table, int write, 3092 void __user *buffer, size_t *lenp, loff_t *ppos); 3093 int proc_nr_dentry(struct ctl_table *table, int write, 3094 void __user *buffer, size_t *lenp, loff_t *ppos); 3095 int proc_nr_inodes(struct ctl_table *table, int write, 3096 void __user *buffer, size_t *lenp, loff_t *ppos); 3097 int __init get_filesystem_list(char *buf); 3098 3099 #define __FMODE_EXEC ((__force int) FMODE_EXEC) 3100 #define __FMODE_NONOTIFY ((__force int) FMODE_NONOTIFY) 3101 3102 #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE]) 3103 #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \ 3104 (flag & __FMODE_NONOTIFY))) 3105 3106 static inline bool is_sxid(umode_t mode) 3107 { 3108 return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP)); 3109 } 3110 3111 static inline int check_sticky(struct inode *dir, struct inode *inode) 3112 { 3113 if (!(dir->i_mode & S_ISVTX)) 3114 return 0; 3115 3116 return __check_sticky(dir, inode); 3117 } 3118 3119 static inline void inode_has_no_xattr(struct inode *inode) 3120 { 3121 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC)) 3122 inode->i_flags |= S_NOSEC; 3123 } 3124 3125 static inline bool is_root_inode(struct inode *inode) 3126 { 3127 return inode == inode->i_sb->s_root->d_inode; 3128 } 3129 3130 static inline bool dir_emit(struct dir_context *ctx, 3131 const char *name, int namelen, 3132 u64 ino, unsigned type) 3133 { 3134 return ctx->actor(ctx, name, namelen, ctx->pos, ino, type) == 0; 3135 } 3136 static inline bool dir_emit_dot(struct file *file, struct dir_context *ctx) 3137 { 3138 return ctx->actor(ctx, ".", 1, ctx->pos, 3139 file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0; 3140 } 3141 static inline bool dir_emit_dotdot(struct file *file, struct dir_context *ctx) 3142 { 3143 return ctx->actor(ctx, "..", 2, ctx->pos, 3144 parent_ino(file->f_path.dentry), DT_DIR) == 0; 3145 } 3146 static inline bool dir_emit_dots(struct file *file, struct dir_context *ctx) 3147 { 3148 if (ctx->pos == 0) { 3149 if (!dir_emit_dot(file, ctx)) 3150 return false; 3151 ctx->pos = 1; 3152 } 3153 if (ctx->pos == 1) { 3154 if (!dir_emit_dotdot(file, ctx)) 3155 return false; 3156 ctx->pos = 2; 3157 } 3158 return true; 3159 } 3160 static inline bool dir_relax(struct inode *inode) 3161 { 3162 inode_unlock(inode); 3163 inode_lock(inode); 3164 return !IS_DEADDIR(inode); 3165 } 3166 3167 static inline bool dir_relax_shared(struct inode *inode) 3168 { 3169 inode_unlock_shared(inode); 3170 inode_lock_shared(inode); 3171 return !IS_DEADDIR(inode); 3172 } 3173 3174 extern bool path_noexec(const struct path *path); 3175 extern void inode_nohighmem(struct inode *inode); 3176 3177 #endif /* _LINUX_FS_H */

Here is an explanation of a rule violation arisen while checking your driver against a corresponding kernel.

Note that it may be false positive, i.e. there isn't a real error indeed. Please analyze a given error trace and related source code to understand whether there is an error in your driver.

Error trace column contains a path on which the given rule is violated. You can expand/collapse some entity classes by clicking on corresponding checkboxes in a main menu or in an advanced Others menu. Also you can expand/collapse each particular entity by clicking on +/-. In hovering on some entities you can see some tips. Also the error trace is bound with related source code. Line numbers may be shown as links on the left. You can click on them to open corresponding lines in source code.

Source code column contains a content of files related with the error trace. There is source code of your driver (note that there are some LDV modifications at the end), kernel headers and rule model. Tabs show a currently opened file and other available files. In hovering on them you can see full file names. On clicking a corresponding file content will be shown.

Ядро Модуль Правило Верификатор Вердикт Статус Время создания Описание проблемы
linux-4.7-rc1.tar.xz drivers/ide/ide-tape.ko 106_1a CPAchecker Bug Fixed 2016-08-19 01:50:35 L0238

Комментарий

Reported: 30 Apr 2016

[В начало]