- 论坛徽章:
- 0
|
本帖最后由 testh 于 2012-06-14 15:47 编辑
虽然没有实际用C++写过东西,但是对知道C++中有个this指针,原意为指向类自身的指针。
但是我在跟踪mount源码的时候,看到了如下的代码:
- /*
- * Name resolution.
- * This is the basic name resolution function, turning a pathname into
- * the final dentry. We expect 'base' to be positive and a directory.
- *
- * Returns 0 and nd will have valid dentry and mnt on success.
- * Returns error and drops reference to input namei data on failure.
- */
- static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
- {
- struct path next;
- struct inode *inode;
- int err;
- unsigned int lookup_flags = nd->flags;
-
- while (*name=='/')
- name++;
- if (!*name)
- goto return_reval;
- inode = nd->dentry->d_inode;
- if (nd->depth)
- lookup_flags = LOOKUP_FOLLOW;
- /* At this point we know we have a real path component. */
- for(;;) {
- unsigned long hash;
- struct qstr this;
- unsigned int c;
- err = exec_permission_lite(inode, nd);
- if (err == -EAGAIN) {
- err = permission(inode, MAY_EXEC, nd);
- }
- if (err)
- break;
- this.name = name; //////<<==========这里也有一个this
- c = *(const unsigned char *)name;
- hash = init_name_hash();
- do {
- name++;
- hash = partial_name_hash(c, hash);
- c = *(const unsigned char *)name;
- } while (c && (c != '/'));
- this.len = name - (const char *) this.name;
- this.hash = end_name_hash(hash);
复制代码 this.name=name;
想请教下熟悉的朋友,这种用法的含义是否与C++语法中的this一致,如果一致的话,那这个this又指向谁呢?
文件路径linux2.6.16/fs/Namei.c |
|