R语言中desc <- fs@description是什么意思
时间: 2024-06-07 09:10:35 浏览: 23
在R语言中,`fs@description`是一种用于获取文件系统对象的描述信息的方法。具体来说,`fs`是一个文件系统对象,`@`符号表示访问该对象的属性或方法,`description`表示该对象的描述信息属性。因此,`desc <- fs@description`的意思是将`fs`对象的描述信息赋值给变量`desc`。这个描述信息通常包括文件系统的路径、名称、大小、权限等相关信息。
相关问题
#include <linux/init.h> /* __init and __exit macroses */ #include <linux/kernel.h> /* KERN_INFO macros */ #include <linux/module.h> /* required for all kernel modules */ #include <linux/moduleparam.h> /* module_param() and MODULE_PARM_DESC() */ #include <linux/fs.h> /* struct file_operations, struct file */ #include <linux/miscdevice.h> /* struct miscdevice and misc_[de]register() */ #include <linux/slab.h> /* kzalloc() function */ #include <linux/uaccess.h> /* copy_{to,from}_user() */ #include <linux/init_task.h> //init_task再次定义 #include "proc_relate.h" MODULE_LICENSE("GPL"); MODULE_AUTHOR("Wu Yimin>"); MODULE_DESCRIPTION("proc_relate kernel modoule"); static int proc_relate_open(struct inode *inode, struct file *file) { struct proc_info *buf; int err = 0; buf=kmalloc(sizeof(struct proc_info)*30,GFP_KERNEL); file->private_data = buf; return err; } static ssize_t proc_relate_read(struct file *file, char __user * out,size_t size, loff_t * off) { struct proc_info *buf = file->private_data; /* 你需要补充的代码 */ } static int proc_relate_close(struct inode *inode, struct file *file) { struct buffer *buf = file->private_data; kfree(buf); return 0; } static struct file_operations proc_relate_fops = { .owner = THIS_MODULE, .open = proc_relate_open, .read = proc_relate_read, .release = proc_relate_close, .llseek = noop_llseek }; static struct miscdevice proc_relate_misc_device = { .minor = MISC_DYNAMIC_MINOR, .name = "proc_relate", .fops = &proc_relate_fops }; static int __init proc_relate_init(void) { misc_register(&proc_relate_misc_device); printk(KERN_INFO "proc_relate device has been registered.\n"); return 0; } static void __exit proc_relate_exit(void) { misc_deregister(&proc_relate_misc_device); printk(KERN_INFO "proc_relate device has been unregistered\n"); } module_init(proc_relate_init); module_exit(proc_relate_exit);补充这段代码需要补充的函数部分,使其能编译为内核模块,安装该内核模块后测试程序,运行结果类似如下:Here is parent process,pid = 7329 this is a child,pid is 7330 this is another child,pid is 7331 this is a child,pid is 7333 In thread,pid=7331 tid=7334 thread id=1254224352 this is a child,pid is 7332 this is a child,pid is 7335 ------------------------------------------------------- pid=2616 tgid=2616 comm=sshd sessionid=4 mm=ffff8000fae19000 activeMM=ffff8000fae19000 parent =1971 real_parent=1971 group_leader2616 ------------------------------------------------------- pid=2670 tgid=2670 comm=sshd sessionid=4 mm=ffff8000fa477500 activeMM=ffff8000fa477500 parent =2616 real_parent=2616 group_leader2670 -------------------------------------------------------
这段代码中缺少的部分是 proc_relate_read() 函数的实现。这个函数需要完成从内核空间读取信息并将其复制到用户空间的功能。
以下是一个可能的实现:
static ssize_t proc_relate_read(struct file *file, char __user * out,
size_t size, loff_t * off)
{
struct proc_info *buf = file->private_data;
struct task_struct *task;
int count = 0;
char *tmp_buf;
if (*off > 0) {
return 0; /* End of file */
}
tmp_buf = kmalloc(size, GFP_KERNEL);
if (!tmp_buf) {
return -ENOMEM;
}
/* Traverse the process tree and copy information to buffer */
for_each_process(task) {
snprintf(tmp_buf + count, size - count,
"this is a child,pid is %d\n", task->pid);
count += strlen(tmp_buf + count);
if (list_empty(&task->children)) {
continue;
}
/* Traverse the children of the current task */
list_for_each_entry(task, &task->children, sibling) {
snprintf(tmp_buf + count, size - count,
"this is a child,pid is %d\n", task->pid);
count += strlen(tmp_buf + count);
}
}
/* Copy buffer to user space */
if (copy_to_user(out, tmp_buf, count)) {
kfree(tmp_buf);
return -EFAULT;
}
*off += count;
kfree(tmp_buf);
return count;
}
这个函数使用了 for_each_process() 宏来遍历进程树,并将每个进程的 PID 写入缓冲区。然后,它使用 copy_to_user() 函数将缓冲区的内容复制到用户空间。
注意,该实现并不完美。例如,它没有处理缓冲区溢出的情况,并且只返回进程的 PID,而不是更有用的信息。但是,它可以作为一个起点,让你了解如何在内核模块中读取和复制信息。
以hive的角度检查语法: with cur_dim_comb as (SELECT DISTINCT t.dim_comb ,t.var_sub_class ,t.acc_value FROM gerp.cux_cst_data_alloc_his t WHERE t.top_var_type = '10' AND t.job_ver_id in (SELECT ver.job_ver_id AS p_job_ver_id FROM gerp.cux_cst_dist_jobs_all job INNER JOIN gerp.cux_cst_dist_jobs_vers_all ver ON job.job_id = ver.job_id )) select tp.bd_code --事业部编码 ,tp.bd_name --事业部名称 ,hp.ou_code --OU名称 ,hp.ou_name --OU编码 ,op.main_class_desc --差异大类 ,op.acc_value --科目代码 ,op.acc_desc --科目名称 ,op.dim_comb --区分维度 ,op.begin_amount --期初余额 ,op.accrual_amount --本期发生 ,op.balance_diff_alloc_amount --期末差异结存 ,op.var_sub_class ,op.main_class_value ,op.org_id ,op.period_name ,op.job_ver_id from (select up.* ,q1.* from (SELECT DISTINCT maincl.* ,t.* FROM t inner join (SELECT fv.flex_value ,fv.description FROM fv inner join fs on fv.flex_value_set_id = fs.flex_value_set_id AND fs.flex_value_set_name = 'CUX_CST_VARIANCE_TYPE' AND fv.enabled_flag = 'Y' AND fv.hierarchy_level = '2' AND fv.flex_value LIKE '10%' ) maincl on t.var_main_class = maincl.flex_value inner join cur_dim_comb on cur_dim_comb.var_sub_class = t.var_sub_class and cur_dim_comb.acc_value = t.acc_value WHERE 1 = 1 AND t.top_var_type = '10' AND t.job_ver_id in (SELECT ver.job_ver_id AS p_job_ver_id FROM gerp.cux_cst_dist_jobs_all job INNER JOIN gerp.cux_cst_dist_jobs_vers_all ver ON job.job_id = ver.job_id) ORDER BY maincl.description ,t.acc_value ,cur_dim_comb.dim_comb ) up inner join (SELECT t1.* ,SUM(t1.begin_amount) begin_amount ,SUM(t1.accrual_amount) accrual_amount ,SUM(t1.balance_diff_alloc_amount) balance_diff_alloc_amount FROM gerp.cux_cst_data_alloc_his t1 LEFT JOIN gerp.cux_cst_data_alloc_his t ON t1.top_var_type = '10' AND t1.var_sub_class = t.var_sub_class --p_var_sub_class AND t1.org_id = t.org_id --p_org_id AND t1.period_name = t.period_name --p_period_name AND t1.job_ver_id = t.job_ver_id --p_job_ver_id AND t1.acc_value = t.acc_value --p_acc_value WHERE t1.dim_comb in (select distinct dim_comb from cur_dim_comb) group by t1.org_id,t1.period_name,t1.job_ver_id,t1.var_sub_class,t1.acc_value ) q1 on q1.org_id = up.org_id --p_org_id AND q1.period_name = up.period_name --p_period_name AND q1.job_ver_id = up.job_ver_id --p_job_ver_id AND q1.var_sub_class = up.var_sub_class --p_var_sub_class AND q1.acc_value = up.acc_value --p_acc_value ) op
从 Hive 的角度来检查语法,以下是您提供的 SQL 查询语句:
```
with cur_dim_comb as (
SELECT DISTINCT t.dim_comb, t.var_sub_class, t.acc_value
FROM gerp.cux_cst_data_alloc_his t
WHERE t.top_var_type = '10'
AND t.job_ver_id in (
SELECT ver.job_ver_id AS p_job_ver_id
FROM gerp.cux_cst_dist_jobs_all job
INNER JOIN gerp.cux_cst_dist_jobs_vers_all ver
ON job.job_id = ver.job_id
)
)
select
tp.bd_code, --事业部编码
tp.bd_name, --事业部名称
hp.ou_code, --OU名称
hp.ou_name, --OU编码
op.main_class_desc, --差异大类
op.acc_value, --科目代码
op.acc_desc, --科目名称
op.dim_comb, --区分维度
op.begin_amount, --期初余额
op.accrual_amount, --本期发生
op.balance_diff_alloc_amount, --期末差异结存
op.var_sub_class,
op.main_class_value,
op.org_id,
op.period_name,
op.job_ver_id
from (
select up.*, q1.*
from (
SELECT DISTINCT
maincl.*,
t.*
FROM
t
inner join (
SELECT
fv.flex_value,
fv.description
FROM
fv
inner join fs
on fv.flex_value_set_id = fs.flex_value_set_id
AND fs.flex_value_set_name = 'CUX_CST_VARIANCE_TYPE'
AND fv.enabled_flag = 'Y'
AND fv.hierarchy_level = '2'
AND fv.flex_value LIKE '10%'
) maincl
on t.var_main_class = maincl.flex_value
inner join cur_dim_comb
on cur_dim_comb.var_sub_class = t.var_sub_class
and cur_dim_comb.acc_value = t.acc_value
WHERE
1 = 1
AND t.top_var_type = '10'
AND t.job_ver_id in (
SELECT ver.job_ver_id AS p_job_ver_id
FROM gerp.cux_cst_dist_jobs_all job
INNER JOIN gerp.cux_cst_dist_jobs_vers_all ver
ON job.job_id = ver.job_id
)
ORDER BY
maincl.description,
t.acc_value,
cur_dim_comb.dim_comb
) up
inner join (
SELECT
t1.*,
SUM(t1.begin_amount) begin_amount,
SUM(t1.accrual_amount) accrual_amount,
SUM(t1.balance_diff_alloc_amount) balance_diff_alloc_amount
FROM
gerp.cux_cst_data_alloc_his t1
LEFT JOIN gerp.cux_cst_data_alloc_his t
ON t1.top_var_type = '10'
AND t1.var_sub_class = t.var_sub_class --p_var_sub_class
AND t1.org_id = t.org_id --p_org_id
AND t1.period_name = t.period_name --p_period_name
AND t1.job_ver_id = t.job_ver_id --p_job_ver_id
AND t1.acc_value = t.acc_value --p_acc_value
WHERE
t1.dim_comb in (select distinct dim_comb from cur_dim_comb)
group by
t1.org_id,
t1.period_name,
t1.job_ver_id,
t1.var_sub_class,
t1.acc_value
) q1
on q1.org_id = up.org_id --p_org_id
AND q1.period_name = up.period_name --p_period_name
AND q1.job_ver_id = up.job_ver_id --p_job_ver_id
AND q1.var_sub_class = up.var_sub_class --p_var_sub_class
AND q1.acc_value = up.acc_value --p_acc_value
) op
```
从语法角度来看,该查询语句是有效的。但是,如果您想要确保语句完全符合您的预期,请先测试该语句在您的环境中的执行结果。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)