[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/7] Mini-OS: add concept of mount points
On 05.02.23 13:45, Samuel Thibault wrote: Juergen Gross, le ven. 03 févr. 2023 10:18:04 +0100, a ecrit:+int open(const char *pathname, int flags, ...) +{ + unsigned int m, mlen; + struct mount_point *mnt; + mode_t mode = 0; + va_list ap; + + if ( flags & O_CREAT ) + { + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); } - if (!strncmp(pathname, "/dev/mem", strlen("/dev/mem"))) { - fd = alloc_fd(FTYPE_MEM); - printk("open(/dev/mem) -> %d\n", fd); - return fd; + + for ( m = 0; m < ARRAY_SIZE(mount_points); m++ ) + { + mnt = mount_points + m; + mlen = strlen(mnt->path); + if ( !strncmp(pathname, mnt->path, mlen) && + (pathname[mlen] == '/' || pathname[mlen] == 0) ) + return mnt->open(mnt, pathname, flags, mode);Thinking about it more: don't we want to pass pathname+mlen? So that the open function doesn't have to care where it's mounted. I think both variants have their pros and cons. As the open functions have the mount point available via the mnt parameter I can change it. Juergen Attachment:
OpenPGP_0xB0DE9DD628BF132F.asc Attachment:
OpenPGP_signature
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |