2009-10-01 16:00:27 +02:00
|
|
|
#include "inc.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <minix/com.h>
|
|
|
|
#include <minix/vfsif.h>
|
|
|
|
|
|
|
|
#include "buf.h"
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static char *get_name(char *name, char string[NAME_MAX+1]);
|
2013-03-07 15:46:21 +01:00
|
|
|
static int parse_path(pino_t dir_ino, pino_t root_ino, int flags, struct
|
2012-03-24 16:16:34 +01:00
|
|
|
dir_record **res_inop, size_t *offsetp);
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* fs_lookup *
|
2009-10-01 16:00:27 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_lookup() {
|
2009-10-01 16:00:27 +02:00
|
|
|
cp_grant_id_t grant;
|
2010-04-01 15:25:05 +02:00
|
|
|
int r, len, flags;
|
2010-02-19 11:00:32 +01:00
|
|
|
size_t offset;
|
2013-03-07 15:46:21 +01:00
|
|
|
pino_t dir_ino, root_ino;
|
2009-10-01 16:00:27 +02:00
|
|
|
struct dir_record *dir;
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
grant = fs_m_in.REQ_GRANT;
|
|
|
|
len = fs_m_in.REQ_PATH_LEN; /* including terminating nul */
|
2013-03-07 15:46:21 +01:00
|
|
|
dir_ino = (pino_t) fs_m_in.REQ_DIR_INO;
|
|
|
|
root_ino = (pino_t) fs_m_in.REQ_ROOT_INO;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
flags = fs_m_in.REQ_FLAGS;
|
2013-03-07 15:46:21 +01:00
|
|
|
caller_uid = (uid_t) fs_m_in.REQ_UID;
|
|
|
|
caller_gid = (gid_t) fs_m_in.REQ_GID;
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
/* Check length. */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if(len > sizeof(user_path)) return(E2BIG); /* too big for buffer */
|
|
|
|
if(len < 1) return(EINVAL); /* too small */
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
/* Copy the pathname and set up caller's user and group id */
|
2010-06-08 15:58:01 +02:00
|
|
|
r = sys_safecopyfrom(VFS_PROC_NR, grant, 0, (vir_bytes) user_path,
|
2012-06-16 03:46:15 +02:00
|
|
|
(phys_bytes) len);
|
2009-10-01 16:00:27 +02:00
|
|
|
if (r != OK) {
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
printf("ISOFS %s:%d sys_safecopyfrom failed: %d\n",
|
|
|
|
__FILE__, __LINE__, r);
|
|
|
|
return(r);
|
2009-10-01 16:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify this is a null-terminated path. */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if(user_path[len-1] != '\0') return(EINVAL);
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
/* Lookup inode */
|
|
|
|
dir = NULL;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
offset = 0;
|
|
|
|
r = parse_path(dir_ino, root_ino, flags, &dir, &offset);
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
if (r == ELEAVEMOUNT) {
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Report offset and the error */
|
|
|
|
fs_m_out.RES_OFFSET = offset;
|
|
|
|
fs_m_out.RES_SYMLOOP = 0;
|
|
|
|
return(r);
|
2009-10-01 16:00:27 +02:00
|
|
|
}
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (r != OK && r != EENTERMOUNT) return(r);
|
2009-10-01 16:00:27 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
fs_m_out.RES_INODE_NR = ID_DIR_RECORD(dir);
|
|
|
|
fs_m_out.RES_MODE = dir->d_mode;
|
2014-02-24 17:02:03 +01:00
|
|
|
fs_m_out.RES_FILE_SIZE = dir->d_file_size;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
fs_m_out.RES_SYMLOOP = 0;
|
|
|
|
fs_m_out.RES_UID = SYS_UID; /* root */
|
|
|
|
fs_m_out.RES_GID = SYS_GID; /* operator */
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (r == EENTERMOUNT) {
|
|
|
|
fs_m_out.RES_OFFSET = offset;
|
|
|
|
release_dir_record(dir);
|
|
|
|
}
|
2009-10-01 16:00:27 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2009-10-01 16:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The search dir actually performs the operation of searching for the
|
|
|
|
* compoent ``string" in ldir_ptr. It returns the response and the number of
|
|
|
|
* the inode in numb. */
|
|
|
|
/*===========================================================================*
|
|
|
|
* search_dir *
|
|
|
|
*===========================================================================*/
|
2013-03-07 15:46:21 +01:00
|
|
|
int search_dir(
|
|
|
|
register struct dir_record *ldir_ptr, /* dir record parent */
|
|
|
|
char string[NAME_MAX], /* component to search for */
|
|
|
|
pino_t *numb /* pointer to new dir record */
|
|
|
|
) {
|
2009-10-01 16:00:27 +02:00
|
|
|
struct dir_record *dir_tmp;
|
2010-04-01 15:25:05 +02:00
|
|
|
register struct buf *bp;
|
|
|
|
int pos;
|
2009-10-01 16:00:27 +02:00
|
|
|
char* comma_pos = NULL;
|
|
|
|
char tmp_string[NAME_MAX];
|
|
|
|
|
|
|
|
/* This function search a particular element (in string) in a inode and
|
|
|
|
* return its number */
|
|
|
|
|
|
|
|
/* Initialize the tmp array */
|
|
|
|
memset(tmp_string,'\0',NAME_MAX);
|
|
|
|
|
|
|
|
if ((ldir_ptr->d_mode & I_TYPE) != I_DIRECTORY) {
|
|
|
|
return(ENOTDIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(string,".") == 0) {
|
|
|
|
*numb = ID_DIR_RECORD(ldir_ptr);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(string,"..") == 0 && ldir_ptr->loc_extent_l == v_pri.dir_rec_root->loc_extent_l) {
|
|
|
|
*numb = ROOT_INO_NR;
|
|
|
|
/* *numb = ID_DIR_RECORD(ldir_ptr); */
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the dir's content */
|
|
|
|
pos = ldir_ptr->ext_attr_rec_length;
|
|
|
|
bp = get_block(ldir_ptr->loc_extent_l);
|
|
|
|
|
2010-05-10 15:26:00 +02:00
|
|
|
if (bp == NULL)
|
2009-10-01 16:00:27 +02:00
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
while (pos < v_pri.logical_block_size_l) {
|
|
|
|
if ((dir_tmp = get_free_dir_record()) == NULL) {
|
|
|
|
put_block(bp);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2012-10-16 17:40:39 +02:00
|
|
|
if (create_dir_record(dir_tmp,b_data(bp) + pos,
|
2013-03-07 15:46:21 +01:00
|
|
|
ldir_ptr->loc_extent_l*v_pri.logical_block_size_l + pos) == EINVAL)
|
2009-10-01 16:00:27 +02:00
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if (dir_tmp->length == 0) {
|
|
|
|
release_dir_record(dir_tmp);
|
|
|
|
put_block(bp);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(tmp_string,dir_tmp->file_id,dir_tmp->length_file_id);
|
|
|
|
comma_pos = strchr(tmp_string,';');
|
|
|
|
if (comma_pos != NULL)
|
|
|
|
*comma_pos = 0;
|
|
|
|
else
|
|
|
|
tmp_string[dir_tmp->length_file_id] = 0;
|
|
|
|
if (tmp_string[strlen(tmp_string) - 1] == '.')
|
|
|
|
tmp_string[strlen(tmp_string) - 1] = '\0';
|
|
|
|
|
|
|
|
if (strcmp(tmp_string,string) == 0 ||
|
|
|
|
(dir_tmp->file_id[0] == 1 && strcmp(string,"..") == 0)) {
|
|
|
|
|
|
|
|
/* If the element is found or we are searchig for... */
|
|
|
|
|
|
|
|
if (dir_tmp->loc_extent_l == dir_records->loc_extent_l) {
|
|
|
|
/* In this case the inode is a root because the parent
|
|
|
|
* points to the same location than the inode. */
|
|
|
|
*numb = 1;
|
|
|
|
release_dir_record(dir_tmp);
|
|
|
|
put_block(bp);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir_tmp->ext_attr_rec_length != 0) {
|
|
|
|
dir_tmp->ext_attr = get_free_ext_attr();
|
2012-10-16 17:40:39 +02:00
|
|
|
create_ext_attr(dir_tmp->ext_attr,b_data(bp));
|
2009-10-01 16:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*numb = ID_DIR_RECORD(dir_tmp);
|
|
|
|
release_dir_record(dir_tmp);
|
|
|
|
put_block(bp);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos += dir_tmp->length;
|
|
|
|
release_dir_record(dir_tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
put_block(bp);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* parse_path *
|
2009-10-01 16:00:27 +02:00
|
|
|
*===========================================================================*/
|
2013-03-07 15:46:21 +01:00
|
|
|
static int parse_path(
|
|
|
|
pino_t dir_ino,
|
|
|
|
pino_t root_ino,
|
|
|
|
int flags,
|
|
|
|
struct dir_record **res_inop,
|
|
|
|
size_t *offsetp
|
|
|
|
) {
|
2009-10-01 16:00:27 +02:00
|
|
|
int r;
|
|
|
|
char string[NAME_MAX+1];
|
|
|
|
char *cp, *ncp;
|
|
|
|
struct dir_record *start_dir, *old_dir;
|
|
|
|
|
|
|
|
/* Find starting inode inode according to the request message */
|
|
|
|
if ((start_dir = get_dir_record(dir_ino)) == NULL) {
|
2012-11-15 12:06:41 +01:00
|
|
|
printf("ISOFS: couldn't find starting inode %u\n", dir_ino);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(ENOENT);
|
2009-10-01 16:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cp = user_path;
|
|
|
|
|
|
|
|
/* Scan the path component by component. */
|
|
|
|
while (TRUE) {
|
|
|
|
if (cp[0] == '\0') {
|
|
|
|
/* Empty path */
|
|
|
|
*res_inop= start_dir;
|
|
|
|
*offsetp += cp-user_path;
|
|
|
|
|
|
|
|
/* Return EENTERMOUNT if we are at a mount point */
|
|
|
|
if (start_dir->d_mountpoint)
|
|
|
|
return EENTERMOUNT;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cp[0] == '/') {
|
|
|
|
/* Special case code. If the remaining path consists of just
|
|
|
|
* slashes, we need to look up '.'
|
|
|
|
*/
|
|
|
|
while(cp[0] == '/')
|
|
|
|
cp++;
|
|
|
|
if (cp[0] == '\0') {
|
2012-07-26 17:16:50 +02:00
|
|
|
strlcpy(string, ".", NAME_MAX + 1);
|
2009-10-01 16:00:27 +02:00
|
|
|
ncp = cp;
|
|
|
|
}
|
|
|
|
else
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
ncp = get_name(cp, string);
|
2009-10-01 16:00:27 +02:00
|
|
|
} else
|
|
|
|
/* Just get the first component */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
ncp = get_name(cp, string);
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
/* Special code for '..'. A process is not allowed to leave a chrooted
|
|
|
|
* environment. A lookup of '..' at the root of a mounted filesystem
|
|
|
|
* has to return ELEAVEMOUNT.
|
|
|
|
*/
|
|
|
|
if (strcmp(string, "..") == 0) {
|
|
|
|
|
|
|
|
/* This condition is not necessary since it will never be the root filesystem */
|
|
|
|
/* if (start_dir == dir_records) { */
|
|
|
|
/* cp = ncp; */
|
|
|
|
/* continue; /\* Just ignore the '..' at a process' */
|
|
|
|
/* * root. */
|
|
|
|
/* *\/ */
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
if (start_dir == dir_records) {
|
|
|
|
/* Climbing up mountpoint */
|
|
|
|
release_dir_record(start_dir);
|
|
|
|
*res_inop = NULL;
|
|
|
|
*offsetp += cp-user_path;
|
|
|
|
return ELEAVEMOUNT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Only check for a mount point if we are not looking for '..'. */
|
|
|
|
if (start_dir->d_mountpoint) {
|
|
|
|
*res_inop= start_dir;
|
|
|
|
*offsetp += cp-user_path;
|
|
|
|
return EENTERMOUNT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There is more path. Keep parsing. */
|
|
|
|
old_dir = start_dir;
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = advance(old_dir, string, &start_dir);
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
if (r != OK) {
|
|
|
|
release_dir_record(old_dir);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
release_dir_record(old_dir);
|
|
|
|
cp = ncp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* advance *
|
2009-10-01 16:00:27 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int advance(dirp, string, resp)
|
2009-10-01 16:00:27 +02:00
|
|
|
struct dir_record *dirp; /* inode for directory to be searched */
|
|
|
|
char string[NAME_MAX]; /* component name to look for */
|
|
|
|
struct dir_record **resp; /* resulting inode */
|
|
|
|
{
|
|
|
|
/* Given a directory and a component of a path, look up the component in
|
|
|
|
* the directory, find the inode, open it, and return a pointer to its inode
|
|
|
|
* slot.
|
|
|
|
*/
|
|
|
|
|
|
|
|
register struct dir_record *rip = NULL;
|
2010-04-01 15:25:05 +02:00
|
|
|
int r;
|
2013-03-07 15:46:21 +01:00
|
|
|
pino_t numb;
|
2009-10-01 16:00:27 +02:00
|
|
|
|
|
|
|
/* If 'string' is empty, yield same inode straight away. */
|
|
|
|
if (string[0] == '\0') {
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for NULL. */
|
|
|
|
if (dirp == NULL) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If 'string' is not present in the directory, signal error. */
|
|
|
|
if ( (r = search_dir(dirp, string, &numb)) != OK) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The component has been found in the directory. Get inode. */
|
|
|
|
if ( (rip = get_dir_record((int) numb)) == NULL) {
|
|
|
|
return(err_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
*resp= rip;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* get_name *
|
2009-10-01 16:00:27 +02:00
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static char *get_name(path_name, string)
|
2009-10-01 16:00:27 +02:00
|
|
|
char *path_name; /* path name to parse */
|
|
|
|
char string[NAME_MAX+1]; /* component extracted from 'old_name' */
|
|
|
|
{
|
|
|
|
/* Given a pointer to a path name in fs space, 'path_name', copy the first
|
|
|
|
* component to 'string' (truncated if necessary, always nul terminated).
|
|
|
|
* A pointer to the string after the first component of the name as yet
|
|
|
|
* unparsed is returned. Roughly speaking,
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
* 'get_name' = 'path_name' - 'string'.
|
2009-10-01 16:00:27 +02:00
|
|
|
*
|
|
|
|
* This routine follows the standard convention that /usr/ast, /usr//ast,
|
|
|
|
* //usr///ast and /usr/ast/ are all equivalent.
|
|
|
|
*/
|
|
|
|
size_t len;
|
|
|
|
char *cp, *ep;
|
|
|
|
|
|
|
|
cp= path_name;
|
|
|
|
|
|
|
|
/* Skip leading slashes */
|
|
|
|
while (cp[0] == '/')
|
|
|
|
cp++;
|
|
|
|
|
|
|
|
/* Find the end of the first component */
|
|
|
|
ep= cp;
|
|
|
|
while(ep[0] != '\0' && ep[0] != '/')
|
|
|
|
ep++;
|
|
|
|
|
|
|
|
len= ep-cp;
|
|
|
|
|
|
|
|
/* Truncate the amount to be copied if it exceeds NAME_MAX */
|
|
|
|
if (len > NAME_MAX)
|
|
|
|
len= NAME_MAX;
|
|
|
|
|
|
|
|
/* Special case of the string at cp is empty */
|
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
/* Return "." */
|
2012-07-26 17:16:50 +02:00
|
|
|
strlcpy(string, ".", NAME_MAX + 1);
|
2009-10-01 16:00:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(string, cp, len);
|
|
|
|
string[len]= '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
return ep;
|
|
|
|
}
|