1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
11 * linux/fs/minix/dir.c
14 * Copyright (C) 1991, 1992 Linus Torvalds
16 * ext2 directory handling functions
18 * Big-endian to little-endian byte-swapping/bitmaps by
19 * David S. Miller (davem@caip.rutgers.edu), 1995
21 * All code that works with directory layout had been switched to pagecache
24 * Adapted for Lustre Light
25 * Copyright (C) 2002-2003, Cluster File Systems, Inc.
30 #include <linux/ext2_fs.h>
31 #include <linux/pagemap.h>
33 #include <linux/version.h>
34 #include <linux/smp_lock.h>
35 #include <asm/uaccess.h>
36 #include <linux/file.h>
37 #include <linux/kmod.h>
38 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
39 # include <linux/locks.h> // for wait_on_buffer
41 # include <linux/buffer_head.h> // for wait_on_buffer
44 #define DEBUG_SUBSYSTEM S_LLITE
46 #include <linux/obd_support.h>
47 #include <linux/obd_class.h>
48 #include <linux/lustre_lib.h>
49 #include <linux/lustre_idl.h>
50 #include <linux/lustre_mds.h>
51 #include <linux/lustre_lite.h>
52 #include <linux/lustre_dlm.h>
53 #include <linux/lustre_sec.h>
54 #include <linux/lustre_acl.h>
55 #include "llite_internal.h"
57 typedef struct ext2_dir_entry_2 ext2_dirent;
59 #define PageChecked(page) test_bit(PG_checked, &(page)->flags)
60 #define SetPageChecked(page) set_bit(PG_checked, &(page)->flags)
62 /* returns the page unlocked, but with a reference */
63 static int ll_dir_readpage(struct file *file, struct page *page)
65 struct inode *inode = page->mapping->host;
66 struct ptlrpc_request *request;
67 struct mds_body *body;
73 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
74 inode->i_generation, inode);
76 mdc_pack_id(&id, inode->i_ino, inode->i_generation,
77 S_IFDIR, id_group(&ll_i2info(inode)->lli_id),
78 id_fid(&ll_i2info(inode)->lli_id));
80 offset = page->index << PAGE_SHIFT;
81 rc = md_readpage(ll_i2sbi(inode)->ll_md_exp, &id, offset,
84 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
85 LASSERT (body != NULL); /* checked by md_readpage() */
86 LASSERT_REPSWABBED (request, 0); /* swabbed by md_readpage() */
88 #warning "FIXME ASAP!"
89 //inode->i_size = body->size;
90 SetPageUptodate(page);
92 ptlrpc_req_finished(request);
98 struct address_space_operations ll_dir_aops = {
99 .readpage = ll_dir_readpage,
103 * ext2 uses block-sized chunks. Arguably, sector-sized ones would be
104 * more robust, but we have what we have
106 static inline unsigned ext2_chunk_size(struct inode *inode)
108 return inode->i_sb->s_blocksize;
111 static inline void ext2_put_page(struct page *page)
114 page_cache_release(page);
117 static inline unsigned long dir_pages(struct inode *inode)
119 return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
122 static void ext2_check_page(struct page *page)
124 struct inode *dir = page->mapping->host;
125 unsigned chunk_size = ext2_chunk_size(dir);
126 char *kaddr = page_address(page);
127 // u32 max_inumber = le32_to_cpu(sb->u.ext2_sb.s_es->s_inodes_count);
128 unsigned offs, rec_len;
129 unsigned limit = PAGE_CACHE_SIZE;
133 if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
134 limit = dir->i_size & ~PAGE_CACHE_MASK;
135 if (limit & (chunk_size - 1)) {
136 CERROR("limit %d dir size %lld index %ld\n",
137 limit, dir->i_size, page->index);
140 for (offs = limit; offs<PAGE_CACHE_SIZE; offs += chunk_size) {
141 ext2_dirent *p = (ext2_dirent*)(kaddr + offs);
142 p->rec_len = cpu_to_le16(chunk_size);
149 for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) {
150 p = (ext2_dirent *)(kaddr + offs);
151 rec_len = le16_to_cpu(p->rec_len);
153 if (rec_len < EXT2_DIR_REC_LEN(1))
157 if (rec_len < EXT2_DIR_REC_LEN(p->name_len))
159 if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))
161 // if (le32_to_cpu(p->inode) > max_inumber)
167 SetPageChecked(page);
170 /* Too bad, we had an error */
173 CERROR("ext2_check_page"
174 "size of directory #%lu is not a multiple of chunk size\n",
179 error = "rec_len is smaller than minimal";
182 error = "unaligned directory entry";
185 error = "rec_len is too small for name_len";
188 error = "directory entry across blocks";
191 // error = "inode out of bounds";
193 CERROR("ext2_check_page: bad entry in directory #%lu: %s - "
194 "offset=%lu+%u, inode=%lu, rec_len=%d, name_len=%d",
195 dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT), offs,
196 (unsigned long) le32_to_cpu(p->inode),
197 rec_len, p->name_len);
200 p = (ext2_dirent *)(kaddr + offs);
201 CERROR("ext2_check_page"
202 "entry in directory #%lu spans the page boundary"
203 "offset=%lu, inode=%lu",
204 dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
205 (unsigned long) le32_to_cpu(p->inode));
207 SetPageChecked(page);
211 static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
213 struct ll_inode_info *li = ll_i2info(dir);
214 struct ldlm_res_id res_id =
215 { .name = { id_fid(&li->lli_id), id_group(&li->lli_id)} };
216 struct lustre_handle lockh;
217 struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_md_exp);
218 struct address_space *mapping = dir->i_mapping;
220 ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
223 obddev = md_get_real_obd(ll_i2sbi(dir)->ll_md_exp, &li->lli_id);
224 rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
225 &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh);
227 struct lookup_intent it = { .it_op = IT_READDIR };
228 struct ptlrpc_request *request;
229 struct mdc_op_data *op_data;
231 OBD_ALLOC(op_data, sizeof(*op_data));
233 return ERR_PTR(-ENOMEM);
235 ll_prepare_mdc_data(op_data, dir, NULL, NULL, 0, 0);
237 rc = ll_intent_alloc(&it);
241 rc = md_enqueue(ll_i2sbi(dir)->ll_md_exp, LDLM_IBITS, &it,
242 LCK_PR, op_data, &lockh, NULL, 0,
243 ldlm_completion_ast, ll_mdc_blocking_ast, dir);
244 OBD_FREE(op_data, sizeof(*op_data));
246 request = (struct ptlrpc_request *)LUSTRE_IT(&it)->it_data;
250 ptlrpc_req_finished(request);
252 CERROR("lock enqueue: rc: %d\n", rc);
256 if (ptlrpcs_check_cred(obddev->u.cli.cl_import)) {
257 /* return immediately if no credential held */
258 ldlm_lock_decref(&lockh, LCK_PR);
259 return ERR_PTR(-EACCES);
262 ldlm_lock_dump_handle(D_OTHER, &lockh);
264 page = read_cache_page(mapping, n,
265 (filler_t*)mapping->a_ops->readpage, NULL);
269 if (!PageUptodate(page))
271 if (!PageChecked(page))
272 ext2_check_page(page);
278 ldlm_lock_decref(&lockh, LCK_PR);
283 page = ERR_PTR(-EIO);
288 * p is at least 6 bytes before the end of page
290 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
292 return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
295 static inline unsigned
296 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
298 ext2_dirent *de = (ext2_dirent*)(base + offset);
299 ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
300 while ((char*)p < (char*)de)
301 p = ext2_next_entry(p);
302 return (char *)p - base;
305 static unsigned char ext2_filetype_table[EXT2_FT_MAX] = {
306 [EXT2_FT_UNKNOWN] DT_UNKNOWN,
307 [EXT2_FT_REG_FILE] DT_REG,
308 [EXT2_FT_DIR] DT_DIR,
309 [EXT2_FT_CHRDEV] DT_CHR,
310 [EXT2_FT_BLKDEV] DT_BLK,
311 [EXT2_FT_FIFO] DT_FIFO,
312 [EXT2_FT_SOCK] DT_SOCK,
313 [EXT2_FT_SYMLINK] DT_LNK,
317 int ll_readdir(struct file * filp, void * dirent, filldir_t filldir)
319 struct inode *inode = filp->f_dentry->d_inode;
320 loff_t pos = filp->f_pos;
321 // XXX struct super_block *sb = inode->i_sb;
322 unsigned offset = pos & ~PAGE_CACHE_MASK;
323 unsigned long n = pos >> PAGE_CACHE_SHIFT;
324 unsigned long npages = dir_pages(inode);
325 unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
326 unsigned char *types = ext2_filetype_table;
327 int need_revalidate = (filp->f_version != inode->i_version);
331 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %llu/%llu\n",
332 inode->i_ino, inode->i_generation, inode, pos, inode->i_size);
334 if (pos > inode->i_size - EXT2_DIR_REC_LEN(1))
337 for ( ; n < npages; n++, offset = 0) {
342 CDEBUG(D_EXT2,"read %lu of dir %lu/%u page %lu/%lu size %llu\n",
343 PAGE_CACHE_SIZE, inode->i_ino, inode->i_generation,
344 n, npages, inode->i_size);
345 page = ll_get_dir_page(inode, n);
347 /* size might have been updated by md_readpage() */
348 npages = dir_pages(inode);
352 CERROR("error reading dir %lu/%u page %lu: rc %d\n",
353 inode->i_ino, inode->i_generation, n, rc);
357 kaddr = page_address(page);
358 if (need_revalidate) {
359 offset = ext2_validate_entry(kaddr, offset, chunk_mask);
362 de = (ext2_dirent *)(kaddr+offset);
363 limit = kaddr + PAGE_CACHE_SIZE - EXT2_DIR_REC_LEN(1);
364 for ( ;(char*)de <= limit; de = ext2_next_entry(de)) {
368 rc = 0; /* no error if we return something */
370 offset = (char *)de - kaddr;
371 over = filldir(dirent, de->name, de->name_len,
372 (n<<PAGE_CACHE_SHIFT) | offset,
373 le32_to_cpu(de->inode),
374 types[de->file_type &
388 filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
389 filp->f_version = inode->i_version;
394 static int ll_mkdir_stripe(struct inode *inode, unsigned long arg)
396 struct ptlrpc_request *request = NULL;
397 struct ll_sb_info *sbi = ll_i2sbi(inode);
398 struct ll_user_mkdir_stripe lums;
399 struct mdc_op_data *op_data;
406 if (copy_from_user(&lums, (void *)arg, sizeof(lums)))
409 if (lums.lums_namelen <= 0)
411 OBD_ALLOC(name, lums.lums_namelen);
415 if (copy_from_user(name, lums.lums_name, lums.lums_namelen))
416 GOTO(out, err = -EFAULT);
418 CDEBUG(D_VFSTRACE, "ioctl Op:name=%s,dir=%lu/%u(%p)\n",
419 name, inode->i_ino, inode->i_generation, inode);
420 nstripes = lums.lums_nstripes;
422 mode = lums.lums_mode;
423 mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
425 OBD_ALLOC(op_data, sizeof(*op_data));
427 GOTO(out, err = -ENOMEM);
428 ll_prepare_mdc_data(op_data, inode, NULL, name,lums.lums_namelen,0);
429 err = md_create(sbi->ll_md_exp, op_data, &nstripes, sizeof(nstripes),
430 mode, current->fsuid, current->fsgid, 0, &request);
431 OBD_FREE(op_data, sizeof(*op_data));
432 ptlrpc_req_finished(request);
435 OBD_FREE(name, lums.lums_namelen);
440 * we don't call getxattr_internal/setxattr_internal because we
441 * need more precisely control.
443 static int ll_ioctl_getfacl(struct inode *inode,
445 struct ll_acl_ioctl_data *ioc)
447 struct ptlrpc_request *req = NULL;
448 struct mds_body *body;
454 if (!ioc->cmd || !ioc->cmd_len ||
455 !ioc->res || !ioc->res_len) {
456 CERROR("error: cmd %p, len %lu, res %p, len %lu\n",
457 ioc->cmd, ioc->cmd_len, ioc->res, ioc->res_len);
461 OBD_ALLOC(cmd, ioc->cmd_len);
464 if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
465 GOTO(out, rc = -EFAULT);
467 /* we didn't call ll_getxattr_internal() because we'd like to
468 * copy from reply buffer to user space directly.
470 ll_inode2id(&id, inode);
471 rc = md_getattr(ll_i2sbi(inode)->ll_md_exp, &id, OBD_MD_FLXATTR,
472 XATTR_NAME_LUSTRE_ACL,
473 cmd, ioc->cmd_len, ioc->res_len, &req);
475 CERROR("rc: %d\n", rc);
479 res = lustre_msg_buf(req->rq_repmsg, 1, ioc->res_len);
481 if (copy_to_user(ioc->res, res, ioc->res_len))
484 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
486 ioc->status = (__s32) body->flags;
491 ptlrpc_req_finished(req);
492 OBD_FREE(cmd, ioc->cmd_len);
497 static int ll_ioctl_setfacl(struct inode *inode,
499 struct ll_acl_ioctl_data *ioc)
501 struct ptlrpc_request *req = NULL;
502 struct mdc_op_data op_data;
503 struct mds_body *body;
509 if (!ioc->cmd || !ioc->cmd_len) {
510 CERROR("error: cmd %p, len %lu\n", ioc->cmd, ioc->cmd_len);
514 OBD_ALLOC(cmd, ioc->cmd_len);
517 if (copy_from_user(cmd, ioc->cmd, ioc->cmd_len))
518 GOTO(out, rc = -EFAULT);
520 memset(&attr, 0x0, sizeof(attr));
521 attr.ia_valid |= ATTR_EA;
522 attr.ia_attr_flags = 0;
524 ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
526 rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, &op_data, &attr,
527 (void*) XATTR_NAME_LUSTRE_ACL,
528 sizeof(XATTR_NAME_LUSTRE_ACL),
529 (void*) cmd, ioc->cmd_len, &req);
531 CERROR("md_setattr fails: rc = %d\n", rc);
535 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
537 ioc->status = (__s32) body->flags;
539 LASSERT(req->rq_repmsg->bufcount == 2);
540 replen = req->rq_repmsg->buflens[1];
541 LASSERT(replen <= LUSTRE_ACL_SIZE_MAX);
543 if (replen > ioc->res_len)
544 replen = ioc->res_len;
545 if (copy_to_user(ioc->res,
546 lustre_msg_buf(req->rq_repmsg, 1, replen),
553 ptlrpc_req_finished(req);
554 OBD_FREE(cmd, ioc->cmd_len);
559 static int ll_dir_ioctl(struct inode *inode, struct file *file,
560 unsigned int cmd, unsigned long arg)
562 struct ll_sb_info *sbi = ll_i2sbi(inode);
563 struct obd_ioctl_data *data;
566 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n",
567 inode->i_ino, inode->i_generation, inode, cmd);
569 if (_IOC_TYPE(cmd) == 'T') /* tty ioctls */
572 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_IOCTL);
574 case EXT3_IOC_GETFLAGS:
575 case EXT3_IOC_SETFLAGS:
576 RETURN(ll_iocontrol(inode, file, cmd, arg));
577 case IOC_MDC_LOOKUP: {
578 struct ptlrpc_request *request = NULL;
582 int namelen, rc, len = 0;
585 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
590 filename = data->ioc_inlbuf1;
591 namelen = data->ioc_inllen1;
594 CDEBUG(D_INFO, "IOC_MDC_LOOKUP missing filename\n");
595 GOTO(out, rc = -EINVAL);
599 ll_inode2id(&id, inode);
600 rc = md_getattr_lock(sbi->ll_md_exp, &id,
601 filename, namelen, valid, 0, &request);
603 CDEBUG(D_INFO, "md_getattr_lock: %d\n", rc);
607 ptlrpc_req_finished(request);
611 obd_ioctl_freedata(buf, len);
614 case LL_IOC_MDC_MKDIRSTRIPE:
615 RETURN(ll_mkdir_stripe(inode, arg));
616 case LL_IOC_LOV_SETSTRIPE: {
617 struct ptlrpc_request *request = NULL;
618 struct mdc_op_data *op_data;
619 struct iattr attr = { 0 };
620 struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
623 LASSERT(sizeof(lum) == sizeof(*lump));
624 LASSERT(sizeof(lum.lmm_objects[0]) ==
625 sizeof(lump->lmm_objects[0]));
626 rc = copy_from_user(&lum, lump, sizeof(lum));
630 if (lum.lmm_magic != LOV_USER_MAGIC)
633 OBD_ALLOC(op_data, sizeof(*op_data));
637 ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
639 rc = md_setattr(sbi->ll_md_exp, op_data, &attr, &lum,
640 sizeof(lum), NULL, 0, &request);
641 OBD_FREE(op_data, sizeof(*op_data));
642 ptlrpc_req_finished(request);
645 if (rc != -EPERM && rc != -EACCES)
646 CERROR("md_setattr fails: rc = %d\n", rc);
650 case LL_IOC_LOV_GETSTRIPE: {
651 struct ptlrpc_request *request = NULL;
652 struct lov_user_md *lump = (struct lov_user_md *)arg;
653 struct lov_mds_md *lmm;
655 struct mds_body *body;
659 valid |= OBD_MD_FLDIREA;
661 ll_inode2id(&id, inode);
662 rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0,
663 obd_size_diskmd(sbi->ll_dt_exp, NULL),
666 CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc);
670 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
671 LASSERT(body != NULL); /* checked by md_getattr_lock */
672 LASSERT_REPSWABBED(request, 0);/* swabbed by md_getattr_lock */
674 lmmsize = body->eadatasize;
676 GOTO(out_get, rc = -ENODATA);
678 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
679 LASSERT(lmm != NULL);
680 LASSERT_REPSWABBED(request, 1);
681 rc = copy_to_user(lump, lmm, lmmsize);
683 GOTO(out_get, rc = -EFAULT);
687 ptlrpc_req_finished(request);
690 case IOC_MDC_SHOWFID: {
691 struct lustre_id *idp = (struct lustre_id *)arg;
696 filename = getname((const char *)arg);
697 if (IS_ERR(filename))
698 RETURN(PTR_ERR(filename));
700 ll_inode2id(&id, inode);
702 rc = ll_get_fid(sbi->ll_md_exp, &id, filename, &id);
704 GOTO(out_filename, rc);
706 rc = copy_to_user(idp, &id, sizeof(*idp));
708 GOTO(out_filename, rc = -EFAULT);
715 case IOC_MDC_GETSTRIPE: {
716 struct lov_user_md *lump = (struct lov_user_md *)arg;
717 struct ptlrpc_request *request = NULL;
718 struct lov_mds_md *lmm;
719 struct mds_body *body;
724 filename = getname((const char *)arg);
725 if (IS_ERR(filename))
726 RETURN(PTR_ERR(filename));
728 ll_inode2id(&id, inode);
729 rc = md_getattr_lock(sbi->ll_md_exp, &id, filename,
730 strlen(filename) + 1, OBD_MD_FLEASIZE,
731 obd_size_diskmd(sbi->ll_dt_exp, NULL),
734 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
739 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
740 LASSERT(body != NULL); /* checked by md_getattr_lock */
741 LASSERT_REPSWABBED(request, 0);/* swabbed by md_getattr_lock */
743 lmmsize = body->eadatasize;
745 if (!(body->valid & OBD_MD_FLEASIZE) || lmmsize == 0)
746 GOTO(out_req, rc = -ENODATA);
749 GOTO(out_req, rc = -EFBIG);
751 lmm = lustre_msg_buf(request->rq_repmsg, 1, lmmsize);
752 LASSERT(lmm != NULL);
753 LASSERT_REPSWABBED(request, 1);
755 rc = copy_to_user(lump, lmm, lmmsize);
757 GOTO(out_req, rc = -EFAULT);
761 ptlrpc_req_finished(request);
767 struct ptlrpc_request *req = NULL;
770 struct client_obd *cli;
771 struct obd_device *obd;
773 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
778 obd = class_name2obd(data->ioc_inlbuf1);
781 GOTO(out_ping, rc = -ENODEV);
783 if (!obd->obd_attached) {
784 CERROR("Device %d not attached\n", obd->obd_minor);
785 GOTO(out_ping, rc = -ENODEV);
787 if (!obd->obd_set_up) {
788 CERROR("Device %d still not setup\n", obd->obd_minor);
789 GOTO(out_ping, rc = -ENODEV);
792 req = ptlrpc_prep_req(cli->cl_import, LUSTRE_OBD_VERSION,
793 OBD_PING, 0, NULL, NULL);
795 GOTO(out_ping, rc = -ENOMEM);
797 req->rq_replen = lustre_msg_size(0, NULL);
798 req->rq_send_state = LUSTRE_IMP_FULL;
800 rc = ptlrpc_queue_wait(req);
802 ptlrpc_req_finished(req);
804 obd_ioctl_freedata(buf, len);
807 case OBD_IOC_LLOG_CATINFO: {
808 struct ptlrpc_request *req = NULL;
814 rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
819 if (!data->ioc_inlbuf1) {
820 obd_ioctl_freedata(buf, len);
824 lens[0] = data->ioc_inllen1;
825 bufs[0] = data->ioc_inlbuf1;
826 if (data->ioc_inllen2) {
827 lens[1] = data->ioc_inllen2;
828 bufs[1] = data->ioc_inlbuf2;
833 size = data->ioc_plen1;
834 req = ptlrpc_prep_req(sbi2md(sbi)->cl_import,
835 LUSTRE_LOG_VERSION, LLOG_CATINFO,
838 GOTO(out_catinfo, rc = -ENOMEM);
840 req->rq_replen = lustre_msg_size(1, &size);
842 rc = ptlrpc_queue_wait(req);
843 str = lustre_msg_string(req->rq_repmsg, 0, data->ioc_plen1);
845 rc = copy_to_user(data->ioc_pbuf1, str,
847 ptlrpc_req_finished(req);
849 obd_ioctl_freedata(buf, len);
852 case LL_IOC_GETFACL: {
853 struct ll_acl_ioctl_data ioc, *uioc;
856 if (copy_from_user(&ioc, (void *) arg, sizeof(ioc)))
859 rc = ll_ioctl_getfacl(inode, file, &ioc);
861 uioc = (struct ll_acl_ioctl_data *) arg;
862 if (copy_to_user(&uioc->status, &ioc.status,
868 case LL_IOC_SETFACL: {
869 struct ll_acl_ioctl_data ioc, *uioc;
872 if (copy_from_user(&ioc, (void *) arg, sizeof(ioc)))
875 rc = ll_ioctl_setfacl(inode, file, &ioc);
877 uioc = (struct ll_acl_ioctl_data *) arg;
878 if (copy_to_user(&uioc->status, &ioc.status,
884 case LL_IOC_FLUSH_CRED:
885 RETURN(ll_flush_cred(inode));
887 return obd_iocontrol(cmd, sbi->ll_dt_exp, 0,
892 int ll_dir_open(struct inode *inode, struct file *file)
894 return ll_file_open(inode, file);
897 int ll_dir_release(struct inode *inode, struct file *file)
899 return ll_file_release(inode, file);
902 struct file_operations ll_dir_operations = {
904 .release = ll_dir_release,
905 .read = generic_read_dir,
906 .readdir = ll_readdir,
907 .ioctl = ll_dir_ioctl